diff --git a/README.md b/README.md
index 261b98a..d9d98e6 100644
--- a/README.md
+++ b/README.md
@@ -3,8 +3,8 @@
Open World RPG
-*Current version: 0.1.0*
-*Uses Love2D version 11.1.0*
+*Current version: 0.1.1*
+*Uses Love2D version 11.2.0*
![](https://i.imgur.com/rF9idF9.png)
diff --git a/client.lua b/client.lua
index eb74bb1..d66a637 100644
--- a/client.lua
+++ b/client.lua
@@ -231,7 +231,7 @@ function client.sendMessage(msg)
end
end
-for _, v in pairs{'spawnProjectile', 'moveItem', 'dropItem', 'useItem', 'usePortal'} do
+for _, v in ipairs{'spawnProjectile', 'moveItem', 'dropItem', 'useItem', 'usePortal'} do
client[v] = function(data)
client.nutClient:sendRPC(v, bitser.dumps(data))
end
diff --git a/conf.lua b/conf.lua
index cdea46d..a9c438f 100644
--- a/conf.lua
+++ b/conf.lua
@@ -2,9 +2,9 @@
function love.conf(t)
t.title = 'Tier'
t.identity = t.title
- t.window.width = 480*3
- t.window.height = 270*3
+ t.window.width = 480*2
+ t.window.height = 270*2
t.window.resizable = true
- t.window.vsync = false
+ t.window.vsync = 0
t.console = true
end
diff --git a/entities.lua b/entities.lua
index bc79dca..6fd89d8 100644
--- a/entities.lua
+++ b/entities.lua
@@ -19,7 +19,7 @@ local entityDefs = {
require 'entityDefs.slime'
}
-for _, sc in pairs{'server', 'client'} do
+for _, sc in ipairs{'server', 'client'} do
-- entities.server.defs.slime = slime.server
for _, v in pairs(entityDefs) do
entities[sc].defs[v.server.type] = v[sc]
diff --git a/entityDefs/_base.lua b/entityDefs/_base.lua
index a904eb1..dcf63a3 100644
--- a/entityDefs/_base.lua
+++ b/entityDefs/_base.lua
@@ -4,7 +4,7 @@ local base = {
client = {}
}
-for _, sc in pairs{'server', 'client'} do
+for _, sc in ipairs{'server', 'client'} do
base[sc].newDefaults = function()
return {
id = lume.uuid(),
@@ -44,10 +44,11 @@ function base.server:spawn()
end
function base.server:serialize()
- return {
- id = self.id, type = self.type,
- x = self.x, y = self.y
- }
+ local t = {}
+ for _, v in ipairs{'id', 'type', 'x', 'y'} do
+ t[v] = self[v]
+ end
+ return t
end
function base.server:update(dt)
@@ -86,13 +87,13 @@ function base.client:spawn()
end
function base.client:setState(state)
- for _, v in pairs{'x', 'y'} do
+ for _, v in ipairs{'x', 'y'} do
self[v] = state[v]
end
end
function base.client:lerpState(a, b, t)
- for _, v in pairs{'x', 'y'} do
+ for _, v in ipairs{'x', 'y'} do
self[v] = lume.lerp(a[v], b[v], t)
end
end
diff --git a/entityDefs/player.lua b/entityDefs/player.lua
index 96f758a..4f22271 100644
--- a/entityDefs/player.lua
+++ b/entityDefs/player.lua
@@ -5,7 +5,7 @@ local player = {
client = base.client:new()
}
-for _, sc in pairs{'server', 'client'} do
+for _, sc in ipairs{'server', 'client'} do
player[sc].newDefaults = function()
return {
id = lume.uuid(),
@@ -74,33 +74,30 @@ function player.server:spawn()
end
function player.server:serialize()
- return {
- id = self.id, type = self.type,
- name = self.name,
- x = self.x, y = self.y,
- xv = self.xv, yv = self.yv,
- walkTimer = self.walkTimer,
- swingTimer = self.swingTimer,
- swinging = self.swinging,
- automaticSwing = self.automaticSwing,
- direction = self.direction,
- spd = self.spd, xp = self.xp,
- stats = self.stats,
- inventory = self.inventory
- }
+ local t = {}
+ for _, v in ipairs{
+ 'id', 'type', 'name',
+ 'x', 'y', 'xv', 'yv',
+ 'walkTimer', 'swingTimer', 'swinging', 'automaticSwing',
+ 'direction', 'spd', 'xp',
+ 'stats', 'inventory'
+ } do
+ t[v] = self[v]
+ end
+ return t
end
function player.server:setInputState(state)
- for _, v in pairs{'w', 'a', 's', 'd', 'lshift'} do
+ for _, v in ipairs{'w', 'a', 's', 'd', 'lshift'} do
self.inputState[v] = state.keyboard[v]
end
- for _, v in pairs{'lmb', 'x', 'y'} do
+ for _, v in ipairs{'lmb', 'x', 'y'} do
self.inputState[v] = state.mouse[v]
end
end
function player.server:setState(state)
- for _, v in pairs{
+ for _, v in ipairs{
'x', 'y', 'xv', 'yv',
'walkTimer', 'swingTimer', 'swinging',
'direction'
@@ -226,28 +223,28 @@ function player.client:spawn()
end
function player.client:serialize()
- return {
- x = self.x, y = self.y,
- xv = self.xv, yv = self.yv,
- walkTimer = self.walkTimer,
- swingTimer = self.swingTimer,
- swinging = self.swinging,
- direction = self.direction,
- inputState = self.inputState
- }
+ local t = {}
+ for _, v in ipairs{
+ 'x', 'y', 'xv', 'yv',
+ 'walkTimer', 'swingTimer', 'swinging',
+ 'direction', 'inputState'
+ } do
+ t[v] = self[v]
+ end
+ return t
end
function player.client:setInputState(state)
- for _, v in pairs{'w', 'a', 's', 'd', 'lshift'} do
+ for _, v in ipairs{'w', 'a', 's', 'd', 'lshift'} do
self.inputState.keyboard[v] = state.keyboard[v]
end
- for _, v in pairs{'lmb', 'x', 'y'} do
+ for _, v in ipairs{'lmb', 'x', 'y'} do
self.inputState.mouse[v] = state.mouse[v]
end
end
function player.client:setState(state)
- for _, v in pairs{
+ for _, v in ipairs{
'x', 'y', 'xv', 'yv',
'walkTimer', 'swingTimer', 'automaticSwing', 'swinging',
'direction', 'spd', 'xp',
@@ -263,15 +260,15 @@ end
function player.client:lerpState(a, b, t)
local state = {}
- for _, v in pairs{'x', 'y', 'xv', 'yv', 'walkTimer', 'swingTimer'} do
+ for _, v in ipairs{'x', 'y', 'xv', 'yv', 'walkTimer', 'swingTimer'} do
state[v] = lume.lerp(a[v], b[v], t)
end
-- set instead of interpolate timers if b < a
-- todo: interpolate flag
- for _, v in pairs{'walkTimer', 'swingTimer'} do
+ for _, v in ipairs{'walkTimer', 'swingTimer'} do
if b[v] < a[v] then state[v] = b[v] end
end
- for _, v in pairs{'automaticSwing', 'swinging',
+ for _, v in ipairs{'automaticSwing', 'swinging',
'direction', 'spd', 'xp', 'stats', 'inventory'} do
state[v] = b[v]
end
diff --git a/entityDefs/slime.lua b/entityDefs/slime.lua
index 3374eba..4563a6b 100644
--- a/entityDefs/slime.lua
+++ b/entityDefs/slime.lua
@@ -5,7 +5,7 @@ local slime = {
client = base.client:new()
}
-for _, sc in pairs{'server', 'client'} do
+for _, sc in ipairs{'server', 'client'} do
slime[sc].newDefaults = function()
return {
id = lume.uuid(),
@@ -64,13 +64,15 @@ function slime.server:spawn()
end
function slime.server:serialize()
- return {
- id = self.id, type = self.type,
- x = self.x, y = self.y,
- xv = self.xv, yv = self.yv,
- slimeType = self.slimeType,
- hpMax = self.hpMax, hp = self.hp
- }
+ local t = {}
+ for _, v in ipairs{
+ 'id', 'type',
+ 'x', 'y', 'xv', 'yv',
+ 'slimeType', 'hpMax', 'hp'
+ } do
+ t[v] = self[v]
+ end
+ return t
end
function slime.server:update(dt)
@@ -179,7 +181,7 @@ function slime.client:spawn()
end
function slime.client:setState(state)
- for _, v in pairs{'x', 'y', 'xv', 'yv', 'slimeType', 'hpMax', 'hp'} do
+ for _, v in ipairs{'x', 'y', 'xv', 'yv', 'slimeType', 'hpMax', 'hp'} do
self[v] = state[v]
end
if self.body and not self.body:isDestroyed() then
@@ -190,10 +192,10 @@ end
function slime.client:lerpState(a, b, t)
local state = {}
- for _, v in pairs{'x', 'y', 'xv', 'yv'} do
+ for _, v in ipairs{'x', 'y', 'xv', 'yv'} do
state[v] = lume.lerp(a[v], b[v], t)
end
- for _, v in pairs{'slimeType', 'hpMax', 'hp'} do
+ for _, v in ipairs{'slimeType', 'hpMax', 'hp'} do
state[v] = b[v]
end
self:setState(state)
diff --git a/hud.lua b/hud.lua
index 93deebe..526ab92 100644
--- a/hud.lua
+++ b/hud.lua
@@ -367,14 +367,14 @@ function hud.draw()
love.graphics.setFont(font)
local stats_x, stats_y = 202, 227
local stats_dx, stats_dy = 20, 11
- for j, row in pairs{'base', 'arm', 'total'} do
+ for j, row in ipairs{'base', 'arm', 'total'} do
local c = ({
{255/255, 175/255, 48/255},
{255/255, 84/255, 252/255},
{48/255, 255/255, 241/255}
})[j]
love.graphics.setColor(c)
- for i, col in pairs{'vit', 'atk', 'spd', 'wis', 'def', 'reg'} do
+ for i, col in ipairs{'vit', 'atk', 'spd', 'wis', 'def', 'reg'} do
local sx = stats_x + stats_dx*(i-1)
local sy = stats_y + stats_dy*(j-1)
sx = x + (sx - hud.statsPanel.openPos.x)
diff --git a/loadassets.lua b/loadassets.lua
index e9a0dcf..7780bd1 100644
--- a/loadassets.lua
+++ b/loadassets.lua
@@ -153,7 +153,7 @@ love.graphics.clear(0, 0, 0)
love.graphics.setCanvas()
-- black tile
table.insert(tileImgs, love.graphics.newImage(tileCanv:newImageData()))
-for _, v in pairs{'grass', 'sand', 'rock', 'water'} do
+for _, v in ipairs{'grass', 'sand', 'rock', 'water'} do
love.graphics.setCanvas(tileCanv)
love.graphics.clear()
love.graphics.draw(tileSheets.ts1.sheet, tileSheets.ts1.quads[v], 0, 0)
diff --git a/lootBag.lua b/lootBag.lua
index 4cce337..1ef7660 100644
--- a/lootBag.lua
+++ b/lootBag.lua
@@ -5,7 +5,7 @@ lootBag = {
}
local defaults = {server={}, client={}}
-for _, sc in pairs{'server', 'client'} do
+for _, sc in ipairs{'server', 'client'} do
for k, v in pairs{x=0, y=0, type='lootBag'} do
defaults[sc][k] = function() return v end
end
diff --git a/menu.lua b/menu.lua
index 69fe126..154dcfc 100644
--- a/menu.lua
+++ b/menu.lua
@@ -1,13 +1,6 @@
menu = {}
-menu.state = 'main'
-menu.buttons = {}
-menu.inputs = {}
-menu.infos = {}
-menu.activeInput = nil
-menu.logoAnimTimer = 0
-
function menu.addButton(t)
local defaults = {
state = 'main',
@@ -77,50 +70,96 @@ function menu.addInfo(t)
return t
end
-function menu.load()
- local menuFactoryDefaults = {
- name = 'Player',
- ip = '127.0.0.1',
- port = '1357',
- resolution = 2,
- fullscreen = 1,
- vsync = true,
- cursorLock = false
- }
+menu.factoryDefaults = {
+ name = 'Player',
+ ip = '127.0.0.1',
+ port = '1357',
+ resolution = 1,
+ fullscreen = 1,
+ vsync = false,
+ cursorLock = false
+}
- local menuDefaults
- function menu.readDefaults()
- local path = love.filesystem.getRealDirectory('menuDefaults.json') .. '/menuDefaults.json'
- local file = io.open(path, 'rb')
- local content = file:read('*a')
- file:close()
- menuDefaults = json.decode(content)
- for k, v in pairs(menuFactoryDefaults) do
- if menuDefaults[k] == nil then
- menuDefaults[k] = v
- end
+function menu.readDefaults()
+ local path = love.filesystem.getRealDirectory('menuDefaults.json') .. '/menuDefaults.json'
+ local file = io.open(path, 'rb')
+ local content = file:read('*a')
+ file:close()
+ menu.defaults = json.decode(content)
+ for k, v in pairs(menu.factoryDefaults) do
+ if menu.defaults[k] == nil then
+ menu.defaults[k] = v
end
end
+end
+
+function menu.writeDefaults()
+ local content = json.encode{
+ name = menu.nameInput.value,
+ ip = menu.ipInput.value,
+ port = menu.portInput.value,
+ resolution = menu.resolutionBtn.active,
+ fullscreen = menu.fullscreenBtn.active,
+ vsync = menu.vsyncBtn.active,
+ cursorLock = menu.cursorLockBtn.active
+ }
+ love.filesystem.write('menuDefaults.json', content)
+end
+
+function menu.applyOptions()
+ local w, h, flags = love.window.getMode()
+ local vsyncOn = flags.vsync ~= 0
+ flags.vsync = menu.defaults.vsync and 1 or 0
+
+ local fullscreen, fstype = love.window.getFullscreen()
+ local newResolution = menu.resolutionBtn.items[menu.defaults.resolution]
+ if not (fullscreen and fstype == 'desktop')
+ and newResolution ~= string.format('%sx%s', w, h) then
+ w, h = newResolution:match('(%d+)x(%d+)')
+ local wd, hd = love.window.getDesktopDimensions()
+ flags.x = wd/2 - w/2
+ flags.y = hd/2 - h/2
+ love.window.setMode(w, h, flags)
+ love.resize(w, h)
+ elseif vsyncOn ~= menu.defaults.vsync then
+ love.window.setMode(w, h, flags)
+ end
+
+ local currentWindowType = love.window.getFullscreen()
+ local newWindowType = menu.fullscreenBtn.items[menu.defaults.fullscreen]
+ if newWindowType == 'Windowed'
+ and currentWindowType ~= 'Windowed' then
+ love.window.setFullscreen(false)
+ w, h = love.graphics.getDimensions()
+ love.resize(w, h)
+ elseif newWindowType == 'Borderless Fullscreen Windowed'
+ and currentWindowType ~= 'Borderless Fullscreen Windowed' then
+ love.window.setFullscreen(true, 'desktop')
+ w, h = love.graphics.getDimensions()
+ love.resize(w, h)
+ elseif newWindowType == 'Fullscreen'
+ and currentWindowType ~= 'Fullscreen' then
+ love.window.setFullscreen(true, 'exclusive')
+ w, h = love.graphics.getDimensions()
+ love.resize(w, h)
+ end
+end
+
+function menu.load()
+ menu.state = 'main'
+ menu.buttons = {}
+ menu.inputs = {}
+ menu.infos = {}
+ menu.activeInput = nil
+ menu.logoAnimTimer = 0
+
if not pcall(menu.readDefaults) then
-- write default if not exist or malformed
- local content = json.encode(menuFactoryDefaults)
+ local content = json.encode(menu.factoryDefaults)
love.filesystem.write('menuDefaults.json', content)
menu.readDefaults()
end
- function menu.writeDefaults()
- local content = json.encode{
- name = menu.nameInput.value,
- ip = menu.ipInput.value,
- port = menu.portInput.value,
- resolution = menu.resolutionBtn.active,
- fullscreen = menu.fullscreenBtn.active,
- vsync = menu.vsyncBtn.active,
- cursorLock = menu.cursorLockBtn.active
- }
- love.filesystem.write('menuDefaults.json', content)
- end
-
local exitY = 220
local h = 40
menu.addButton{text='Play', y=exitY - h*2.5, action = function()
@@ -133,7 +172,7 @@ function menu.load()
love.event.quit()
end}
- menu.nameInput = menu.addInput{state='play', text='Player Name', value=menuDefaults.name, x=gsx/2 - 70, y=exitY - h*2}
+ menu.nameInput = menu.addInput{state='play', text='Player Name', value=menu.defaults.name, x=gsx/2 - 70, y=exitY - h*2}
menu.addButton{state='play', text='Singleplayer', x=gsx/2 - 70, y=exitY - h*1, action=function()
chat.log = {}
server.start(nil, true)
@@ -141,8 +180,8 @@ function menu.load()
menu.state = 'connect'
menu.connectInfo.text = 'Starting Game'
end}
- menu.ipInput = menu.addInput{state='play', text='IP', value=menuDefaults.ip, x=gsx/2 + 70, y=exitY - h*3}
- menu.portInput = menu.addInput{state='play', text='Port', value=menuDefaults.port, x=gsx/2 + 70, y=exitY - h*2}
+ menu.ipInput = menu.addInput{state='play', text='IP', value=menu.defaults.ip, x=gsx/2 + 70, y=exitY - h*3}
+ menu.portInput = menu.addInput{state='play', text='Port', value=menu.defaults.port, x=gsx/2 + 70, y=exitY - h*2}
menu.addButton{state='play', text='Host', x=gsx/2 + 70 - 25, y=exitY - h*1, action=function()
chat.log = {}
-- todo: notify if not open or other err
@@ -178,9 +217,9 @@ function menu.load()
menu.resolutionBtn = menu.addButton{state='options', text='Resolution', y=exitY - h*4,
type='cycle', items={'960x540', '1440x810', '1920x1080'},
- active=menuDefaults.resolution, action=function(v)
+ active=menu.defaults.resolution, action=function(v)
local fullscreen, fstype = love.window.getFullscreen()
- if not (fullscreen and fstype == 'desktop') then
+ if not fullscreen then
local w, h, flags = love.window.getMode()
w, h = v:match('(%d+)x(%d+)')
local wd, hd = love.window.getDesktopDimensions()
@@ -197,7 +236,7 @@ function menu.load()
love.graphics.setColor(0.4, 0.4, 0.4)
end
local fullscreen, fstype = love.window.getFullscreen()
- if fullscreen and fstype == 'desktop' then
+ if fullscreen then
love.graphics.setColor(0.7, 0.7, 0.7)
end
love.graphics.rectangle('fill', v.bx, v.by, v.bw, v.bh)
@@ -206,7 +245,7 @@ function menu.load()
text.print(v.text, lume.round(v.x - v.font:getWidth(v.text)/2), lume.round(v.by - v.font:getHeight()))
love.graphics.setColor(1, 1, 1)
local txt = v.items[v.active]
- if fullscreen and fstype == 'desktop' then
+ if fullscreen then
local w, h = love.graphics.getDimensions()
txt = w .. 'x' .. h
end
@@ -214,71 +253,51 @@ function menu.load()
end}
menu.fullscreenBtn = menu.addButton{state='options', text='Fullscreen', y=exitY - h*3,
type='cycle', items={'Windowed', 'Borderless Fullscreen Windowed', 'Fullscreen'},
- active=menuDefaults.fullscreen, action=function(v)
+ active=menu.defaults.fullscreen, action=function(v)
if v == 'Windowed' then
- love.window.setFullscreen(false)
- local w, h = love.graphics.getDimensions()
+ local w, h, flags = love.window.getMode()
+ local rb = menu.resolutionBtn
+ w, h = rb.items[rb.active]:match('(%d+)x(%d+)')
+ flags.fullscreen = false
+ flags.fullscreentype = 'desktop'
+ love.window.setMode(w, h, flags)
love.resize(w, h)
+ local dw, dh = love.window.getDesktopDimensions(flags.display)
+ love.window.setPosition(lume.round(dw/2 - w/2), lume.round(dh/2 - h/2))
elseif v == 'Borderless Fullscreen Windowed' then
- love.window.setFullscreen(true, 'desktop')
- local w, h = love.graphics.getDimensions()
+ local w, h, flags = love.window.getMode()
+ w, h = love.window.getDesktopDimensions(flags.display)
+ flags.fullscreen = true
+ flags.fullscreentype = 'desktop'
+ love.window.setMode(w, h, flags)
love.resize(w, h)
elseif v == 'Fullscreen' then
- love.window.setFullscreen(true, 'exclusive')
- local w, h = love.graphics.getDimensions()
+ local w, h, flags = love.window.getMode()
+ w, h = love.window.getDesktopDimensions(flags.display)
+ flags.fullscreen = true
+ flags.fullscreentype = 'exclusive'
+ love.window.setMode(w, h, flags)
love.resize(w, h)
end
end}
menu.vsyncBtn = menu.addButton{state='options', text='Vsync', y=exitY - h*2.2, type='toggle',
- active=menuDefaults.vsync, action=function(v)
+ active=menu.defaults.vsync, action=function(v)
local w, h, flags = love.window.getMode()
- flags.vsync = v
+ flags.vsync = v and 1 or 0
love.window.setMode(w, h, flags)
end}
- menu.cursorLockBtn = menu.addButton{state='options', text='Cursor Lock', y=exitY - h*1.4, type='toggle', active=menuDefaults.cursorLock}
+ menu.cursorLockBtn = menu.addButton{state='options', text='Cursor Lock', y=exitY - h*1.4, type='toggle', active=menu.defaults.cursorLock}
menu.addButton{state='options', text='Back', y=exitY, action=function()
menu.state = 'main'
end}
+ menu.addButton{state='options', text='Load Defaults', x=400, y=exitY, action=function()
+ local content = json.encode(menu.factoryDefaults)
+ love.filesystem.write('menuDefaults.json', content)
+ menu.load()
+ menu.state = 'options'
+ end}
- -- apply options (block-local vars)
- repeat
- local w, h, flags = love.window.getMode()
- local vsyncOn = flags.vsync
- flags.vsync = menuDefaults.vsync
-
- local fullscreen, fstype = love.window.getFullscreen()
- local newResolution = menu.resolutionBtn.items[menuDefaults.resolution]
- if not (fullscreen and fstype == 'desktop')
- and newResolution ~= string.format('%sx%s', w, h) then
- w, h = newResolution:match('(%d+)x(%d+)')
- local wd, hd = love.window.getDesktopDimensions()
- flags.x = wd/2 - w/2
- flags.y = hd/2 - h/2
- love.window.setMode(w, h, flags)
- love.resize(w, h)
- elseif vsyncOn ~= menuDefaults.vsync then
- love.window.setMode(w, h, flags)
- end
-
- local currentWindowType = love.window.getFullscreen()
- local newWindowType = menu.fullscreenBtn.items[menuDefaults.fullscreen]
- if newWindowType == 'Windowed'
- and currentWindowType ~= 'Windowed' then
- love.window.setFullscreen(false)
- w, h = love.graphics.getDimensions()
- love.resize(w, h)
- elseif newWindowType == 'Borderless Fullscreen Windowed'
- and currentWindowType ~= 'Borderless Fullscreen Windowed' then
- love.window.setFullscreen(true, 'desktop')
- w, h = love.graphics.getDimensions()
- love.resize(w, h)
- elseif newWindowType == 'Fullscreen'
- and currentWindowType ~= 'Fullscreen' then
- love.window.setFullscreen(true, 'exclusive')
- w, h = love.graphics.getDimensions()
- love.resize(w, h)
- end
- until true
+ menu.applyOptions()
end
function menu.update(dt)
diff --git a/physics.lua b/physics.lua
index fc0f317..7344c66 100644
--- a/physics.lua
+++ b/physics.lua
@@ -7,7 +7,7 @@ physics = {
love.physics.setMeter(16)
local defaults = {server={}, client={}}
-for _, sc in pairs{'server', 'client'} do
+for _, sc in ipairs{'server', 'client'} do
defaults[sc].postUpdateQueue = function() return {} end
end
@@ -25,7 +25,7 @@ end
function physics.server:load()
self.beginContact = function(a, b, coll)
- for _, v in pairs{{a, b}, {b, a}} do
+ for _, v in ipairs{{a, b}, {b, a}} do
local fixa = v[1]
local fixb = v[2]
local uda = fixa:getUserData() or {}
@@ -83,7 +83,7 @@ end
function physics.client:load()
self.beginContact = function(a, b, coll)
- for _, v in pairs{{a, b}, {b, a}} do
+ for _, v in ipairs{{a, b}, {b, a}} do
local fixa = v[1]
local fixb = v[2]
local uda = fixa:getUserData() or {}
diff --git a/playerController.lua b/playerController.lua
index fd8a8cb..c4e592e 100644
--- a/playerController.lua
+++ b/playerController.lua
@@ -17,7 +17,7 @@ function playerController.update(dt)
-- update player input
local inputState = {keyboard={}, mouse={}}
- for _, key in pairs{'w', 'a', 's', 'd', 'lshift'} do
+ for _, key in ipairs{'w', 'a', 's', 'd', 'lshift'} do
inputState.keyboard[key] = love.keyboard.isScancodeDown(key) and not chat.active
end
inputState.mouse.lmb = love.mouse.isDown(1) and not uiMouseDown
diff --git a/realm.lua b/realm.lua
index 72c9971..d1c7ed9 100644
--- a/realm.lua
+++ b/realm.lua
@@ -5,13 +5,13 @@ realm = {
}
local defaults = {server={}, client={}}
-for _, sc in pairs{'server', 'client'} do
+for _, sc in ipairs{'server', 'client'} do
defaults[sc].id = function() return lume.uuid() end
defaults[sc].name = function() return 'realm' end
- for _, v in pairs{'entities', 'projectiles', 'slimeBalls', 'lootBags', 'portals'} do
+ for _, v in ipairs{'entities', 'projectiles', 'slimeBalls', 'lootBags', 'portals'} do
defaults[sc][v] = function() return {} end
end
- for _, v in pairs{{'physics', physics}, {'world', world}} do
+ for _, v in ipairs{{'physics', physics}, {'world', world}} do
defaults[sc][v[1]] = function() return v[2][sc]:new() end
end
end
diff --git a/server.lua b/server.lua
index 4124a21..f786e7d 100644
--- a/server.lua
+++ b/server.lua
@@ -21,7 +21,7 @@ function server.start(port, singleplayer)
requestPlayer = function(self, data, clientId)
local postfix = 0
local reservedNames = {}
- for _, v in pairs{'Server', 'server'} do reservedNames[v] = true end
+ for _, v in ipairs{'Server', 'server'} do reservedNames[v] = true end
while server.playerNames[buildName(data, postfix)]
or reservedNames[buildName(data, postfix)] do
postfix = postfix + 1
diff --git a/world.lua b/world.lua
index c927a8d..5dc5ab8 100644
--- a/world.lua
+++ b/world.lua
@@ -7,7 +7,7 @@ world = {
local chunkSize = 8
local defaults = {server={}, client={}}
-for _, sc in pairs{'server', 'client'} do
+for _, sc in ipairs{'server', 'client'} do
defaults[sc].chunks = function() return {} end
defaults[sc].chunkSize = function() return chunkSize end
end