fix: mark as local some forgotten local variables

This commit is contained in:
Kazhnuz 2020-09-13 16:57:06 +02:00
parent 877de98f67
commit 250d75ee77
15 changed files with 31 additions and 27 deletions

View file

@ -2,6 +2,10 @@
"Lua.diagnostics.globals": [ "Lua.diagnostics.globals": [
"love", "love",
"unpack", "unpack",
"loadstring" "loadstring",
"game",
"core",
"scenes",
"utils"
] ]
} }

View file

@ -69,6 +69,7 @@ end
function InputManager:getKey(sourceid, padkey) function InputManager:getKey(sourceid, padkey)
local padkey = padkey local padkey = padkey
local key
for k,v in pairs(self.data[sourceid].keys) do for k,v in pairs(self.data[sourceid].keys) do
if (k == padkey) then key = v end if (k == padkey) then key = v end
end end

View file

@ -32,7 +32,7 @@ function Background:new(filepath)
self.batch = love.graphics.newSpriteBatch(self.image , 1000 ) self.batch = love.graphics.newSpriteBatch(self.image , 1000 )
self.width, self.height = self.image:getDimensions() self.width, self.height = self.image:getDimensions()
screenwidth, screenheight = core.screen:getDimensions() local screenwidth, screenheight = core.screen:getDimensions()
local w = math.floor(screenwidth / self.width) * self.width + 1 local w = math.floor(screenwidth / self.width) * self.width + 1
local h = math.floor(screenheight / self.height) * self.height + 1 local h = math.floor(screenheight / self.height) * self.height + 1

View file

@ -137,7 +137,7 @@ function GameSystem:write()
if (self.currentSlot > 0) then if (self.currentSlot > 0) then
local data = self:getData() local data = self:getData()
savepath = self:getSavePath(self.currentSlot, true) local savepath = self:getSavePath(self.currentSlot, true)
binser.writeFile(savepath, data) binser.writeFile(savepath, data)
end end
end end

View file

@ -147,7 +147,7 @@ end
-- Handle the keyboard/manette functions -- Handle the keyboard/manette functions
function GridBox:keyreleased(key, code) function GridBox:keyreleased(key, code)
slotID = self:getWidgetSlot(self.widget.selected) local slotID = self:getWidgetSlot(self.widget.selected)
local col, line = self.cursor.x, self.cursor.y local col, line = self.cursor.x, self.cursor.y
if key == 'left' then if key == 'left' then
self:moveCol(-1) self:moveCol(-1)
@ -181,13 +181,13 @@ function GridBox:moveCol(direction)
if utils.math.sign(xx - orig_x) == direction then if utils.math.sign(xx - orig_x) == direction then
if utils.math.pointDistance(orig_x, orig_y, xx, yy) < distance then if utils.math.pointDistance(orig_x, orig_y, xx, yy) < distance then
distance = utils.math.pointDistance(orig_x, orig_y, xx, yy) distance = utils.math.pointDistance(orig_x, orig_y, xx, yy)
nearestWidget = v.widgetID nearastWidget = v.widgetID
end end
end end
end end
if nearestWidget ~= 0 then if nearastWidget ~= 0 then
self.widget.selected = nearestWidget self.widget.selected = nearastWidget
end end
end end
@ -202,13 +202,13 @@ function GridBox:moveLine(direction)
if utils.math.sign(yy - orig_y) == direction then if utils.math.sign(yy - orig_y) == direction then
if utils.math.pointDistance(orig_x, orig_y, xx, yy) < distance then if utils.math.pointDistance(orig_x, orig_y, xx, yy) < distance then
distance = utils.math.pointDistance(orig_x, orig_y, xx, yy) distance = utils.math.pointDistance(orig_x, orig_y, xx, yy)
nearestWidget = v.widgetID nearastWidget = v.widgetID
end end
end end
end end
if nearestWidget ~= 0 then if nearastWidget ~= 0 then
self.widget.selected = nearestWidget self.widget.selected = nearastWidget
end end
end end

View file

@ -118,7 +118,7 @@ function BaseActor:setFilter()
end end
function BaseActor:getFuturePosition(dt) function BaseActor:getFuturePosition(dt)
local dx, dy local dx, dy, dz
dx = self.x + self.xsp * dt dx = self.x + self.xsp * dt
dy = self.y + self.ysp * dt dy = self.y + self.ysp * dt
dz = self.z + self.zsp * dt dz = self.z + self.zsp * dt

View file

@ -178,7 +178,7 @@ function CameraSystem:attachView(id)
self.current_canvas = love.graphics.getCanvas() self.current_canvas = love.graphics.getCanvas()
love.graphics.setCanvas(view.canvas) love.graphics.setCanvas(view.canvas)
love.graphics.clear() love.graphics.clear()
local tx, ty, scale
if id ~= nil then if id ~= nil then
-- Du à la manière dont fonctionne STI, on est obligé de récupérer les info -- Du à la manière dont fonctionne STI, on est obligé de récupérer les info
-- de position de camera pour afficher la carte par rapport à ces infos -- de position de camera pour afficher la carte par rapport à ces infos

View file

@ -119,7 +119,7 @@ function OptionsManager:getTranslationDefaultData()
local _path = TRANSLATION_PATH .. "init.lua" local _path = TRANSLATION_PATH .. "init.lua"
local fileinfo = love.filesystem.getInfo(_path) local fileinfo = love.filesystem.getInfo(_path)
local datas = nil local datas = nil
local lang
if fileinfo ~= nil then if fileinfo ~= nil then
lang = require(TRANSLATION_PATH) lang = require(TRANSLATION_PATH)
lang.current = lang.default or "en" lang.current = lang.default or "en"
@ -144,12 +144,12 @@ end
function OptionsManager:write() function OptionsManager:write()
local data = self:getData() local data = self:getData()
filepath = self:getFile(true) local filepath = self:getFile(true)
binser.writeFile(filepath, data) binser.writeFile(filepath, data)
end end
function OptionsManager:read() function OptionsManager:read()
filepath = self:getFile(true) local filepath = self:getFile(true)
if utils.filesystem.exists("options.data") then if utils.filesystem.exists("options.data") then
local loadedDatas = binser.readFile(filepath) local loadedDatas = binser.readFile(filepath)
self.controller.debug:print("core/options", "data file found, loading it") self.controller.debug:print("core/options", "data file found, loading it")

View file

@ -69,7 +69,7 @@ function Graphics.printWithSpacing(text, spacing, align, x, y, r, sx, sy, ox, oy
for i=1, lenght do for i=1, lenght do
local char = string.sub(text, i, i) local char = string.sub(text, i, i)
pos = math.floor(x + xx - width) local pos = math.floor(x + xx - width)
love.graphics.print(char, pos, y) love.graphics.print(char, pos, y)
xx = xx + font:getWidth(char) + spacing xx = xx + font:getWidth(char) + spacing
end end

View file

@ -63,7 +63,7 @@ function Math.vector(x1, y1, x2, y2)
local vecx, vecy local vecx, vecy
vecx = x2 - x1 vecx = x2 - x1
vexy = y2 - y1 vecy = y2 - y1
return vecx, vecy return vecx, vecy
end end

View file

@ -71,8 +71,8 @@ end
function AbstractCharacter:setLevel(newlevel) function AbstractCharacter:setLevel(newlevel)
self.level = newlevel self.level = newlevel
local exp, exp_next, exp_current local exp, exp_next, exp_current
exp_min = charutils.getExpValue(self.level) local exp_min = charutils.getExpValue(self.level)
exp_max = charutils.getExpValue(self.level + 1) local exp_max = charutils.getExpValue(self.level + 1)
exp = self.exp exp = self.exp
self.exp = math.max(math.min(exp, exp_max - 1), exp_min) self.exp = math.max(math.min(exp, exp_max - 1), exp_min)

View file

@ -64,7 +64,7 @@ end
function Game:read(save_id) function Game:read(save_id)
self.slot = save_id self.slot = save_id
if (self.slot > 0) then if (self.slot > 0) then
filepath = self:getSaveFile(self.slot, true) local filepath = self:getSaveFile(self.slot, true)
if love.filesystem.exists("save" .. self.slot .. ".save") then if love.filesystem.exists("save" .. self.slot .. ".save") then
local loadedDatas = binser.readFile(filepath) local loadedDatas = binser.readFile(filepath)
@ -78,7 +78,7 @@ function Game:write(save_id)
if (self.slot > 0) then if (self.slot > 0) then
local data = self:getData() local data = self:getData()
filepath = self:getSaveFile(self.slot, true) local filepath = self:getSaveFile(self.slot, true)
binser.writeFile(filepath, data) binser.writeFile(filepath, data)
end end
end end
@ -99,7 +99,7 @@ end
function Game:resetSaves() function Game:resetSaves()
for i=1, self.slotNumber do for i=1, self.slotNumber do
filepath = self:getSaveFile(i, true) local filepath = self:getSaveFile(i, true)
if love.filesystem.exists("save" .. i .. ".save") then if love.filesystem.exists("save" .. i .. ".save") then
love.filesystem.remove( "save" .. i .. ".save" ) love.filesystem.remove( "save" .. i .. ".save" )
end end
@ -111,8 +111,7 @@ function Game:update(dt)
end end
function Game:getTime() function Game:getTime()
local time = self.gametime local hours, minutes, seconds
local hours, minute, seconds
seconds = math.floor(self.gametime) seconds = math.floor(self.gametime)
minutes = math.floor(seconds / 60) minutes = math.floor(seconds / 60)
hours = math.floor(minutes / 60) hours = math.floor(minutes / 60)

View file

@ -19,7 +19,7 @@ function Pocket:addItem(item, number)
end end
if (not success) then if (not success) then
itemData = {} local itemData = {}
itemData.name = item itemData.name = item
itemData.number = number itemData.number = number
table.insert(self.list, itemData) table.insert(self.list, itemData)

View file

@ -28,7 +28,7 @@ function Charset:addChar(ii, jj)
local charx, chary = (jj-1)*(CHARWIDTH*3), (ii-1)*(CHARHEIGHT*4) local charx, chary = (jj-1)*(CHARWIDTH*3), (ii-1)*(CHARHEIGHT*4)
local char = {} local char = {}
for i=1, 4 do for i=1, 4 do
animatedDirection = {} local animatedDirection = {}
local running = {} local running = {}
for j=1, 3 do for j=1, 3 do
local x, y = charx + ((j-1)*CHARWIDTH), (chary + (i-1)*CHARHEIGHT) local x, y = charx + ((j-1)*CHARWIDTH), (chary + (i-1)*CHARHEIGHT)

View file

@ -90,7 +90,7 @@ end
function menu.BoxedWidget:drawCanvas() function menu.BoxedWidget:drawCanvas()
love.graphics.draw(self.box, 0, 0) love.graphics.draw(self.box, 0, 0)
h = math.floor(self.height / 2) - (self.font:getHeight() / 2) - 1 local h = math.floor(self.height / 2) - (self.font:getHeight() / 2) - 1
love.graphics.setColor(0, 0, 0, .8) love.graphics.setColor(0, 0, 0, .8)
self.font:print(self.label, 17, h, "left") self.font:print(self.label, 17, h, "left")
self.font:print(self.label2, self.width - 8, h, "right") self.font:print(self.label2, self.width - 8, h, "right")