aboutsummaryrefslogtreecommitdiff
path: root/builtin/common/misc_helpers.lua
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2014-12-12 01:10:19 +0000
committerShadowNinja <shadowninja@minetest.net>2014-12-11 21:37:46 -0500
commitf114fc74d621a7cfb1e63b5405fddb0208ee71d2 (patch)
tree4a00df92724326509263987a681e73d8e32175dc /builtin/common/misc_helpers.lua
parentfb80a7c111c138d335f4c7e68fc098f8aa8483d3 (diff)
downloadminetest-f114fc74d621a7cfb1e63b5405fddb0208ee71d2.tar.gz
minetest-f114fc74d621a7cfb1e63b5405fddb0208ee71d2.tar.bz2
minetest-f114fc74d621a7cfb1e63b5405fddb0208ee71d2.zip
Fix undeclared globals in functions and shorten lines in misc_helpers.lua.
Diffstat (limited to 'builtin/common/misc_helpers.lua')
-rw-r--r--builtin/common/misc_helpers.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index e1dc28965..dc358e65a 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -463,7 +463,8 @@ function core.explode_table_event(evt)
local t = parts[1]:trim()
local r = tonumber(parts[2]:trim())
local c = tonumber(parts[3]:trim())
- if type(r) == "number" and type(c) == "number" and t ~= "INV" then
+ if type(r) == "number" and type(c) == "number"
+ and t ~= "INV" then
return {type=t, row=r, column=c}
end
end
@@ -532,16 +533,18 @@ if INIT == "mainmenu" then
local arg = {n=select('#', ...), ...}
if arg.n >= 1 then
-- Insert positional parameters ($1, $2, ...)
- result = ''
- pos = 1
+ local result = ''
+ local pos = 1
while pos <= text:len() do
- newpos = text:find('[$]', pos)
+ local newpos = text:find('[$]', pos)
if newpos == nil then
result = result .. text:sub(pos)
pos = text:len() + 1
else
- paramindex = tonumber(text:sub(newpos+1, newpos+1))
- result = result .. text:sub(pos, newpos-1) .. tostring(arg[paramindex])
+ local paramindex =
+ tonumber(text:sub(newpos+1, newpos+1))
+ result = result .. text:sub(pos, newpos-1)
+ .. tostring(arg[paramindex])
pos = newpos + 2
end
end