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.
master
ShadowNinja 2014-12-12 14:49:19 -05:00
parent a024042bf5
commit 43d1f375d1
46 changed files with 411 additions and 417 deletions

View File

@ -463,7 +463,7 @@ if INIT == "game" then
core.rotate_node = function(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})
return itemstack
end
@ -642,8 +642,8 @@ end
local ESCAPE_CHAR = string.char(0x1b)
-- Client-sided mods don't have access to getbool
if core.setting_getbool and core.setting_getbool("disable_escape_sequences") then
-- Client-side mods don't have access to settings
if core.settings and core.settings:get_bool("disable_escape_sequences") then
function core.get_color_escape_sequence(color)
return ""

View File

@ -167,7 +167,7 @@ local function switch_to_tab(self, index)
self.current_tab = self.tablist[index].name
if (self.autosave_tab) then
core.setting_set(self.name .. "_LAST",self.current_tab)
core.settings:set(self.name .. "_LAST",self.current_tab)
end
-- call for tab to enter

View File

@ -106,7 +106,7 @@ core.builtin_auth_handler = {
end
end
-- 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
privileges[priv] = true
end
@ -125,7 +125,7 @@ core.builtin_auth_handler = {
core.log('info', "Built-in authentication handler adding player '"..name.."'")
core.auth_table[name] = {
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(),
}
save_auth_file()
@ -148,7 +148,7 @@ core.builtin_auth_handler = {
if not core.auth_table[name] then
core.builtin_auth_handler.create_auth(name,
core.get_password_hash(name,
core.setting_get("default_password")))
core.settings:get("default_password")))
end
core.auth_table[name].privileges = privileges
core.notify_authentication_modified(name)

View File

@ -39,7 +39,7 @@ core.register_on_chat_message(function(name, message)
return true -- Handled chat message
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
-- Before any chattcommands that should be profiled
profiler.init_chatcommand()
@ -82,7 +82,7 @@ core.register_chatcommand("me", {
core.register_chatcommand("admin", {
description = "Show the name of the server owner",
func = function(name)
local admin = minetest.setting_get("name")
local admin = minetest.settings:get("name")
if admin then
return true, "The administrator of this server is "..admin.."."
else
@ -119,7 +119,7 @@ local function handle_grant_command(caller, grantname, grantprivstr)
local privs = core.get_player_privs(grantname)
local privs_unknown = ""
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
if not basic_privs[priv] and not caller_privs.privs then
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 privs = core.get_player_privs(revoke_name)
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
if not basic_privs[priv] and
not core.check_player_privs(name, {privs=true}) then
@ -419,20 +419,20 @@ core.register_chatcommand("set", {
func = function(name, param)
local arg, setname, setvalue = string.match(param, "(-[n]) ([^ ]+) (.+)")
if arg and arg == "-n" and setname and setvalue then
core.setting_set(setname, setvalue)
core.settings:set(setname, setvalue)
return true, setname .. " = " .. setvalue
end
local setname, setvalue = string.match(param, "([^ ]+) (.+)")
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."
end
core.setting_set(setname, setvalue)
core.settings:set(setname, setvalue)
return true, setname .. " = " .. setvalue
end
local setname = string.match(param, "([^ ]+)")
if setname then
local setvalue = core.setting_get(setname)
local setvalue = core.settings:get(setname)
if not setvalue then
setvalue = "<not set>"
end
@ -667,7 +667,7 @@ core.register_chatcommand("rollback_check", {
.. " seconds = 86400 = 24h, limit = 5",
privs = {rollback=true},
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."
end
local range, seconds, limit =
@ -718,7 +718,7 @@ core.register_chatcommand("rollback", {
description = "Revert actions of a player. Default for <seconds> is 60",
privs = {rollback=true},
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."
end
local target_name, seconds = string.match(param, ":([^ ]+) *(%d*)")

View File

@ -49,3 +49,24 @@ setmetatable(core.env, {
function core.rollback_get_last_node_actor(pos, range, seconds)
return core.rollback_get_node_actions(pos, range, seconds, 1)[1]
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")

View File

@ -40,7 +40,7 @@ function core.forceload_block(pos, transient)
elseif other_table[hash] ~= nil then
relevant_table[hash] = 1
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
end
total_forceloaded = total_forceloaded+1

View File

@ -13,7 +13,7 @@ dofile(gamepath.."constants.lua")
assert(loadfile(gamepath.."item.lua"))(builtin_shared)
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")
end

View File

@ -483,7 +483,7 @@ function core.node_dig(pos, node, digger)
wielded = wdef.after_use(wielded, digger, node, dp) or wielded
else
-- 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)
if wielded:get_count() == 0 and wdef.sound and wdef.sound.breaks then
core.sound_play(wdef.sound.breaks, {pos = pos, gain = 0.5})

View File

@ -14,7 +14,7 @@ end
-- If item_entity_ttl is not set, enity will have default life time
-- 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
time_to_live = 900
end

View File

@ -121,7 +121,7 @@ function core.get_node_group(name, group)
end
function core.setting_get_pos(name)
local value = core.setting_get(name)
local value = core.settings:get(name)
if not value then
return nil
end

View File

@ -1,5 +1,5 @@
-- cache setting
local enable_damage = core.setting_getbool("enable_damage") == true
local enable_damage = core.settings:get_bool("enable_damage")
local health_bar_definition =
{

View File

@ -1,10 +1,10 @@
-- Minetest: builtin/static_spawn.lua
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
core.log("error", "The static_spawnpoint setting is invalid: \""..
core.setting_get("static_spawnpoint").."\"")
core.settings:get("static_spawnpoint").."\"")
end
end

View File

@ -38,7 +38,7 @@ dofile(commonpath .. "misc_helpers.lua")
if INIT == "game" then
dofile(gamepath .. "init.lua")
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
dofile(mm_script)
else

View File

@ -43,10 +43,10 @@ end
local function configure_selected_world_params(idx)
local worldconfig = modmgr.get_worldconfig(menudata.worldlist:get_list()[idx].path)
if worldconfig.creative_mode then
core.setting_set("creative_mode", worldconfig.creative_mode)
core.settings:set("creative_mode", worldconfig.creative_mode)
end
if worldconfig.enable_damage then
core.setting_set("enable_damage", worldconfig.enable_damage)
core.settings:set("enable_damage", worldconfig.enable_damage)
end
end
@ -164,8 +164,8 @@ end
--------------------------------------------------------------------------------
os.tempfolder = function()
if core.setting_get("TMPFolder") then
return core.setting_get("TMPFolder") .. DIR_DELIM .. "MT_" .. math.random(0,10000)
if core.settings:get("TMPFolder") then
return core.settings:get("TMPFolder") .. DIR_DELIM .. "MT_" .. math.random(0,10000)
end
local filetocheck = os.tmpname()
@ -206,7 +206,7 @@ function menu_handle_key_up_down(fields, textlist, settingname)
oldidx < menudata.worldlist:size() then
newidx = oldidx + 1
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)
return true
end
@ -328,9 +328,9 @@ function menu_worldmt_legacy(selected)
for _, mode_name in pairs(modes_names) do
local mode_val = menu_worldmt(selected, mode_name)
if mode_val then
core.setting_set(mode_name, mode_val)
core.settings:set(mode_name, mode_val)
else
menu_worldmt(selected, mode_name, core.setting_get(mode_name))
menu_worldmt(selected, mode_name, core.settings:get(mode_name))
end
end
end

View File

@ -123,7 +123,7 @@ local function handle_buttons(this, fields)
if fields["world_config_modlist"] ~= nil then
local event = core.explode_table_event(fields["world_config_modlist"])
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
enable_mod(this)
@ -227,7 +227,7 @@ function create_configure_world_dlg(worldidx)
handle_buttons,
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
dlg.data.selected_mod = 0
end

View File

@ -18,8 +18,8 @@
local function create_world_formspec(dialogdata)
local mapgens = core.get_mapgen_names()
local current_seed = core.setting_get("fixed_map_seed") or ""
local current_mg = core.setting_get("mg_name")
local current_seed = core.settings:get("fixed_map_seed") or ""
local current_mg = core.settings:get("mg_name")
local mglist = ""
local selindex = 1
@ -33,7 +33,7 @@ local function create_world_formspec(dialogdata)
end
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
if gameid ~= nil then
@ -90,10 +90,10 @@ local function create_world_buttonhandler(this, fields)
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
core.setting_set("mg_name",fields["dd_mapgen"])
core.settings:set("mg_name",fields["dd_mapgen"])
message = core.create_world(worldname,gameindex)
else
message = fgettext("A world named \"$1\" already exists", worldname)
@ -102,13 +102,13 @@ local function create_world_buttonhandler(this, fields)
if message ~= nil then
gamedata.errormessage = message
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
menudata.worldlist:set_filtercriteria(gamemgr.games[gameindex].id)
mm_texture.update("singleplayer", gamemgr.games[gameindex].id)
end
menudata.worldlist:refresh()
core.setting_set("mainmenu_last_selected_world",
core.settings:set("mainmenu_last_selected_world",
menudata.worldlist:raw_index_by_uid(worldname))
end
else

View File

@ -423,7 +423,7 @@ local settings = full_settings
local selected_setting = 1
local function get_current_value(setting)
local value = core.setting_get(setting.name)
local value = core.settings:get(setting.name)
if value == nil then
value = setting.default
end
@ -539,11 +539,11 @@ local function handle_change_setting_buttons(this, fields)
if setting.type == "bool" then
local new_value = fields["dd_setting_value"]
-- 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
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
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())
return true
end
core.setting_set(setting.name, new_value)
core.settings:set(setting.name, new_value)
elseif setting.type == "float" then
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())
return true
end
core.setting_set(setting.name, new_value)
core.settings:set(setting.name, new_value)
elseif setting.type == "flags" then
local new_value = fields["te_setting_value"]
@ -589,13 +589,13 @@ local function handle_change_setting_buttons(this, fields)
return true
end
end
core.setting_set(setting.name, new_value)
core.settings:set(setting.name, new_value)
else
local new_value = fields["te_setting_value"]
core.setting_set(setting.name, new_value)
core.settings:set(setting.name, new_value)
end
core.setting_save()
core.settings:write()
this:delete()
return true
end
@ -629,7 +629,7 @@ local function create_settings_formspec(tabview, name, tabdata)
local current_level = 0
for _, entry in ipairs(settings) do
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)
else
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[7,6;3,1;btn_restore;" .. fgettext("Restore Default") .. "]" ..
"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
end
@ -680,8 +680,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
local setting = settings[selected_setting]
if setting and setting.type == "bool" then
local current_value = get_current_value(setting)
core.setting_setbool(setting.name, not core.is_yes(current_value))
core.setting_save()
core.settings:set_bool(setting.name, not core.is_yes(current_value))
core.settings:write()
return true
else
list_enter = true
@ -736,8 +736,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
if fields["btn_restore"] then
local setting = settings[selected_setting]
if setting and setting.type ~= "category" then
core.setting_set(setting.name, setting.default)
core.setting_save()
core.settings:set(setting.name, setting.default)
core.settings:write()
core.update_formspec(this:get_formspec())
end
return true
@ -749,8 +749,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
end
if fields["cb_tech_settings"] then
core.setting_set("main_menu_technical_settings", fields["cb_tech_settings"])
core.setting_save()
core.settings:set("main_menu_technical_settings", fields["cb_tech_settings"])
core.settings:write()
core.update_formspec(this:get_formspec())
return true
end

View File

@ -119,9 +119,9 @@ local function init_globals()
menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
menudata.worldlist:set_sortmode("alphabetic")
if not core.setting_get("menu_last_game") then
local default_game = core.setting_get("default_game") or "minetest"
core.setting_set("menu_last_game", default_game)
if not core.settings:get("menu_last_game") then
local default_game = core.settings:get("default_game") or "minetest"
core.settings:set("menu_last_game", default_game)
end
mm_texture.init()
@ -149,7 +149,7 @@ local function init_globals()
tv_main:set_fixed_size(false)
if PLATFORM ~= "Android" then
tv_main:set_tab(core.setting_get("maintab_LAST"))
tv_main:set_tab(core.settings:get("maintab_LAST"))
end
ui.set_default("maintab")
tv_main:show()

View File

@ -233,14 +233,14 @@ function modstore.handle_buttons(parent, fields, name, data)
if not core.handle_async(
function(param)
local fullurl = core.setting_get("modstore_download_url") ..
local fullurl = core.settings:get("modstore_download_url") ..
param.moddetails.download_url
if param.version ~= nil then
local found = false
for i=1,#param.moddetails.versions, 1 do
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
found = true
end
@ -400,7 +400,7 @@ function modstore.getscreenshot(ypos,listentry)
listentry.texturename = "in progress"
--prepare url and filename
local fullurl = core.setting_get("modstore_download_url") ..
local fullurl = core.settings:get("modstore_download_url") ..
listentry.details.screenshot_url
local filename = os.tempfolder() .. "_MID_" .. listentry.id

View File

@ -39,14 +39,14 @@ local function get_formspec(tabview, name, tabdata)
-- Address / Port
"label[7.75,-0.25;" .. fgettext("Address / Port") .. "]" ..
"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;;" ..
core.formspec_escape(core.setting_get("remote_port")) .. "]" ..
core.formspec_escape(core.settings:get("remote_port")) .. "]" ..
-- Name / Password
"label[7.75,0.95;" .. fgettext("Name / Password") .. "]" ..
"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;]" ..
-- Description Background
@ -135,7 +135,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
if fields.te_name then
gamedata.playername = fields.te_name
core.setting_set("name", fields.te_name)
core.settings:set("name", fields.te_name)
end
if fields.favourites then
@ -163,8 +163,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
gamedata.serverdescription = fav.description
if gamedata.address and gamedata.port then
core.setting_set("address", gamedata.address)
core.setting_set("remote_port", gamedata.port)
core.settings:set("address", gamedata.address)
core.settings:set("remote_port", gamedata.port)
core.start()
end
end
@ -187,8 +187,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
end
if address and port then
core.setting_set("address", address)
core.setting_set("remote_port", port)
core.settings:set("address", address)
core.settings:set("remote_port", port)
end
tabdata.fav_selected = event.row
end
@ -219,8 +219,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
local port = fav.port
gamedata.serverdescription = fav.description
if address and port then
core.setting_set("address", address)
core.setting_set("remote_port", port)
core.settings:set("address", address)
core.settings:set("remote_port", port)
end
tabdata.fav_selected = fav_idx
@ -235,8 +235,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
asyncOnlineFavourites()
tabdata.fav_selected = nil
core.setting_set("address", "")
core.setting_set("remote_port", "30000")
core.settings:set("address", "")
core.settings:set("remote_port", "30000")
return true
end
@ -293,8 +293,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
end)
menudata.search_result = search_result
local first_server = search_result[1]
core.setting_set("address", first_server.address)
core.setting_set("remote_port", first_server.port)
core.settings:set("address", first_server.address)
core.settings:set("remote_port", first_server.port)
end
return true
end
@ -325,8 +325,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
gamedata.serverdescription = ""
end
core.setting_set("address", fields.te_address)
core.setting_set("remote_port", fields.te_port)
core.settings:set("address", fields.te_address)
core.settings:set("remote_port", fields.te_port)
core.start()
return true

View File

@ -19,7 +19,7 @@
local function get_formspec(tabview, name, tabdata)
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 =
@ -29,29 +29,29 @@ local function get_formspec(tabview, name, tabdata)
"button[8.5,5;3.25,0.5;start_server;" .. fgettext("Start Game") .. "]" ..
"label[4,-0.25;" .. fgettext("Select World:") .. "]" ..
"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") .. ";" ..
dump(core.setting_getbool("enable_damage")) .. "]" ..
dump(core.settings:get_bool("enable_damage")) .. "]" ..
"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") .. "]" ..
"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;]"
local bind_addr = core.setting_get("bind_address")
local bind_addr = core.settings:get("bind_address")
if bind_addr ~= nil and bind_addr ~= "" then
retval = retval ..
"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") .. ";" ..
core.formspec_escape(core.setting_get("port")) .. "]"
core.formspec_escape(core.settings:get("port")) .. "]"
else
retval = retval ..
"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
retval = retval ..
"textlist[4,0.25;7.5,3.7;srv_worlds;" ..
menu_render_worldlist() ..
@ -75,7 +75,7 @@ local function main_button_handler(this, fields, name, tabdata)
world_doubleclick = true
end
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")))
return true
end
@ -86,7 +86,7 @@ local function main_button_handler(this, fields, name, tabdata)
end
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")
menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"])
@ -94,7 +94,7 @@ local function main_button_handler(this, fields, name, tabdata)
end
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")
menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"])
@ -102,7 +102,7 @@ local function main_button_handler(this, fields, name, tabdata)
end
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")
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.address = ""
core.setting_set("port",gamedata.port)
core.settings:set("port",gamedata.port)
if fields["te_serveraddr"] ~= nil then
core.setting_set("bind_address",fields["te_serveraddr"])
core.settings:set("bind_address",fields["te_serveraddr"])
end
--update last game
local world = menudata.worldlist:get_raw_element(gamedata.selected_world)
if world then
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
core.start()

View File

@ -70,39 +70,39 @@ local dd_options = {
local getSettingIndex = {
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
if style == name then return idx end
end
return 1
end,
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
if style == name then return idx end
end
return 1
end,
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
elseif core.setting_get(dd_options.filters[2][3]) == "false" and
core.setting_get(dd_options.filters[2][2]) == "true" then
elseif core.settings:get(dd_options.filters[2][3]) == "false" and
core.settings:get(dd_options.filters[2][2]) == "true" then
return 2
end
return 1
end,
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
elseif core.setting_get(dd_options.mipmap[2][3]) == "false" and
core.setting_get(dd_options.mipmap[2][2]) == "true" then
elseif core.settings:get(dd_options.mipmap[2][3]) == "false" and
core.settings:get(dd_options.mipmap[2][2]) == "true" then
return 2
end
return 1
end,
Antialiasing = function()
local antialiasing_setting = core.setting_get("fsaa")
local antialiasing_setting = core.settings:get("fsaa")
for i = 1, #dd_options.antialiasing[2] do
if antialiasing_setting == dd_options.antialiasing[2][i] then
return i
@ -177,15 +177,15 @@ local function formspec(tabview, name, tabdata)
local tab_string =
"box[0,0;3.5,4.5;#999999]" ..
"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") .. ";"
.. dump(core.setting_getbool("enable_particles")) .. "]" ..
.. dump(core.settings:get_bool("enable_particles")) .. "]" ..
"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") .. ";"
.. dump(core.setting_getbool("opaque_water")) .. "]" ..
.. dump(core.settings:get_bool("opaque_water")) .. "]" ..
"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] .. ";"
.. getSettingIndex.NodeHighlighting() .. "]" ..
"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() .. "]" ..
"label[3.85,3.45;" .. fgettext("Screen:") .. "]" ..
"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]" ..
"checkbox[8,0;cb_shaders;" .. fgettext("Shaders") .. ";"
.. dump(core.setting_getbool("enable_shaders")) .. "]"
.. dump(core.settings:get_bool("enable_shaders")) .. "]"
if PLATFORM == "Android" then
tab_string = tab_string ..
@ -221,29 +221,29 @@ local function formspec(tabview, name, tabdata)
.. fgettext("Advanced Settings") .. "]"
if core.setting_get("touchscreen_threshold") ~= nil then
if core.settings:get("touchscreen_threshold") ~= nil then
tab_string = tab_string ..
"label[4.3,4.1;" .. fgettext("Touchthreshold (px)") .. "]" ..
"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
if core.setting_getbool("enable_shaders") then
if core.settings:get_bool("enable_shaders") then
tab_string = tab_string ..
"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") .. ";"
.. dump(core.setting_getbool("tone_mapping")) .. "]" ..
.. dump(core.settings:get_bool("tone_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") .. ";"
.. 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") .. ";"
.. dump(core.setting_getbool("enable_waving_water")) .. "]" ..
.. dump(core.settings:get_bool("enable_waving_water")) .. "]" ..
"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") .. ";"
.. dump(core.setting_getbool("enable_waving_plants")) .. "]"
.. dump(core.settings:get_bool("enable_waving_plants")) .. "]"
else
tab_string = tab_string ..
"tablecolumns[color;text]" ..
@ -274,64 +274,64 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
return true
end
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
end
if fields["cb_particles"] then
core.setting_set("enable_particles", fields["cb_particles"])
core.settings:set("enable_particles", fields["cb_particles"])
return true
end
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
end
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
end
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
end
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
end
if fields["cb_shaders"] then
if (core.setting_get("video_driver") == "direct3d8" or
core.setting_get("video_driver") == "direct3d9") then
core.setting_set("enable_shaders", "false")
if (core.settings:get("video_driver") == "direct3d8" or
core.settings:get("video_driver") == "direct3d9") then
core.settings:set("enable_shaders", "false")
gamedata.errormessage = fgettext("To enable shaders the OpenGL driver needs to be used.")
else
core.setting_set("enable_shaders", fields["cb_shaders"])
core.settings:set("enable_shaders", fields["cb_shaders"])
end
return true
end
if fields["cb_bumpmapping"] then
core.setting_set("enable_bumpmapping", fields["cb_bumpmapping"])
core.settings:set("enable_bumpmapping", fields["cb_bumpmapping"])
return true
end
if fields["cb_tonemapping"] then
core.setting_set("tone_mapping", fields["cb_tonemapping"])
core.settings:set("tone_mapping", fields["cb_tonemapping"])
return true
end
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
end
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
end
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
end
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
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
end
if fields["btn_change_keys"] then
@ -339,7 +339,7 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
return true
end
if fields["cb_touchscreen_target"] then
core.setting_set("touchtarget", fields["cb_touchscreen_target"])
core.settings:set("touchtarget", fields["cb_touchscreen_target"])
return true
end
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
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
end
end
for i = 1, #labels.node_highlighting do
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
end
end
if fields["dd_filters"] == labels.filters[1] then
core.setting_set("bilinear_filter", "false")
core.setting_set("trilinear_filter", "false")
core.settings:set("bilinear_filter", "false")
core.settings:set("trilinear_filter", "false")
ddhandled = true
elseif fields["dd_filters"] == labels.filters[2] then
core.setting_set("bilinear_filter", "true")
core.setting_set("trilinear_filter", "false")
core.settings:set("bilinear_filter", "true")
core.settings:set("trilinear_filter", "false")
ddhandled = true
elseif fields["dd_filters"] == labels.filters[3] then
core.setting_set("bilinear_filter", "false")
core.setting_set("trilinear_filter", "true")
core.settings:set("bilinear_filter", "false")
core.settings:set("trilinear_filter", "true")
ddhandled = true
end
if fields["dd_mipmap"] == labels.mipmap[1] then
core.setting_set("mip_map", "false")
core.setting_set("anisotropic_filter", "false")
core.settings:set("mip_map", "false")
core.settings:set("anisotropic_filter", "false")
ddhandled = true
elseif fields["dd_mipmap"] == labels.mipmap[2] then
core.setting_set("mip_map", "true")
core.setting_set("anisotropic_filter", "false")
core.settings:set("mip_map", "true")
core.settings:set("anisotropic_filter", "false")
ddhandled = true
elseif fields["dd_mipmap"] == labels.mipmap[3] then
core.setting_set("mip_map", "true")
core.setting_set("anisotropic_filter", "true")
core.settings:set("mip_map", "true")
core.settings:set("anisotropic_filter", "true")
ddhandled = true
end
if fields["dd_antialiasing"] then
core.setting_set("fsaa",
core.settings:set("fsaa",
antialiasing_fname_to_name(fields["dd_antialiasing"]))
ddhandled = true
end
if fields["dd_touchthreshold"] then
core.setting_set("touchscreen_threshold", fields["dd_touchthreshold"])
core.settings:set("touchscreen_threshold", fields["dd_touchthreshold"])
ddhandled = true
end

View File

@ -25,12 +25,12 @@ local function get_formspec(tabview, name, tabdata)
local retval =
"label[9.5,0;".. fgettext("Name / Password") .. "]" ..
"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;;" ..
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") .. "]" ..
"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;]"
@ -89,9 +89,9 @@ local function get_formspec(tabview, name, tabdata)
-- checkboxes
retval = retval ..
"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") .. ";" ..
dump(core.setting_getbool("enable_damage")) .. "]"
dump(core.settings:get_bool("enable_damage")) .. "]"
-- buttons
retval = retval ..
"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
if address and port then
core.setting_set("address", address)
core.setting_set("remote_port", port)
core.settings:set("address", address)
core.settings:set("remote_port", port)
end
tabdata.fav_selected = event.row
end
@ -145,18 +145,18 @@ local function main_button_handler(tabview, fields, name, tabdata)
asyncOnlineFavourites()
tabdata.fav_selected = nil
core.setting_set("address", "")
core.setting_set("remote_port", "30000")
core.settings:set("address", "")
core.settings:set("remote_port", "30000")
return true
end
if fields.cb_creative then
core.setting_set("creative_mode", fields.cb_creative)
core.settings:set("creative_mode", fields.cb_creative)
return true
end
if fields.cb_damage then
core.setting_set("enable_damage", fields.cb_damage)
core.settings:set("enable_damage", fields.cb_damage)
return true
end
@ -186,12 +186,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
gamedata.selected_world = 0
core.setting_set("address", fields.te_address)
core.setting_set("remote_port", fields.te_port)
core.start()
return true
end
core.settings:set("address", fields.te_address)
core.settings:set("remote_port", fields.te_port)
if fields.btn_config_sp_world then
local configdialog = create_configure_world_dlg(1)

View File

@ -16,7 +16,7 @@
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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)
return game
@ -36,10 +36,10 @@ local function singleplayer_refresh_gamebar()
if ("game_btnbar_" .. gamemgr.games[j].id == key) then
mm_texture.update("singleplayer", gamemgr.games[j])
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)
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
local selected = core.get_textlist_index("sp_worlds")
if selected ~= nil and selected < #menudata.worldlist:get_list() then
@ -89,7 +89,7 @@ local function get_formspec(tabview, name, tabdata)
local retval = ""
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 ..
@ -99,9 +99,9 @@ local function get_formspec(tabview, name, tabdata)
"button[8.5,5;3.25,0.5;play;".. fgettext("Play") .. "]" ..
"label[4,-0.25;".. fgettext("Select World:") .. "]"..
"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") .. ";" ..
dump(core.setting_getbool("enable_damage")) .. "]"..
dump(core.settings:get_bool("enable_damage")) .. "]"..
"textlist[4,0.25;7.5,3.7;sp_worlds;" ..
menu_render_worldlist() ..
";" .. index .. "]"
@ -125,7 +125,7 @@ local function main_button_handler(this, fields, name, tabdata)
end
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))
return true
end
@ -136,7 +136,7 @@ local function main_button_handler(this, fields, name, tabdata)
end
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")
menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"])
@ -144,7 +144,7 @@ local function main_button_handler(this, fields, name, tabdata)
end
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")
menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"])

View File

@ -54,9 +54,9 @@ local function get_formspec(tabview, name, tabdata)
local retval = "label[4,-0.25;" .. fgettext("Select texture pack:") .. "]" ..
"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 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
@ -106,7 +106,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
local event = core.explode_textlist_event(fields["TPs"])
if event.type == "CHG" or event.type == "DCL" then
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 current_index = core.get_textlist_index("TPs")
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
new_path = ""
end
core.setting_set("texture_path", new_path)
core.settings:set("texture_path", new_path)
end
end
return true

View File

@ -24,7 +24,7 @@ function mm_texture.init()
DIR_DELIM .. "pack" .. DIR_DELIM
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
end
@ -61,7 +61,7 @@ function mm_texture.reset()
mm_texture.set_generic("header")
if not have_bg then
if core.setting_getbool("menu_clouds") then
if core.settings:get_bool("menu_clouds") then
core.set_clouds(true)
else
mm_texture.set_dirt_bg()
@ -88,7 +88,7 @@ function mm_texture.update_game(gamedetails)
if not have_bg then
if core.setting_getbool("menu_clouds") then
if core.settings:get_bool("menu_clouds") then
core.set_clouds(true)
else
mm_texture.set_dirt_bg()

View File

@ -15,10 +15,18 @@
--with this program; if not, write to the Free Software Foundation, Inc.,
--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 = {}
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")
profiler.instrument = instrumentation.instrument
@ -27,7 +35,7 @@ profiler.instrument = instrumentation.instrument
-- Is called later, after `core.register_chatcommand` was set up.
--
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
instrumentation.init_chatcommand()
end

View File

@ -17,8 +17,9 @@
local format, pairs, type = string.format, pairs, type
local core, get_current_modname = core, core.get_current_modname
local profiler, sampler = ...
local instrument_builtin = core.setting_getbool("instrument.builtin") or false
local profiler, sampler, get_bool_default = ...
local instrument_builtin = get_bool_default("instrument.builtin", false)
local register_functions = {
register_globalstep = 0,
@ -137,7 +138,7 @@ local function instrument_register(func, func_name)
end
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
core.register_chatcommand = function(cmd, def)
def.func = instrument {
@ -153,8 +154,7 @@ end
-- Start instrumenting selected functions
--
local function init()
local is_set = core.setting_getbool
if is_set("instrument.entity") or true then
if get_bool_default("instrument.entity", true) then
-- Explicitly declare entity api-methods.
-- Simple iteration would ignore lookup via __index.
local entity_instrumentation = {
@ -180,7 +180,7 @@ local function init()
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.
local orig_register_abm = core.register_abm
core.register_abm = function(spec)
@ -193,7 +193,7 @@ local function init()
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.
local orig_register_lbm = core.register_lbm
core.register_lbm = function(spec)
@ -206,13 +206,13 @@ local function init()
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
core[func_name] = instrument_register(core[func_name], func_name)
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
-- So keep the `return` for better optimization.
profiler.empty_instrument = instrument {

View File

@ -18,7 +18,7 @@
local DIR_DELIM, LINE_DELIM = DIR_DELIM, "\n"
local table, unpack, string, pairs, io, os = table, unpack, string, pairs, io, os
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 = {}
---
@ -229,7 +229,7 @@ end
local worldpath = core.get_worldpath()
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
core.mkdir(sprintf("%s%s%s", worldpath, DIR_DELIM, report_path))
end
@ -249,7 +249,7 @@ end
--
function reporter.save(profile, format, filter)
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
if filter == "" then
filter = nil

View File

@ -185,7 +185,7 @@ end
function sampler.init()
sampler.reset()
if core.setting_getbool("instrument.profiler") then
if core.settings:get_bool("instrument.profiler") then
core.register_globalstep(function()
if logged_time == 0 then
return

View File

@ -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
registered callbacks.
`minetest.setting_get(name)` and `minetest.setting_getbool(name)` can be used
to read custom or existing settings at load time, if necessary.
`minetest.settings` can be used to read custom or existing settings at load
time, if necessary. (See `Settings`)
### `models`
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
### Setting-related
* `minetest.setting_set(name, 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.
* `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
* `minetest.settings`: Settings object containing all of the settings from the
main config file (`minetest.conf`).
* `minetest.setting_get_pos(name)`: Loads a setting from the main settings and
parses it as a position (in the format `(1,2,3)`). Returns a position or nil.
### Authentication
* `minetest.notify_authentication_modified(name)`
@ -3536,10 +3530,15 @@ It can be created via `Settings(filename)`.
* `get(key)`: returns a value
* `get_bool(key)`: returns a boolean
* `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)
* `get_names()`: returns `{key1,...}`
* `write()`: returns a boolean (`true` for success)
* write changes to file
* Writes changes to file.
* `to_table()`: returns `{[key1]=value1,...}`
Mapgen objects

View File

@ -76,14 +76,9 @@ AsyncEngine::~AsyncEngine()
}
/******************************************************************************/
bool AsyncEngine::registerFunction(const char* name, lua_CFunction func)
void AsyncEngine::registerStateInitializer(StateInitializer func)
{
if (initDone) {
return false;
}
functionList[name] = func;
return true;
stateInitializers.push_back(func);
}
/******************************************************************************/
@ -204,11 +199,9 @@ void AsyncEngine::pushFinishedJobs(lua_State* L) {
/******************************************************************************/
void AsyncEngine::prepareEnvironment(lua_State* L, int top)
{
for (UNORDERED_MAP<std::string, lua_CFunction>::iterator it = functionList.begin();
it != functionList.end(); ++it) {
lua_pushstring(L, it->first.c_str());
lua_pushcfunction(L, it->second);
lua_settable(L, top);
for (std::vector<StateInitializer>::iterator it = stateInitializers.begin();
it != stateInitializers.end(); it++) {
(*it)(L, top);
}
}

View File

@ -75,16 +75,16 @@ private:
// Asynchornous thread and job management
class AsyncEngine {
friend class AsyncWorkerThread;
typedef void (*StateInitializer)(lua_State *L, int top);
public:
AsyncEngine();
~AsyncEngine();
/**
* Register function to be used within engine
* @param name Function name to be used within Lua environment
* Register function to be called on new states
* @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
@ -140,8 +140,8 @@ private:
// Variable locking the engine against further modification
bool initDone;
// Internal store for registred functions
UNORDERED_MAP<std::string, lua_CFunction> functionList;
// Internal store for registred state initializers
std::vector<StateInitializer> stateInitializers;
// Internal counter to create job IDs
unsigned int jobIdCounter;

View File

@ -74,17 +74,13 @@ std::string ModApiBase::getCurrentModPath(lua_State *L)
}
bool ModApiBase::registerFunction(
lua_State *L,
const char *name,
lua_CFunction fct,
int top)
bool ModApiBase::registerFunction(lua_State *L, const char *name,
lua_CFunction func, int top)
{
//TODO check presence first!
// TODO: Check presence first!
lua_pushstring(L,name);
lua_pushcfunction(L,fct);
lua_settable(L, top);
lua_pushcfunction(L, func);
lua_setfield(L, top, name);
return true;
}

View File

@ -68,9 +68,8 @@ public:
static bool registerFunction(lua_State *L,
const char* name,
lua_CFunction fct,
int top
);
lua_CFunction func,
int top);
};
#endif /* L_BASE_H_ */

View File

@ -31,8 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define luamethod(class, name) {#name, 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 ASYNC_API_FCT(name) engine.registerFunction(#name, l_##name)
#define API_FCT(name) registerFunction(L, #name, l_##name, top)
#define MAP_LOCK_REQUIRED
#define NO_MAP_LOCK_REQUIRED

View File

@ -38,6 +38,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IFileArchive.h>
#include <IFileSystem.h>
/******************************************************************************/
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);
ASYNC_API_FCT(get_games);
ASYNC_API_FCT(get_favorites);
ASYNC_API_FCT(get_mapgen_names);
ASYNC_API_FCT(get_modpath);
ASYNC_API_FCT(get_gamepath);
ASYNC_API_FCT(get_texturepath);
ASYNC_API_FCT(get_texturepath_share);
ASYNC_API_FCT(create_dir);
ASYNC_API_FCT(delete_dir);
ASYNC_API_FCT(copy_dir);
//ASYNC_API_FCT(extract_zip); //TODO remove dependency to GuiEngine
ASYNC_API_FCT(download_file);
ASYNC_API_FCT(get_modstore_details);
ASYNC_API_FCT(get_modstore_list);
//ASYNC_API_FCT(gettext); (gettext lib isn't threadsafe)
API_FCT(get_worlds);
API_FCT(get_games);
API_FCT(get_favorites);
API_FCT(get_mapgen_names);
API_FCT(get_modpath);
API_FCT(get_gamepath);
API_FCT(get_texturepath);
API_FCT(get_texturepath_share);
API_FCT(create_dir);
API_FCT(delete_dir);
API_FCT(copy_dir);
//API_FCT(extract_zip); //TODO remove dependency to GuiEngine
API_FCT(download_file);
API_FCT(get_modstore_details);
API_FCT(get_modstore_list);
//API_FCT(gettext); (gettext lib isn't threadsafe)
}

View File

@ -142,6 +142,7 @@ private:
static int l_do_async_callback(lua_State *L);
public:
/**
* initialize this API module
* @param L lua stack to initialize
@ -149,7 +150,7 @@ public:
*/
static void Initialize(lua_State *L, int top);
static void InitializeAsync(AsyncEngine& engine);
static void InitializeAsync(lua_State *L, int top);
};

View File

@ -23,6 +23,47 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.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
int LuaSettings::gc_object(lua_State* L)
{
@ -31,6 +72,7 @@ int LuaSettings::gc_object(lua_State* L)
return 0;
}
// get(self, key) -> value
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));
const char* value = luaL_checkstring(L, 3);
SET_SECURITY_CHECK(L, key);
if (!o->m_settings->set(key, value))
throw LuaError("Invalid sequence found in setting parameters");
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
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));
SET_SECURITY_CHECK(L, key);
bool success = o->m_settings->remove(key);
lua_pushboolean(L, success);
@ -147,19 +209,6 @@ int LuaSettings::l_to_table(lua_State* L)
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)
{
@ -190,7 +239,7 @@ void LuaSettings::Register(lua_State* L)
}
// 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)
{
NO_MAP_LOCK_REQUIRED;
@ -209,8 +258,9 @@ LuaSettings* LuaSettings::checkobject(lua_State* L, int narg)
NO_MAP_LOCK_REQUIRED;
luaL_checktype(L, narg, LUA_TUSERDATA);
void *ud = luaL_checkudata(L, narg, className);
if(!ud) luaL_typerror(L, narg, className);
return *(LuaSettings**)ud; // unbox pointer
if (!ud)
luaL_typerror(L, narg, className);
return *(LuaSettings**) ud; // unbox pointer
}
const char LuaSettings::className[] = "Settings";
@ -218,6 +268,7 @@ const luaL_Reg LuaSettings::methods[] = {
luamethod(LuaSettings, get),
luamethod(LuaSettings, get_bool),
luamethod(LuaSettings, set),
luamethod(LuaSettings, set_bool),
luamethod(LuaSettings, remove),
luamethod(LuaSettings, get_names),
luamethod(LuaSettings, write),

View File

@ -42,6 +42,9 @@ private:
// set(self, key, value)
static int l_set(lua_State *L);
// set_bool(self, key, value)
static int l_set_bool(lua_State* L);
// remove(self, key) -> success
static int l_remove(lua_State *L);
@ -54,16 +57,20 @@ private:
// to_table(self) -> {[key1]=value1,...}
static int l_to_table(lua_State *L);
bool m_write_allowed;
Settings *m_settings;
std::string m_filename;
bool m_is_own_settings;
bool m_write_allowed;
public:
LuaSettings(const char *filename, bool write_allowed);
LuaSettings(Settings *settings, const std::string &filename);
LuaSettings(const std::string &filename, bool write_allowed);
~LuaSettings();
static void create(lua_State *L, Settings *settings, const std::string &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 LuaSettings *checkobject(lua_State *L, int narg);

View File

@ -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_internal.h"
#include "lua_api/l_settings.h"
#include "common/c_converter.h"
#include "common/c_content.h"
#include "cpp_api/s_async.h"
@ -77,71 +78,6 @@ int ModApiUtil::l_get_us_time(lua_State *L)
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])
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(setting_set);
API_FCT(setting_get);
API_FCT(setting_setbool);
API_FCT(setting_getbool);
API_FCT(setting_save);
API_FCT(parse_json);
API_FCT(write_json);
@ -524,6 +454,9 @@ void ModApiUtil::Initialize(lua_State *L, int top)
API_FCT(decode_base64);
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)
@ -548,34 +481,31 @@ void ModApiUtil::InitializeClient(lua_State *L, int top)
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);
ASYNC_API_FCT(setting_get);
//ASYNC_API_FCT(setting_setbool);
ASYNC_API_FCT(setting_getbool);
//ASYNC_API_FCT(setting_save);
API_FCT(parse_json);
API_FCT(write_json);
ASYNC_API_FCT(parse_json);
ASYNC_API_FCT(write_json);
API_FCT(is_yes);
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);
ASYNC_API_FCT(decompress);
API_FCT(mkdir);
API_FCT(get_dir_list);
ASYNC_API_FCT(mkdir);
ASYNC_API_FCT(get_dir_list);
API_FCT(encode_base64);
API_FCT(decode_base64);
ASYNC_API_FCT(encode_base64);
ASYNC_API_FCT(decode_base64);
API_FCT(get_version);
ASYNC_API_FCT(get_version);
LuaSettings::create(L, g_settings, g_settings_path);
lua_setfield(L, top, "settings");
}

View File

@ -45,21 +45,6 @@ private:
// get us precision time
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])
static int l_parse_json(lua_State *L);
@ -109,8 +94,9 @@ private:
static int l_get_version(lua_State *L);
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 InitializeAsync(AsyncEngine &engine);

View File

@ -62,17 +62,17 @@ ClientScripting::ClientScripting(Client *client):
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);
StorageRef::Register(L);
LuaMinimap::Register(L);
NodeMetaRef::RegisterClient(L);
LuaLocalPlayer::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)

View File

@ -59,23 +59,28 @@ MainMenuScripting::MainMenuScripting(GUIEngine* guiengine)
/******************************************************************************/
void MainMenuScripting::initializeModApi(lua_State *L, int top)
{
registerLuaClasses(L, top);
// Initialize mod API modules
ModApiMainMenu::Initialize(L, top);
ModApiUtil::Initialize(L, top);
ModApiSound::Initialize(L, top);
// Register reference classes (userdata)
LuaSettings::Register(L);
// Register functions to async environment
ModApiMainMenu::InitializeAsync(asyncEngine);
ModApiUtil::InitializeAsync(asyncEngine);
asyncEngine.registerStateInitializer(registerLuaClasses);
asyncEngine.registerStateInitializer(ModApiMainMenu::InitializeAsync);
asyncEngine.registerStateInitializer(ModApiUtil::InitializeAsync);
// Initialize async environment
//TODO possibly make number of async threads configurable
asyncEngine.initialize(MAINMENU_NUM_ASYNC_THREADS);
}
/******************************************************************************/
void MainMenuScripting::registerLuaClasses(lua_State *L, int top)
{
LuaSettings::Register(L);
}
/******************************************************************************/
void MainMenuScripting::step()
{

View File

@ -44,6 +44,7 @@ public:
const std::string &serialized_params);
private:
void initializeModApi(lua_State *L, int top);
static void registerLuaClasses(lua_State *L, int top);
AsyncEngine asyncEngine;
DISABLE_CLASS_COPY(MainMenuScripting);

View File

@ -82,19 +82,6 @@ ServerScripting::ServerScripting(Server* server)
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)
InvRef::Register(L);
ItemStackMetaRef::Register(L);
@ -111,6 +98,19 @@ void ServerScripting::InitializeModApi(lua_State *L, int top)
ObjectRef::Register(L);
LuaSettings::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)