Use a settings object for the main settings
This unifies the settings APIs. This also unifies the sync and async registration APIs, since the async registration API did not support adding non-functions to the API table.
This commit is contained in:
parent
a024042bf5
commit
43d1f375d1
|
@ -463,7 +463,7 @@ if INIT == "game" then
|
||||||
|
|
||||||
core.rotate_node = function(itemstack, placer, pointed_thing)
|
core.rotate_node = function(itemstack, placer, pointed_thing)
|
||||||
core.rotate_and_place(itemstack, placer, pointed_thing,
|
core.rotate_and_place(itemstack, placer, pointed_thing,
|
||||||
core.setting_getbool("creative_mode"),
|
core.settings:get_bool("creative_mode"),
|
||||||
{invert_wall = placer:get_player_control().sneak})
|
{invert_wall = placer:get_player_control().sneak})
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
@ -642,8 +642,8 @@ end
|
||||||
|
|
||||||
local ESCAPE_CHAR = string.char(0x1b)
|
local ESCAPE_CHAR = string.char(0x1b)
|
||||||
|
|
||||||
-- Client-sided mods don't have access to getbool
|
-- Client-side mods don't have access to settings
|
||||||
if core.setting_getbool and core.setting_getbool("disable_escape_sequences") then
|
if core.settings and core.settings:get_bool("disable_escape_sequences") then
|
||||||
|
|
||||||
function core.get_color_escape_sequence(color)
|
function core.get_color_escape_sequence(color)
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -167,7 +167,7 @@ local function switch_to_tab(self, index)
|
||||||
self.current_tab = self.tablist[index].name
|
self.current_tab = self.tablist[index].name
|
||||||
|
|
||||||
if (self.autosave_tab) then
|
if (self.autosave_tab) then
|
||||||
core.setting_set(self.name .. "_LAST",self.current_tab)
|
core.settings:set(self.name .. "_LAST",self.current_tab)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- call for tab to enter
|
-- call for tab to enter
|
||||||
|
|
|
@ -106,7 +106,7 @@ core.builtin_auth_handler = {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- For the admin, give everything
|
-- For the admin, give everything
|
||||||
elseif name == core.setting_get("name") then
|
elseif name == core.settings:get("name") then
|
||||||
for priv, def in pairs(core.registered_privileges) do
|
for priv, def in pairs(core.registered_privileges) do
|
||||||
privileges[priv] = true
|
privileges[priv] = true
|
||||||
end
|
end
|
||||||
|
@ -125,7 +125,7 @@ core.builtin_auth_handler = {
|
||||||
core.log('info', "Built-in authentication handler adding player '"..name.."'")
|
core.log('info', "Built-in authentication handler adding player '"..name.."'")
|
||||||
core.auth_table[name] = {
|
core.auth_table[name] = {
|
||||||
password = password,
|
password = password,
|
||||||
privileges = core.string_to_privs(core.setting_get("default_privs")),
|
privileges = core.string_to_privs(core.settings:get("default_privs")),
|
||||||
last_login = os.time(),
|
last_login = os.time(),
|
||||||
}
|
}
|
||||||
save_auth_file()
|
save_auth_file()
|
||||||
|
@ -148,7 +148,7 @@ core.builtin_auth_handler = {
|
||||||
if not core.auth_table[name] then
|
if not core.auth_table[name] then
|
||||||
core.builtin_auth_handler.create_auth(name,
|
core.builtin_auth_handler.create_auth(name,
|
||||||
core.get_password_hash(name,
|
core.get_password_hash(name,
|
||||||
core.setting_get("default_password")))
|
core.settings:get("default_password")))
|
||||||
end
|
end
|
||||||
core.auth_table[name].privileges = privileges
|
core.auth_table[name].privileges = privileges
|
||||||
core.notify_authentication_modified(name)
|
core.notify_authentication_modified(name)
|
||||||
|
|
|
@ -39,7 +39,7 @@ core.register_on_chat_message(function(name, message)
|
||||||
return true -- Handled chat message
|
return true -- Handled chat message
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if core.setting_getbool("profiler.load") then
|
if core.settings:get_bool("profiler.load") then
|
||||||
-- Run after register_chatcommand and its register_on_chat_message
|
-- Run after register_chatcommand and its register_on_chat_message
|
||||||
-- Before any chattcommands that should be profiled
|
-- Before any chattcommands that should be profiled
|
||||||
profiler.init_chatcommand()
|
profiler.init_chatcommand()
|
||||||
|
@ -82,7 +82,7 @@ core.register_chatcommand("me", {
|
||||||
core.register_chatcommand("admin", {
|
core.register_chatcommand("admin", {
|
||||||
description = "Show the name of the server owner",
|
description = "Show the name of the server owner",
|
||||||
func = function(name)
|
func = function(name)
|
||||||
local admin = minetest.setting_get("name")
|
local admin = minetest.settings:get("name")
|
||||||
if admin then
|
if admin then
|
||||||
return true, "The administrator of this server is "..admin.."."
|
return true, "The administrator of this server is "..admin.."."
|
||||||
else
|
else
|
||||||
|
@ -119,7 +119,7 @@ local function handle_grant_command(caller, grantname, grantprivstr)
|
||||||
local privs = core.get_player_privs(grantname)
|
local privs = core.get_player_privs(grantname)
|
||||||
local privs_unknown = ""
|
local privs_unknown = ""
|
||||||
local basic_privs =
|
local basic_privs =
|
||||||
core.string_to_privs(core.setting_get("basic_privs") or "interact,shout")
|
core.string_to_privs(core.settings:get("basic_privs") or "interact,shout")
|
||||||
for priv, _ in pairs(grantprivs) do
|
for priv, _ in pairs(grantprivs) do
|
||||||
if not basic_privs[priv] and not caller_privs.privs then
|
if not basic_privs[priv] and not caller_privs.privs then
|
||||||
return false, "Your privileges are insufficient."
|
return false, "Your privileges are insufficient."
|
||||||
|
@ -185,7 +185,7 @@ core.register_chatcommand("revoke", {
|
||||||
local revoke_privs = core.string_to_privs(revoke_priv_str)
|
local revoke_privs = core.string_to_privs(revoke_priv_str)
|
||||||
local privs = core.get_player_privs(revoke_name)
|
local privs = core.get_player_privs(revoke_name)
|
||||||
local basic_privs =
|
local basic_privs =
|
||||||
core.string_to_privs(core.setting_get("basic_privs") or "interact,shout")
|
core.string_to_privs(core.settings:get("basic_privs") or "interact,shout")
|
||||||
for priv, _ in pairs(revoke_privs) do
|
for priv, _ in pairs(revoke_privs) do
|
||||||
if not basic_privs[priv] and
|
if not basic_privs[priv] and
|
||||||
not core.check_player_privs(name, {privs=true}) then
|
not core.check_player_privs(name, {privs=true}) then
|
||||||
|
@ -419,20 +419,20 @@ core.register_chatcommand("set", {
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local arg, setname, setvalue = string.match(param, "(-[n]) ([^ ]+) (.+)")
|
local arg, setname, setvalue = string.match(param, "(-[n]) ([^ ]+) (.+)")
|
||||||
if arg and arg == "-n" and setname and setvalue then
|
if arg and arg == "-n" and setname and setvalue then
|
||||||
core.setting_set(setname, setvalue)
|
core.settings:set(setname, setvalue)
|
||||||
return true, setname .. " = " .. setvalue
|
return true, setname .. " = " .. setvalue
|
||||||
end
|
end
|
||||||
local setname, setvalue = string.match(param, "([^ ]+) (.+)")
|
local setname, setvalue = string.match(param, "([^ ]+) (.+)")
|
||||||
if setname and setvalue then
|
if setname and setvalue then
|
||||||
if not core.setting_get(setname) then
|
if not core.settings:get(setname) then
|
||||||
return false, "Failed. Use '/set -n <name> <value>' to create a new setting."
|
return false, "Failed. Use '/set -n <name> <value>' to create a new setting."
|
||||||
end
|
end
|
||||||
core.setting_set(setname, setvalue)
|
core.settings:set(setname, setvalue)
|
||||||
return true, setname .. " = " .. setvalue
|
return true, setname .. " = " .. setvalue
|
||||||
end
|
end
|
||||||
local setname = string.match(param, "([^ ]+)")
|
local setname = string.match(param, "([^ ]+)")
|
||||||
if setname then
|
if setname then
|
||||||
local setvalue = core.setting_get(setname)
|
local setvalue = core.settings:get(setname)
|
||||||
if not setvalue then
|
if not setvalue then
|
||||||
setvalue = "<not set>"
|
setvalue = "<not set>"
|
||||||
end
|
end
|
||||||
|
@ -667,7 +667,7 @@ core.register_chatcommand("rollback_check", {
|
||||||
.. " seconds = 86400 = 24h, limit = 5",
|
.. " seconds = 86400 = 24h, limit = 5",
|
||||||
privs = {rollback=true},
|
privs = {rollback=true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
if not core.setting_getbool("enable_rollback_recording") then
|
if not core.settings:get_bool("enable_rollback_recording") then
|
||||||
return false, "Rollback functions are disabled."
|
return false, "Rollback functions are disabled."
|
||||||
end
|
end
|
||||||
local range, seconds, limit =
|
local range, seconds, limit =
|
||||||
|
@ -718,7 +718,7 @@ core.register_chatcommand("rollback", {
|
||||||
description = "Revert actions of a player. Default for <seconds> is 60",
|
description = "Revert actions of a player. Default for <seconds> is 60",
|
||||||
privs = {rollback=true},
|
privs = {rollback=true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
if not core.setting_getbool("enable_rollback_recording") then
|
if not core.settings:get_bool("enable_rollback_recording") then
|
||||||
return false, "Rollback functions are disabled."
|
return false, "Rollback functions are disabled."
|
||||||
end
|
end
|
||||||
local target_name, seconds = string.match(param, ":([^ ]+) *(%d*)")
|
local target_name, seconds = string.match(param, ":([^ ]+) *(%d*)")
|
||||||
|
|
|
@ -49,3 +49,24 @@ setmetatable(core.env, {
|
||||||
function core.rollback_get_last_node_actor(pos, range, seconds)
|
function core.rollback_get_last_node_actor(pos, range, seconds)
|
||||||
return core.rollback_get_node_actions(pos, range, seconds, 1)[1]
|
return core.rollback_get_node_actions(pos, range, seconds, 1)[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
-- core.setting_*
|
||||||
|
--
|
||||||
|
|
||||||
|
local settings = core.settings
|
||||||
|
|
||||||
|
local function setting_proxy(name)
|
||||||
|
return function(...)
|
||||||
|
core.log("deprecated", "WARNING: minetest.setting_* "..
|
||||||
|
"functions are deprecated. "..
|
||||||
|
"Use methods on the minetest.settings object.")
|
||||||
|
return settings[name](settings, ...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
core.setting_set = setting_proxy("set")
|
||||||
|
core.setting_get = setting_proxy("get")
|
||||||
|
core.setting_setbool = setting_proxy("set_bool")
|
||||||
|
core.setting_getbool = setting_proxy("get_bool")
|
||||||
|
core.setting_save = setting_proxy("write")
|
||||||
|
|
|
@ -40,7 +40,7 @@ function core.forceload_block(pos, transient)
|
||||||
elseif other_table[hash] ~= nil then
|
elseif other_table[hash] ~= nil then
|
||||||
relevant_table[hash] = 1
|
relevant_table[hash] = 1
|
||||||
else
|
else
|
||||||
if total_forceloaded >= (tonumber(core.setting_get("max_forceloaded_blocks")) or 16) then
|
if total_forceloaded >= (tonumber(core.settings:get("max_forceloaded_blocks")) or 16) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
total_forceloaded = total_forceloaded+1
|
total_forceloaded = total_forceloaded+1
|
||||||
|
|
|
@ -13,7 +13,7 @@ dofile(gamepath.."constants.lua")
|
||||||
assert(loadfile(gamepath.."item.lua"))(builtin_shared)
|
assert(loadfile(gamepath.."item.lua"))(builtin_shared)
|
||||||
dofile(gamepath.."register.lua")
|
dofile(gamepath.."register.lua")
|
||||||
|
|
||||||
if core.setting_getbool("profiler.load") then
|
if core.settings:get_bool("profiler.load") then
|
||||||
profiler = dofile(scriptpath.."profiler"..DIR_DELIM.."init.lua")
|
profiler = dofile(scriptpath.."profiler"..DIR_DELIM.."init.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -483,7 +483,7 @@ function core.node_dig(pos, node, digger)
|
||||||
wielded = wdef.after_use(wielded, digger, node, dp) or wielded
|
wielded = wdef.after_use(wielded, digger, node, dp) or wielded
|
||||||
else
|
else
|
||||||
-- Wear out tool
|
-- Wear out tool
|
||||||
if not core.setting_getbool("creative_mode") then
|
if not core.settings:get_bool("creative_mode") then
|
||||||
wielded:add_wear(dp.wear)
|
wielded:add_wear(dp.wear)
|
||||||
if wielded:get_count() == 0 and wdef.sound and wdef.sound.breaks then
|
if wielded:get_count() == 0 and wdef.sound and wdef.sound.breaks then
|
||||||
core.sound_play(wdef.sound.breaks, {pos = pos, gain = 0.5})
|
core.sound_play(wdef.sound.breaks, {pos = pos, gain = 0.5})
|
||||||
|
|
|
@ -14,7 +14,7 @@ end
|
||||||
-- If item_entity_ttl is not set, enity will have default life time
|
-- If item_entity_ttl is not set, enity will have default life time
|
||||||
-- Setting it to -1 disables the feature
|
-- Setting it to -1 disables the feature
|
||||||
|
|
||||||
local time_to_live = tonumber(core.setting_get("item_entity_ttl"))
|
local time_to_live = tonumber(core.settings:get("item_entity_ttl"))
|
||||||
if not time_to_live then
|
if not time_to_live then
|
||||||
time_to_live = 900
|
time_to_live = 900
|
||||||
end
|
end
|
||||||
|
|
|
@ -121,7 +121,7 @@ function core.get_node_group(name, group)
|
||||||
end
|
end
|
||||||
|
|
||||||
function core.setting_get_pos(name)
|
function core.setting_get_pos(name)
|
||||||
local value = core.setting_get(name)
|
local value = core.settings:get(name)
|
||||||
if not value then
|
if not value then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
-- cache setting
|
-- cache setting
|
||||||
local enable_damage = core.setting_getbool("enable_damage") == true
|
local enable_damage = core.settings:get_bool("enable_damage")
|
||||||
|
|
||||||
local health_bar_definition =
|
local health_bar_definition =
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
-- Minetest: builtin/static_spawn.lua
|
-- Minetest: builtin/static_spawn.lua
|
||||||
|
|
||||||
local function warn_invalid_static_spawnpoint()
|
local function warn_invalid_static_spawnpoint()
|
||||||
if core.setting_get("static_spawnpoint") and
|
if core.settings:get("static_spawnpoint") and
|
||||||
not core.setting_get_pos("static_spawnpoint") then
|
not core.setting_get_pos("static_spawnpoint") then
|
||||||
core.log("error", "The static_spawnpoint setting is invalid: \""..
|
core.log("error", "The static_spawnpoint setting is invalid: \""..
|
||||||
core.setting_get("static_spawnpoint").."\"")
|
core.settings:get("static_spawnpoint").."\"")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ dofile(commonpath .. "misc_helpers.lua")
|
||||||
if INIT == "game" then
|
if INIT == "game" then
|
||||||
dofile(gamepath .. "init.lua")
|
dofile(gamepath .. "init.lua")
|
||||||
elseif INIT == "mainmenu" then
|
elseif INIT == "mainmenu" then
|
||||||
local mm_script = core.setting_get("main_menu_script")
|
local mm_script = core.settings:get("main_menu_script")
|
||||||
if mm_script and mm_script ~= "" then
|
if mm_script and mm_script ~= "" then
|
||||||
dofile(mm_script)
|
dofile(mm_script)
|
||||||
else
|
else
|
||||||
|
|
|
@ -43,10 +43,10 @@ end
|
||||||
local function configure_selected_world_params(idx)
|
local function configure_selected_world_params(idx)
|
||||||
local worldconfig = modmgr.get_worldconfig(menudata.worldlist:get_list()[idx].path)
|
local worldconfig = modmgr.get_worldconfig(menudata.worldlist:get_list()[idx].path)
|
||||||
if worldconfig.creative_mode then
|
if worldconfig.creative_mode then
|
||||||
core.setting_set("creative_mode", worldconfig.creative_mode)
|
core.settings:set("creative_mode", worldconfig.creative_mode)
|
||||||
end
|
end
|
||||||
if worldconfig.enable_damage then
|
if worldconfig.enable_damage then
|
||||||
core.setting_set("enable_damage", worldconfig.enable_damage)
|
core.settings:set("enable_damage", worldconfig.enable_damage)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -164,8 +164,8 @@ end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
os.tempfolder = function()
|
os.tempfolder = function()
|
||||||
if core.setting_get("TMPFolder") then
|
if core.settings:get("TMPFolder") then
|
||||||
return core.setting_get("TMPFolder") .. DIR_DELIM .. "MT_" .. math.random(0,10000)
|
return core.settings:get("TMPFolder") .. DIR_DELIM .. "MT_" .. math.random(0,10000)
|
||||||
end
|
end
|
||||||
|
|
||||||
local filetocheck = os.tmpname()
|
local filetocheck = os.tmpname()
|
||||||
|
@ -206,7 +206,7 @@ function menu_handle_key_up_down(fields, textlist, settingname)
|
||||||
oldidx < menudata.worldlist:size() then
|
oldidx < menudata.worldlist:size() then
|
||||||
newidx = oldidx + 1
|
newidx = oldidx + 1
|
||||||
end
|
end
|
||||||
core.setting_set(settingname, menudata.worldlist:get_raw_index(newidx))
|
core.settings:set(settingname, menudata.worldlist:get_raw_index(newidx))
|
||||||
configure_selected_world_params(newidx)
|
configure_selected_world_params(newidx)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -328,9 +328,9 @@ function menu_worldmt_legacy(selected)
|
||||||
for _, mode_name in pairs(modes_names) do
|
for _, mode_name in pairs(modes_names) do
|
||||||
local mode_val = menu_worldmt(selected, mode_name)
|
local mode_val = menu_worldmt(selected, mode_name)
|
||||||
if mode_val then
|
if mode_val then
|
||||||
core.setting_set(mode_name, mode_val)
|
core.settings:set(mode_name, mode_val)
|
||||||
else
|
else
|
||||||
menu_worldmt(selected, mode_name, core.setting_get(mode_name))
|
menu_worldmt(selected, mode_name, core.settings:get(mode_name))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -123,7 +123,7 @@ local function handle_buttons(this, fields)
|
||||||
if fields["world_config_modlist"] ~= nil then
|
if fields["world_config_modlist"] ~= nil then
|
||||||
local event = core.explode_table_event(fields["world_config_modlist"])
|
local event = core.explode_table_event(fields["world_config_modlist"])
|
||||||
this.data.selected_mod = event.row
|
this.data.selected_mod = event.row
|
||||||
core.setting_set("world_config_selected_mod", event.row)
|
core.settings:set("world_config_selected_mod", event.row)
|
||||||
|
|
||||||
if event.type == "DCL" then
|
if event.type == "DCL" then
|
||||||
enable_mod(this)
|
enable_mod(this)
|
||||||
|
@ -227,7 +227,7 @@ function create_configure_world_dlg(worldidx)
|
||||||
handle_buttons,
|
handle_buttons,
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
dlg.data.selected_mod = tonumber(core.setting_get("world_config_selected_mod"))
|
dlg.data.selected_mod = tonumber(core.settings:get("world_config_selected_mod"))
|
||||||
if dlg.data.selected_mod == nil then
|
if dlg.data.selected_mod == nil then
|
||||||
dlg.data.selected_mod = 0
|
dlg.data.selected_mod = 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
local function create_world_formspec(dialogdata)
|
local function create_world_formspec(dialogdata)
|
||||||
local mapgens = core.get_mapgen_names()
|
local mapgens = core.get_mapgen_names()
|
||||||
|
|
||||||
local current_seed = core.setting_get("fixed_map_seed") or ""
|
local current_seed = core.settings:get("fixed_map_seed") or ""
|
||||||
local current_mg = core.setting_get("mg_name")
|
local current_mg = core.settings:get("mg_name")
|
||||||
|
|
||||||
local mglist = ""
|
local mglist = ""
|
||||||
local selindex = 1
|
local selindex = 1
|
||||||
|
@ -33,7 +33,7 @@ local function create_world_formspec(dialogdata)
|
||||||
end
|
end
|
||||||
mglist = mglist:sub(1, -2)
|
mglist = mglist:sub(1, -2)
|
||||||
|
|
||||||
local gameid = core.setting_get("menu_last_game")
|
local gameid = core.settings:get("menu_last_game")
|
||||||
|
|
||||||
local game, gameidx = nil , 0
|
local game, gameidx = nil , 0
|
||||||
if gameid ~= nil then
|
if gameid ~= nil then
|
||||||
|
@ -90,10 +90,10 @@ local function create_world_buttonhandler(this, fields)
|
||||||
|
|
||||||
local message = nil
|
local message = nil
|
||||||
|
|
||||||
core.setting_set("fixed_map_seed", fields["te_seed"])
|
core.settings:set("fixed_map_seed", fields["te_seed"])
|
||||||
|
|
||||||
if not menudata.worldlist:uid_exists_raw(worldname) then
|
if not menudata.worldlist:uid_exists_raw(worldname) then
|
||||||
core.setting_set("mg_name",fields["dd_mapgen"])
|
core.settings:set("mg_name",fields["dd_mapgen"])
|
||||||
message = core.create_world(worldname,gameindex)
|
message = core.create_world(worldname,gameindex)
|
||||||
else
|
else
|
||||||
message = fgettext("A world named \"$1\" already exists", worldname)
|
message = fgettext("A world named \"$1\" already exists", worldname)
|
||||||
|
@ -102,13 +102,13 @@ local function create_world_buttonhandler(this, fields)
|
||||||
if message ~= nil then
|
if message ~= nil then
|
||||||
gamedata.errormessage = message
|
gamedata.errormessage = message
|
||||||
else
|
else
|
||||||
core.setting_set("menu_last_game",gamemgr.games[gameindex].id)
|
core.settings:set("menu_last_game",gamemgr.games[gameindex].id)
|
||||||
if this.data.update_worldlist_filter then
|
if this.data.update_worldlist_filter then
|
||||||
menudata.worldlist:set_filtercriteria(gamemgr.games[gameindex].id)
|
menudata.worldlist:set_filtercriteria(gamemgr.games[gameindex].id)
|
||||||
mm_texture.update("singleplayer", gamemgr.games[gameindex].id)
|
mm_texture.update("singleplayer", gamemgr.games[gameindex].id)
|
||||||
end
|
end
|
||||||
menudata.worldlist:refresh()
|
menudata.worldlist:refresh()
|
||||||
core.setting_set("mainmenu_last_selected_world",
|
core.settings:set("mainmenu_last_selected_world",
|
||||||
menudata.worldlist:raw_index_by_uid(worldname))
|
menudata.worldlist:raw_index_by_uid(worldname))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -423,7 +423,7 @@ local settings = full_settings
|
||||||
local selected_setting = 1
|
local selected_setting = 1
|
||||||
|
|
||||||
local function get_current_value(setting)
|
local function get_current_value(setting)
|
||||||
local value = core.setting_get(setting.name)
|
local value = core.settings:get(setting.name)
|
||||||
if value == nil then
|
if value == nil then
|
||||||
value = setting.default
|
value = setting.default
|
||||||
end
|
end
|
||||||
|
@ -539,11 +539,11 @@ local function handle_change_setting_buttons(this, fields)
|
||||||
if setting.type == "bool" then
|
if setting.type == "bool" then
|
||||||
local new_value = fields["dd_setting_value"]
|
local new_value = fields["dd_setting_value"]
|
||||||
-- Note: new_value is the actual (translated) value shown in the dropdown
|
-- Note: new_value is the actual (translated) value shown in the dropdown
|
||||||
core.setting_setbool(setting.name, new_value == fgettext("Enabled"))
|
core.settings:set_bool(setting.name, new_value == fgettext("Enabled"))
|
||||||
|
|
||||||
elseif setting.type == "enum" then
|
elseif setting.type == "enum" then
|
||||||
local new_value = fields["dd_setting_value"]
|
local new_value = fields["dd_setting_value"]
|
||||||
core.setting_set(setting.name, new_value)
|
core.settings:set(setting.name, new_value)
|
||||||
|
|
||||||
elseif setting.type == "int" then
|
elseif setting.type == "int" then
|
||||||
local new_value = tonumber(fields["te_setting_value"])
|
local new_value = tonumber(fields["te_setting_value"])
|
||||||
|
@ -565,7 +565,7 @@ local function handle_change_setting_buttons(this, fields)
|
||||||
core.update_formspec(this:get_formspec())
|
core.update_formspec(this:get_formspec())
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
core.setting_set(setting.name, new_value)
|
core.settings:set(setting.name, new_value)
|
||||||
|
|
||||||
elseif setting.type == "float" then
|
elseif setting.type == "float" then
|
||||||
local new_value = tonumber(fields["te_setting_value"])
|
local new_value = tonumber(fields["te_setting_value"])
|
||||||
|
@ -575,7 +575,7 @@ local function handle_change_setting_buttons(this, fields)
|
||||||
core.update_formspec(this:get_formspec())
|
core.update_formspec(this:get_formspec())
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
core.setting_set(setting.name, new_value)
|
core.settings:set(setting.name, new_value)
|
||||||
|
|
||||||
elseif setting.type == "flags" then
|
elseif setting.type == "flags" then
|
||||||
local new_value = fields["te_setting_value"]
|
local new_value = fields["te_setting_value"]
|
||||||
|
@ -589,13 +589,13 @@ local function handle_change_setting_buttons(this, fields)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
core.setting_set(setting.name, new_value)
|
core.settings:set(setting.name, new_value)
|
||||||
|
|
||||||
else
|
else
|
||||||
local new_value = fields["te_setting_value"]
|
local new_value = fields["te_setting_value"]
|
||||||
core.setting_set(setting.name, new_value)
|
core.settings:set(setting.name, new_value)
|
||||||
end
|
end
|
||||||
core.setting_save()
|
core.settings:write()
|
||||||
this:delete()
|
this:delete()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -629,7 +629,7 @@ local function create_settings_formspec(tabview, name, tabdata)
|
||||||
local current_level = 0
|
local current_level = 0
|
||||||
for _, entry in ipairs(settings) do
|
for _, entry in ipairs(settings) do
|
||||||
local name
|
local name
|
||||||
if not core.setting_getbool("main_menu_technical_settings") and entry.readable_name then
|
if not core.settings:get_bool("main_menu_technical_settings") and entry.readable_name then
|
||||||
name = fgettext_ne(entry.readable_name)
|
name = fgettext_ne(entry.readable_name)
|
||||||
else
|
else
|
||||||
name = entry.name
|
name = entry.name
|
||||||
|
@ -666,7 +666,7 @@ local function create_settings_formspec(tabview, name, tabdata)
|
||||||
"button[10,6;2,1;btn_edit;" .. fgettext("Edit") .. "]" ..
|
"button[10,6;2,1;btn_edit;" .. fgettext("Edit") .. "]" ..
|
||||||
"button[7,6;3,1;btn_restore;" .. fgettext("Restore Default") .. "]" ..
|
"button[7,6;3,1;btn_restore;" .. fgettext("Restore Default") .. "]" ..
|
||||||
"checkbox[0,5.3;cb_tech_settings;" .. fgettext("Show technical names") .. ";"
|
"checkbox[0,5.3;cb_tech_settings;" .. fgettext("Show technical names") .. ";"
|
||||||
.. dump(core.setting_getbool("main_menu_technical_settings")) .. "]"
|
.. dump(core.settings:get_bool("main_menu_technical_settings")) .. "]"
|
||||||
|
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
@ -680,8 +680,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
|
||||||
local setting = settings[selected_setting]
|
local setting = settings[selected_setting]
|
||||||
if setting and setting.type == "bool" then
|
if setting and setting.type == "bool" then
|
||||||
local current_value = get_current_value(setting)
|
local current_value = get_current_value(setting)
|
||||||
core.setting_setbool(setting.name, not core.is_yes(current_value))
|
core.settings:set_bool(setting.name, not core.is_yes(current_value))
|
||||||
core.setting_save()
|
core.settings:write()
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
list_enter = true
|
list_enter = true
|
||||||
|
@ -736,8 +736,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
|
||||||
if fields["btn_restore"] then
|
if fields["btn_restore"] then
|
||||||
local setting = settings[selected_setting]
|
local setting = settings[selected_setting]
|
||||||
if setting and setting.type ~= "category" then
|
if setting and setting.type ~= "category" then
|
||||||
core.setting_set(setting.name, setting.default)
|
core.settings:set(setting.name, setting.default)
|
||||||
core.setting_save()
|
core.settings:write()
|
||||||
core.update_formspec(this:get_formspec())
|
core.update_formspec(this:get_formspec())
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
@ -749,8 +749,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields["cb_tech_settings"] then
|
if fields["cb_tech_settings"] then
|
||||||
core.setting_set("main_menu_technical_settings", fields["cb_tech_settings"])
|
core.settings:set("main_menu_technical_settings", fields["cb_tech_settings"])
|
||||||
core.setting_save()
|
core.settings:write()
|
||||||
core.update_formspec(this:get_formspec())
|
core.update_formspec(this:get_formspec())
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -119,9 +119,9 @@ local function init_globals()
|
||||||
menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
|
menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
|
||||||
menudata.worldlist:set_sortmode("alphabetic")
|
menudata.worldlist:set_sortmode("alphabetic")
|
||||||
|
|
||||||
if not core.setting_get("menu_last_game") then
|
if not core.settings:get("menu_last_game") then
|
||||||
local default_game = core.setting_get("default_game") or "minetest"
|
local default_game = core.settings:get("default_game") or "minetest"
|
||||||
core.setting_set("menu_last_game", default_game)
|
core.settings:set("menu_last_game", default_game)
|
||||||
end
|
end
|
||||||
|
|
||||||
mm_texture.init()
|
mm_texture.init()
|
||||||
|
@ -149,7 +149,7 @@ local function init_globals()
|
||||||
tv_main:set_fixed_size(false)
|
tv_main:set_fixed_size(false)
|
||||||
|
|
||||||
if PLATFORM ~= "Android" then
|
if PLATFORM ~= "Android" then
|
||||||
tv_main:set_tab(core.setting_get("maintab_LAST"))
|
tv_main:set_tab(core.settings:get("maintab_LAST"))
|
||||||
end
|
end
|
||||||
ui.set_default("maintab")
|
ui.set_default("maintab")
|
||||||
tv_main:show()
|
tv_main:show()
|
||||||
|
|
|
@ -233,14 +233,14 @@ function modstore.handle_buttons(parent, fields, name, data)
|
||||||
|
|
||||||
if not core.handle_async(
|
if not core.handle_async(
|
||||||
function(param)
|
function(param)
|
||||||
local fullurl = core.setting_get("modstore_download_url") ..
|
local fullurl = core.settings:get("modstore_download_url") ..
|
||||||
param.moddetails.download_url
|
param.moddetails.download_url
|
||||||
|
|
||||||
if param.version ~= nil then
|
if param.version ~= nil then
|
||||||
local found = false
|
local found = false
|
||||||
for i=1,#param.moddetails.versions, 1 do
|
for i=1,#param.moddetails.versions, 1 do
|
||||||
if param.moddetails.versions[i].date:sub(1,10) == param.version then
|
if param.moddetails.versions[i].date:sub(1,10) == param.version then
|
||||||
fullurl = core.setting_get("modstore_download_url") ..
|
fullurl = core.settings:get("modstore_download_url") ..
|
||||||
param.moddetails.versions[i].download_url
|
param.moddetails.versions[i].download_url
|
||||||
found = true
|
found = true
|
||||||
end
|
end
|
||||||
|
@ -400,7 +400,7 @@ function modstore.getscreenshot(ypos,listentry)
|
||||||
listentry.texturename = "in progress"
|
listentry.texturename = "in progress"
|
||||||
|
|
||||||
--prepare url and filename
|
--prepare url and filename
|
||||||
local fullurl = core.setting_get("modstore_download_url") ..
|
local fullurl = core.settings:get("modstore_download_url") ..
|
||||||
listentry.details.screenshot_url
|
listentry.details.screenshot_url
|
||||||
local filename = os.tempfolder() .. "_MID_" .. listentry.id
|
local filename = os.tempfolder() .. "_MID_" .. listentry.id
|
||||||
|
|
||||||
|
|
|
@ -39,14 +39,14 @@ local function get_formspec(tabview, name, tabdata)
|
||||||
-- Address / Port
|
-- Address / Port
|
||||||
"label[7.75,-0.25;" .. fgettext("Address / Port") .. "]" ..
|
"label[7.75,-0.25;" .. fgettext("Address / Port") .. "]" ..
|
||||||
"field[8,0.65;3.25,0.5;te_address;;" ..
|
"field[8,0.65;3.25,0.5;te_address;;" ..
|
||||||
core.formspec_escape(core.setting_get("address")) .. "]" ..
|
core.formspec_escape(core.settings:get("address")) .. "]" ..
|
||||||
"field[11.1,0.65;1.4,0.5;te_port;;" ..
|
"field[11.1,0.65;1.4,0.5;te_port;;" ..
|
||||||
core.formspec_escape(core.setting_get("remote_port")) .. "]" ..
|
core.formspec_escape(core.settings:get("remote_port")) .. "]" ..
|
||||||
|
|
||||||
-- Name / Password
|
-- Name / Password
|
||||||
"label[7.75,0.95;" .. fgettext("Name / Password") .. "]" ..
|
"label[7.75,0.95;" .. fgettext("Name / Password") .. "]" ..
|
||||||
"field[8,1.85;2.9,0.5;te_name;;" ..
|
"field[8,1.85;2.9,0.5;te_name;;" ..
|
||||||
core.formspec_escape(core.setting_get("name")) .. "]" ..
|
core.formspec_escape(core.settings:get("name")) .. "]" ..
|
||||||
"pwdfield[10.73,1.85;1.77,0.5;te_pwd;]" ..
|
"pwdfield[10.73,1.85;1.77,0.5;te_pwd;]" ..
|
||||||
|
|
||||||
-- Description Background
|
-- Description Background
|
||||||
|
@ -135,7 +135,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
|
|
||||||
if fields.te_name then
|
if fields.te_name then
|
||||||
gamedata.playername = fields.te_name
|
gamedata.playername = fields.te_name
|
||||||
core.setting_set("name", fields.te_name)
|
core.settings:set("name", fields.te_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.favourites then
|
if fields.favourites then
|
||||||
|
@ -163,8 +163,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
gamedata.serverdescription = fav.description
|
gamedata.serverdescription = fav.description
|
||||||
|
|
||||||
if gamedata.address and gamedata.port then
|
if gamedata.address and gamedata.port then
|
||||||
core.setting_set("address", gamedata.address)
|
core.settings:set("address", gamedata.address)
|
||||||
core.setting_set("remote_port", gamedata.port)
|
core.settings:set("remote_port", gamedata.port)
|
||||||
core.start()
|
core.start()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -187,8 +187,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
if address and port then
|
if address and port then
|
||||||
core.setting_set("address", address)
|
core.settings:set("address", address)
|
||||||
core.setting_set("remote_port", port)
|
core.settings:set("remote_port", port)
|
||||||
end
|
end
|
||||||
tabdata.fav_selected = event.row
|
tabdata.fav_selected = event.row
|
||||||
end
|
end
|
||||||
|
@ -219,8 +219,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
local port = fav.port
|
local port = fav.port
|
||||||
gamedata.serverdescription = fav.description
|
gamedata.serverdescription = fav.description
|
||||||
if address and port then
|
if address and port then
|
||||||
core.setting_set("address", address)
|
core.settings:set("address", address)
|
||||||
core.setting_set("remote_port", port)
|
core.settings:set("remote_port", port)
|
||||||
end
|
end
|
||||||
|
|
||||||
tabdata.fav_selected = fav_idx
|
tabdata.fav_selected = fav_idx
|
||||||
|
@ -235,8 +235,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
asyncOnlineFavourites()
|
asyncOnlineFavourites()
|
||||||
tabdata.fav_selected = nil
|
tabdata.fav_selected = nil
|
||||||
|
|
||||||
core.setting_set("address", "")
|
core.settings:set("address", "")
|
||||||
core.setting_set("remote_port", "30000")
|
core.settings:set("remote_port", "30000")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -293,8 +293,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
end)
|
end)
|
||||||
menudata.search_result = search_result
|
menudata.search_result = search_result
|
||||||
local first_server = search_result[1]
|
local first_server = search_result[1]
|
||||||
core.setting_set("address", first_server.address)
|
core.settings:set("address", first_server.address)
|
||||||
core.setting_set("remote_port", first_server.port)
|
core.settings:set("remote_port", first_server.port)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -325,8 +325,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
gamedata.serverdescription = ""
|
gamedata.serverdescription = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
core.setting_set("address", fields.te_address)
|
core.settings:set("address", fields.te_address)
|
||||||
core.setting_set("remote_port", fields.te_port)
|
core.settings:set("remote_port", fields.te_port)
|
||||||
|
|
||||||
core.start()
|
core.start()
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
local function get_formspec(tabview, name, tabdata)
|
local function get_formspec(tabview, name, tabdata)
|
||||||
|
|
||||||
local index = menudata.worldlist:get_current_index(
|
local index = menudata.worldlist:get_current_index(
|
||||||
tonumber(core.setting_get("mainmenu_last_selected_world"))
|
tonumber(core.settings:get("mainmenu_last_selected_world"))
|
||||||
)
|
)
|
||||||
|
|
||||||
local retval =
|
local retval =
|
||||||
|
@ -29,27 +29,27 @@ local function get_formspec(tabview, name, tabdata)
|
||||||
"button[8.5,5;3.25,0.5;start_server;" .. fgettext("Start Game") .. "]" ..
|
"button[8.5,5;3.25,0.5;start_server;" .. fgettext("Start Game") .. "]" ..
|
||||||
"label[4,-0.25;" .. fgettext("Select World:") .. "]" ..
|
"label[4,-0.25;" .. fgettext("Select World:") .. "]" ..
|
||||||
"checkbox[0.25,0.25;cb_creative_mode;" .. fgettext("Creative Mode") .. ";" ..
|
"checkbox[0.25,0.25;cb_creative_mode;" .. fgettext("Creative Mode") .. ";" ..
|
||||||
dump(core.setting_getbool("creative_mode")) .. "]" ..
|
dump(core.settings:get_bool("creative_mode")) .. "]" ..
|
||||||
"checkbox[0.25,0.7;cb_enable_damage;" .. fgettext("Enable Damage") .. ";" ..
|
"checkbox[0.25,0.7;cb_enable_damage;" .. fgettext("Enable Damage") .. ";" ..
|
||||||
dump(core.setting_getbool("enable_damage")) .. "]" ..
|
dump(core.settings:get_bool("enable_damage")) .. "]" ..
|
||||||
"checkbox[0.25,1.15;cb_server_announce;" .. fgettext("Public") .. ";" ..
|
"checkbox[0.25,1.15;cb_server_announce;" .. fgettext("Public") .. ";" ..
|
||||||
dump(core.setting_getbool("server_announce")) .. "]" ..
|
dump(core.settings:get_bool("server_announce")) .. "]" ..
|
||||||
"label[0.25,2.2;" .. fgettext("Name/Password") .. "]" ..
|
"label[0.25,2.2;" .. fgettext("Name/Password") .. "]" ..
|
||||||
"field[0.55,3.2;3.5,0.5;te_playername;;" ..
|
"field[0.55,3.2;3.5,0.5;te_playername;;" ..
|
||||||
core.formspec_escape(core.setting_get("name")) .. "]" ..
|
core.formspec_escape(core.settings:get("name")) .. "]" ..
|
||||||
"pwdfield[0.55,4;3.5,0.5;te_passwd;]"
|
"pwdfield[0.55,4;3.5,0.5;te_passwd;]"
|
||||||
|
|
||||||
local bind_addr = core.setting_get("bind_address")
|
local bind_addr = core.settings:get("bind_address")
|
||||||
if bind_addr ~= nil and bind_addr ~= "" then
|
if bind_addr ~= nil and bind_addr ~= "" then
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"field[0.55,5.2;2.25,0.5;te_serveraddr;" .. fgettext("Bind Address") .. ";" ..
|
"field[0.55,5.2;2.25,0.5;te_serveraddr;" .. fgettext("Bind Address") .. ";" ..
|
||||||
core.formspec_escape(core.setting_get("bind_address")) .. "]" ..
|
core.formspec_escape(core.settings:get("bind_address")) .. "]" ..
|
||||||
"field[2.8,5.2;1.25,0.5;te_serverport;" .. fgettext("Port") .. ";" ..
|
"field[2.8,5.2;1.25,0.5;te_serverport;" .. fgettext("Port") .. ";" ..
|
||||||
core.formspec_escape(core.setting_get("port")) .. "]"
|
core.formspec_escape(core.settings:get("port")) .. "]"
|
||||||
else
|
else
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"field[0.55,5.2;3.5,0.5;te_serverport;" .. fgettext("Server Port") .. ";" ..
|
"field[0.55,5.2;3.5,0.5;te_serverport;" .. fgettext("Server Port") .. ";" ..
|
||||||
core.formspec_escape(core.setting_get("port")) .. "]"
|
core.formspec_escape(core.settings:get("port")) .. "]"
|
||||||
end
|
end
|
||||||
|
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
|
@ -75,7 +75,7 @@ local function main_button_handler(this, fields, name, tabdata)
|
||||||
world_doubleclick = true
|
world_doubleclick = true
|
||||||
end
|
end
|
||||||
if event.type == "CHG" then
|
if event.type == "CHG" then
|
||||||
core.setting_set("mainmenu_last_selected_world",
|
core.settings:set("mainmenu_last_selected_world",
|
||||||
menudata.worldlist:get_raw_index(core.get_textlist_index("srv_worlds")))
|
menudata.worldlist:get_raw_index(core.get_textlist_index("srv_worlds")))
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -86,7 +86,7 @@ local function main_button_handler(this, fields, name, tabdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields["cb_creative_mode"] then
|
if fields["cb_creative_mode"] then
|
||||||
core.setting_set("creative_mode", fields["cb_creative_mode"])
|
core.settings:set("creative_mode", fields["cb_creative_mode"])
|
||||||
local selected = core.get_textlist_index("srv_worlds")
|
local selected = core.get_textlist_index("srv_worlds")
|
||||||
menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"])
|
menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"])
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ local function main_button_handler(this, fields, name, tabdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields["cb_enable_damage"] then
|
if fields["cb_enable_damage"] then
|
||||||
core.setting_set("enable_damage", fields["cb_enable_damage"])
|
core.settings:set("enable_damage", fields["cb_enable_damage"])
|
||||||
local selected = core.get_textlist_index("srv_worlds")
|
local selected = core.get_textlist_index("srv_worlds")
|
||||||
menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"])
|
menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"])
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ local function main_button_handler(this, fields, name, tabdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields["cb_server_announce"] then
|
if fields["cb_server_announce"] then
|
||||||
core.setting_set("server_announce", fields["cb_server_announce"])
|
core.settings:set("server_announce", fields["cb_server_announce"])
|
||||||
local selected = core.get_textlist_index("srv_worlds")
|
local selected = core.get_textlist_index("srv_worlds")
|
||||||
menu_worldmt(selected, "server_announce", fields["cb_server_announce"])
|
menu_worldmt(selected, "server_announce", fields["cb_server_announce"])
|
||||||
|
|
||||||
|
@ -120,16 +120,16 @@ local function main_button_handler(this, fields, name, tabdata)
|
||||||
gamedata.port = fields["te_serverport"]
|
gamedata.port = fields["te_serverport"]
|
||||||
gamedata.address = ""
|
gamedata.address = ""
|
||||||
|
|
||||||
core.setting_set("port",gamedata.port)
|
core.settings:set("port",gamedata.port)
|
||||||
if fields["te_serveraddr"] ~= nil then
|
if fields["te_serveraddr"] ~= nil then
|
||||||
core.setting_set("bind_address",fields["te_serveraddr"])
|
core.settings:set("bind_address",fields["te_serveraddr"])
|
||||||
end
|
end
|
||||||
|
|
||||||
--update last game
|
--update last game
|
||||||
local world = menudata.worldlist:get_raw_element(gamedata.selected_world)
|
local world = menudata.worldlist:get_raw_element(gamedata.selected_world)
|
||||||
if world then
|
if world then
|
||||||
local game, index = gamemgr.find_by_gameid(world.gameid)
|
local game, index = gamemgr.find_by_gameid(world.gameid)
|
||||||
core.setting_set("menu_last_game", game.id)
|
core.settings:set("menu_last_game", game.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
core.start()
|
core.start()
|
||||||
|
|
|
@ -70,39 +70,39 @@ local dd_options = {
|
||||||
|
|
||||||
local getSettingIndex = {
|
local getSettingIndex = {
|
||||||
Leaves = function()
|
Leaves = function()
|
||||||
local style = core.setting_get("leaves_style")
|
local style = core.settings:get("leaves_style")
|
||||||
for idx, name in pairs(dd_options.leaves[2]) do
|
for idx, name in pairs(dd_options.leaves[2]) do
|
||||||
if style == name then return idx end
|
if style == name then return idx end
|
||||||
end
|
end
|
||||||
return 1
|
return 1
|
||||||
end,
|
end,
|
||||||
NodeHighlighting = function()
|
NodeHighlighting = function()
|
||||||
local style = core.setting_get("node_highlighting")
|
local style = core.settings:get("node_highlighting")
|
||||||
for idx, name in pairs(dd_options.node_highlighting[2]) do
|
for idx, name in pairs(dd_options.node_highlighting[2]) do
|
||||||
if style == name then return idx end
|
if style == name then return idx end
|
||||||
end
|
end
|
||||||
return 1
|
return 1
|
||||||
end,
|
end,
|
||||||
Filter = function()
|
Filter = function()
|
||||||
if core.setting_get(dd_options.filters[2][3]) == "true" then
|
if core.settings:get(dd_options.filters[2][3]) == "true" then
|
||||||
return 3
|
return 3
|
||||||
elseif core.setting_get(dd_options.filters[2][3]) == "false" and
|
elseif core.settings:get(dd_options.filters[2][3]) == "false" and
|
||||||
core.setting_get(dd_options.filters[2][2]) == "true" then
|
core.settings:get(dd_options.filters[2][2]) == "true" then
|
||||||
return 2
|
return 2
|
||||||
end
|
end
|
||||||
return 1
|
return 1
|
||||||
end,
|
end,
|
||||||
Mipmap = function()
|
Mipmap = function()
|
||||||
if core.setting_get(dd_options.mipmap[2][3]) == "true" then
|
if core.settings:get(dd_options.mipmap[2][3]) == "true" then
|
||||||
return 3
|
return 3
|
||||||
elseif core.setting_get(dd_options.mipmap[2][3]) == "false" and
|
elseif core.settings:get(dd_options.mipmap[2][3]) == "false" and
|
||||||
core.setting_get(dd_options.mipmap[2][2]) == "true" then
|
core.settings:get(dd_options.mipmap[2][2]) == "true" then
|
||||||
return 2
|
return 2
|
||||||
end
|
end
|
||||||
return 1
|
return 1
|
||||||
end,
|
end,
|
||||||
Antialiasing = function()
|
Antialiasing = function()
|
||||||
local antialiasing_setting = core.setting_get("fsaa")
|
local antialiasing_setting = core.settings:get("fsaa")
|
||||||
for i = 1, #dd_options.antialiasing[2] do
|
for i = 1, #dd_options.antialiasing[2] do
|
||||||
if antialiasing_setting == dd_options.antialiasing[2][i] then
|
if antialiasing_setting == dd_options.antialiasing[2][i] then
|
||||||
return i
|
return i
|
||||||
|
@ -177,15 +177,15 @@ local function formspec(tabview, name, tabdata)
|
||||||
local tab_string =
|
local tab_string =
|
||||||
"box[0,0;3.5,4.5;#999999]" ..
|
"box[0,0;3.5,4.5;#999999]" ..
|
||||||
"checkbox[0.25,0;cb_smooth_lighting;" .. fgettext("Smooth Lighting") .. ";"
|
"checkbox[0.25,0;cb_smooth_lighting;" .. fgettext("Smooth Lighting") .. ";"
|
||||||
.. dump(core.setting_getbool("smooth_lighting")) .. "]" ..
|
.. dump(core.settings:get_bool("smooth_lighting")) .. "]" ..
|
||||||
"checkbox[0.25,0.5;cb_particles;" .. fgettext("Particles") .. ";"
|
"checkbox[0.25,0.5;cb_particles;" .. fgettext("Particles") .. ";"
|
||||||
.. dump(core.setting_getbool("enable_particles")) .. "]" ..
|
.. dump(core.settings:get_bool("enable_particles")) .. "]" ..
|
||||||
"checkbox[0.25,1;cb_3d_clouds;" .. fgettext("3D Clouds") .. ";"
|
"checkbox[0.25,1;cb_3d_clouds;" .. fgettext("3D Clouds") .. ";"
|
||||||
.. dump(core.setting_getbool("enable_3d_clouds")) .. "]" ..
|
.. dump(core.settings:get_bool("enable_3d_clouds")) .. "]" ..
|
||||||
"checkbox[0.25,1.5;cb_opaque_water;" .. fgettext("Opaque Water") .. ";"
|
"checkbox[0.25,1.5;cb_opaque_water;" .. fgettext("Opaque Water") .. ";"
|
||||||
.. dump(core.setting_getbool("opaque_water")) .. "]" ..
|
.. dump(core.settings:get_bool("opaque_water")) .. "]" ..
|
||||||
"checkbox[0.25,2.0;cb_connected_glass;" .. fgettext("Connected Glass") .. ";"
|
"checkbox[0.25,2.0;cb_connected_glass;" .. fgettext("Connected Glass") .. ";"
|
||||||
.. dump(core.setting_getbool("connected_glass")) .. "]" ..
|
.. dump(core.settings:get_bool("connected_glass")) .. "]" ..
|
||||||
"dropdown[0.25,2.8;3.3;dd_node_highlighting;" .. dd_options.node_highlighting[1] .. ";"
|
"dropdown[0.25,2.8;3.3;dd_node_highlighting;" .. dd_options.node_highlighting[1] .. ";"
|
||||||
.. getSettingIndex.NodeHighlighting() .. "]" ..
|
.. getSettingIndex.NodeHighlighting() .. "]" ..
|
||||||
"dropdown[0.25,3.6;3.3;dd_leaves_style;" .. dd_options.leaves[1] .. ";"
|
"dropdown[0.25,3.6;3.3;dd_leaves_style;" .. dd_options.leaves[1] .. ";"
|
||||||
|
@ -201,10 +201,10 @@ local function formspec(tabview, name, tabdata)
|
||||||
.. getSettingIndex.Antialiasing() .. "]" ..
|
.. getSettingIndex.Antialiasing() .. "]" ..
|
||||||
"label[3.85,3.45;" .. fgettext("Screen:") .. "]" ..
|
"label[3.85,3.45;" .. fgettext("Screen:") .. "]" ..
|
||||||
"checkbox[3.85,3.6;cb_autosave_screensize;" .. fgettext("Autosave screen size") .. ";"
|
"checkbox[3.85,3.6;cb_autosave_screensize;" .. fgettext("Autosave screen size") .. ";"
|
||||||
.. dump(core.setting_getbool("autosave_screensize")) .. "]" ..
|
.. dump(core.settings:get_bool("autosave_screensize")) .. "]" ..
|
||||||
"box[7.75,0;4,4.4;#999999]" ..
|
"box[7.75,0;4,4.4;#999999]" ..
|
||||||
"checkbox[8,0;cb_shaders;" .. fgettext("Shaders") .. ";"
|
"checkbox[8,0;cb_shaders;" .. fgettext("Shaders") .. ";"
|
||||||
.. dump(core.setting_getbool("enable_shaders")) .. "]"
|
.. dump(core.settings:get_bool("enable_shaders")) .. "]"
|
||||||
|
|
||||||
if PLATFORM == "Android" then
|
if PLATFORM == "Android" then
|
||||||
tab_string = tab_string ..
|
tab_string = tab_string ..
|
||||||
|
@ -221,29 +221,29 @@ local function formspec(tabview, name, tabdata)
|
||||||
.. fgettext("Advanced Settings") .. "]"
|
.. fgettext("Advanced Settings") .. "]"
|
||||||
|
|
||||||
|
|
||||||
if core.setting_get("touchscreen_threshold") ~= nil then
|
if core.settings:get("touchscreen_threshold") ~= nil then
|
||||||
tab_string = tab_string ..
|
tab_string = tab_string ..
|
||||||
"label[4.3,4.1;" .. fgettext("Touchthreshold (px)") .. "]" ..
|
"label[4.3,4.1;" .. fgettext("Touchthreshold (px)") .. "]" ..
|
||||||
"dropdown[3.85,4.55;3.85;dd_touchthreshold;0,10,20,30,40,50;" ..
|
"dropdown[3.85,4.55;3.85;dd_touchthreshold;0,10,20,30,40,50;" ..
|
||||||
((tonumber(core.setting_get("touchscreen_threshold")) / 10) + 1) .. "]"
|
((tonumber(core.settings:get("touchscreen_threshold")) / 10) + 1) .. "]"
|
||||||
end
|
end
|
||||||
|
|
||||||
if core.setting_getbool("enable_shaders") then
|
if core.settings:get_bool("enable_shaders") then
|
||||||
tab_string = tab_string ..
|
tab_string = tab_string ..
|
||||||
"checkbox[8,0.5;cb_bumpmapping;" .. fgettext("Bump Mapping") .. ";"
|
"checkbox[8,0.5;cb_bumpmapping;" .. fgettext("Bump Mapping") .. ";"
|
||||||
.. dump(core.setting_getbool("enable_bumpmapping")) .. "]" ..
|
.. dump(core.settings:get_bool("enable_bumpmapping")) .. "]" ..
|
||||||
"checkbox[8,1;cb_tonemapping;" .. fgettext("Tone Mapping") .. ";"
|
"checkbox[8,1;cb_tonemapping;" .. fgettext("Tone Mapping") .. ";"
|
||||||
.. dump(core.setting_getbool("tone_mapping")) .. "]" ..
|
.. dump(core.settings:get_bool("tone_mapping")) .. "]" ..
|
||||||
"checkbox[8,1.5;cb_generate_normalmaps;" .. fgettext("Normal Mapping") .. ";"
|
"checkbox[8,1.5;cb_generate_normalmaps;" .. fgettext("Normal Mapping") .. ";"
|
||||||
.. dump(core.setting_getbool("generate_normalmaps")) .. "]" ..
|
.. dump(core.settings:get_bool("generate_normalmaps")) .. "]" ..
|
||||||
"checkbox[8,2;cb_parallax;" .. fgettext("Parallax Occlusion") .. ";"
|
"checkbox[8,2;cb_parallax;" .. fgettext("Parallax Occlusion") .. ";"
|
||||||
.. dump(core.setting_getbool("enable_parallax_occlusion")) .. "]" ..
|
.. dump(core.settings:get_bool("enable_parallax_occlusion")) .. "]" ..
|
||||||
"checkbox[8,2.5;cb_waving_water;" .. fgettext("Waving Water") .. ";"
|
"checkbox[8,2.5;cb_waving_water;" .. fgettext("Waving Water") .. ";"
|
||||||
.. dump(core.setting_getbool("enable_waving_water")) .. "]" ..
|
.. dump(core.settings:get_bool("enable_waving_water")) .. "]" ..
|
||||||
"checkbox[8,3;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";"
|
"checkbox[8,3;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";"
|
||||||
.. dump(core.setting_getbool("enable_waving_leaves")) .. "]" ..
|
.. dump(core.settings:get_bool("enable_waving_leaves")) .. "]" ..
|
||||||
"checkbox[8,3.5;cb_waving_plants;" .. fgettext("Waving Plants") .. ";"
|
"checkbox[8,3.5;cb_waving_plants;" .. fgettext("Waving Plants") .. ";"
|
||||||
.. dump(core.setting_getbool("enable_waving_plants")) .. "]"
|
.. dump(core.settings:get_bool("enable_waving_plants")) .. "]"
|
||||||
else
|
else
|
||||||
tab_string = tab_string ..
|
tab_string = tab_string ..
|
||||||
"tablecolumns[color;text]" ..
|
"tablecolumns[color;text]" ..
|
||||||
|
@ -274,64 +274,64 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_smooth_lighting"] then
|
if fields["cb_smooth_lighting"] then
|
||||||
core.setting_set("smooth_lighting", fields["cb_smooth_lighting"])
|
core.settings:set("smooth_lighting", fields["cb_smooth_lighting"])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_particles"] then
|
if fields["cb_particles"] then
|
||||||
core.setting_set("enable_particles", fields["cb_particles"])
|
core.settings:set("enable_particles", fields["cb_particles"])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_3d_clouds"] then
|
if fields["cb_3d_clouds"] then
|
||||||
core.setting_set("enable_3d_clouds", fields["cb_3d_clouds"])
|
core.settings:set("enable_3d_clouds", fields["cb_3d_clouds"])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_opaque_water"] then
|
if fields["cb_opaque_water"] then
|
||||||
core.setting_set("opaque_water", fields["cb_opaque_water"])
|
core.settings:set("opaque_water", fields["cb_opaque_water"])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_connected_glass"] then
|
if fields["cb_connected_glass"] then
|
||||||
core.setting_set("connected_glass", fields["cb_connected_glass"])
|
core.settings:set("connected_glass", fields["cb_connected_glass"])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_autosave_screensize"] then
|
if fields["cb_autosave_screensize"] then
|
||||||
core.setting_set("autosave_screensize", fields["cb_autosave_screensize"])
|
core.settings:set("autosave_screensize", fields["cb_autosave_screensize"])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_shaders"] then
|
if fields["cb_shaders"] then
|
||||||
if (core.setting_get("video_driver") == "direct3d8" or
|
if (core.settings:get("video_driver") == "direct3d8" or
|
||||||
core.setting_get("video_driver") == "direct3d9") then
|
core.settings:get("video_driver") == "direct3d9") then
|
||||||
core.setting_set("enable_shaders", "false")
|
core.settings:set("enable_shaders", "false")
|
||||||
gamedata.errormessage = fgettext("To enable shaders the OpenGL driver needs to be used.")
|
gamedata.errormessage = fgettext("To enable shaders the OpenGL driver needs to be used.")
|
||||||
else
|
else
|
||||||
core.setting_set("enable_shaders", fields["cb_shaders"])
|
core.settings:set("enable_shaders", fields["cb_shaders"])
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_bumpmapping"] then
|
if fields["cb_bumpmapping"] then
|
||||||
core.setting_set("enable_bumpmapping", fields["cb_bumpmapping"])
|
core.settings:set("enable_bumpmapping", fields["cb_bumpmapping"])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_tonemapping"] then
|
if fields["cb_tonemapping"] then
|
||||||
core.setting_set("tone_mapping", fields["cb_tonemapping"])
|
core.settings:set("tone_mapping", fields["cb_tonemapping"])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_generate_normalmaps"] then
|
if fields["cb_generate_normalmaps"] then
|
||||||
core.setting_set("generate_normalmaps", fields["cb_generate_normalmaps"])
|
core.settings:set("generate_normalmaps", fields["cb_generate_normalmaps"])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_parallax"] then
|
if fields["cb_parallax"] then
|
||||||
core.setting_set("enable_parallax_occlusion", fields["cb_parallax"])
|
core.settings:set("enable_parallax_occlusion", fields["cb_parallax"])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_waving_water"] then
|
if fields["cb_waving_water"] then
|
||||||
core.setting_set("enable_waving_water", fields["cb_waving_water"])
|
core.settings:set("enable_waving_water", fields["cb_waving_water"])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_waving_leaves"] then
|
if fields["cb_waving_leaves"] then
|
||||||
core.setting_set("enable_waving_leaves", fields["cb_waving_leaves"])
|
core.settings:set("enable_waving_leaves", fields["cb_waving_leaves"])
|
||||||
end
|
end
|
||||||
if fields["cb_waving_plants"] then
|
if fields["cb_waving_plants"] then
|
||||||
core.setting_set("enable_waving_plants", fields["cb_waving_plants"])
|
core.settings:set("enable_waving_plants", fields["cb_waving_plants"])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["btn_change_keys"] then
|
if fields["btn_change_keys"] then
|
||||||
|
@ -339,7 +339,7 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["cb_touchscreen_target"] then
|
if fields["cb_touchscreen_target"] then
|
||||||
core.setting_set("touchtarget", fields["cb_touchscreen_target"])
|
core.settings:set("touchtarget", fields["cb_touchscreen_target"])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["btn_reset_singleplayer"] then
|
if fields["btn_reset_singleplayer"] then
|
||||||
|
@ -352,49 +352,49 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
|
||||||
|
|
||||||
for i = 1, #labels.leaves do
|
for i = 1, #labels.leaves do
|
||||||
if fields["dd_leaves_style"] == labels.leaves[i] then
|
if fields["dd_leaves_style"] == labels.leaves[i] then
|
||||||
core.setting_set("leaves_style", dd_options.leaves[2][i])
|
core.settings:set("leaves_style", dd_options.leaves[2][i])
|
||||||
ddhandled = true
|
ddhandled = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i = 1, #labels.node_highlighting do
|
for i = 1, #labels.node_highlighting do
|
||||||
if fields["dd_node_highlighting"] == labels.node_highlighting[i] then
|
if fields["dd_node_highlighting"] == labels.node_highlighting[i] then
|
||||||
core.setting_set("node_highlighting", dd_options.node_highlighting[2][i])
|
core.settings:set("node_highlighting", dd_options.node_highlighting[2][i])
|
||||||
ddhandled = true
|
ddhandled = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if fields["dd_filters"] == labels.filters[1] then
|
if fields["dd_filters"] == labels.filters[1] then
|
||||||
core.setting_set("bilinear_filter", "false")
|
core.settings:set("bilinear_filter", "false")
|
||||||
core.setting_set("trilinear_filter", "false")
|
core.settings:set("trilinear_filter", "false")
|
||||||
ddhandled = true
|
ddhandled = true
|
||||||
elseif fields["dd_filters"] == labels.filters[2] then
|
elseif fields["dd_filters"] == labels.filters[2] then
|
||||||
core.setting_set("bilinear_filter", "true")
|
core.settings:set("bilinear_filter", "true")
|
||||||
core.setting_set("trilinear_filter", "false")
|
core.settings:set("trilinear_filter", "false")
|
||||||
ddhandled = true
|
ddhandled = true
|
||||||
elseif fields["dd_filters"] == labels.filters[3] then
|
elseif fields["dd_filters"] == labels.filters[3] then
|
||||||
core.setting_set("bilinear_filter", "false")
|
core.settings:set("bilinear_filter", "false")
|
||||||
core.setting_set("trilinear_filter", "true")
|
core.settings:set("trilinear_filter", "true")
|
||||||
ddhandled = true
|
ddhandled = true
|
||||||
end
|
end
|
||||||
if fields["dd_mipmap"] == labels.mipmap[1] then
|
if fields["dd_mipmap"] == labels.mipmap[1] then
|
||||||
core.setting_set("mip_map", "false")
|
core.settings:set("mip_map", "false")
|
||||||
core.setting_set("anisotropic_filter", "false")
|
core.settings:set("anisotropic_filter", "false")
|
||||||
ddhandled = true
|
ddhandled = true
|
||||||
elseif fields["dd_mipmap"] == labels.mipmap[2] then
|
elseif fields["dd_mipmap"] == labels.mipmap[2] then
|
||||||
core.setting_set("mip_map", "true")
|
core.settings:set("mip_map", "true")
|
||||||
core.setting_set("anisotropic_filter", "false")
|
core.settings:set("anisotropic_filter", "false")
|
||||||
ddhandled = true
|
ddhandled = true
|
||||||
elseif fields["dd_mipmap"] == labels.mipmap[3] then
|
elseif fields["dd_mipmap"] == labels.mipmap[3] then
|
||||||
core.setting_set("mip_map", "true")
|
core.settings:set("mip_map", "true")
|
||||||
core.setting_set("anisotropic_filter", "true")
|
core.settings:set("anisotropic_filter", "true")
|
||||||
ddhandled = true
|
ddhandled = true
|
||||||
end
|
end
|
||||||
if fields["dd_antialiasing"] then
|
if fields["dd_antialiasing"] then
|
||||||
core.setting_set("fsaa",
|
core.settings:set("fsaa",
|
||||||
antialiasing_fname_to_name(fields["dd_antialiasing"]))
|
antialiasing_fname_to_name(fields["dd_antialiasing"]))
|
||||||
ddhandled = true
|
ddhandled = true
|
||||||
end
|
end
|
||||||
if fields["dd_touchthreshold"] then
|
if fields["dd_touchthreshold"] then
|
||||||
core.setting_set("touchscreen_threshold", fields["dd_touchthreshold"])
|
core.settings:set("touchscreen_threshold", fields["dd_touchthreshold"])
|
||||||
ddhandled = true
|
ddhandled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,12 @@ local function get_formspec(tabview, name, tabdata)
|
||||||
local retval =
|
local retval =
|
||||||
"label[9.5,0;".. fgettext("Name / Password") .. "]" ..
|
"label[9.5,0;".. fgettext("Name / Password") .. "]" ..
|
||||||
"field[0.25,3.35;5.5,0.5;te_address;;" ..
|
"field[0.25,3.35;5.5,0.5;te_address;;" ..
|
||||||
core.formspec_escape(core.setting_get("address")) .."]" ..
|
core.formspec_escape(core.settings:get("address")) .."]" ..
|
||||||
"field[5.75,3.35;2.25,0.5;te_port;;" ..
|
"field[5.75,3.35;2.25,0.5;te_port;;" ..
|
||||||
core.formspec_escape(core.setting_get("remote_port")) .."]" ..
|
core.formspec_escape(core.settings:get("remote_port")) .."]" ..
|
||||||
"button[10,2.6;2,1.5;btn_mp_connect;".. fgettext("Connect") .. "]" ..
|
"button[10,2.6;2,1.5;btn_mp_connect;".. fgettext("Connect") .. "]" ..
|
||||||
"field[9.8,1;2.6,0.5;te_name;;" ..
|
"field[9.8,1;2.6,0.5;te_name;;" ..
|
||||||
core.formspec_escape(core.setting_get("name")) .."]" ..
|
core.formspec_escape(core.settings:get("name")) .."]" ..
|
||||||
"pwdfield[9.8,2;2.6,0.5;te_pwd;]"
|
"pwdfield[9.8,2;2.6,0.5;te_pwd;]"
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,9 +89,9 @@ local function get_formspec(tabview, name, tabdata)
|
||||||
-- checkboxes
|
-- checkboxes
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"checkbox[8.0,3.9;cb_creative;".. fgettext("Creative Mode") .. ";" ..
|
"checkbox[8.0,3.9;cb_creative;".. fgettext("Creative Mode") .. ";" ..
|
||||||
dump(core.setting_getbool("creative_mode")) .. "]"..
|
dump(core.settings:get_bool("creative_mode")) .. "]"..
|
||||||
"checkbox[8.0,4.4;cb_damage;".. fgettext("Enable Damage") .. ";" ..
|
"checkbox[8.0,4.4;cb_damage;".. fgettext("Enable Damage") .. ";" ..
|
||||||
dump(core.setting_getbool("enable_damage")) .. "]"
|
dump(core.settings:get_bool("enable_damage")) .. "]"
|
||||||
-- buttons
|
-- buttons
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"button[0,3.7;8,1.5;btn_start_singleplayer;" .. fgettext("Start Singleplayer") .. "]" ..
|
"button[0,3.7;8,1.5;btn_start_singleplayer;" .. fgettext("Start Singleplayer") .. "]" ..
|
||||||
|
@ -128,8 +128,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
if address and port then
|
if address and port then
|
||||||
core.setting_set("address", address)
|
core.settings:set("address", address)
|
||||||
core.setting_set("remote_port", port)
|
core.settings:set("remote_port", port)
|
||||||
end
|
end
|
||||||
tabdata.fav_selected = event.row
|
tabdata.fav_selected = event.row
|
||||||
end
|
end
|
||||||
|
@ -145,18 +145,18 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
asyncOnlineFavourites()
|
asyncOnlineFavourites()
|
||||||
tabdata.fav_selected = nil
|
tabdata.fav_selected = nil
|
||||||
|
|
||||||
core.setting_set("address", "")
|
core.settings:set("address", "")
|
||||||
core.setting_set("remote_port", "30000")
|
core.settings:set("remote_port", "30000")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.cb_creative then
|
if fields.cb_creative then
|
||||||
core.setting_set("creative_mode", fields.cb_creative)
|
core.settings:set("creative_mode", fields.cb_creative)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.cb_damage then
|
if fields.cb_damage then
|
||||||
core.setting_set("enable_damage", fields.cb_damage)
|
core.settings:set("enable_damage", fields.cb_damage)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -186,12 +186,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
|
|
||||||
gamedata.selected_world = 0
|
gamedata.selected_world = 0
|
||||||
|
|
||||||
core.setting_set("address", fields.te_address)
|
core.settings:set("address", fields.te_address)
|
||||||
core.setting_set("remote_port", fields.te_port)
|
core.settings:set("remote_port", fields.te_port)
|
||||||
|
|
||||||
core.start()
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if fields.btn_config_sp_world then
|
if fields.btn_config_sp_world then
|
||||||
local configdialog = create_configure_world_dlg(1)
|
local configdialog = create_configure_world_dlg(1)
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
local function current_game()
|
local function current_game()
|
||||||
local last_game_id = core.setting_get("menu_last_game")
|
local last_game_id = core.settings:get("menu_last_game")
|
||||||
local game, index = gamemgr.find_by_gameid(last_game_id)
|
local game, index = gamemgr.find_by_gameid(last_game_id)
|
||||||
|
|
||||||
return game
|
return game
|
||||||
|
@ -36,10 +36,10 @@ local function singleplayer_refresh_gamebar()
|
||||||
if ("game_btnbar_" .. gamemgr.games[j].id == key) then
|
if ("game_btnbar_" .. gamemgr.games[j].id == key) then
|
||||||
mm_texture.update("singleplayer", gamemgr.games[j])
|
mm_texture.update("singleplayer", gamemgr.games[j])
|
||||||
core.set_topleft_text(gamemgr.games[j].name)
|
core.set_topleft_text(gamemgr.games[j].name)
|
||||||
core.setting_set("menu_last_game",gamemgr.games[j].id)
|
core.settings:set("menu_last_game",gamemgr.games[j].id)
|
||||||
menudata.worldlist:set_filtercriteria(gamemgr.games[j].id)
|
menudata.worldlist:set_filtercriteria(gamemgr.games[j].id)
|
||||||
local index = filterlist.get_current_index(menudata.worldlist,
|
local index = filterlist.get_current_index(menudata.worldlist,
|
||||||
tonumber(core.setting_get("mainmenu_last_selected_world")))
|
tonumber(core.settings:get("mainmenu_last_selected_world")))
|
||||||
if not index or index < 1 then
|
if not index or index < 1 then
|
||||||
local selected = core.get_textlist_index("sp_worlds")
|
local selected = core.get_textlist_index("sp_worlds")
|
||||||
if selected ~= nil and selected < #menudata.worldlist:get_list() then
|
if selected ~= nil and selected < #menudata.worldlist:get_list() then
|
||||||
|
@ -89,7 +89,7 @@ local function get_formspec(tabview, name, tabdata)
|
||||||
local retval = ""
|
local retval = ""
|
||||||
|
|
||||||
local index = filterlist.get_current_index(menudata.worldlist,
|
local index = filterlist.get_current_index(menudata.worldlist,
|
||||||
tonumber(core.setting_get("mainmenu_last_selected_world"))
|
tonumber(core.settings:get("mainmenu_last_selected_world"))
|
||||||
)
|
)
|
||||||
|
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
|
@ -99,9 +99,9 @@ local function get_formspec(tabview, name, tabdata)
|
||||||
"button[8.5,5;3.25,0.5;play;".. fgettext("Play") .. "]" ..
|
"button[8.5,5;3.25,0.5;play;".. fgettext("Play") .. "]" ..
|
||||||
"label[4,-0.25;".. fgettext("Select World:") .. "]"..
|
"label[4,-0.25;".. fgettext("Select World:") .. "]"..
|
||||||
"checkbox[0.25,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
|
"checkbox[0.25,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
|
||||||
dump(core.setting_getbool("creative_mode")) .. "]"..
|
dump(core.settings:get_bool("creative_mode")) .. "]"..
|
||||||
"checkbox[0.25,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" ..
|
"checkbox[0.25,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" ..
|
||||||
dump(core.setting_getbool("enable_damage")) .. "]"..
|
dump(core.settings:get_bool("enable_damage")) .. "]"..
|
||||||
"textlist[4,0.25;7.5,3.7;sp_worlds;" ..
|
"textlist[4,0.25;7.5,3.7;sp_worlds;" ..
|
||||||
menu_render_worldlist() ..
|
menu_render_worldlist() ..
|
||||||
";" .. index .. "]"
|
";" .. index .. "]"
|
||||||
|
@ -125,7 +125,7 @@ local function main_button_handler(this, fields, name, tabdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
if event.type == "CHG" and selected ~= nil then
|
if event.type == "CHG" and selected ~= nil then
|
||||||
core.setting_set("mainmenu_last_selected_world",
|
core.settings:set("mainmenu_last_selected_world",
|
||||||
menudata.worldlist:get_raw_index(selected))
|
menudata.worldlist:get_raw_index(selected))
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -136,7 +136,7 @@ local function main_button_handler(this, fields, name, tabdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields["cb_creative_mode"] then
|
if fields["cb_creative_mode"] then
|
||||||
core.setting_set("creative_mode", fields["cb_creative_mode"])
|
core.settings:set("creative_mode", fields["cb_creative_mode"])
|
||||||
local selected = core.get_textlist_index("sp_worlds")
|
local selected = core.get_textlist_index("sp_worlds")
|
||||||
menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"])
|
menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"])
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ local function main_button_handler(this, fields, name, tabdata)
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields["cb_enable_damage"] then
|
if fields["cb_enable_damage"] then
|
||||||
core.setting_set("enable_damage", fields["cb_enable_damage"])
|
core.settings:set("enable_damage", fields["cb_enable_damage"])
|
||||||
local selected = core.get_textlist_index("sp_worlds")
|
local selected = core.get_textlist_index("sp_worlds")
|
||||||
menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"])
|
menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"])
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,9 @@ local function get_formspec(tabview, name, tabdata)
|
||||||
local retval = "label[4,-0.25;" .. fgettext("Select texture pack:") .. "]" ..
|
local retval = "label[4,-0.25;" .. fgettext("Select texture pack:") .. "]" ..
|
||||||
"textlist[4,0.25;7.5,5.0;TPs;"
|
"textlist[4,0.25;7.5,5.0;TPs;"
|
||||||
|
|
||||||
local current_texture_path = core.setting_get("texture_path")
|
local current_texture_path = core.settings:get("texture_path")
|
||||||
local list = filter_texture_pack_list(core.get_dir_list(core.get_texturepath(), true))
|
local list = filter_texture_pack_list(core.get_dir_list(core.get_texturepath(), true))
|
||||||
local index = tonumber(core.setting_get("mainmenu_last_selected_TP"))
|
local index = tonumber(core.settings:get("mainmenu_last_selected_TP"))
|
||||||
|
|
||||||
if not index then index = 1 end
|
if not index then index = 1 end
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
local event = core.explode_textlist_event(fields["TPs"])
|
local event = core.explode_textlist_event(fields["TPs"])
|
||||||
if event.type == "CHG" or event.type == "DCL" then
|
if event.type == "CHG" or event.type == "DCL" then
|
||||||
local index = core.get_textlist_index("TPs")
|
local index = core.get_textlist_index("TPs")
|
||||||
core.setting_set("mainmenu_last_selected_TP", index)
|
core.settings:set("mainmenu_last_selected_TP", index)
|
||||||
local list = filter_texture_pack_list(core.get_dir_list(core.get_texturepath(), true))
|
local list = filter_texture_pack_list(core.get_dir_list(core.get_texturepath(), true))
|
||||||
local current_index = core.get_textlist_index("TPs")
|
local current_index = core.get_textlist_index("TPs")
|
||||||
if current_index and #list >= current_index then
|
if current_index and #list >= current_index then
|
||||||
|
@ -114,7 +114,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
if list[current_index] == fgettext("None") then
|
if list[current_index] == fgettext("None") then
|
||||||
new_path = ""
|
new_path = ""
|
||||||
end
|
end
|
||||||
core.setting_set("texture_path", new_path)
|
core.settings:set("texture_path", new_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -24,7 +24,7 @@ function mm_texture.init()
|
||||||
DIR_DELIM .. "pack" .. DIR_DELIM
|
DIR_DELIM .. "pack" .. DIR_DELIM
|
||||||
mm_texture.basetexturedir = mm_texture.defaulttexturedir
|
mm_texture.basetexturedir = mm_texture.defaulttexturedir
|
||||||
|
|
||||||
mm_texture.texturepack = core.setting_get("texture_path")
|
mm_texture.texturepack = core.settings:get("texture_path")
|
||||||
|
|
||||||
mm_texture.gameid = nil
|
mm_texture.gameid = nil
|
||||||
end
|
end
|
||||||
|
@ -61,7 +61,7 @@ function mm_texture.reset()
|
||||||
mm_texture.set_generic("header")
|
mm_texture.set_generic("header")
|
||||||
|
|
||||||
if not have_bg then
|
if not have_bg then
|
||||||
if core.setting_getbool("menu_clouds") then
|
if core.settings:get_bool("menu_clouds") then
|
||||||
core.set_clouds(true)
|
core.set_clouds(true)
|
||||||
else
|
else
|
||||||
mm_texture.set_dirt_bg()
|
mm_texture.set_dirt_bg()
|
||||||
|
@ -88,7 +88,7 @@ function mm_texture.update_game(gamedetails)
|
||||||
|
|
||||||
if not have_bg then
|
if not have_bg then
|
||||||
|
|
||||||
if core.setting_getbool("menu_clouds") then
|
if core.settings:get_bool("menu_clouds") then
|
||||||
core.set_clouds(true)
|
core.set_clouds(true)
|
||||||
else
|
else
|
||||||
mm_texture.set_dirt_bg()
|
mm_texture.set_dirt_bg()
|
||||||
|
|
|
@ -15,10 +15,18 @@
|
||||||
--with this program; if not, write to the Free Software Foundation, Inc.,
|
--with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
local function get_bool_default(name, default)
|
||||||
|
local val = core.settings:get_bool(name)
|
||||||
|
if val == nil then
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
return val
|
||||||
|
end
|
||||||
|
|
||||||
local profiler_path = core.get_builtin_path()..DIR_DELIM.."profiler"..DIR_DELIM
|
local profiler_path = core.get_builtin_path()..DIR_DELIM.."profiler"..DIR_DELIM
|
||||||
local profiler = {}
|
local profiler = {}
|
||||||
local sampler = assert(loadfile(profiler_path .. "sampling.lua"))(profiler)
|
local sampler = assert(loadfile(profiler_path .. "sampling.lua"))(profiler)
|
||||||
local instrumentation = assert(loadfile(profiler_path .. "instrumentation.lua"))(profiler, sampler)
|
local instrumentation = assert(loadfile(profiler_path .. "instrumentation.lua"))(profiler, sampler, get_bool_default)
|
||||||
local reporter = dofile(profiler_path .. "reporter.lua")
|
local reporter = dofile(profiler_path .. "reporter.lua")
|
||||||
profiler.instrument = instrumentation.instrument
|
profiler.instrument = instrumentation.instrument
|
||||||
|
|
||||||
|
@ -27,7 +35,7 @@ profiler.instrument = instrumentation.instrument
|
||||||
-- Is called later, after `core.register_chatcommand` was set up.
|
-- Is called later, after `core.register_chatcommand` was set up.
|
||||||
--
|
--
|
||||||
function profiler.init_chatcommand()
|
function profiler.init_chatcommand()
|
||||||
local instrument_profiler = core.setting_getbool("instrument.profiler") or false
|
local instrument_profiler = get_bool_default("instrument.profiler", false)
|
||||||
if instrument_profiler then
|
if instrument_profiler then
|
||||||
instrumentation.init_chatcommand()
|
instrumentation.init_chatcommand()
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,8 +17,9 @@
|
||||||
|
|
||||||
local format, pairs, type = string.format, pairs, type
|
local format, pairs, type = string.format, pairs, type
|
||||||
local core, get_current_modname = core, core.get_current_modname
|
local core, get_current_modname = core, core.get_current_modname
|
||||||
local profiler, sampler = ...
|
local profiler, sampler, get_bool_default = ...
|
||||||
local instrument_builtin = core.setting_getbool("instrument.builtin") or false
|
|
||||||
|
local instrument_builtin = get_bool_default("instrument.builtin", false)
|
||||||
|
|
||||||
local register_functions = {
|
local register_functions = {
|
||||||
register_globalstep = 0,
|
register_globalstep = 0,
|
||||||
|
@ -137,7 +138,7 @@ local function instrument_register(func, func_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function init_chatcommand()
|
local function init_chatcommand()
|
||||||
if core.setting_getbool("instrument.chatcommand") or true then
|
if get_bool_default("instrument.chatcommand", true) then
|
||||||
local orig_register_chatcommand = core.register_chatcommand
|
local orig_register_chatcommand = core.register_chatcommand
|
||||||
core.register_chatcommand = function(cmd, def)
|
core.register_chatcommand = function(cmd, def)
|
||||||
def.func = instrument {
|
def.func = instrument {
|
||||||
|
@ -153,8 +154,7 @@ end
|
||||||
-- Start instrumenting selected functions
|
-- Start instrumenting selected functions
|
||||||
--
|
--
|
||||||
local function init()
|
local function init()
|
||||||
local is_set = core.setting_getbool
|
if get_bool_default("instrument.entity", true) then
|
||||||
if is_set("instrument.entity") or true then
|
|
||||||
-- Explicitly declare entity api-methods.
|
-- Explicitly declare entity api-methods.
|
||||||
-- Simple iteration would ignore lookup via __index.
|
-- Simple iteration would ignore lookup via __index.
|
||||||
local entity_instrumentation = {
|
local entity_instrumentation = {
|
||||||
|
@ -180,7 +180,7 @@ local function init()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_set("instrument.abm") or true then
|
if get_bool_default("instrument.abm", true) then
|
||||||
-- Wrap register_abm() to automatically instrument abms.
|
-- Wrap register_abm() to automatically instrument abms.
|
||||||
local orig_register_abm = core.register_abm
|
local orig_register_abm = core.register_abm
|
||||||
core.register_abm = function(spec)
|
core.register_abm = function(spec)
|
||||||
|
@ -193,7 +193,7 @@ local function init()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_set("instrument.lbm") or true then
|
if get_bool_default("instrument.lbm", true) then
|
||||||
-- Wrap register_lbm() to automatically instrument lbms.
|
-- Wrap register_lbm() to automatically instrument lbms.
|
||||||
local orig_register_lbm = core.register_lbm
|
local orig_register_lbm = core.register_lbm
|
||||||
core.register_lbm = function(spec)
|
core.register_lbm = function(spec)
|
||||||
|
@ -206,13 +206,13 @@ local function init()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_set("instrument.global_callback") or true then
|
if get_bool_default("instrument.global_callback", true) then
|
||||||
for func_name, _ in pairs(register_functions) do
|
for func_name, _ in pairs(register_functions) do
|
||||||
core[func_name] = instrument_register(core[func_name], func_name)
|
core[func_name] = instrument_register(core[func_name], func_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_set("instrument.profiler") or false then
|
if get_bool_default("instrument.profiler", false) then
|
||||||
-- Measure overhead of instrumentation, but keep it down for functions
|
-- Measure overhead of instrumentation, but keep it down for functions
|
||||||
-- So keep the `return` for better optimization.
|
-- So keep the `return` for better optimization.
|
||||||
profiler.empty_instrument = instrument {
|
profiler.empty_instrument = instrument {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
local DIR_DELIM, LINE_DELIM = DIR_DELIM, "\n"
|
local DIR_DELIM, LINE_DELIM = DIR_DELIM, "\n"
|
||||||
local table, unpack, string, pairs, io, os = table, unpack, string, pairs, io, os
|
local table, unpack, string, pairs, io, os = table, unpack, string, pairs, io, os
|
||||||
local rep, sprintf, tonumber = string.rep, string.format, tonumber
|
local rep, sprintf, tonumber = string.rep, string.format, tonumber
|
||||||
local core, setting_get = core, core.setting_get
|
local core, settings = core, core.settings
|
||||||
local reporter = {}
|
local reporter = {}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -229,7 +229,7 @@ end
|
||||||
|
|
||||||
local worldpath = core.get_worldpath()
|
local worldpath = core.get_worldpath()
|
||||||
local function get_save_path(format, filter)
|
local function get_save_path(format, filter)
|
||||||
local report_path = setting_get("profiler.report_path") or ""
|
local report_path = settings:get("profiler.report_path") or ""
|
||||||
if report_path ~= "" then
|
if report_path ~= "" then
|
||||||
core.mkdir(sprintf("%s%s%s", worldpath, DIR_DELIM, report_path))
|
core.mkdir(sprintf("%s%s%s", worldpath, DIR_DELIM, report_path))
|
||||||
end
|
end
|
||||||
|
@ -249,7 +249,7 @@ end
|
||||||
--
|
--
|
||||||
function reporter.save(profile, format, filter)
|
function reporter.save(profile, format, filter)
|
||||||
if not format or format == "" then
|
if not format or format == "" then
|
||||||
format = setting_get("profiler.default_report_format") or "txt"
|
format = settings:get("profiler.default_report_format") or "txt"
|
||||||
end
|
end
|
||||||
if filter == "" then
|
if filter == "" then
|
||||||
filter = nil
|
filter = nil
|
||||||
|
|
|
@ -185,7 +185,7 @@ end
|
||||||
function sampler.init()
|
function sampler.init()
|
||||||
sampler.reset()
|
sampler.reset()
|
||||||
|
|
||||||
if core.setting_getbool("instrument.profiler") then
|
if core.settings:get_bool("instrument.profiler") then
|
||||||
core.register_globalstep(function()
|
core.register_globalstep(function()
|
||||||
if logged_time == 0 then
|
if logged_time == 0 then
|
||||||
return
|
return
|
||||||
|
|
|
@ -172,8 +172,8 @@ The main Lua script. Running this script should register everything it
|
||||||
wants to register. Subsequent execution depends on minetest calling the
|
wants to register. Subsequent execution depends on minetest calling the
|
||||||
registered callbacks.
|
registered callbacks.
|
||||||
|
|
||||||
`minetest.setting_get(name)` and `minetest.setting_getbool(name)` can be used
|
`minetest.settings` can be used to read custom or existing settings at load
|
||||||
to read custom or existing settings at load time, if necessary.
|
time, if necessary. (See `Settings`)
|
||||||
|
|
||||||
### `models`
|
### `models`
|
||||||
Models for entities or meshnodes.
|
Models for entities or meshnodes.
|
||||||
|
@ -2177,16 +2177,10 @@ Call these functions only at load time!
|
||||||
* See `minetest.builtin_auth_handler` in `builtin.lua` for reference
|
* See `minetest.builtin_auth_handler` in `builtin.lua` for reference
|
||||||
|
|
||||||
### Setting-related
|
### Setting-related
|
||||||
* `minetest.setting_set(name, value)`
|
* `minetest.settings`: Settings object containing all of the settings from the
|
||||||
* Setting names can't contain whitespace or any of `="{}#`.
|
main config file (`minetest.conf`).
|
||||||
* Setting values can't contain the sequence `\n"""`.
|
* `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
|
||||||
* Setting names starting with "secure." can't be set.
|
parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
|
||||||
* `minetest.setting_get(name)`: returns string or `nil`
|
|
||||||
* `minetest.setting_setbool(name, value)`
|
|
||||||
* See documentation on `setting_set` for restrictions.
|
|
||||||
* `minetest.setting_getbool(name)`: returns boolean or `nil`
|
|
||||||
* `minetest.setting_get_pos(name)`: returns position or nil
|
|
||||||
* `minetest.setting_save()`, returns `nil`, save all settings to config file
|
|
||||||
|
|
||||||
### Authentication
|
### Authentication
|
||||||
* `minetest.notify_authentication_modified(name)`
|
* `minetest.notify_authentication_modified(name)`
|
||||||
|
@ -3536,10 +3530,15 @@ It can be created via `Settings(filename)`.
|
||||||
* `get(key)`: returns a value
|
* `get(key)`: returns a value
|
||||||
* `get_bool(key)`: returns a boolean
|
* `get_bool(key)`: returns a boolean
|
||||||
* `set(key, value)`
|
* `set(key, value)`
|
||||||
|
* Setting names can't contain whitespace or any of `="{}#`.
|
||||||
|
* Setting values can't contain the sequence `\n"""`.
|
||||||
|
* Setting names starting with "secure." can't be set on the main settings object (`minetest.settings`).
|
||||||
|
* `set_bool(key, value)`
|
||||||
|
* See documentation for set() above.
|
||||||
* `remove(key)`: returns a boolean (`true` for success)
|
* `remove(key)`: returns a boolean (`true` for success)
|
||||||
* `get_names()`: returns `{key1,...}`
|
* `get_names()`: returns `{key1,...}`
|
||||||
* `write()`: returns a boolean (`true` for success)
|
* `write()`: returns a boolean (`true` for success)
|
||||||
* write changes to file
|
* Writes changes to file.
|
||||||
* `to_table()`: returns `{[key1]=value1,...}`
|
* `to_table()`: returns `{[key1]=value1,...}`
|
||||||
|
|
||||||
Mapgen objects
|
Mapgen objects
|
||||||
|
|
|
@ -76,14 +76,9 @@ AsyncEngine::~AsyncEngine()
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
bool AsyncEngine::registerFunction(const char* name, lua_CFunction func)
|
void AsyncEngine::registerStateInitializer(StateInitializer func)
|
||||||
{
|
{
|
||||||
if (initDone) {
|
stateInitializers.push_back(func);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
functionList[name] = func;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -204,11 +199,9 @@ void AsyncEngine::pushFinishedJobs(lua_State* L) {
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
void AsyncEngine::prepareEnvironment(lua_State* L, int top)
|
void AsyncEngine::prepareEnvironment(lua_State* L, int top)
|
||||||
{
|
{
|
||||||
for (UNORDERED_MAP<std::string, lua_CFunction>::iterator it = functionList.begin();
|
for (std::vector<StateInitializer>::iterator it = stateInitializers.begin();
|
||||||
it != functionList.end(); ++it) {
|
it != stateInitializers.end(); it++) {
|
||||||
lua_pushstring(L, it->first.c_str());
|
(*it)(L, top);
|
||||||
lua_pushcfunction(L, it->second);
|
|
||||||
lua_settable(L, top);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,16 +75,16 @@ private:
|
||||||
// Asynchornous thread and job management
|
// Asynchornous thread and job management
|
||||||
class AsyncEngine {
|
class AsyncEngine {
|
||||||
friend class AsyncWorkerThread;
|
friend class AsyncWorkerThread;
|
||||||
|
typedef void (*StateInitializer)(lua_State *L, int top);
|
||||||
public:
|
public:
|
||||||
AsyncEngine();
|
AsyncEngine();
|
||||||
~AsyncEngine();
|
~AsyncEngine();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register function to be used within engine
|
* Register function to be called on new states
|
||||||
* @param name Function name to be used within Lua environment
|
|
||||||
* @param func C function to be called
|
* @param func C function to be called
|
||||||
*/
|
*/
|
||||||
bool registerFunction(const char* name, lua_CFunction func);
|
void registerStateInitializer(StateInitializer func);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create async engine tasks and lock function registration
|
* Create async engine tasks and lock function registration
|
||||||
|
@ -140,8 +140,8 @@ private:
|
||||||
// Variable locking the engine against further modification
|
// Variable locking the engine against further modification
|
||||||
bool initDone;
|
bool initDone;
|
||||||
|
|
||||||
// Internal store for registred functions
|
// Internal store for registred state initializers
|
||||||
UNORDERED_MAP<std::string, lua_CFunction> functionList;
|
std::vector<StateInitializer> stateInitializers;
|
||||||
|
|
||||||
// Internal counter to create job IDs
|
// Internal counter to create job IDs
|
||||||
unsigned int jobIdCounter;
|
unsigned int jobIdCounter;
|
||||||
|
|
|
@ -74,17 +74,13 @@ std::string ModApiBase::getCurrentModPath(lua_State *L)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ModApiBase::registerFunction(
|
bool ModApiBase::registerFunction(lua_State *L, const char *name,
|
||||||
lua_State *L,
|
lua_CFunction func, int top)
|
||||||
const char *name,
|
|
||||||
lua_CFunction fct,
|
|
||||||
int top)
|
|
||||||
{
|
{
|
||||||
//TODO check presence first!
|
// TODO: Check presence first!
|
||||||
|
|
||||||
lua_pushstring(L,name);
|
lua_pushcfunction(L, func);
|
||||||
lua_pushcfunction(L,fct);
|
lua_setfield(L, top, name);
|
||||||
lua_settable(L, top);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,9 +68,8 @@ public:
|
||||||
|
|
||||||
static bool registerFunction(lua_State *L,
|
static bool registerFunction(lua_State *L,
|
||||||
const char* name,
|
const char* name,
|
||||||
lua_CFunction fct,
|
lua_CFunction func,
|
||||||
int top
|
int top);
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* L_BASE_H_ */
|
#endif /* L_BASE_H_ */
|
||||||
|
|
|
@ -32,7 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#define luamethod(class, name) {#name, class::l_##name}
|
#define luamethod(class, name) {#name, class::l_##name}
|
||||||
#define luamethod_aliased(class, name, alias) {#name, class::l_##name}, {#alias, class::l_##name}
|
#define luamethod_aliased(class, name, alias) {#name, class::l_##name}, {#alias, class::l_##name}
|
||||||
#define API_FCT(name) registerFunction(L, #name, l_##name, top)
|
#define API_FCT(name) registerFunction(L, #name, l_##name, top)
|
||||||
#define ASYNC_API_FCT(name) engine.registerFunction(#name, l_##name)
|
|
||||||
|
|
||||||
#define MAP_LOCK_REQUIRED
|
#define MAP_LOCK_REQUIRED
|
||||||
#define NO_MAP_LOCK_REQUIRED
|
#define NO_MAP_LOCK_REQUIRED
|
||||||
|
|
|
@ -38,6 +38,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include <IFileArchive.h>
|
#include <IFileArchive.h>
|
||||||
#include <IFileSystem.h>
|
#include <IFileSystem.h>
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
std::string ModApiMainMenu::getTextData(lua_State *L, std::string name)
|
std::string ModApiMainMenu::getTextData(lua_State *L, std::string name)
|
||||||
{
|
{
|
||||||
|
@ -1141,23 +1142,24 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
void ModApiMainMenu::InitializeAsync(AsyncEngine& engine)
|
void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
|
||||||
{
|
{
|
||||||
|
|
||||||
ASYNC_API_FCT(get_worlds);
|
API_FCT(get_worlds);
|
||||||
ASYNC_API_FCT(get_games);
|
API_FCT(get_games);
|
||||||
ASYNC_API_FCT(get_favorites);
|
API_FCT(get_favorites);
|
||||||
ASYNC_API_FCT(get_mapgen_names);
|
API_FCT(get_mapgen_names);
|
||||||
ASYNC_API_FCT(get_modpath);
|
API_FCT(get_modpath);
|
||||||
ASYNC_API_FCT(get_gamepath);
|
API_FCT(get_gamepath);
|
||||||
ASYNC_API_FCT(get_texturepath);
|
API_FCT(get_texturepath);
|
||||||
ASYNC_API_FCT(get_texturepath_share);
|
API_FCT(get_texturepath_share);
|
||||||
ASYNC_API_FCT(create_dir);
|
API_FCT(create_dir);
|
||||||
ASYNC_API_FCT(delete_dir);
|
API_FCT(delete_dir);
|
||||||
ASYNC_API_FCT(copy_dir);
|
API_FCT(copy_dir);
|
||||||
//ASYNC_API_FCT(extract_zip); //TODO remove dependency to GuiEngine
|
//API_FCT(extract_zip); //TODO remove dependency to GuiEngine
|
||||||
ASYNC_API_FCT(download_file);
|
API_FCT(download_file);
|
||||||
ASYNC_API_FCT(get_modstore_details);
|
API_FCT(get_modstore_details);
|
||||||
ASYNC_API_FCT(get_modstore_list);
|
API_FCT(get_modstore_list);
|
||||||
//ASYNC_API_FCT(gettext); (gettext lib isn't threadsafe)
|
//API_FCT(gettext); (gettext lib isn't threadsafe)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,7 @@ private:
|
||||||
static int l_do_async_callback(lua_State *L);
|
static int l_do_async_callback(lua_State *L);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initialize this API module
|
* initialize this API module
|
||||||
* @param L lua stack to initialize
|
* @param L lua stack to initialize
|
||||||
|
@ -149,7 +150,7 @@ public:
|
||||||
*/
|
*/
|
||||||
static void Initialize(lua_State *L, int top);
|
static void Initialize(lua_State *L, int top);
|
||||||
|
|
||||||
static void InitializeAsync(AsyncEngine& engine);
|
static void InitializeAsync(lua_State *L, int top);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,47 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define SET_SECURITY_CHECK(L, name) \
|
||||||
|
if (o->m_settings == g_settings && ScriptApiSecurity::isSecure(L) && \
|
||||||
|
name.compare(0, 7, "secure.") == 0) { \
|
||||||
|
throw LuaError("Attempt to set secure setting."); \
|
||||||
|
}
|
||||||
|
|
||||||
|
LuaSettings::LuaSettings(Settings *settings, const std::string &filename) :
|
||||||
|
m_settings(settings),
|
||||||
|
m_filename(filename),
|
||||||
|
m_is_own_settings(false),
|
||||||
|
m_write_allowed(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LuaSettings::LuaSettings(const std::string &filename, bool write_allowed) :
|
||||||
|
m_filename(filename),
|
||||||
|
m_is_own_settings(true),
|
||||||
|
m_write_allowed(write_allowed)
|
||||||
|
{
|
||||||
|
m_settings = new Settings();
|
||||||
|
m_settings->readConfigFile(filename.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
LuaSettings::~LuaSettings()
|
||||||
|
{
|
||||||
|
if (m_is_own_settings)
|
||||||
|
delete m_settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LuaSettings::create(lua_State *L, Settings *settings,
|
||||||
|
const std::string &filename)
|
||||||
|
{
|
||||||
|
LuaSettings *o = new LuaSettings(settings, filename);
|
||||||
|
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
|
||||||
|
luaL_getmetatable(L, className);
|
||||||
|
lua_setmetatable(L, -2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// garbage collector
|
// garbage collector
|
||||||
int LuaSettings::gc_object(lua_State* L)
|
int LuaSettings::gc_object(lua_State* L)
|
||||||
{
|
{
|
||||||
|
@ -31,6 +72,7 @@ int LuaSettings::gc_object(lua_State* L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// get(self, key) -> value
|
// get(self, key) -> value
|
||||||
int LuaSettings::l_get(lua_State* L)
|
int LuaSettings::l_get(lua_State* L)
|
||||||
{
|
{
|
||||||
|
@ -74,12 +116,30 @@ int LuaSettings::l_set(lua_State* L)
|
||||||
std::string key = std::string(luaL_checkstring(L, 2));
|
std::string key = std::string(luaL_checkstring(L, 2));
|
||||||
const char* value = luaL_checkstring(L, 3);
|
const char* value = luaL_checkstring(L, 3);
|
||||||
|
|
||||||
|
SET_SECURITY_CHECK(L, key);
|
||||||
|
|
||||||
if (!o->m_settings->set(key, value))
|
if (!o->m_settings->set(key, value))
|
||||||
throw LuaError("Invalid sequence found in setting parameters");
|
throw LuaError("Invalid sequence found in setting parameters");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set_bool(self, key, value)
|
||||||
|
int LuaSettings::l_set_bool(lua_State* L)
|
||||||
|
{
|
||||||
|
NO_MAP_LOCK_REQUIRED;
|
||||||
|
LuaSettings* o = checkobject(L, 1);
|
||||||
|
|
||||||
|
std::string key = std::string(luaL_checkstring(L, 2));
|
||||||
|
bool value = lua_toboolean(L, 3);
|
||||||
|
|
||||||
|
SET_SECURITY_CHECK(L, key);
|
||||||
|
|
||||||
|
o->m_settings->setBool(key, value);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// remove(self, key) -> success
|
// remove(self, key) -> success
|
||||||
int LuaSettings::l_remove(lua_State* L)
|
int LuaSettings::l_remove(lua_State* L)
|
||||||
{
|
{
|
||||||
|
@ -88,6 +148,8 @@ int LuaSettings::l_remove(lua_State* L)
|
||||||
|
|
||||||
std::string key = std::string(luaL_checkstring(L, 2));
|
std::string key = std::string(luaL_checkstring(L, 2));
|
||||||
|
|
||||||
|
SET_SECURITY_CHECK(L, key);
|
||||||
|
|
||||||
bool success = o->m_settings->remove(key);
|
bool success = o->m_settings->remove(key);
|
||||||
lua_pushboolean(L, success);
|
lua_pushboolean(L, success);
|
||||||
|
|
||||||
|
@ -147,19 +209,6 @@ int LuaSettings::l_to_table(lua_State* L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaSettings::LuaSettings(const char* filename, bool write_allowed)
|
|
||||||
{
|
|
||||||
m_write_allowed = write_allowed;
|
|
||||||
m_filename = std::string(filename);
|
|
||||||
|
|
||||||
m_settings = new Settings();
|
|
||||||
m_settings->readConfigFile(m_filename.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
LuaSettings::~LuaSettings()
|
|
||||||
{
|
|
||||||
delete m_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LuaSettings::Register(lua_State* L)
|
void LuaSettings::Register(lua_State* L)
|
||||||
{
|
{
|
||||||
|
@ -190,7 +239,7 @@ void LuaSettings::Register(lua_State* L)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LuaSettings(filename)
|
// LuaSettings(filename)
|
||||||
// Creates an LuaSettings and leaves it on top of stack
|
// Creates a LuaSettings and leaves it on top of the stack
|
||||||
int LuaSettings::create_object(lua_State* L)
|
int LuaSettings::create_object(lua_State* L)
|
||||||
{
|
{
|
||||||
NO_MAP_LOCK_REQUIRED;
|
NO_MAP_LOCK_REQUIRED;
|
||||||
|
@ -209,7 +258,8 @@ LuaSettings* LuaSettings::checkobject(lua_State* L, int narg)
|
||||||
NO_MAP_LOCK_REQUIRED;
|
NO_MAP_LOCK_REQUIRED;
|
||||||
luaL_checktype(L, narg, LUA_TUSERDATA);
|
luaL_checktype(L, narg, LUA_TUSERDATA);
|
||||||
void *ud = luaL_checkudata(L, narg, className);
|
void *ud = luaL_checkudata(L, narg, className);
|
||||||
if(!ud) luaL_typerror(L, narg, className);
|
if (!ud)
|
||||||
|
luaL_typerror(L, narg, className);
|
||||||
return *(LuaSettings**) ud; // unbox pointer
|
return *(LuaSettings**) ud; // unbox pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,6 +268,7 @@ const luaL_Reg LuaSettings::methods[] = {
|
||||||
luamethod(LuaSettings, get),
|
luamethod(LuaSettings, get),
|
||||||
luamethod(LuaSettings, get_bool),
|
luamethod(LuaSettings, get_bool),
|
||||||
luamethod(LuaSettings, set),
|
luamethod(LuaSettings, set),
|
||||||
|
luamethod(LuaSettings, set_bool),
|
||||||
luamethod(LuaSettings, remove),
|
luamethod(LuaSettings, remove),
|
||||||
luamethod(LuaSettings, get_names),
|
luamethod(LuaSettings, get_names),
|
||||||
luamethod(LuaSettings, write),
|
luamethod(LuaSettings, write),
|
||||||
|
|
|
@ -42,6 +42,9 @@ private:
|
||||||
// set(self, key, value)
|
// set(self, key, value)
|
||||||
static int l_set(lua_State *L);
|
static int l_set(lua_State *L);
|
||||||
|
|
||||||
|
// set_bool(self, key, value)
|
||||||
|
static int l_set_bool(lua_State* L);
|
||||||
|
|
||||||
// remove(self, key) -> success
|
// remove(self, key) -> success
|
||||||
static int l_remove(lua_State *L);
|
static int l_remove(lua_State *L);
|
||||||
|
|
||||||
|
@ -54,16 +57,20 @@ private:
|
||||||
// to_table(self) -> {[key1]=value1,...}
|
// to_table(self) -> {[key1]=value1,...}
|
||||||
static int l_to_table(lua_State *L);
|
static int l_to_table(lua_State *L);
|
||||||
|
|
||||||
bool m_write_allowed;
|
|
||||||
Settings *m_settings;
|
Settings *m_settings;
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
|
bool m_is_own_settings;
|
||||||
|
bool m_write_allowed;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LuaSettings(const char *filename, bool write_allowed);
|
LuaSettings(Settings *settings, const std::string &filename);
|
||||||
|
LuaSettings(const std::string &filename, bool write_allowed);
|
||||||
~LuaSettings();
|
~LuaSettings();
|
||||||
|
|
||||||
|
static void create(lua_State *L, Settings *settings, const std::string &filename);
|
||||||
|
|
||||||
// LuaSettings(filename)
|
// LuaSettings(filename)
|
||||||
// Creates an LuaSettings and leaves it on top of stack
|
// Creates a LuaSettings and leaves it on top of the stack
|
||||||
static int create_object(lua_State *L);
|
static int create_object(lua_State *L);
|
||||||
|
|
||||||
static LuaSettings *checkobject(lua_State *L, int narg);
|
static LuaSettings *checkobject(lua_State *L, int narg);
|
||||||
|
|
|
@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
#include "lua_api/l_util.h"
|
#include "lua_api/l_util.h"
|
||||||
#include "lua_api/l_internal.h"
|
#include "lua_api/l_internal.h"
|
||||||
|
#include "lua_api/l_settings.h"
|
||||||
#include "common/c_converter.h"
|
#include "common/c_converter.h"
|
||||||
#include "common/c_content.h"
|
#include "common/c_content.h"
|
||||||
#include "cpp_api/s_async.h"
|
#include "cpp_api/s_async.h"
|
||||||
|
@ -77,71 +78,6 @@ int ModApiUtil::l_get_us_time(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_SECURE_SETTING(L, name) \
|
|
||||||
if (ScriptApiSecurity::isSecure(L) && \
|
|
||||||
name.compare(0, 7, "secure.") == 0) { \
|
|
||||||
throw LuaError("Attempt to set secure setting."); \
|
|
||||||
}
|
|
||||||
|
|
||||||
// setting_set(name, value)
|
|
||||||
int ModApiUtil::l_setting_set(lua_State *L)
|
|
||||||
{
|
|
||||||
NO_MAP_LOCK_REQUIRED;
|
|
||||||
std::string name = luaL_checkstring(L, 1);
|
|
||||||
std::string value = luaL_checkstring(L, 2);
|
|
||||||
CHECK_SECURE_SETTING(L, name);
|
|
||||||
g_settings->set(name, value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// setting_get(name)
|
|
||||||
int ModApiUtil::l_setting_get(lua_State *L)
|
|
||||||
{
|
|
||||||
NO_MAP_LOCK_REQUIRED;
|
|
||||||
const char *name = luaL_checkstring(L, 1);
|
|
||||||
try{
|
|
||||||
std::string value = g_settings->get(name);
|
|
||||||
lua_pushstring(L, value.c_str());
|
|
||||||
} catch(SettingNotFoundException &e){
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// setting_setbool(name)
|
|
||||||
int ModApiUtil::l_setting_setbool(lua_State *L)
|
|
||||||
{
|
|
||||||
NO_MAP_LOCK_REQUIRED;
|
|
||||||
std::string name = luaL_checkstring(L, 1);
|
|
||||||
bool value = lua_toboolean(L, 2);
|
|
||||||
CHECK_SECURE_SETTING(L, name);
|
|
||||||
g_settings->setBool(name, value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// setting_getbool(name)
|
|
||||||
int ModApiUtil::l_setting_getbool(lua_State *L)
|
|
||||||
{
|
|
||||||
NO_MAP_LOCK_REQUIRED;
|
|
||||||
const char *name = luaL_checkstring(L, 1);
|
|
||||||
try{
|
|
||||||
bool value = g_settings->getBool(name);
|
|
||||||
lua_pushboolean(L, value);
|
|
||||||
} catch(SettingNotFoundException &e){
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// setting_save()
|
|
||||||
int ModApiUtil::l_setting_save(lua_State *L)
|
|
||||||
{
|
|
||||||
NO_MAP_LOCK_REQUIRED;
|
|
||||||
if(g_settings_path != "")
|
|
||||||
g_settings->updateConfigFile(g_settings_path.c_str());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse_json(str[, nullvalue])
|
// parse_json(str[, nullvalue])
|
||||||
int ModApiUtil::l_parse_json(lua_State *L)
|
int ModApiUtil::l_parse_json(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -493,12 +429,6 @@ void ModApiUtil::Initialize(lua_State *L, int top)
|
||||||
|
|
||||||
API_FCT(get_us_time);
|
API_FCT(get_us_time);
|
||||||
|
|
||||||
API_FCT(setting_set);
|
|
||||||
API_FCT(setting_get);
|
|
||||||
API_FCT(setting_setbool);
|
|
||||||
API_FCT(setting_getbool);
|
|
||||||
API_FCT(setting_save);
|
|
||||||
|
|
||||||
API_FCT(parse_json);
|
API_FCT(parse_json);
|
||||||
API_FCT(write_json);
|
API_FCT(write_json);
|
||||||
|
|
||||||
|
@ -524,6 +454,9 @@ void ModApiUtil::Initialize(lua_State *L, int top)
|
||||||
API_FCT(decode_base64);
|
API_FCT(decode_base64);
|
||||||
|
|
||||||
API_FCT(get_version);
|
API_FCT(get_version);
|
||||||
|
|
||||||
|
LuaSettings::create(L, g_settings, g_settings_path);
|
||||||
|
lua_setfield(L, top, "settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModApiUtil::InitializeClient(lua_State *L, int top)
|
void ModApiUtil::InitializeClient(lua_State *L, int top)
|
||||||
|
@ -548,34 +481,31 @@ void ModApiUtil::InitializeClient(lua_State *L, int top)
|
||||||
API_FCT(get_version);
|
API_FCT(get_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModApiUtil::InitializeAsync(AsyncEngine& engine)
|
void ModApiUtil::InitializeAsync(lua_State *L, int top)
|
||||||
{
|
{
|
||||||
ASYNC_API_FCT(log);
|
API_FCT(log);
|
||||||
|
|
||||||
ASYNC_API_FCT(get_us_time);
|
API_FCT(get_us_time);
|
||||||
|
|
||||||
//ASYNC_API_FCT(setting_set);
|
API_FCT(parse_json);
|
||||||
ASYNC_API_FCT(setting_get);
|
API_FCT(write_json);
|
||||||
//ASYNC_API_FCT(setting_setbool);
|
|
||||||
ASYNC_API_FCT(setting_getbool);
|
|
||||||
//ASYNC_API_FCT(setting_save);
|
|
||||||
|
|
||||||
ASYNC_API_FCT(parse_json);
|
API_FCT(is_yes);
|
||||||
ASYNC_API_FCT(write_json);
|
|
||||||
|
|
||||||
ASYNC_API_FCT(is_yes);
|
API_FCT(get_builtin_path);
|
||||||
|
|
||||||
ASYNC_API_FCT(get_builtin_path);
|
API_FCT(compress);
|
||||||
|
API_FCT(decompress);
|
||||||
|
|
||||||
ASYNC_API_FCT(compress);
|
API_FCT(mkdir);
|
||||||
ASYNC_API_FCT(decompress);
|
API_FCT(get_dir_list);
|
||||||
|
|
||||||
ASYNC_API_FCT(mkdir);
|
API_FCT(encode_base64);
|
||||||
ASYNC_API_FCT(get_dir_list);
|
API_FCT(decode_base64);
|
||||||
|
|
||||||
ASYNC_API_FCT(encode_base64);
|
API_FCT(get_version);
|
||||||
ASYNC_API_FCT(decode_base64);
|
|
||||||
|
|
||||||
ASYNC_API_FCT(get_version);
|
LuaSettings::create(L, g_settings, g_settings_path);
|
||||||
|
lua_setfield(L, top, "settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,21 +45,6 @@ private:
|
||||||
// get us precision time
|
// get us precision time
|
||||||
static int l_get_us_time(lua_State *L);
|
static int l_get_us_time(lua_State *L);
|
||||||
|
|
||||||
// setting_set(name, value)
|
|
||||||
static int l_setting_set(lua_State *L);
|
|
||||||
|
|
||||||
// setting_get(name)
|
|
||||||
static int l_setting_get(lua_State *L);
|
|
||||||
|
|
||||||
// setting_setbool(name, value)
|
|
||||||
static int l_setting_setbool(lua_State *L);
|
|
||||||
|
|
||||||
// setting_getbool(name)
|
|
||||||
static int l_setting_getbool(lua_State *L);
|
|
||||||
|
|
||||||
// setting_save()
|
|
||||||
static int l_setting_save(lua_State *L);
|
|
||||||
|
|
||||||
// parse_json(str[, nullvalue])
|
// parse_json(str[, nullvalue])
|
||||||
static int l_parse_json(lua_State *L);
|
static int l_parse_json(lua_State *L);
|
||||||
|
|
||||||
|
@ -109,8 +94,9 @@ private:
|
||||||
static int l_get_version(lua_State *L);
|
static int l_get_version(lua_State *L);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Initialize(lua_State *L, int top);
|
|
||||||
|
|
||||||
|
static void Initialize(lua_State *L, int top);
|
||||||
|
static void InitializeAsync(lua_State *L, int top);
|
||||||
static void InitializeClient(lua_State *L, int top);
|
static void InitializeClient(lua_State *L, int top);
|
||||||
|
|
||||||
static void InitializeAsync(AsyncEngine &engine);
|
static void InitializeAsync(AsyncEngine &engine);
|
||||||
|
|
|
@ -62,17 +62,17 @@ ClientScripting::ClientScripting(Client *client):
|
||||||
|
|
||||||
void ClientScripting::InitializeModApi(lua_State *L, int top)
|
void ClientScripting::InitializeModApi(lua_State *L, int top)
|
||||||
{
|
{
|
||||||
ModApiUtil::InitializeClient(L, top);
|
|
||||||
ModApiClient::Initialize(L, top);
|
|
||||||
ModApiStorage::Initialize(L, top);
|
|
||||||
ModApiEnvMod::InitializeClient(L, top);
|
|
||||||
|
|
||||||
LuaItemStack::Register(L);
|
LuaItemStack::Register(L);
|
||||||
StorageRef::Register(L);
|
StorageRef::Register(L);
|
||||||
LuaMinimap::Register(L);
|
LuaMinimap::Register(L);
|
||||||
NodeMetaRef::RegisterClient(L);
|
NodeMetaRef::RegisterClient(L);
|
||||||
LuaLocalPlayer::Register(L);
|
LuaLocalPlayer::Register(L);
|
||||||
LuaCamera::Register(L);
|
LuaCamera::Register(L);
|
||||||
|
|
||||||
|
ModApiUtil::InitializeClient(L, top);
|
||||||
|
ModApiClient::Initialize(L, top);
|
||||||
|
ModApiStorage::Initialize(L, top);
|
||||||
|
ModApiEnvMod::InitializeClient(L, top);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientScripting::on_client_ready(LocalPlayer *localplayer)
|
void ClientScripting::on_client_ready(LocalPlayer *localplayer)
|
||||||
|
|
|
@ -59,23 +59,28 @@ MainMenuScripting::MainMenuScripting(GUIEngine* guiengine)
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
void MainMenuScripting::initializeModApi(lua_State *L, int top)
|
void MainMenuScripting::initializeModApi(lua_State *L, int top)
|
||||||
{
|
{
|
||||||
|
registerLuaClasses(L, top);
|
||||||
|
|
||||||
// Initialize mod API modules
|
// Initialize mod API modules
|
||||||
ModApiMainMenu::Initialize(L, top);
|
ModApiMainMenu::Initialize(L, top);
|
||||||
ModApiUtil::Initialize(L, top);
|
ModApiUtil::Initialize(L, top);
|
||||||
ModApiSound::Initialize(L, top);
|
ModApiSound::Initialize(L, top);
|
||||||
|
|
||||||
// Register reference classes (userdata)
|
asyncEngine.registerStateInitializer(registerLuaClasses);
|
||||||
LuaSettings::Register(L);
|
asyncEngine.registerStateInitializer(ModApiMainMenu::InitializeAsync);
|
||||||
|
asyncEngine.registerStateInitializer(ModApiUtil::InitializeAsync);
|
||||||
// Register functions to async environment
|
|
||||||
ModApiMainMenu::InitializeAsync(asyncEngine);
|
|
||||||
ModApiUtil::InitializeAsync(asyncEngine);
|
|
||||||
|
|
||||||
// Initialize async environment
|
// Initialize async environment
|
||||||
//TODO possibly make number of async threads configurable
|
//TODO possibly make number of async threads configurable
|
||||||
asyncEngine.initialize(MAINMENU_NUM_ASYNC_THREADS);
|
asyncEngine.initialize(MAINMENU_NUM_ASYNC_THREADS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
void MainMenuScripting::registerLuaClasses(lua_State *L, int top)
|
||||||
|
{
|
||||||
|
LuaSettings::Register(L);
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
void MainMenuScripting::step()
|
void MainMenuScripting::step()
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
const std::string &serialized_params);
|
const std::string &serialized_params);
|
||||||
private:
|
private:
|
||||||
void initializeModApi(lua_State *L, int top);
|
void initializeModApi(lua_State *L, int top);
|
||||||
|
static void registerLuaClasses(lua_State *L, int top);
|
||||||
|
|
||||||
AsyncEngine asyncEngine;
|
AsyncEngine asyncEngine;
|
||||||
DISABLE_CLASS_COPY(MainMenuScripting);
|
DISABLE_CLASS_COPY(MainMenuScripting);
|
||||||
|
|
|
@ -82,19 +82,6 @@ ServerScripting::ServerScripting(Server* server)
|
||||||
|
|
||||||
void ServerScripting::InitializeModApi(lua_State *L, int top)
|
void ServerScripting::InitializeModApi(lua_State *L, int top)
|
||||||
{
|
{
|
||||||
// Initialize mod api modules
|
|
||||||
ModApiCraft::Initialize(L, top);
|
|
||||||
ModApiEnvMod::Initialize(L, top);
|
|
||||||
ModApiInventory::Initialize(L, top);
|
|
||||||
ModApiItemMod::Initialize(L, top);
|
|
||||||
ModApiMapgen::Initialize(L, top);
|
|
||||||
ModApiParticles::Initialize(L, top);
|
|
||||||
ModApiRollback::Initialize(L, top);
|
|
||||||
ModApiServer::Initialize(L, top);
|
|
||||||
ModApiUtil::Initialize(L, top);
|
|
||||||
ModApiHttp::Initialize(L, top);
|
|
||||||
ModApiStorage::Initialize(L, top);
|
|
||||||
|
|
||||||
// Register reference classes (userdata)
|
// Register reference classes (userdata)
|
||||||
InvRef::Register(L);
|
InvRef::Register(L);
|
||||||
ItemStackMetaRef::Register(L);
|
ItemStackMetaRef::Register(L);
|
||||||
|
@ -111,6 +98,19 @@ void ServerScripting::InitializeModApi(lua_State *L, int top)
|
||||||
ObjectRef::Register(L);
|
ObjectRef::Register(L);
|
||||||
LuaSettings::Register(L);
|
LuaSettings::Register(L);
|
||||||
StorageRef::Register(L);
|
StorageRef::Register(L);
|
||||||
|
|
||||||
|
// Initialize mod api modules
|
||||||
|
ModApiCraft::Initialize(L, top);
|
||||||
|
ModApiEnvMod::Initialize(L, top);
|
||||||
|
ModApiInventory::Initialize(L, top);
|
||||||
|
ModApiItemMod::Initialize(L, top);
|
||||||
|
ModApiMapgen::Initialize(L, top);
|
||||||
|
ModApiParticles::Initialize(L, top);
|
||||||
|
ModApiRollback::Initialize(L, top);
|
||||||
|
ModApiServer::Initialize(L, top);
|
||||||
|
ModApiUtil::Initialize(L, top);
|
||||||
|
ModApiHttp::Initialize(L, top);
|
||||||
|
ModApiStorage::Initialize(L, top);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_deprecated(const std::string &message)
|
void log_deprecated(const std::string &message)
|
||||||
|
|
Loading…
Reference in New Issue