mirror of
https://github.com/minetest/minetest_game.git
synced 2024-12-22 15:00:18 +01:00
Remove unused and clean up missused variable-value assignments.
* Unused variables * Unused values (assigned to variables, but overwritten before use) * Defining already defined variables instead of reassigning to them.
This commit is contained in:
parent
d7a7456007
commit
4473627de0
@ -100,7 +100,7 @@ end
|
||||
|
||||
local function update_formspecs(finished)
|
||||
local ges = #minetest.get_connected_players()
|
||||
local form_n = ""
|
||||
local form_n
|
||||
local is_majority = (ges / 2) < player_in_bed
|
||||
|
||||
if finished then
|
||||
|
@ -32,8 +32,6 @@ function beds.read_spawns()
|
||||
beds.save_spawns()
|
||||
os.rename(file, file .. ".backup")
|
||||
file = org_file
|
||||
else
|
||||
spawns = {}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -167,7 +167,7 @@ function boat.on_step(self, dtime)
|
||||
|
||||
local p = self.object:getpos()
|
||||
p.y = p.y - 0.5
|
||||
local new_velo = {x = 0, y = 0, z = 0}
|
||||
local new_velo
|
||||
local new_acce = {x = 0, y = 0, z = 0}
|
||||
if not is_water(p) then
|
||||
local nodedef = minetest.registered_nodes[minetest.get_node(p).name]
|
||||
|
@ -174,7 +174,6 @@ minetest.register_on_dieplayer(function(player)
|
||||
pos.z = math.floor(pos.z+0.5)
|
||||
local param2 = minetest.dir_to_facedir(player:get_look_dir())
|
||||
local player_name = player:get_player_name()
|
||||
local player_inv = player:get_inventory()
|
||||
|
||||
if (not may_replace(pos, player)) then
|
||||
if (may_replace({x=pos.x, y=pos.y+1, z=pos.z}, player)) then
|
||||
|
@ -80,8 +80,9 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
|
||||
else
|
||||
-- not buildable to; place the liquid above
|
||||
-- check if the node above can be replaced
|
||||
|
||||
lpos = pointed_thing.above
|
||||
local node = minetest.get_node_or_nil(lpos)
|
||||
node = minetest.get_node_or_nil(lpos)
|
||||
local above_ndef = node and minetest.registered_nodes[node.name]
|
||||
|
||||
if not above_ndef or not above_ndef.buildable_to then
|
||||
|
@ -197,7 +197,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
creative.update_creative_inventory(player_name)
|
||||
creative.set_creative_formspec(player, 0)
|
||||
else
|
||||
local formspec = player:get_inventory_formspec()
|
||||
local start_i = player_inventory[player_name].start_i or 0
|
||||
|
||||
if fields.creative_prev then
|
||||
|
@ -15,7 +15,7 @@ local lpp = 14 -- Lines per book's page
|
||||
local function book_on_use(itemstack, user)
|
||||
local player_name = user:get_player_name()
|
||||
local data = minetest.deserialize(itemstack:get_metadata())
|
||||
local formspec, title, text, owner = "", "", "", player_name
|
||||
local title, text, owner = "", "", player_name
|
||||
local page, page_max, lines, string = 1, 1, {}, ""
|
||||
|
||||
if data then
|
||||
@ -38,6 +38,7 @@ local function book_on_use(itemstack, user)
|
||||
end
|
||||
end
|
||||
|
||||
local formspec
|
||||
if owner == player_name then
|
||||
formspec = "size[8,8]" .. default.gui_bg ..
|
||||
default.gui_bg_img ..
|
||||
@ -152,7 +153,6 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv
|
||||
return
|
||||
end
|
||||
|
||||
local copy = ItemStack("default:book_written")
|
||||
local original
|
||||
local index
|
||||
for i = 1, player:get_inventory():get_size("craft") do
|
||||
|
@ -111,7 +111,6 @@ local function furnace_node_timer(pos, elapsed)
|
||||
local inv = meta:get_inventory()
|
||||
local srclist = inv:get_list("src")
|
||||
local fuellist = inv:get_list("fuel")
|
||||
local dstlist = inv:get_list("dst")
|
||||
|
||||
--
|
||||
-- Cooking
|
||||
@ -172,7 +171,7 @@ local function furnace_node_timer(pos, elapsed)
|
||||
-- Update formspec, infotext and node
|
||||
--
|
||||
local formspec = inactive_formspec
|
||||
local item_state = ""
|
||||
local item_state
|
||||
local item_percent = 0
|
||||
if cookable then
|
||||
item_percent = math.floor(src_time / cooked.time * 100)
|
||||
|
@ -176,8 +176,8 @@ function default.grow_tree(pos, is_apple_tree, bad)
|
||||
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local minp, maxp = vm:read_from_map(
|
||||
{x = pos.x - 2, y = pos.y, z = pos.z - 2},
|
||||
{x = pos.x + 2, y = pos.y + height + 1, z = pos.z + 2}
|
||||
{x = x - 2, y = y, z = z - 2},
|
||||
{x = x + 2, y = y + height + 1, z = z + 2}
|
||||
)
|
||||
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
|
||||
local data = vm:get_data()
|
||||
@ -211,8 +211,8 @@ function default.grow_jungle_tree(pos, bad)
|
||||
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local minp, maxp = vm:read_from_map(
|
||||
{x = pos.x - 3, y = pos.y - 1, z = pos.z - 3},
|
||||
{x = pos.x + 3, y = pos.y + height + 1, z = pos.z + 3}
|
||||
{x = x - 3, y = y - 1, z = z - 3},
|
||||
{x = x + 3, y = y + height + 1, z = z + 3}
|
||||
)
|
||||
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
|
||||
local data = vm:get_data()
|
||||
@ -331,7 +331,7 @@ function default.grow_pine_tree(pos, snow)
|
||||
end
|
||||
end
|
||||
|
||||
local dev = 2
|
||||
dev = 2
|
||||
for yy = my + 1, my + 2 do
|
||||
for zz = z - dev, z + dev do
|
||||
local vi = a:index(x - dev, yy, zz)
|
||||
|
@ -156,7 +156,6 @@ function _doors.door_toggle(pos, node, clicker)
|
||||
end
|
||||
end
|
||||
|
||||
local old = state
|
||||
-- until Lua-5.2 we have no bitwise operators :(
|
||||
if state % 2 == 1 then
|
||||
state = state - 1
|
||||
@ -186,7 +185,6 @@ end
|
||||
local function on_place_node(place_to, newnode,
|
||||
placer, oldnode, itemstack, pointed_thing)
|
||||
-- Run script hook
|
||||
local _, callback
|
||||
for _, callback in ipairs(core.registered_on_placenodes) do
|
||||
-- Deepcopy pos, node and pointed_thing because callback can modify them
|
||||
local place_to_copy = {x = place_to.x, y = place_to.y, z = place_to.z}
|
||||
@ -250,7 +248,7 @@ function doors.register(name, def)
|
||||
inventory_image = def.inventory_image,
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pos = nil
|
||||
local pos
|
||||
|
||||
if not pointed_thing.type == "node" then
|
||||
return itemstack
|
||||
@ -314,7 +312,6 @@ function doors.register(name, def)
|
||||
meta:set_int("state", state)
|
||||
|
||||
if def.protected then
|
||||
local pn = placer:get_player_name()
|
||||
meta:set_string("doors_owner", pn)
|
||||
meta:set_string("infotext", "Owned by " .. pn)
|
||||
end
|
||||
@ -347,7 +344,7 @@ function doors.register(name, def)
|
||||
return true
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local name = ""
|
||||
local name
|
||||
if digger then
|
||||
name = digger:get_player_name()
|
||||
end
|
||||
|
@ -319,11 +319,9 @@ farming.register_plant = function(name, def)
|
||||
nodegroups[pname] = i
|
||||
|
||||
local next_plant = nil
|
||||
local on_timer = nil
|
||||
|
||||
if i < def.steps then
|
||||
next_plant = mname .. ":" .. pname .. "_" .. (i + 1)
|
||||
on_timer = farming.grow_plant
|
||||
lbm_nodes[#lbm_nodes + 1] = mname .. ":" .. pname .. "_" .. i
|
||||
end
|
||||
|
||||
|
@ -153,7 +153,7 @@ local function entity_physics(pos, radius, drops)
|
||||
local dir = vector.normalize(vector.subtract(obj_pos, pos))
|
||||
local moveoff = vector.multiply(dir, dist + 1.0)
|
||||
local newpos = vector.add(pos, moveoff)
|
||||
local newpos = vector.add(newpos, {x = 0, y = 0.2, z = 0})
|
||||
newpos = vector.add(newpos, {x = 0, y = 0.2, z = 0})
|
||||
obj:setpos(newpos)
|
||||
|
||||
obj:set_hp(obj:get_hp() - damage)
|
||||
@ -261,7 +261,7 @@ function tnt.burn(pos)
|
||||
end
|
||||
|
||||
local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast)
|
||||
local pos = vector.round(pos)
|
||||
pos = vector.round(pos)
|
||||
-- scan for adjacent TNT nodes first, and enlarge the explosion
|
||||
local vm1 = VoxelManip()
|
||||
local p1 = vector.subtract(pos, 2)
|
||||
@ -298,11 +298,11 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast)
|
||||
-- perform the explosion
|
||||
local vm = VoxelManip()
|
||||
local pr = PseudoRandom(os.time())
|
||||
local p1 = vector.subtract(pos, radius)
|
||||
local p2 = vector.add(pos, radius)
|
||||
local minp, maxp = vm:read_from_map(p1, p2)
|
||||
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
|
||||
local data = vm:get_data()
|
||||
p1 = vector.subtract(pos, radius)
|
||||
p2 = vector.add(pos, radius)
|
||||
minp, maxp = vm:read_from_map(p1, p2)
|
||||
a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
|
||||
data = vm:get_data()
|
||||
|
||||
local drops = {}
|
||||
local on_blast_queue = {}
|
||||
@ -515,7 +515,7 @@ if enable_tnt then
|
||||
end
|
||||
|
||||
function tnt.register_tnt(def)
|
||||
local name = ""
|
||||
local name
|
||||
if not def.name:find(':') then
|
||||
name = "tnt:" .. def.name
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user