aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui <Rui914@users.noreply.github.com>2016-05-13 01:38:29 +1000
committerCraig Robbins <kde.psych@gmail.com>2016-05-13 01:41:16 +1000
commit9d3d43f3340030db8855ebc394e969f10d00dc30 (patch)
tree76d8394c67050f5eec7bcdc5c0428f73690fb454
parent997002703be14826b73a38bfd0e92e6b0c7c4bfd (diff)
downloadminetest-9d3d43f3340030db8855ebc394e969f10d00dc30.tar.gz
minetest-9d3d43f3340030db8855ebc394e969f10d00dc30.tar.bz2
minetest-9d3d43f3340030db8855ebc394e969f10d00dc30.zip
Fix #4111 ("Provided world path doesn't exist" if choosing singleplayer on first run")
Bug and whitespace error fixed (Zeno)
-rw-r--r--builtin/mainmenu/init.lua21
1 files changed, 18 insertions, 3 deletions
diff --git a/builtin/mainmenu/init.lua b/builtin/mainmenu/init.lua
index 6dd345ff4..7f0c1e386 100644
--- a/builtin/mainmenu/init.lua
+++ b/builtin/mainmenu/init.lua
@@ -77,13 +77,28 @@ local function init_globals()
if PLATFORM == "Android" then
local world_list = core.get_worlds()
- local world_index = table.indexof(world_list, "singleplayerworld")
+ local world_index
+
+ local found_singleplayerworld = false
+ for i, world in ipairs(world_list) do
+ if world.name == "singleplayerworld" then
+ found_singleplayerworld = true
+ world_index = i
+ break
+ end
+ end
- if world_index == -1 then
+ if not found_singleplayerworld then
core.create_world("singleplayerworld", 1)
world_list = core.get_worlds()
- world_index = table.indexof(world_list, "singleplayerworld")
+
+ for i, world in ipairs(world_list) do
+ if world.name == "singleplayerworld" then
+ world_index = i
+ break
+ end
+ end
end
gamedata.worldindex = world_index