mirror of
https://github.com/minetest/minetest.git
synced 2025-07-07 02:10:22 +02:00
Allow random menu images for subgames
This commit is contained in:
@ -159,6 +159,7 @@ function dump(o, indent, nested, level)
|
||||
return "{"..table.concat(t, ", ").."}"
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function string.split(str, delim, include_empty, max_splits, sep_is_pattern)
|
||||
delim = delim or ","
|
||||
max_splits = max_splits or -1
|
||||
@ -183,10 +184,23 @@ function string.split(str, delim, include_empty, max_splits, sep_is_pattern)
|
||||
return items
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function table.indexof(list, val)
|
||||
for i = 1, #list do
|
||||
if list[i] == val then
|
||||
return i
|
||||
end
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
assert(table.indexof({"foo", "bar"}, "foo") == 1)
|
||||
assert(table.indexof({"foo", "bar"}, "baz") == -1)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function file_exists(filename)
|
||||
local f = io.open(filename, "r")
|
||||
if f==nil then
|
||||
if f == nil then
|
||||
return false
|
||||
else
|
||||
f:close()
|
||||
|
Reference in New Issue
Block a user