From 30b0a155fb1f116a6fe51cdf482cc5d8e653f503 Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 26 Jun 2016 14:46:15 +0200 Subject: [PATCH] Stop shadowing upvalues and definitions. --- mods/beds/api.lua | 8 ++++---- mods/creative/init.lua | 19 ++++++++++--------- mods/doors/init.lua | 6 +++--- mods/fire/init.lua | 4 ++-- mods/tnt/init.lua | 10 +++++----- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/mods/beds/api.lua b/mods/beds/api.lua index d640a311..3624ea45 100644 --- a/mods/beds/api.lua +++ b/mods/beds/api.lua @@ -59,8 +59,8 @@ function beds.register_bed(name, def) return itemstack end - local def = minetest.registered_nodes[minetest.get_node(pos).name] - if not def or not def.buildable_to then + local node_def = minetest.registered_nodes[minetest.get_node(pos).name] + if not node_def or not node_def.buildable_to then return itemstack end @@ -113,8 +113,8 @@ function beds.register_bed(name, def) end local newp = vector.add(pos, minetest.facedir_to_dir(new_param2)) local node3 = minetest.get_node_or_nil(newp) - local def = node3 and minetest.registered_nodes[node3.name] - if not def or not def.buildable_to then + local node_def = node3 and minetest.registered_nodes[node3.name] + if not node_def or not node_def.buildable_to then return false end if minetest.is_protected(newp, user:get_player_name()) then diff --git a/mods/creative/init.lua b/mods/creative/init.lua index abb11aa5..1e7b4087 100644 --- a/mods/creative/init.lua +++ b/mods/creative/init.lua @@ -5,15 +5,16 @@ local player_inventory = {} local creative_mode = minetest.setting_getbool("creative_mode") -- Create detached creative inventory after loading all mods -creative.init_creative_inventory = function(player) - local player_name = player:get_player_name() - player_inventory[player_name] = {} - player_inventory[player_name].size = 0 - player_inventory[player_name].filter = "" - player_inventory[player_name].start_i = 1 - player_inventory[player_name].tab_id = 2 +creative.init_creative_inventory = function(owner) + local owner_name = owner:get_player_name() + player_inventory[owner_name] = { + size = 0, + filter = "", + start_i = 1, + tab_id = 2, + } - minetest.create_detached_inventory("creative_" .. player_name, { + minetest.create_detached_inventory("creative_" .. owner_name, { allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) if creative_mode and not to_list == "main" then return count @@ -45,7 +46,7 @@ creative.init_creative_inventory = function(player) end, }) - creative.update_creative_inventory(player_name) + creative.update_creative_inventory(owner_name) --print("creative inventory size: " .. player_inventory[player_name].size) end diff --git a/mods/doors/init.lua b/mods/doors/init.lua index f39cedff..7e587dcf 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -344,11 +344,11 @@ function doors.register(name, def) return true end local meta = minetest.get_meta(pos) - local name + local owner_name if digger then - name = digger:get_player_name() + owner_name = digger:get_player_name() end - return meta:get_string("doors_owner") == name + return meta:get_string("doors_owner") == owner_name end if not def.sounds then diff --git a/mods/fire/init.lua b/mods/fire/init.lua index 08b53a89..90e2f0a8 100644 --- a/mods/fire/init.lua +++ b/mods/fire/init.lua @@ -284,8 +284,8 @@ else local p = minetest.find_node_near(p0, 1, {"group:flammable"}) if p then -- remove flammable nodes around flame - local node = minetest.get_node(p) - local def = minetest.registered_nodes[node.name] + local flammable_node = minetest.get_node(p) + local def = minetest.registered_nodes[flammable_node.name] if def.on_burn then def.on_burn(p) else diff --git a/mods/tnt/init.lua b/mods/tnt/init.lua index 023a39b1..c5aa95c9 100644 --- a/mods/tnt/init.lua +++ b/mods/tnt/init.lua @@ -12,7 +12,7 @@ local loss_prob = {} loss_prob["default:cobble"] = 3 loss_prob["default:dirt"] = 4 -local radius = tonumber(minetest.setting_get("tnt_radius") or 3) +local tnt_radius = tonumber(minetest.setting_get("tnt_radius") or 3) -- Fill a list with data for content IDs, after all nodes are registered local cid_data = {} @@ -345,10 +345,10 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast) end end - for _, data in ipairs(on_blast_queue) do - local dist = math.max(1, vector.distance(data.pos, pos)) + for _, queued_data in ipairs(on_blast_queue) do + local dist = math.max(1, vector.distance(queued_data.pos, pos)) local intensity = (radius * radius) / (dist * dist) - local node_drops = data.on_blast(data.pos, intensity) + local node_drops = queued_data.on_blast(queued_data.pos, intensity) if node_drops then for _, item in ipairs(node_drops) do add_drop(drops, item) @@ -589,5 +589,5 @@ end tnt.register_tnt({ name = "tnt:tnt", description = "TNT", - radius = radius, + radius = tnt_radius, })