From 32c44e00c4b4f7348a63975c87dff06ddf75e592 Mon Sep 17 00:00:00 2001 From: MoNTE48 Date: Wed, 16 Oct 2019 20:08:12 +0200 Subject: [PATCH] Builtin: Clearing Functions and Variables --- builtin/async/init.lua | 2 +- builtin/client/chatcommands.lua | 6 +++--- builtin/client/init.lua | 2 +- builtin/common/async_event.lua | 2 +- builtin/common/filterlist.lua | 14 ++++++------ builtin/fstk/ui.lua | 10 ++++----- builtin/game/chatcommands.lua | 22 +++++++++---------- builtin/game/falling.lua | 6 +++--- builtin/game/hunger.lua | 8 +++---- builtin/game/item.lua | 8 +++---- builtin/game/item_entity.lua | 4 ++-- builtin/game/misc.lua | 8 +++---- builtin/game/register.lua | 8 +++---- builtin/mainmenu/common.lua | 6 +++--- builtin/mainmenu/dlg_config_world.lua | 4 ++-- builtin/mainmenu/dlg_create_world.lua | 9 ++++---- builtin/mainmenu/dlg_settings_advanced.lua | 2 +- builtin/mainmenu/init.lua | 2 +- builtin/mainmenu/modmgr.lua | 14 ++++++------ builtin/mainmenu/tab_credits.lua | 2 +- builtin/mainmenu/tab_local.lua | 25 +++++----------------- builtin/mainmenu/tab_mods.lua | 12 +++++------ builtin/mainmenu/tab_online.lua | 8 +++---- builtin/mainmenu/tab_server.lua | 9 ++++---- builtin/mainmenu/tab_settings.lua | 5 ++--- builtin/mainmenu/tab_texturepacks.lua | 6 +++--- builtin/profiler/init.lua | 2 +- builtin/profiler/sampling.lua | 2 +- 28 files changed, 93 insertions(+), 115 deletions(-) diff --git a/builtin/async/init.lua b/builtin/async/init.lua index 75d70134..7fe54f58 100644 --- a/builtin/async/init.lua +++ b/builtin/async/init.lua @@ -4,7 +4,7 @@ core.log("info", "Initializing Asynchronous environment") function core.job_processor(serialized_func, serialized_param) local func = loadstring(serialized_func) local param = core.deserialize(serialized_param) - local retval = nil + local retval if type(func) == "function" then retval = core.serialize(func(param)) diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index 2b8cc4ac..59881402 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -39,7 +39,7 @@ end) core.register_chatcommand("list_players", { description = core.gettext("List online players"), - func = function(param) + func = function() local players = table.concat(core.get_player_names(), ", ") core.display_chat_message(core.gettext("Online players: ") .. players) end @@ -47,14 +47,14 @@ core.register_chatcommand("list_players", { core.register_chatcommand("disconnect", { description = core.gettext("Exit to main menu"), - func = function(param) + func = function() core.disconnect() end, }) core.register_chatcommand("clear_chat_queue", { description = core.gettext("Clear the out chat queue"), - func = function(param) + func = function() core.clear_out_chat_queue() return true, core.gettext("The out chat queue is now empty") end, diff --git a/builtin/client/init.lua b/builtin/client/init.lua index 5cdbe3e0..72611133 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -16,7 +16,7 @@ core.register_on_death(function() core.show_formspec("bultin:death", formspec) end) -core.register_on_formspec_input(function(formname, fields) +core.register_on_formspec_input(function(formname) if formname == "bultin:death" then core.send_respawn() end diff --git a/builtin/common/async_event.lua b/builtin/common/async_event.lua index 2e0f4237..f2a70c46 100644 --- a/builtin/common/async_event.lua +++ b/builtin/common/async_event.lua @@ -9,7 +9,7 @@ end if core.register_globalstep then core.register_globalstep(function(dtime) - for i, job in ipairs(core.get_finished_jobs()) do + for _, job in ipairs(core.get_finished_jobs()) do handle_job(job.jobid, job.retval) end end) diff --git a/builtin/common/filterlist.lua b/builtin/common/filterlist.lua index 66a54e1e..58bd26ab 100644 --- a/builtin/common/filterlist.lua +++ b/builtin/common/filterlist.lua @@ -146,7 +146,7 @@ function filterlist.get_raw_index(self,listindex) for i,v in ipairs(self.m_raw_list) do - if self.m_compare_fct(v,entry) then + if self.m_compare_fct(v, entry) then return i end end @@ -165,7 +165,7 @@ function filterlist.get_current_index(self,listindex) for i,v in ipairs(self.m_processed_list) do - if self.m_compare_fct(v,entry) then + if self.m_compare_fct(v, entry) then return i end end @@ -186,9 +186,9 @@ function filterlist.process(self) self.m_processed_list = {} - for k,v in pairs(self.m_raw_list) do + for _, v in pairs(self.m_raw_list) do if self.m_filtercriteria == nil or - self.m_filter_fct(v,self.m_filtercriteria) then + self.m_filter_fct(v, self.m_filtercriteria) then self.m_processed_list[#self.m_processed_list + 1] = v end end @@ -215,8 +215,8 @@ end -------------------------------------------------------------------------------- function filterlist.uid_exists_raw(self,uid) - for i,v in ipairs(self.m_raw_list) do - if self.m_uid_match_fct(v,uid) then + for _, v in ipairs(self.m_raw_list) do + if self.m_uid_match_fct(v, uid) then return true end end @@ -228,7 +228,7 @@ function filterlist.raw_index_by_uid(self, uid) local elementcount = 0 local elementidx = 0 for i,v in ipairs(self.m_raw_list) do - if self.m_uid_match_fct(v,uid) then + if self.m_uid_match_fct(v, uid) then elementcount = elementcount +1 elementidx = i end diff --git a/builtin/fstk/ui.lua b/builtin/fstk/ui.lua index f6b70e4d..9cb7e567 100644 --- a/builtin/fstk/ui.lua +++ b/builtin/fstk/ui.lua @@ -128,7 +128,7 @@ function ui.update() restart_btn else local active_toplevel_ui_elements = 0 - for key,value in pairs(ui.childlist) do + for _, value in pairs(ui.childlist) do if (value.type == "toplevel") then local retval = value:get_formspec() @@ -141,7 +141,7 @@ function ui.update() -- no need to show addons if there ain't a toplevel element if (active_toplevel_ui_elements > 0) then - for key,value in pairs(ui.childlist) do + for _, value in pairs(ui.childlist) do if (value.type == "addon") then local retval = value:get_formspec() @@ -169,8 +169,7 @@ end -------------------------------------------------------------------------------- function ui.handle_buttons(fields) - for key,value in pairs(ui.childlist) do - + for _, value in pairs(ui.childlist) do local retval = value:handle_buttons(fields) if retval then @@ -184,8 +183,7 @@ end -------------------------------------------------------------------------------- function ui.handle_events(event) - for key,value in pairs(ui.childlist) do - + for _, value in pairs(ui.childlist) do if value.handle_events ~= nil then local retval = value:handle_events(event) diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index a386fc87..18f295f7 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -340,7 +340,7 @@ core.register_chatcommand("teleport", { return pos, false end - local teleportee = nil + local teleportee local p = {} p.x, p.y, p.z = string.match(param, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$") p.x = tonumber(p.x) @@ -358,9 +358,9 @@ core.register_chatcommand("teleport", { end end - local teleportee = nil - local p = nil - local target_name = nil + local teleportee + local p + local target_name target_name = param:match("^([^ ]+)$") teleportee = core.get_player_by_name(name) if target_name then @@ -380,9 +380,9 @@ core.register_chatcommand("teleport", { return false, "You don't have permission to teleport other players (missing bring privilege)" end - local teleportee = nil + local teleportee local p = {} - local teleportee_name = nil + local teleportee_name teleportee_name, p.x, p.y, p.z = param:match( "^([^ ]+) +([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$") p.x, p.y, p.z = tonumber(p.x), tonumber(p.y), tonumber(p.z) @@ -395,10 +395,10 @@ core.register_chatcommand("teleport", { .. " to " .. core.pos_to_string(vector.round(p)) end - local teleportee = nil - local p = nil - local teleportee_name = nil - local target_name = nil + local teleportee + local p + local teleportee_name + local target_name teleportee_name, target_name = string.match(param, "^([^ ]+) +([^ ]+)$") if teleportee_name then teleportee = core.get_player_by_name(teleportee_name) @@ -749,7 +749,7 @@ core.register_chatcommand("rollback", { end local target_name, seconds = string.match(param, ":([^ ]+) *(%d*)") if not target_name then - local player_name = nil + local player_name player_name, seconds = string.match(param, "([^ ]+) *(%d*)") if not player_name then return false, "Invalid parameters. See /help rollback" diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua index 053153f6..96e39c2a 100644 --- a/builtin/game/falling.lua +++ b/builtin/game/falling.lua @@ -318,17 +318,17 @@ end -- Global callbacks -- -local function on_placenode(p, node) +local function on_placenode(p) core.check_for_falling(p) end core.register_on_placenode(on_placenode) -local function on_dignode(p, node) +local function on_dignode(p) core.check_for_falling(p) end core.register_on_dignode(on_dignode) -local function on_punchnode(p, node) +local function on_punchnode(p) core.check_for_falling(p) end core.register_on_punchnode(on_punchnode) diff --git a/builtin/game/hunger.lua b/builtin/game/hunger.lua index f7b8e0be..d0a45c86 100644 --- a/builtin/game/hunger.lua +++ b/builtin/game/hunger.lua @@ -371,16 +371,16 @@ end) core.register_globalstep(hunger_globaltimer) -core.register_on_placenode(function(pos, oldnode, player, ext) +core.register_on_placenode(function(_, _, player) hunger.exhaust_player(player, settings.exhaust_place, hunger.exhaustion_reasons.place) end) -core.register_on_dignode(function(pos, oldnode, player, ext) +core.register_on_dignode(function(_, _, player) hunger.exhaust_player(player, settings.exhaust_dig, hunger.exhaustion_reasons.dig) end) -core.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) +core.register_on_craft(function(_, player) hunger.exhaust_player(player, settings.exhaust_craft, hunger.exhaustion_reasons.craft) end) -core.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage) +core.register_on_punchplayer(function(_, hitter) hunger.exhaust_player(hitter, settings.exhaust_punch, hunger.exhaustion_reasons.punch) end) core.register_on_respawnplayer(function(player) diff --git a/builtin/game/item.lua b/builtin/game/item.lua index fc032901..b010fc08 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -347,7 +347,7 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2, -- Transfer color information if metatable.palette_index and not def.place_param2 then - local color_divisor = nil + local color_divisor if def.paramtype2 == "color" then color_divisor = 1 elseif def.paramtype2 == "colorwallmounted" then @@ -449,7 +449,7 @@ local function item_throw_step(entity, dtime) entity.object:remove() return end - local hit_object = nil + local hit_object local dir = vector.normalize(entity.object:get_velocity()) local pos2 = vector.add(pos, vector.multiply(dir, 3)) local _, node_pos = minetest.line_of_sight(pos, pos2) @@ -490,7 +490,7 @@ function core.item_throw(name, thrower, speed, accel, on_impact) return end pos.y = pos.y + 1.5 - local obj = nil + local obj local properties = {is_visible=true} if core.registered_entities[name] then obj = core.add_entity(pos, name) @@ -674,7 +674,7 @@ function core.node_dig(pos, node, digger) -- Handle drops core.handle_node_drops(pos, drops, digger) - local oldmetadata = nil + local oldmetadata if def and def.after_dig_node then oldmetadata = core.get_meta(pos):to_table() end diff --git a/builtin/game/item_entity.lua b/builtin/game/item_entity.lua index a7460322..e6499f9e 100644 --- a/builtin/game/item_entity.lua +++ b/builtin/game/item_entity.lua @@ -306,7 +306,7 @@ core.register_entity(":__builtin:item", { return end local objects = core.get_objects_inside_radius(pos, 0.25) - for k, obj in pairs(objects) do + for _, obj in pairs(objects) do local entity = obj:get_luaentity() if entity and entity.name == "__builtin:item" then if self:try_merge_with(own_stack, obj, entity) then @@ -342,7 +342,7 @@ local function collect_items(player) -- Detect local col_pos = vector.add(pos, {x = 0, y = 1.3, z = 0}) local objects = core.get_objects_inside_radius(col_pos, 2) - for k, obj in pairs(objects) do + for _, obj in pairs(objects) do local entity = obj:get_luaentity() if entity and entity.name == "__builtin:item" and not entity.collectioner and entity.age > 0.5 then diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index 1ce7d6b9..19ca9a02 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -25,7 +25,7 @@ function core.check_player_privs(name, ...) end else -- Only a list, we can process it directly. - for key, priv in pairs(requested_privs) do + for _, priv in pairs(requested_privs) do if not player_privs[priv] then missing_privileges[#missing_privileges + 1] = priv end @@ -61,7 +61,7 @@ end) function core.get_connected_players() local temp_table = {} - for index, value in pairs(player_list) do + for _, value in pairs(player_list) do if value:is_player_connected() then temp_table[#temp_table + 1] = value end @@ -150,12 +150,12 @@ function core.setting_get_pos(name) end -- To be overriden by protection mods -function core.is_protected(pos, name) +function core.is_protected() return false end -- To be overriden by protection mods -function core.is_protected_action(pos, name) +function core.is_protected_action() return false end diff --git a/builtin/game/register.lua b/builtin/game/register.lua index eb162e33..406fd9b1 100644 --- a/builtin/game/register.lua +++ b/builtin/game/register.lua @@ -419,7 +419,7 @@ function core.run_callbacks(callbacks, mode, ...) return false end end - local ret = nil + local ret for i = 1, cb_len do local origin = core.callback_origins[callbacks[i]] if origin then @@ -579,9 +579,9 @@ core.registered_on_punchplayers, core.register_on_punchplayer = make_registratio players_per_step = core.settings:get("players_per_globalstep") players_per_step = players_per_step and tonumber(players_per_step) or 20 -local player_iter = nil -local player_iter_forced = nil -local playerstep_iter = nil +local player_iter +local player_iter_forced +local playerstep_iter local playerstep_funcs = {} local playerstep_funcs_forced = {} local playernames = {} diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua index 52ce10a7..836f694c 100644 --- a/builtin/mainmenu/common.lua +++ b/builtin/mainmenu/common.lua @@ -51,7 +51,7 @@ local function configure_selected_world_params(idx) end -------------------------------------------------------------------------------- -function image_column(tooltip, flagname) +function image_column(tooltip) return "image,tooltip=" .. core.formspec_escape(tooltip) .. "," .. "0=" .. core.formspec_escape(defaulttexturedir .. "blank.png") .. "," .. "1=" .. core.formspec_escape(defaulttexturedir .. "server_flags_favorite.png") .. "," .. @@ -189,7 +189,7 @@ function menu_render_worldlist() local retval = "" local current_worldlist = menudata.worldlist:get_list() - for i, v in ipairs(current_worldlist) do + for _, v in ipairs(current_worldlist) do if retval ~= "" then retval = retval .. "," end retval = retval .. core.formspec_escape(v.name) .. "" end @@ -232,7 +232,7 @@ function asyncOnlineFavourites() end core.handle_async( - function(param) + function() return core.get_favorites("online") end, nil, diff --git a/builtin/mainmenu/dlg_config_world.lua b/builtin/mainmenu/dlg_config_world.lua index b0524fff..7badd7fd 100644 --- a/builtin/mainmenu/dlg_config_world.lua +++ b/builtin/mainmenu/dlg_config_world.lua @@ -160,7 +160,7 @@ local function handle_buttons(this, fields) local rawlist = this.data.list:get_raw_list() local i,mod - for i,mod in ipairs(rawlist) do + for _, mod in ipairs(rawlist) do if not mod.is_modpack and not mod.is_game_content then if modname_valid(mod.name) then @@ -175,7 +175,7 @@ local function handle_buttons(this, fields) end -- Remove mods that are not present anymore - for key,value in pairs(mods) do + for key, _ in pairs(mods) do if key:sub(1,9) == "load_mod_" then worldfile:remove(key) end diff --git a/builtin/mainmenu/dlg_create_world.lua b/builtin/mainmenu/dlg_create_world.lua index 467eb149..eb7444ca 100644 --- a/builtin/mainmenu/dlg_create_world.lua +++ b/builtin/mainmenu/dlg_create_world.lua @@ -15,7 +15,7 @@ --with this program; if not, write to the Free Software Foundation, Inc., --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -local function create_world_formspec(dialogdata) +local function create_world_formspec() local mapgens = core.get_mapgen_names() local current_seed = core.settings:get("fixed_map_seed") or "" local current_mg = core.settings:get("mg_name") @@ -23,7 +23,7 @@ local function create_world_formspec(dialogdata) local mglist = "" local selindex = 1 local i = 1 - for k,v in pairs(mapgens) do + for _, v in pairs(mapgens) do if current_mg == v then selindex = i end @@ -34,9 +34,8 @@ local function create_world_formspec(dialogdata) local gameid = core.settings:get("menu_last_game") - local game, gameidx = nil , 0 if gameid ~= nil then - game, gameidx = gamemgr.find_by_gameid(gameid) + local gameidx = gamemgr.find_by_gameid(gameid) if gameidx == nil then gameidx = 0 @@ -87,7 +86,7 @@ local function create_world_buttonhandler(this, fields) if gameindex ~= nil and worldname ~= "" then - local message = nil + local message core.settings:set("fixed_map_seed", fields["te_seed"]) diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua index 95ac6d6c..550cd867 100644 --- a/builtin/mainmenu/dlg_settings_advanced.lua +++ b/builtin/mainmenu/dlg_settings_advanced.lua @@ -358,7 +358,7 @@ local function filter_settings(settings, searchstring) local result = {} local category_stack = {} local current_level = 0 - local best_setting = nil + local best_setting for _, entry in pairs(settings) do if entry.type == "category" then -- Remove all settingless categories diff --git a/builtin/mainmenu/init.lua b/builtin/mainmenu/init.lua index 4b46a204..460c7f03 100644 --- a/builtin/mainmenu/init.lua +++ b/builtin/mainmenu/init.lua @@ -61,7 +61,7 @@ if not use_simple_menu then end -------------------------------------------------------------------------------- -local function main_event_handler(tabview, event) +local function main_event_handler(_, event) if event == "MenuQuit" then core.close() end diff --git a/builtin/mainmenu/modmgr.lua b/builtin/mainmenu/modmgr.lua index 9c8076f4..6aa3df19 100644 --- a/builtin/mainmenu/modmgr.lua +++ b/builtin/mainmenu/modmgr.lua @@ -142,7 +142,7 @@ end -------------------------------------------------------------------------------- function modmgr.parse_register_line(line) local pos1 = line:find("\"") - local pos2 = nil + local pos2 if pos1 ~= nil then pos2 = line:find("\"",pos1+1) end @@ -169,7 +169,7 @@ end -------------------------------------------------------------------------------- function modmgr.parse_dofile_line(modpath,line) local pos1 = line:find("\"") - local pos2 = nil + local pos2 if pos1 ~= nil then pos2 = line:find("\"",pos1+1) end @@ -193,7 +193,7 @@ function modmgr.identify_modname(modpath,filename) local line = testfile:read() while line~= nil do - local modname = nil + local modname if line:find("minetest.register_tool") then modname = modmgr.parse_register_line(line) @@ -226,8 +226,6 @@ function modmgr.identify_modname(modpath,filename) end -------------------------------------------------------------------------------- function modmgr.render_modlist(render_list) - local retval = "" - if render_list == nil then if modmgr.global_mods == nil then modmgr.refresh_globals() @@ -236,7 +234,7 @@ function modmgr.render_modlist(render_list) end local list = render_list:get_list() - local last_modpack = nil + local last_modpack local retval = {} for i, v in ipairs(list) do local color = "" @@ -343,7 +341,7 @@ function modmgr.installmod(modfilename,basename) local basefolder = modmgr.getbasefolder(modpath) if basefolder.type == "modpack" then - local clean_path = nil + local clean_path if basename ~= nil then clean_path = "mp_" .. basename @@ -441,7 +439,7 @@ function modmgr.preparemodlist(data) for key,value in pairs(worldfile:to_table()) do if key:sub(1, 9) == "load_mod_" then key = key:sub(10) - local element = nil + local element for i=1,#retval,1 do if retval[i].name == key and not retval[i].is_modpack then diff --git a/builtin/mainmenu/tab_credits.lua b/builtin/mainmenu/tab_credits.lua index 54083b93..bea1b94f 100644 --- a/builtin/mainmenu/tab_credits.lua +++ b/builtin/mainmenu/tab_credits.lua @@ -94,7 +94,7 @@ end return { name = "credits", caption = fgettext("Credits"), - cbf_formspec = function(tabview, name, tabdata) + cbf_formspec = function() local version = core.get_version() return "label[0.1,-0.1;MultiCraft Open Source Project, ver. " .. version.string .. "]" .. "label[0.1,0.3;Copyright (C) 2014-2019 MultiCraft Development Team]" .. diff --git a/builtin/mainmenu/tab_local.lua b/builtin/mainmenu/tab_local.lua index e6170cf3..9c46dc3c 100644 --- a/builtin/mainmenu/tab_local.lua +++ b/builtin/mainmenu/tab_local.lua @@ -15,22 +15,11 @@ --with this program; if not, write to the Free Software Foundation, Inc., --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -local function current_game() - local last_game_id = core.settings:get("menu_last_game") - local game, index = gamemgr.find_by_gameid(last_game_id) - - return game -end - - -local function get_formspec(tabview, name, tabdata) - local retval = "" - +local function get_formspec() local index = filterlist.get_current_index(menudata.worldlist, - tonumber(core.settings:get("mainmenu_last_selected_world")) - ) + tonumber(core.settings:get("mainmenu_last_selected_world"))) - retval = retval .. + local retval = "image_button[0,4.84;3.31,0.92;" .. core.formspec_escape(defaulttexturedir .. "blank.png") .. ";world_delete;;true;false]" .. @@ -53,7 +42,7 @@ local function get_formspec(tabview, name, tabdata) return retval end -local function main_button_handler(this, fields, name, tabdata) +local function main_button_handler(this, fields, name) assert(name == "local") local world_doubleclick = false @@ -122,7 +111,7 @@ local function main_button_handler(this, fields, name, tabdata) --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) + local game = gamemgr.find_by_gameid(world.gameid) core.settings:set("menu_last_game", game.id) end @@ -190,14 +179,10 @@ local function main_button_handler(this, fields, name, tabdata) end end -local function on_change(type, old_tab, new_tab) -end - -------------------------------------------------------------------------------- return { name = "local", caption = fgettext("Singleplayer"), cbf_formspec = get_formspec, cbf_button_handler = main_button_handler, - on_change = on_change } diff --git a/builtin/mainmenu/tab_mods.lua b/builtin/mainmenu/tab_mods.lua index 1be6bd79..661ebbed 100644 --- a/builtin/mainmenu/tab_mods.lua +++ b/builtin/mainmenu/tab_mods.lua @@ -16,7 +16,7 @@ --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------------- -local function get_formspec(tabview, name, tabdata) +local function get_formspec(_, _, tabdata) if modmgr.global_mods == nil then modmgr.refresh_globals() @@ -42,18 +42,18 @@ local function get_formspec(tabview, name, tabdata) -- "button[0,4.85;5.25,0.5;btn_modstore;".. fgettext("Online mod repository") .. "]" "" - local selected_mod = nil + local selected_mod if filterlist.size(modmgr.global_mods) >= tabdata.selected_mod then selected_mod = modmgr.global_mods:get_list()[tabdata.selected_mod] end if selected_mod ~= nil then - local modscreenshot = nil + local modscreenshot --check for screenshot beeing available local screenshotfilename = selected_mod.path .. DIR_DELIM .. "screenshot.png" - local error = nil + local error local screenshotfile,error = io.open(screenshotfilename,"r") if error == nil then screenshotfile:close() @@ -68,7 +68,7 @@ local function get_formspec(tabview, name, tabdata) .. "image[5.5,0;3,2;" .. core.formspec_escape(modscreenshot) .. "]" .. "label[8.25,0.6;" .. selected_mod.name .. "]" - local descriptionlines = nil + local descriptionlines error = nil local descriptionfilename = selected_mod.path .. "description.txt" local descriptionfile,error = io.open(descriptionfilename,"r") @@ -126,7 +126,7 @@ local function get_formspec(tabview, name, tabdata) end -------------------------------------------------------------------------------- -local function handle_buttons(tabview, fields, tabname, tabdata) +local function handle_buttons(tabview, fields, _, tabdata) if fields["modlist"] ~= nil then local event = core.explode_table_event(fields["modlist"]) tabdata.selected_mod = event.row diff --git a/builtin/mainmenu/tab_online.lua b/builtin/mainmenu/tab_online.lua index 4c52a9ca..4b236944 100644 --- a/builtin/mainmenu/tab_online.lua +++ b/builtin/mainmenu/tab_online.lua @@ -16,11 +16,11 @@ --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------------- -local function get_formspec(tabview, name, tabdata) +local function get_formspec(_, _, tabdata) -- Update the cached supported proto info, -- it may have changed after a change by the settings menu. common_update_cached_supp_proto() - local fav_selected = nil + local fav_selected if menudata.search_result then fav_selected = menudata.search_result[tabdata.fav_selected] else @@ -139,7 +139,7 @@ local function get_formspec(tabview, name, tabdata) end -------------------------------------------------------------------------------- -local function main_button_handler(tabview, fields, name, tabdata) +local function main_button_handler(_, fields, _, tabdata) local serverlist = menudata.search_result or menudata.favorites if fields.te_name then @@ -360,7 +360,7 @@ local function main_button_handler(tabview, fields, name, tabdata) return false end -local function on_change(type, old_tab, new_tab) +local function on_change(type) if type == "LEAVE" then return end asyncOnlineFavourites() end diff --git a/builtin/mainmenu/tab_server.lua b/builtin/mainmenu/tab_server.lua index 005b4989..bb7b5875 100644 --- a/builtin/mainmenu/tab_server.lua +++ b/builtin/mainmenu/tab_server.lua @@ -16,11 +16,10 @@ --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------------- -local function get_formspec(tabview, name, tabdata) +local function get_formspec() local index = menudata.worldlist:get_current_index( - tonumber(core.setting_get("mainmenu_last_selected_world")) - ) + tonumber(core.setting_get("mainmenu_last_selected_world"))) local retval = "button[4,4.15;2.6,0.5;world_delete;" .. fgettext("Delete") .. "]" .. @@ -66,7 +65,7 @@ local function get_formspec(tabview, name, tabdata) end -------------------------------------------------------------------------------- -local function main_button_handler(this, fields, name, tabdata) +local function main_button_handler(this, fields) local world_doubleclick = false @@ -133,7 +132,7 @@ local function main_button_handler(this, fields, name, tabdata) --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) + local game = gamemgr.find_by_gameid(world.gameid) core.settings:set("menu_last_game", game.id) end diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua index c23cbe4a..a3dfe2fd 100644 --- a/builtin/mainmenu/tab_settings.lua +++ b/builtin/mainmenu/tab_settings.lua @@ -122,7 +122,7 @@ local function antialiasing_fname_to_name(fname) return 0 end -local function formspec(tabview, name, tabdata) +local function formspec() local tab_string = "box[0,0;3.75,4.5;#999999]" .. "checkbox[0.25,0;cb_smooth_lighting;" .. fgettext("Smooth Lighting") .. ";" @@ -208,14 +208,13 @@ local function formspec(tabview, name, tabdata) end -------------------------------------------------------------------------------- -local function handle_settings_buttons(this, fields, tabname, tabdata) +local function handle_settings_buttons(this, fields) if fields["btn_advanced_settings"] ~= nil then local adv_settings_dlg = create_adv_settings_dlg() adv_settings_dlg:set_parent(this) this:hide() adv_settings_dlg:show() - --mm_texture.update("singleplayer", current_game()) return true end if fields["cb_smooth_lighting"] then diff --git a/builtin/mainmenu/tab_texturepacks.lua b/builtin/mainmenu/tab_texturepacks.lua index 6af1a079..3d8ed7e9 100644 --- a/builtin/mainmenu/tab_texturepacks.lua +++ b/builtin/mainmenu/tab_texturepacks.lua @@ -35,7 +35,7 @@ end local function render_texture_pack_list(list) local retval = "" - for i, v in ipairs(list) do + for _, v in ipairs(list) do if v:sub(1, 1) ~= "." then if retval ~= "" then retval = retval .. "," @@ -49,7 +49,7 @@ local function render_texture_pack_list(list) end -------------------------------------------------------------------------------- -local function get_formspec(tabview, name, tabdata) +local function get_formspec() local retval = "label[4,-0.25;" .. fgettext("Select texture pack:") .. "]" .. "textlist[4,0.25;7.5,5.0;TPs;" @@ -101,7 +101,7 @@ local function get_formspec(tabview, name, tabdata) end -------------------------------------------------------------------------------- -local function main_button_handler(tabview, fields, name, tabdata) +local function main_button_handler(_, fields) if fields["TPs"] then local event = core.explode_textlist_event(fields["TPs"]) if event.type == "CHG" or event.type == "DCL" then diff --git a/builtin/profiler/init.lua b/builtin/profiler/init.lua index e0aaa9bb..1437da8b 100644 --- a/builtin/profiler/init.lua +++ b/builtin/profiler/init.lua @@ -45,7 +45,7 @@ function profiler.init_chatcommand() description = "handle the profiler and profiling data", params = param_usage, privs = { server=true }, - func = function(name, param) + func = function(_, param) local command, arg0 = string.match(param, "([^ ]+) ?(.*)") local args = arg0 and string.split(arg0, " ") diff --git a/builtin/profiler/sampling.lua b/builtin/profiler/sampling.lua index 60b71ba7..dd94d1c4 100644 --- a/builtin/profiler/sampling.lua +++ b/builtin/profiler/sampling.lua @@ -140,7 +140,7 @@ end -- Like any globalstep function, this should not be too heavy, -- but does not add to the instrumentation overhead. -- -local function sample(dtime) +local function sample() -- Rare, but happens and is currently of no informational value. if logged_time == 0 then return