summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2014-01-15 19:32:51 -0500
committerShadowNinja <shadowninja@minetest.net>2014-01-15 19:32:51 -0500
commitf7f4c2ddb567ef01bad299ac0c093300909d950c (patch)
tree87412ffcba0c24e536f22ce1dece6cb117407c56
parent7df1bbc190a62968d750e876d7064c3e97f91f40 (diff)
The length of a table with non-sequential indexes in not defined
-rw-r--r--internal.lua9
1 files changed, 4 insertions, 5 deletions
diff --git a/internal.lua b/internal.lua
index 83ae3d5..658da6e 100644
--- a/internal.lua
+++ b/internal.lua
@@ -30,11 +30,10 @@ end
-- Finds the first usable index in a table
-- Eg: {[1]=false,[4]=true} -> 2
local function findFirstUnusedIndex(t)
- for i = 1, #t + 1 do
- if t[i] == nil then
- return i
- end
- end
+ local i = 0
+ repeat i = i + 1
+ until t[i] == nil
+ return i
end
-- Add a area, returning the new area's id.