# HG changeset patch # User Wuzzy # Date 1542585276 -3600 # Node ID 74bf2d906097871468b926b2b5c9c6629f493470 # Parent 8edbdd3a1fe74195c034a57698aad6a540caa3a0 Turn accidental globals to locals in Lua libraries diff -r 8edbdd3a1fe7 -r 74bf2d906097 share/hedgewars/Data/Scripts/Achievements.lua --- a/share/hedgewars/Data/Scripts/Achievements.lua Mon Nov 19 00:19:21 2018 +0100 +++ b/share/hedgewars/Data/Scripts/Achievements.lua Mon Nov 19 00:54:36 2018 +0100 @@ -3,10 +3,10 @@ function awardAchievement(name, statMessage, capgrp) local achievementString = string.format(loc("Achievement gotten: %s"), name) if capgrp == nil then - captionType = capgrpMessage2 + capgrp = capgrpMessage2 end if capgrp ~= false then - AddCaption(achievementString, 0xFFBA00FF, capgrpMessage2) + AddCaption(achievementString, 0xFFBA00FF, capgrp) end if not statMessage then statMessage = achievementString diff -r 8edbdd3a1fe7 -r 74bf2d906097 share/hedgewars/Data/Scripts/Animate.lua --- a/share/hedgewars/Data/Scripts/Animate.lua Mon Nov 19 00:19:21 2018 +0100 +++ b/share/hedgewars/Data/Scripts/Animate.lua Mon Nov 19 00:54:36 2018 +0100 @@ -1,7 +1,7 @@ local animPos, lastx, lasty, jumpTypes, jumpTimes, moveDirs, jumpStarted local moveTime = 0 local backJumped, jTimer, awTime, globalWait, stageEvents, seNum, curEvent -local needtoDecrease +local needToDecrease local AnimList, AnimListNum local FunctionList, FunctionListNum local skipFuncList @@ -168,7 +168,7 @@ end function AnimMove(gear, dir, posx, posy, maxMoveTime) - dirr = moveDirs[dir] + local dirr = moveDirs[dir] SetGearMessage(gear, dirr) moveTime = moveTime + 1 if (maxMoveTime and moveTime > maxMoveTime) then @@ -201,8 +201,8 @@ SetGearMessage(gear, jumpTypes[jumpType]) AnimGearWait(gear, jumpTimes["backback"]) else - curx = GetX(gear) - cury = GetY(gear) + local curx = GetX(gear) + local cury = GetY(gear) if curx == lastx and cury == lasty then jumpStarted = false backJumped = false @@ -274,7 +274,7 @@ if args == nil then args = {} end - retval = func(unpack(args)) + local retval = func(unpack(args)) if retval == false then return false else @@ -342,7 +342,7 @@ end startCinemaLock() - retVal = steps[animPos].func(unpack(steps[animPos].args)) + local retVal = steps[animPos].func(unpack(steps[animPos].args)) if (retVal ~= false) then animPos = animPos + 1 end @@ -427,6 +427,6 @@ -- We consider the gear to be “stopped” if it has been destroyed return true end - dx,dy = GetGearVelocity(gear) + local dx,dy = GetGearVelocity(gear) return math.abs(dx) <= 1 and math.abs(dy) <= 1 end diff -r 8edbdd3a1fe7 -r 74bf2d906097 share/hedgewars/Data/Scripts/OfficialChallenges.lua --- a/share/hedgewars/Data/Scripts/OfficialChallenges.lua Mon Nov 19 00:19:21 2018 +0100 +++ b/share/hedgewars/Data/Scripts/OfficialChallenges.lua Mon Nov 19 00:54:36 2018 +0100 @@ -21,7 +21,7 @@ function detectMapWithDigest() if RopePercent == 100 and MinesNum == 0 then - mapString = hashDigest() .. "," .. LandDigest + local mapString = hashDigest() .. "," .. LandDigest if band(GameFlags, gfBorder) ~= 0 then mapString = "Border," .. mapString diff -r 8edbdd3a1fe7 -r 74bf2d906097 share/hedgewars/Data/Scripts/SimpleMission.lua --- a/share/hedgewars/Data/Scripts/SimpleMission.lua Mon Nov 19 00:19:21 2018 +0100 +++ b/share/hedgewars/Data/Scripts/SimpleMission.lua Mon Nov 19 00:54:36 2018 +0100 @@ -342,7 +342,7 @@ local g4 = (not goal.yMax) or gY <= goal.yMax return g1 and g2 and g3 and g4 elseif goal.type == "distGearPos" or goal.type == "distGearGear" then - local gX, tY, tX, tY + local gX, gY, tX, tY if goal.type == "distGearPos" then if getGearValue(_G.sm.goalGears[goal.id], "sm_destroyed") then -- Fail if gear was destroyed @@ -563,7 +563,7 @@ end _G.onSuddenDeath = function() - sm.isInSuddenDeath = true + _G.sm.isInSuddenDeath = true end _G.onGearWaterSkip = function(gear) diff -r 8edbdd3a1fe7 -r 74bf2d906097 share/hedgewars/Data/Scripts/SpeedShoppa.lua --- a/share/hedgewars/Data/Scripts/SpeedShoppa.lua Mon Nov 19 00:19:21 2018 +0100 +++ b/share/hedgewars/Data/Scripts/SpeedShoppa.lua Mon Nov 19 00:54:36 2018 +0100 @@ -68,7 +68,7 @@ local gameEnded = false local timeOut = false local hogHurt = false -local endTime +local startTime, endTime local crates diff -r 8edbdd3a1fe7 -r 74bf2d906097 share/hedgewars/Data/Scripts/TargetPractice.lua --- a/share/hedgewars/Data/Scripts/TargetPractice.lua Mon Nov 19 00:19:21 2018 +0100 +++ b/share/hedgewars/Data/Scripts/TargetPractice.lua Mon Nov 19 00:54:36 2018 +0100 @@ -177,10 +177,10 @@ end _G.spawnTarget = function() - gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) + local gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) - x = targets[scored+1].x - y = targets[scored+1].y + local x = targets[scored+1].x + local y = targets[scored+1].y SetGearPosition(gear, x, y) diff -r 8edbdd3a1fe7 -r 74bf2d906097 share/hedgewars/Data/Scripts/TechMaps.lua --- a/share/hedgewars/Data/Scripts/TechMaps.lua Mon Nov 19 00:19:21 2018 +0100 +++ b/share/hedgewars/Data/Scripts/TechMaps.lua Mon Nov 19 00:54:36 2018 +0100 @@ -1361,6 +1361,7 @@ function LoadMap(mID) + local tempG techX = {} techY = {} techCount = 1 diff -r 8edbdd3a1fe7 -r 74bf2d906097 share/hedgewars/Data/Scripts/Tracker.lua --- a/share/hedgewars/Data/Scripts/Tracker.lua Mon Nov 19 00:19:21 2018 +0100 +++ b/share/hedgewars/Data/Scripts/Tracker.lua Mon Nov 19 00:54:36 2018 +0100 @@ -32,12 +32,12 @@ end end if trackingTeams and GetGearType(gear) == gtHedgehog then - hogs = teams[GetHogTeamName(gear)] + local hogs = teams[GetHogTeamName(gear)] if hogs ~= nil then if #hogs == 1 then hogs = nil else - for k, hog in ipairs(hogs) do + for k, hog in ipairs(hogs) do if hog == gear then table.remove(hogs, k) break @@ -47,7 +47,7 @@ end elseif resurrecting and GetGearType(gear) == gtResurrector then for k, gear in ipairs(resurrectedHogs) do - team = GetHogTeamName(gear) + local team = GetHogTeamName(gear) if teams[team] == nil then teams[team] = {} end @@ -64,7 +64,7 @@ trackingTeams = true for k, gear in ipairs(gears) do if GetGearType(gear) == gtHedgehog then - team = GetHogTeamName(gear) + local team = GetHogTeamName(gear) if teams[team] == nil then teams[team] = { gear } clans[team] = GetHogClan(gear) @@ -84,10 +84,10 @@ break end end - + if trackingTeams then - hogs = teams[GetHogTeamName(gear)] - + local hogs = teams[GetHogTeamName(gear)] + if hogs ~= nil then if #hogs == 1 then hogs = nil @@ -105,10 +105,10 @@ -- Registers when a hog is restored function trackRestoring(gear) - table.insert(gears, gear) + table.insert(gears, gear) if trackingTeams then - team = GetHogTeamName(gear) + local team = GetHogTeamName(gear) if teams[team] == nil then teams[team] = {} end @@ -126,7 +126,7 @@ -- Set a value for a specific gear function setGearValue(gear, key, value) - found = false + local found = false for id, values in pairs(gearValues) do if id == gear then values[key] = value @@ -166,7 +166,7 @@ -- Set a value for a specific team function setTeamValue(team, key, value) - found = false + local found = false for name, values in pairs(teamValues) do if name == team then values[key] = value @@ -206,7 +206,7 @@ -- Set a value for a specific clan function setClanValue(clan, key, value) - found = false + local found = false for num, values in ipairs(clanValues) do if num == clan then values[key] = value diff -r 8edbdd3a1fe7 -r 74bf2d906097 share/hedgewars/Data/Scripts/Utils.lua --- a/share/hedgewars/Data/Scripts/Utils.lua Mon Nov 19 00:19:21 2018 +0100 +++ b/share/hedgewars/Data/Scripts/Utils.lua Mon Nov 19 00:54:36 2018 +0100 @@ -3,7 +3,7 @@ --[[ FUNCTIONS ]] -- Check if a gear is inside a box function gearIsInBox(gear, x, y, w, h) - gx, gy = GetGearPosition(gear) + local gx, gy = GetGearPosition(gear) if gx >= x and gy >= y and gx <= x + w and gy <= y + h then return true end @@ -12,7 +12,7 @@ -- Check if a gear is inside a circle function gearIsInCircle(gear, x, y, r, useRadius) - gx, gy = GetGearPosition(gear) + local gx, gy = GetGearPosition(gear) if useRadius then r = r + GetGearRadius(gear) end