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": [
"love",
"unpack",
"loadstring"
"loadstring",
"game",
"core",
"scenes",
"utils"
]
}

View file

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

View file

@ -32,7 +32,7 @@ function Background:new(filepath)
self.batch = love.graphics.newSpriteBatch(self.image , 1000 )
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 h = math.floor(screenheight / self.height) * self.height + 1

View file

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

View file

@ -147,7 +147,7 @@ end
-- Handle the keyboard/manette functions
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
if key == 'left' then
self:moveCol(-1)
@ -181,13 +181,13 @@ function GridBox:moveCol(direction)
if utils.math.sign(xx - orig_x) == direction then
if utils.math.pointDistance(orig_x, orig_y, xx, yy) < distance then
distance = utils.math.pointDistance(orig_x, orig_y, xx, yy)
nearestWidget = v.widgetID
nearastWidget = v.widgetID
end
end
end
if nearestWidget ~= 0 then
self.widget.selected = nearestWidget
if nearastWidget ~= 0 then
self.widget.selected = nearastWidget
end
end
@ -202,13 +202,13 @@ function GridBox:moveLine(direction)
if utils.math.sign(yy - orig_y) == direction then
if utils.math.pointDistance(orig_x, orig_y, xx, yy) < distance then
distance = utils.math.pointDistance(orig_x, orig_y, xx, yy)
nearestWidget = v.widgetID
nearastWidget = v.widgetID
end
end
end
if nearestWidget ~= 0 then
self.widget.selected = nearestWidget
if nearastWidget ~= 0 then
self.widget.selected = nearastWidget
end
end

View file

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

View file

@ -178,7 +178,7 @@ function CameraSystem:attachView(id)
self.current_canvas = love.graphics.getCanvas()
love.graphics.setCanvas(view.canvas)
love.graphics.clear()
local tx, ty, scale
if id ~= nil then
-- 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

View file

@ -119,7 +119,7 @@ function OptionsManager:getTranslationDefaultData()
local _path = TRANSLATION_PATH .. "init.lua"
local fileinfo = love.filesystem.getInfo(_path)
local datas = nil
local lang
if fileinfo ~= nil then
lang = require(TRANSLATION_PATH)
lang.current = lang.default or "en"
@ -144,12 +144,12 @@ end
function OptionsManager:write()
local data = self:getData()
filepath = self:getFile(true)
local filepath = self:getFile(true)
binser.writeFile(filepath, data)
end
function OptionsManager:read()
filepath = self:getFile(true)
local filepath = self:getFile(true)
if utils.filesystem.exists("options.data") then
local loadedDatas = binser.readFile(filepath)
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
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)
xx = xx + font:getWidth(char) + spacing
end

View file

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

View file

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

View file

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

View file

@ -19,7 +19,7 @@ function Pocket:addItem(item, number)
end
if (not success) then
itemData = {}
local itemData = {}
itemData.name = item
itemData.number = number
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 char = {}
for i=1, 4 do
animatedDirection = {}
local animatedDirection = {}
local running = {}
for j=1, 3 do
local x, y = charx + ((j-1)*CHARWIDTH), (chary + (i-1)*CHARHEIGHT)

View file

@ -90,7 +90,7 @@ end
function menu.BoxedWidget:drawCanvas()
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)
self.font:print(self.label, 17, h, "left")
self.font:print(self.label2, self.width - 8, h, "right")