diff --git a/mods/ENVIRONMENT/mcl_weather/nether_dust.lua b/mods/ENVIRONMENT/mcl_weather/nether_dust.lua index 16cdc9487..d328dae21 100644 --- a/mods/ENVIRONMENT/mcl_weather/nether_dust.lua +++ b/mods/ENVIRONMENT/mcl_weather/nether_dust.lua @@ -2,7 +2,7 @@ mcl_weather.nether_dust = {} mcl_weather.nether_dust.particles_count = 99 -- calculates coordinates and draw particles for Nether dust -mcl_weather.nether_dust.add_dust_particles = function(player) +function mcl_weather.nether_dust.add_dust_particles(player) for i=mcl_weather.nether_dust.particles_count, 1,-1 do local rpx, rpy, rpz = mcl_weather.get_random_pos_by_player_look_dir(player) minetest.add_particle({ diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index 488f6b1a1..6b89c33be 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -235,7 +235,7 @@ minetest.register_globalstep(function(dtime) end) -local initsky = function(player) +local function initsky(player) if (mcl_weather.skycolor.active) then mcl_weather.skycolor.force_update = true end diff --git a/mods/ENVIRONMENT/mcl_weather/snow.lua b/mods/ENVIRONMENT/mcl_weather/snow.lua index 9ec9fbac1..9f89a3a0a 100644 --- a/mods/ENVIRONMENT/mcl_weather/snow.lua +++ b/mods/ENVIRONMENT/mcl_weather/snow.lua @@ -6,7 +6,7 @@ mcl_weather.snow.particles_count = 15 mcl_weather.snow.init_done = false -- calculates coordinates and draw particles for snow weather -mcl_weather.snow.add_snow_particles = function(player) +function mcl_weather.snow.add_snow_particles(player) mcl_weather.rain.last_rp_count = 0 for i=mcl_weather.snow.particles_count, 1,-1 do local random_pos_x, _, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player) @@ -30,7 +30,7 @@ mcl_weather.snow.add_snow_particles = function(player) end end -mcl_weather.snow.set_sky_box = function() +function mcl_weather.snow.set_sky_box() mcl_weather.skycolor.add_layer( "weather-pack-snow-sky", {{r=0, g=0, b=0}, diff --git a/mods/ENVIRONMENT/mcl_weather/weather_core.lua b/mods/ENVIRONMENT/mcl_weather/weather_core.lua index b8deba318..b41887208 100644 --- a/mods/ENVIRONMENT/mcl_weather/weather_core.lua +++ b/mods/ENVIRONMENT/mcl_weather/weather_core.lua @@ -39,7 +39,7 @@ mcl_weather.reg_weathers["none"] = { local storage = minetest.get_mod_storage() -- Save weather into mod storage, so it can be loaded after restarting the server -local save_weather = function() +local function save_weather() if not mcl_weather.end_time then return end storage:set_string("mcl_weather_state", mcl_weather.state) storage:set_int("mcl_weather_end_time", mcl_weather.end_time) @@ -47,7 +47,7 @@ local save_weather = function() end minetest.register_on_shutdown(save_weather) -mcl_weather.get_rand_end_time = function(min_duration, max_duration) +function mcl_weather.get_rand_end_time(min_duration, max_duration) local r if min_duration ~= nil and max_duration ~= nil then r = math.random(min_duration, max_duration) @@ -57,7 +57,7 @@ mcl_weather.get_rand_end_time = function(min_duration, max_duration) return minetest.get_gametime() + r end -mcl_weather.get_current_light_factor = function() +function mcl_weather.get_current_light_factor() if mcl_weather.state == "none" then return nil else @@ -68,7 +68,7 @@ end -- Returns true if pos is outdoor. -- Outdoor is defined as any node in the Overworld under open sky. -- FIXME: Nodes below glass also count as “outdoor”, this should not be the case. -mcl_weather.is_outdoor = function(pos) +function mcl_weather.is_outdoor(pos) local cpos = {x=pos.x, y=pos.y+1, z=pos.z} local dim = mcl_worlds.pos_to_dimension(cpos) if minetest.get_node_light(cpos, 0.5) == 15 and dim == "overworld" then @@ -79,7 +79,7 @@ end -- checks if player is undewater. This is needed in order to -- turn off weather particles generation. -mcl_weather.is_underwater = function(player) +function mcl_weather.is_underwater(player) local ppos = player:get_pos() local offset = player:get_eye_offset() local player_eye_pos = {x = ppos.x + offset.x, @@ -94,7 +94,7 @@ end -- trying to locate position for particles by player look direction for performance reason. -- it is costly to generate many particles around player so goal is focus mainly on front view. -mcl_weather.get_random_pos_by_player_look_dir = function(player) +function mcl_weather.get_random_pos_by_player_look_dir(player) local look_dir = player:get_look_dir() local player_pos = player:get_pos() @@ -123,6 +123,7 @@ mcl_weather.get_random_pos_by_player_look_dir = function(player) end local t, wci = 0, mcl_weather.check_interval + minetest.register_globalstep(function(dtime) t = t + dtime if t < wci then return end @@ -146,7 +147,7 @@ minetest.register_globalstep(function(dtime) end) -- Sets random weather (which could be 'none' (no weather)). -mcl_weather.set_random_weather = function(weather_name, weather_meta) +function mcl_weather.set_random_weather(weather_name, weather_meta) if weather_meta == nil then return end local transitions = weather_meta.transitions local random_roll = math.random(0,100) @@ -166,7 +167,7 @@ end -- * explicit_end_time is OPTIONAL. If specified, explicitly set the -- gametime (minetest.get_gametime) in which the weather ends. -- * changer is OPTIONAL, for logging purposes. -mcl_weather.change_weather = function(new_weather, explicit_end_time, changer_name) +function mcl_weather.change_weather(new_weather, explicit_end_time, changer_name) local changer_name = changer_name or debug.getinfo(2).name.."()" if (mcl_weather.reg_weathers ~= nil and mcl_weather.reg_weathers[new_weather] ~= nil) then @@ -199,7 +200,7 @@ mcl_weather.change_weather = function(new_weather, explicit_end_time, changer_na return false end -mcl_weather.get_weather = function() +function mcl_weather.get_weather() return mcl_weather.state end @@ -273,7 +274,7 @@ if weather_allow_abm ~= nil and weather_allow_abm == false then end -local load_weather = function() +local function load_weather() local weather = storage:get_string("mcl_weather_state") if weather and weather ~= "" then mcl_weather.state = weather diff --git a/mods/HELP/doc/doc/init.lua b/mods/HELP/doc/doc/init.lua index a04d83bda..cadfff442 100644 --- a/mods/HELP/doc/doc/init.lua +++ b/mods/HELP/doc/doc/init.lua @@ -448,13 +448,13 @@ end doc.entry_builders = {} -- Scrollable freeform text -doc.entry_builders.text = function(data) +function doc.entry_builders.text(data) local formstring = doc.widgets.text(data, doc.FORMSPEC.ENTRY_START_X, doc.FORMSPEC.ENTRY_START_Y, doc.FORMSPEC.ENTRY_WIDTH - 0.4, doc.FORMSPEC.ENTRY_HEIGHT) return formstring end -- Scrollable freeform text with an optional standard gallery (3 rows, 3:2 aspect ratio) -doc.entry_builders.text_and_gallery = function(data, playername) +function doc.entry_builders.text_and_gallery(data, playername) -- How much height the image gallery “steals” from the text widget local stolen_height = 0 local formstring = "" @@ -476,7 +476,7 @@ end doc.widgets = {} -- Scrollable freeform text -doc.widgets.text = function(data, x, y, width, height) +function doc.widgets.text(data, x, y, width, height) if x == nil then x = doc.FORMSPEC.ENTRY_START_X end @@ -502,7 +502,7 @@ end -- Image gallery -- Currently, only one gallery per entry is supported. TODO: Add support for multiple galleries in an entry (low priority) -doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width, rows, align_left, align_top) +function doc.widgets.gallery(imagedata, playername, x, y, aspect_ratio, width, rows, align_left, align_top) if playername == nil then return nil end -- emergency exit local formstring = "" @@ -591,7 +591,7 @@ doc.widgets.gallery = function(imagedata, playername, x, y, aspect_ratio, width, end -- Direct formspec -doc.entry_builders.formspec = function(data) +function doc.entry_builders.formspec(data) return data end @@ -802,7 +802,7 @@ function doc.get_sorted_entry_names(cid) local cat = doc.data.categories[cid] local used_eids = {} -- Helper function to extract the entry ID out of the output table - local extract = function(entry_table) + local function extract(entry_table) local eids = {} for k,v in pairs(entry_table) do local eid = v.eid @@ -1175,7 +1175,7 @@ minetest.register_on_joinplayer(function(player) end) ---[[ Add buttons for inventory mods ]] -local button_action = function(player) +local function button_action(player) doc.show_doc(player:get_player_name()) end diff --git a/mods/HELP/doc/doc_identifier/init.lua b/mods/HELP/doc/doc_identifier/init.lua index a3a35e2fa..a74eb16a3 100644 --- a/mods/HELP/doc/doc_identifier/init.lua +++ b/mods/HELP/doc/doc_identifier/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("doc_identifier") +local S = minetest.get_translator(minetest.get_current_modname()) local doc_identifier = {} @@ -6,15 +6,16 @@ doc_identifier.registered_objects = {} -- API doc.sub.identifier = {} -doc.sub.identifier.register_object = function(object_name, category_id, entry_id) + +function doc.sub.identifier.register_object(object_name, category_id, entry_id) doc_identifier.registered_objects[object_name] = { category = category_id, entry = entry_id } end -- END OF API -doc_identifier.identify = function(itemstack, user, pointed_thing) +function doc_identifier.identify(itemstack, user, pointed_thing) local username = user:get_player_name() - local show_message = function(username, itype, param) + local function show_message(username, itype, param) local vsize = 2 local message if itype == "error_item" then diff --git a/mods/HELP/doc/doc_items/init.lua b/mods/HELP/doc/doc_items/init.lua index edba0dae3..d492e6cf4 100644 --- a/mods/HELP/doc/doc_items/init.lua +++ b/mods/HELP/doc/doc_items/init.lua @@ -1,6 +1,12 @@ -local S = minetest.get_translator("doc_items") +local S = minetest.get_translator(minetest.get_current_modname()) local N = function(s) return s end +local math = math +local string = string + +local tostring = tostring +local pairs = pairs + doc.sub.items = {} -- Template texts @@ -34,13 +40,17 @@ local suppressed = { local forbidden_core_factoids = {} -- Helper functions -local yesno = function(bool) - if bool==true then return S("Yes") - elseif bool==false then return S("No") - else return "N/A" end +local function yesno(bool) + if bool == true then + return S("Yes") + elseif bool == false then + return S("No") + else + return "N/A" + end end -local groups_to_string = function(grouptable, filter) +local function groups_to_string(grouptable, filter) local gstring = "" local groups_count = 0 for id, value in pairs(grouptable) do @@ -66,7 +76,7 @@ local groups_to_string = function(grouptable, filter) end -- Removes all text after the first newline (including the newline) -local scrub_newlines = function(text) +local function scrub_newlines(text) local spl = string.split(text, "\n") if spl and #spl > 0 then return spl[1] @@ -76,7 +86,7 @@ local scrub_newlines = function(text) end --[[ Append a newline to text, unless it already ends with a newline. ]] -local newline = function(text) +local function newline(text) if string.sub(text, #text, #text) == "\n" or text == "" then return text else @@ -85,7 +95,7 @@ local newline = function(text) end --[[ Make sure the text ends with two newlines by appending any missing newlines at the end, if neccessary. ]] -local newline2 = function(text) +local function newline2(text) if string.sub(text, #text-1, #text) == "\n\n" or text == "" then return text elseif string.sub(text, #text, #text) == "\n" then @@ -97,7 +107,7 @@ end -- Extract suitable item description for formspec -local description_for_formspec = function(itemstring) +local function description_for_formspec(itemstring) if minetest.registered_items[itemstring] == nil then -- Huh? The item doesn't exist for some reason. Better give a dummy string minetest.log("warning", "[doc] Unknown item detected: "..tostring(itemstring)) @@ -111,7 +121,7 @@ local description_for_formspec = function(itemstring) end end -local get_entry_name = function(itemstring) +local function get_entry_name(itemstring) local def = minetest.registered_items[itemstring] if def._doc_items_entry_name ~= nil then return def._doc_items_entry_name @@ -122,7 +132,7 @@ local get_entry_name = function(itemstring) end end -doc.sub.items.get_group_name = function(groupname) +function doc.sub.items.get_group_name(groupname) if groupdefs[groupname] ~= nil and doc.sub.items.settings.friendly_group_names == true then return groupdefs[groupname] else @@ -130,7 +140,7 @@ doc.sub.items.get_group_name = function(groupname) end end -local burntime_to_text = function(burntime) +local function burntime_to_text(burntime) if burntime == nil then return S("unknown") elseif burntime == 1 then @@ -146,7 +156,7 @@ end * Full punch interval * Damage groups ]] -local factoid_toolcaps = function(tool_capabilities, check_uses) +local function factoid_toolcaps(tool_capabilities, check_uses) if forbidden_core_factoids.tool_capabilities then return "" end @@ -282,7 +292,7 @@ end - Digging times/groups - level group ]] -local factoid_mining_node = function(data) +local function factoid_mining_node(data) if forbidden_core_factoids.node_mining then return "" end @@ -344,7 +354,7 @@ local factoid_mining_node = function(data) end -- Pointing range of itmes -local range_factoid = function(itemstring, def) +local function range_factoid(itemstring, def) local handrange = minetest.registered_items[""].range local itemrange = def.range if itemstring == "" then @@ -364,7 +374,7 @@ local range_factoid = function(itemstring, def) end -- Smelting fuel factoid -local factoid_fuel = function(itemstring, ctype) +local function factoid_fuel(itemstring, ctype) if forbidden_core_factoids.fuel then return "" end @@ -392,7 +402,7 @@ local factoid_fuel = function(itemstring, ctype) end -- Shows the itemstring of an item -local factoid_itemstring = function(itemstring, playername) +local function factoid_itemstring(itemstring, playername) if forbidden_core_factoids.itemstring then return "" end @@ -405,7 +415,7 @@ local factoid_itemstring = function(itemstring, playername) end end -local entry_image = function(data) +local function entry_image(data) local formstring = "" -- No image for air if data.itemstring ~= "air" then @@ -434,7 +444,7 @@ factoid_generators.craftitems = {} * factoid_type: If set, oly returns factoid with a matching factoid_type. If nil, all factoids for this category will be generated * data: Entry data to parse ]] -local factoid_custom = function(category_id, factoid_type, data) +local function factoid_custom(category_id, factoid_type, data) local ftable = factoid_generators[category_id] local datastring = "" -- Custom factoids are inserted here @@ -450,7 +460,7 @@ local factoid_custom = function(category_id, factoid_type, data) end -- Shows core information shared by all items, to be inserted at the top -local factoids_header = function(data, ctype) +local function factoids_header(data, ctype) local datastring = "" if not forbidden_core_factoids.basics then @@ -510,7 +520,7 @@ local factoids_header = function(data, ctype) end -- Shows less important information shared by all items, to be inserted at the bottom -local factoids_footer = function(data, playername, ctype) +local function factoids_footer(data, playername, ctype) local datastring = "" datastring = datastring .. factoid_custom(ctype, "groups", data) datastring = newline2(datastring) @@ -812,7 +822,7 @@ doc.add_category("nodes", { -- Non-default drops if not forbidden_core_factoids.drops and data.def.drop ~= nil and data.def.drop ~= data.itemstring and data.itemstring ~= "air" then -- TODO: Calculate drop probabilities of max > 1 like for max == 1 - local get_desc = function(stack) + local function get_desc(stack) return description_for_formspec(stack:get_name()) end if data.def.drop == "" then @@ -904,7 +914,7 @@ doc.add_category("nodes", { -- Do some cleanup of the probability table if max == 1 or max == nil then -- Sort by rarity - local comp = function(p1, p2) + local function comp(p1, p2) return p1.rarity < p2.rarity end table.sort(probtables, comp) @@ -1232,7 +1242,7 @@ local function gather_descs() }) end - local add_entries = function(deftable, category_id) + local function add_entries(deftable, category_id) for id, def in pairs(deftable) do local name, ld, uh, im local forced = false diff --git a/mods/HELP/mcl_craftguide/init.lua b/mods/HELP/mcl_craftguide/init.lua index bfaef6011..378b420ff 100644 --- a/mods/HELP/mcl_craftguide/init.lua +++ b/mods/HELP/mcl_craftguide/init.lua @@ -726,7 +726,7 @@ local function make_formspec(name) return concat(fs) end -local show_fs = function(player, name) +local function show_fs(player, name) if sfinv_only then sfinv.set_player_inventory_formspec(player) else diff --git a/mods/HELP/tt/init.lua b/mods/HELP/tt/init.lua index a5ae24a35..838aa3fa5 100644 --- a/mods/HELP/tt/init.lua +++ b/mods/HELP/tt/init.lua @@ -7,11 +7,11 @@ tt.NAME_COLOR = mcl_colors.YELLOW -- API tt.registered_snippets = {} -tt.register_snippet = function(func) +function tt.register_snippet(func) table.insert(tt.registered_snippets, func) end -tt.register_priority_snippet = function(func) +function tt.register_priority_snippet(func) table.insert(tt.registered_snippets, 1, func) end @@ -60,7 +60,7 @@ end minetest.register_on_mods_loaded(append_snippets) -tt.reload_itemstack_description = function(itemstack) +function tt.reload_itemstack_description(itemstack) local itemstring = itemstack:get_name() local def = itemstack:get_definition() local meta = itemstack:get_meta() diff --git a/mods/HUD/hudbars/init.lua b/mods/HUD/hudbars/init.lua index a88d14dcf..8a1e97c9c 100644 --- a/mods/HUD/hudbars/init.lua +++ b/mods/HUD/hudbars/init.lua @@ -179,7 +179,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, direction, format_string_config.format_max_value = "%d" end - hudtable.add_all = function(player, hudtable, start_value, start_max, start_hidden) + function hudtable.add_all(player, hudtable, start_value, start_max, start_hidden) if start_value == nil then start_value = hudtable.default_start_value end if start_max == nil then start_max = hudtable.default_start_max end if start_hidden == nil then start_hidden = hudtable.default_start_hidden end diff --git a/mods/HUD/mcl_experience/init.lua b/mods/HUD/mcl_experience/init.lua index a40599d17..0343efa24 100644 --- a/mods/HUD/mcl_experience/init.lua +++ b/mods/HUD/mcl_experience/init.lua @@ -40,7 +40,7 @@ minetest.register_on_mods_loaded(function() registered_nodes = minetest.registered_nodes end) -local load_data = function(player) +local function load_data(player) local name = player:get_player_name() pool[name] = {} local temp_pool = pool[name] @@ -52,7 +52,7 @@ local load_data = function(player) end -- saves data to be utilized on next login -local save_data = function(player) +local function save_data(player) local name = player:get_player_name() local temp_pool = pool[name] local meta = player:get_meta() @@ -70,7 +70,7 @@ minetest.register_on_leaveplayer(function(player) end) -- create instance of new hud -hud_manager.add_hud = function(player,hud_name,def) +function hud_manager.add_hud(player,hud_name,def) local name = player:get_player_name() if minetest.is_creative_enabled(name) then return @@ -100,7 +100,7 @@ hud_manager.add_hud = function(player,hud_name,def) end -- delete instance of hud -hud_manager.remove_hud = function(player,hud_name) +function hud_manager.remove_hud(player,hud_name) local name = player:get_player_name() if player_huds[name] and player_huds[name][hud_name] then player:hud_remove(player_huds[name][hud_name]) @@ -109,7 +109,7 @@ hud_manager.remove_hud = function(player,hud_name) end -- change element of hud -hud_manager.change_hud = function(data) +function hud_manager.change_hud(data) local name = data.player:get_player_name() if player_huds[name] and player_huds[name][data.hud_name] then data.player:hud_change(player_huds[name][data.hud_name], data.element, data.data) @@ -117,7 +117,7 @@ hud_manager.change_hud = function(data) end -- gets if hud exists -hud_manager.hud_exists = function(player,hud_name) +function hud_manager.hud_exists(player,hud_name) local name = player:get_player_name() if player_huds[name] and player_huds[name][hud_name] then return true @@ -133,7 +133,7 @@ minetest.register_on_leaveplayer(function(player) end) -- is used for shutdowns to save all data -local save_all = function() +local function save_all() for name,_ in pairs(pool) do local player = minetest.get_player_by_name(name) if player then diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index 4d73aca35..972456c3f 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -33,13 +33,13 @@ groups to be set. ]] do for name,def in pairs(minetest.registered_items) do if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) and def.description and def.description ~= "" then - local is_redstone = function(def) + local function is_redstone(def) return def.mesecons or def.groups.mesecon or def.groups.mesecon_conductor_craftable or def.groups.mesecon_effecor_off end - local is_tool = function(def) + local function is_tool(def) return def.groups.tool or (def.tool_capabilities ~= nil and def.tool_capabilities.damage_groups == nil) end - local is_weapon_or_armor = function(def) + local function is_weapon_or_armor(def) return def.groups.weapon or def.groups.weapon_ranged or def.groups.ammo or def.groups.combat_item or ((def.groups.armor_head or def.groups.armor_torso or def.groups.armor_legs or def.groups.armor_feet or def.groups.horse_armor) and def.groups.non_combat_armor ~= 1) end -- Is set to true if it was added in any category besides misc @@ -208,7 +208,7 @@ local filtername = {} local noffset_x_start = -0.24 local noffset_x = noffset_x_start local noffset_y = -0.25 -local next_noffset = function(id, right) +local function next_noffset(id, right) if right then noffset[id] = { 8.94, noffset_y } else @@ -291,7 +291,7 @@ filtername["inv"] = S("Survival Inventory") end]] -mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_size, show, page, filter) +function mcl_inventory.set_creative_formspec(player, start_i, pagenum, inv_size, show, page, filter) --reset_menu_item_bg() pagenum = math.floor(pagenum) or 1 diff --git a/mods/HUD/mcl_inventory/init.lua b/mods/HUD/mcl_inventory/init.lua index 4c50a6c13..a0be9b02e 100644 --- a/mods/HUD/mcl_inventory/init.lua +++ b/mods/HUD/mcl_inventory/init.lua @@ -134,7 +134,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end) if not minetest.is_creative_enabled("") then - mcl_inventory.update_inventory_formspec = function(player) + function mcl_inventory.update_inventory_formspec(player) set_inventory(player) end end @@ -158,7 +158,7 @@ minetest.register_on_joinplayer(function(player) player:hud_set_hotbar_selected_image("mcl_inventory_hotbar_selected.png") local old_update_player = mcl_armor.update_player - mcl_armor.update_player = function(player, info) + function mcl_armor.update_player(player, info) old_update_player(player, info) set_inventory(player, true) end diff --git a/mods/ITEMS/mcl_banners/init.lua b/mods/ITEMS/mcl_banners/init.lua index 63ad0c0b8..4ab291804 100644 --- a/mods/ITEMS/mcl_banners/init.lua +++ b/mods/ITEMS/mcl_banners/init.lua @@ -93,11 +93,11 @@ local layer_ratio = 255 local standing_banner_entity_offset = { x=0, y=-0.499, z=0 } local hanging_banner_entity_offset = { x=0, y=-1.7, z=0 } -local rotation_level_to_yaw = function(rotation_level) +local function rotation_level_to_yaw(rotation_level) return (rotation_level * (math.pi/8)) + math.pi end -local on_dig_banner = function(pos, node, digger) +local function on_dig_banner(pos, node, digger) -- Check protection local name = digger:get_player_name() if minetest.is_protected(pos, name) then @@ -116,7 +116,7 @@ local on_dig_banner = function(pos, node, digger) minetest.remove_node(pos) end -local on_destruct_banner = function(pos, hanging) +local function on_destruct_banner(pos, hanging) local offset, nodename if hanging then offset = hanging_banner_entity_offset @@ -136,15 +136,15 @@ local on_destruct_banner = function(pos, hanging) end end -local on_destruct_standing_banner = function(pos) +local function on_destruct_standing_banner(pos) return on_destruct_banner(pos, false) end -local on_destruct_hanging_banner = function(pos) +local function on_destruct_hanging_banner(pos) return on_destruct_banner(pos, true) end -local make_banner_texture = function(base_color, layers) +local function make_banner_texture(base_color, layers) local colorize if mcl_banners.colors[base_color] then colorize = mcl_banners.colors[base_color][4] @@ -174,7 +174,7 @@ local make_banner_texture = function(base_color, layers) end end -local spawn_banner_entity = function(pos, hanging, itemstack) +local function spawn_banner_entity(pos, hanging, itemstack) local banner if hanging then banner = minetest.add_entity(pos, "mcl_banners:hanging_banner") @@ -198,7 +198,7 @@ local spawn_banner_entity = function(pos, hanging, itemstack) return banner end -local respawn_banner_entity = function(pos, node, force) +local function respawn_banner_entity(pos, node, force) local hanging = node.name == "mcl_banners:hanging_banner" local offset if hanging then diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua index 516624301..65699768e 100644 --- a/mods/ITEMS/mcl_banners/patterncraft.lua +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -259,7 +259,7 @@ for colorid, colortab in pairs(mcl_banners.colors) do end -- Create a banner description containing all the layer names -mcl_banners.make_advanced_banner_description = function(description, layers) +function mcl_banners.make_advanced_banner_description(description, layers) if layers == nil or #layers == 0 then -- No layers, revert to default return "" @@ -296,7 +296,7 @@ Parameters same as for minetest.register_craft_predict. craft_predict is set true when called from minetest.craft_preview, in this case, this function MUST NOT change the crafting grid. ]] -local banner_pattern_craft = function(itemstack, player, old_craft_grid, craft_inv, craft_predict) +local function banner_pattern_craft(itemstack, player, old_craft_grid, craft_inv, craft_predict) if minetest.get_item_group(itemstack:get_name(), "banner") ~= 1 then return end diff --git a/mods/ITEMS/mcl_books/init.lua b/mods/ITEMS/mcl_books/init.lua index b7bd20d9a..0839c1650 100644 --- a/mods/ITEMS/mcl_books/init.lua +++ b/mods/ITEMS/mcl_books/init.lua @@ -30,7 +30,7 @@ end -- Get the included text out of the book item -- itemstack: Book item -- meta: Meta of book (optional) -local get_text = function(itemstack) +local function get_text(itemstack) -- Grab the text local meta = itemstack:get_meta() local text = meta:get_string("text") @@ -56,7 +56,7 @@ local get_text = function(itemstack) return text end -local make_description = function(title, author, generation) +local function make_description(title, author, generation) local desc if generation == 0 then desc = S("“@1”", title) @@ -71,11 +71,11 @@ local make_description = function(title, author, generation) return desc end -local cap_text_length = function(text, max_length) +local function cap_text_length(text, max_length) return string.sub(text, 1, max_length) end -local write = function(itemstack, user, pointed_thing) +local function write(itemstack, user, pointed_thing) -- Call on_rightclick if the pointed node defines it if pointed_thing.type == "node" then local node = minetest.get_node(pointed_thing.under) @@ -96,7 +96,7 @@ local write = function(itemstack, user, pointed_thing) minetest.show_formspec(user:get_player_name(), "mcl_books:writable_book", formspec) end -local read = function(itemstack, user, pointed_thing) +local function read(itemstack, user, pointed_thing) -- Call on_rightclick if the pointed node defines it if pointed_thing.type == "node" then local node = minetest.get_node(pointed_thing.under) diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index a56b2e7cf..8b2eb0ac0 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_bows") +local S = minetest.get_translator(minetest.get_current_modname()) local math = math local vector = vector @@ -79,7 +79,7 @@ local ARROW_ENTITY={ } -- Destroy arrow entity self at pos and drops it as an item -local spawn_item = function(self, pos) +local function spawn_item(self, pos) if not minetest.is_creative_enabled("") then local item = minetest.add_item(pos, "mcl_bows:arrow") item:set_velocity({x=0, y=0, z=0}) @@ -89,7 +89,7 @@ local spawn_item = function(self, pos) self.object:remove() end -local damage_particles = function(pos, is_critical) +local function damage_particles(pos, is_critical) if is_critical then minetest.add_particlespawner({ amount = 15, @@ -111,7 +111,7 @@ local damage_particles = function(pos, is_critical) end end -ARROW_ENTITY.on_step = function(self, dtime) +function ARROW_ENTITY.on_step(self, dtime) mcl_burning.tick(self.object, dtime, self) self._time_in_air = self._time_in_air + .001 @@ -423,13 +423,13 @@ end -- Force recheck of stuck arrows when punched. -- Otherwise, punching has no effect. -ARROW_ENTITY.on_punch = function(self) +function ARROW_ENTITY.on_punch(self) if self._stuck then self._stuckrechecktimer = STUCK_RECHECK_TIME end end -ARROW_ENTITY.get_staticdata = function(self) +function ARROW_ENTITY.get_staticdata(self) local out = { lastpos = self._lastpos, startpos = self._startpos, @@ -451,7 +451,7 @@ ARROW_ENTITY.get_staticdata = function(self) return minetest.serialize(out) end -ARROW_ENTITY.on_activate = function(self, staticdata, dtime_s) +function ARROW_ENTITY.on_activate(self, staticdata, dtime_s) self._time_in_air = 1.0 self._in_player = false local data = minetest.deserialize(staticdata) diff --git a/mods/ITEMS/mcl_bows/bow.lua b/mods/ITEMS/mcl_bows/bow.lua index f752142c2..8d60f3969 100644 --- a/mods/ITEMS/mcl_bows/bow.lua +++ b/mods/ITEMS/mcl_bows/bow.lua @@ -33,7 +33,7 @@ local bow_load = {} -- Another player table, this one stores the wield index of the bow being charged local bow_index = {} -mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damage, is_critical, bow_stack, collectable) +function mcl_bows.shoot_arrow(arrow_item, pos, dir, yaw, shooter, power, damage, is_critical, bow_stack, collectable) local obj = minetest.add_entity({x=pos.x,y=pos.y,z=pos.z}, arrow_item.."_entity") if power == nil then power = BOW_MAX_SPEED --19 @@ -75,7 +75,7 @@ mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damag return obj end -local get_arrow = function(player) +local function get_arrow(player) local inv = player:get_inventory() local arrow_stack, arrow_stack_id for i=1, inv:get_size("main") do @@ -89,7 +89,7 @@ local get_arrow = function(player) return arrow_stack, arrow_stack_id end -local player_shoot_arrow = function(itemstack, player, power, damage, is_critical) +local function player_shoot_arrow(itemstack, player, power, damage, is_critical) local arrow_stack, arrow_stack_id = get_arrow(player) local arrow_itemstring local has_infinity_enchantment = mcl_enchanting.has_enchantment(player:get_wielded_item(), "infinity") @@ -162,7 +162,7 @@ S("The speed and damage of the arrow increases the longer you charge. The regula }) -- Iterates through player inventory and resets all the bows in "charging" state back to their original stage -local reset_bows = function(player) +local function reset_bows(player) local inv = player:get_inventory() local list = inv:get_list("main") for place, stack in pairs(list) do @@ -182,7 +182,7 @@ local reset_bows = function(player) end -- Resets the bow charging state and player speed. To be used when the player is no longer charging the bow -local reset_bow_state = function(player, also_reset_bows) +local function reset_bow_state(player, also_reset_bows) bow_load[player:get_player_name()] = nil bow_index[player:get_player_name()] = nil if minetest.get_modpath("playerphysics") then diff --git a/mods/ITEMS/mcl_brewing/init.lua b/mods/ITEMS/mcl_brewing/init.lua index 1724a982d..bd44b429b 100644 --- a/mods/ITEMS/mcl_brewing/init.lua +++ b/mods/ITEMS/mcl_brewing/init.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator("mcl_brewing") +local S = minetest.get_translator(minetest.get_current_modname()) local function active_brewing_formspec(fuel_percent, brew_percent) @@ -325,7 +325,7 @@ local tiles = { "mcl_brewing_side.png^[transformFX", --front } -local allow_put = function(pos, listname, index, stack, player) +local function allow_put(pos, listname, index, stack, player) local name = player:get_player_name() if minetest.is_protected(pos, name) then minetest.record_protection_violation(pos, name) @@ -335,7 +335,7 @@ local allow_put = function(pos, listname, index, stack, player) end end -local on_put = function(pos, listname, index, stack, player) +local function on_put(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local str = "" @@ -352,18 +352,18 @@ local on_put = function(pos, listname, index, stack, player) --some code here to enforce only potions getting placed on stands end ---[[local after_dig = function(pos, oldnode, oldmetadata, digger) +--[[local function after_dig(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) meta:from_table(oldmetadata) drop_brewing_stand_items(pos, meta) end]] -local on_destruct = function(pos) +local function on_destruct(pos) local meta = minetest.get_meta(pos) drop_brewing_stand_items(pos, meta) end -local allow_take = function(pos, listname, index, stack, player) +local function allow_take(pos, listname, index, stack, player) local name = player:get_player_name() if minetest.is_protected(pos, name) then minetest.record_protection_violation(pos, name) @@ -493,7 +493,6 @@ minetest.register_node("mcl_brewing:stand_100", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -503,7 +502,6 @@ minetest.register_node("mcl_brewing:stand_100", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -511,10 +509,10 @@ minetest.register_node("mcl_brewing:stand_100", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, }) + minetest.register_node("mcl_brewing:stand_010", { description = S("Brewing Stand"), _doc_items_create_entry = false, @@ -567,7 +565,6 @@ minetest.register_node("mcl_brewing:stand_010", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -577,7 +574,6 @@ minetest.register_node("mcl_brewing:stand_010", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -585,10 +581,10 @@ minetest.register_node("mcl_brewing:stand_010", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, }) + minetest.register_node("mcl_brewing:stand_001", { description = S("Brewing Stand"), _doc_items_create_entry = false, @@ -605,7 +601,6 @@ minetest.register_node("mcl_brewing:stand_001", { node_box = { type = "fixed", fixed = { - {-1/16, -5/16, -1/16, 1/16, 8/16, 1/16}, -- heat plume { 2/16, -8/16, -8/16, 8/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base @@ -637,7 +632,6 @@ minetest.register_node("mcl_brewing:stand_001", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -647,7 +641,6 @@ minetest.register_node("mcl_brewing:stand_001", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -655,10 +648,10 @@ minetest.register_node("mcl_brewing:stand_001", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, }) + minetest.register_node("mcl_brewing:stand_110", { description = S("Brewing Stand"), _doc_items_create_entry = false, @@ -675,7 +668,6 @@ minetest.register_node("mcl_brewing:stand_110", { node_box = { type = "fixed", fixed = { - {-1/16, -5/16, -1/16, 1/16, 8/16, 1/16}, -- heat plume { 2/16, -8/16, -8/16, 8/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base @@ -717,7 +709,6 @@ minetest.register_node("mcl_brewing:stand_110", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -727,7 +718,6 @@ minetest.register_node("mcl_brewing:stand_110", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -735,10 +725,10 @@ minetest.register_node("mcl_brewing:stand_110", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, }) + minetest.register_node("mcl_brewing:stand_101", { description = S("Brewing Stand"), _doc_items_create_entry = false, @@ -755,7 +745,6 @@ minetest.register_node("mcl_brewing:stand_101", { node_box = { type = "fixed", fixed = { - {-1/16, -5/16, -1/16, 1/16, 8/16, 1/16}, -- heat plume { 2/16, -8/16, -8/16, 8/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base @@ -793,7 +782,6 @@ minetest.register_node("mcl_brewing:stand_101", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -803,7 +791,6 @@ minetest.register_node("mcl_brewing:stand_101", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -811,10 +798,10 @@ minetest.register_node("mcl_brewing:stand_101", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, }) + minetest.register_node("mcl_brewing:stand_011", { description = S("Brewing Stand"), _doc_items_create_entry = false, @@ -831,7 +818,6 @@ minetest.register_node("mcl_brewing:stand_011", { node_box = { type = "fixed", fixed = { - {-1/16, -5/16, -1/16, 1/16, 8/16, 1/16}, -- heat plume { 2/16, -8/16, -8/16, 8/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base @@ -869,7 +855,6 @@ minetest.register_node("mcl_brewing:stand_011", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -879,7 +864,6 @@ minetest.register_node("mcl_brewing:stand_011", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -887,10 +871,10 @@ minetest.register_node("mcl_brewing:stand_011", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, }) + minetest.register_node("mcl_brewing:stand_111", { description = S("Brewing Stand"), _doc_items_create_entry = false, @@ -907,7 +891,6 @@ minetest.register_node("mcl_brewing:stand_111", { node_box = { type = "fixed", fixed = { - {-1/16, -5/16, -1/16, 1/16, 8/16, 1/16}, -- heat plume { 2/16, -8/16, -8/16, 8/16, -6/16, -2/16}, -- base {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base @@ -952,7 +935,6 @@ minetest.register_node("mcl_brewing:stand_111", { allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, on_metadata_inventory_take = on_put, - on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -962,7 +944,6 @@ minetest.register_node("mcl_brewing:stand_111", { local form = brewing_formspec meta:set_string("formspec", form) end, - on_receive_fields = function(pos, formname, fields, sender) local sender_name = sender:get_player_name() if minetest.is_protected(pos, sender_name) then @@ -970,7 +951,6 @@ minetest.register_node("mcl_brewing:stand_111", { return end end, - on_timer = brewing_stand_timer, on_rotate = on_rotate, })