1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

Save creative_mode and enable_damage setting for each world in world.mt

Create Parameters on world initialisation and set settings of old worlds
This commit is contained in:
fz72 2015-03-15 14:52:10 +01:00 committed by Loic Blot
parent 2f0107f4a7
commit 8ca08a850f
5 changed files with 115 additions and 5 deletions

View file

@ -189,7 +189,6 @@ end
--------------------------------------------------------------------------------
function menu_handle_key_up_down(fields,textlist,settingname)
if fields["key_up"] then
local oldidx = core.get_textlist_index(textlist)
@ -197,6 +196,16 @@ function menu_handle_key_up_down(fields,textlist,settingname)
local newidx = oldidx -1
core.setting_set(settingname,
menudata.worldlist:get_raw_index(newidx))
local worldconfig = modmgr.get_worldconfig(
menudata.worldlist:get_list()[newidx].path)
if worldconfig.creative_mode ~= nil then
core.setting_set("creative_mode", worldconfig.creative_mode)
end
if worldconfig.enable_damage ~= nil then
core.setting_set("enable_damage", worldconfig.enable_damage)
end
end
return true
end
@ -208,6 +217,15 @@ function menu_handle_key_up_down(fields,textlist,settingname)
local newidx = oldidx + 1
core.setting_set(settingname,
menudata.worldlist:get_raw_index(newidx))
local worldconfig = modmgr.get_worldconfig(
menudata.worldlist:get_list()[newidx].path)
if worldconfig.creative_mode ~= nil then
core.setting_set("creative_mode", worldconfig.creative_mode)
end
if worldconfig.enable_damage ~= nil then
core.setting_set("enable_damage", worldconfig.enable_damage)
end
end
return true