forked from mtcontrib/pipeworks
Merge branch 'm_unused_code_removal' into 'master'
Remove or comment unused code and declare some variables local See merge request VanessaE/pipeworks!33
This commit is contained in:
commit
2294a23582
@ -106,7 +106,6 @@ local function after_recipe_change(pos, inventory)
|
||||
inventory:set_stack("output", 1, "")
|
||||
return
|
||||
end
|
||||
local recipe_changed = false
|
||||
local recipe = inventory:get_list("recipe")
|
||||
|
||||
local hash = minetest.hash_node_position(pos)
|
||||
|
@ -7,7 +7,7 @@ local DS = minetest.get_translator("default")
|
||||
|
||||
local fs_helpers = pipeworks.fs_helpers
|
||||
|
||||
tube_entry = "^pipeworks_tube_connection_stony.png"
|
||||
local tube_entry = "^pipeworks_tube_connection_stony.png"
|
||||
|
||||
local function active_formspec(fuel_percent, item_percent, pos, meta)
|
||||
local formspec =
|
||||
|
18
devices.lua
18
devices.lua
@ -10,7 +10,7 @@ function pipeworks.fix_after_rotation(pos, node, user, mode, new_param2)
|
||||
|
||||
if string.find(node.name, "spigot") then new_param2 = new_param2 % 4 end
|
||||
|
||||
newnode = string.gsub(node.name, "_on", "_off")
|
||||
local newnode = string.gsub(node.name, "_on", "_off")
|
||||
minetest.swap_node(pos, { name = newnode, param2 = new_param2 })
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
|
||||
@ -20,7 +20,7 @@ end
|
||||
function pipeworks.rotate_on_place(itemstack, placer, pointed_thing)
|
||||
|
||||
local playername = placer:get_player_name()
|
||||
if not minetest.is_protected(pointed_thing.under, playername)
|
||||
if not minetest.is_protected(pointed_thing.under, playername)
|
||||
and not minetest.is_protected(pointed_thing.above, playername) then
|
||||
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
@ -36,9 +36,7 @@ function pipeworks.rotate_on_place(itemstack, placer, pointed_thing)
|
||||
local under = pointed_thing.under
|
||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local undernode = minetest.get_node(under)
|
||||
local abovenode = minetest.get_node(above)
|
||||
local uname = undernode.name
|
||||
local aname = abovenode.name
|
||||
local isabove = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
|
||||
local pos1 = above
|
||||
|
||||
@ -105,6 +103,7 @@ if minetest.get_modpath("mesecons") then
|
||||
}
|
||||
end
|
||||
|
||||
--[[
|
||||
local pipes_devicelist = {
|
||||
"pump",
|
||||
"valve",
|
||||
@ -120,14 +119,15 @@ local pipes_devicelist = {
|
||||
"storage_tank_9",
|
||||
"storage_tank_10"
|
||||
}
|
||||
--]]
|
||||
|
||||
-- Now define the nodes.
|
||||
|
||||
local states = { "on", "off" }
|
||||
local dgroups = ""
|
||||
|
||||
for s in ipairs(states) do
|
||||
|
||||
local dgroups
|
||||
if states[s] == "off" then
|
||||
dgroups = {snappy=3, pipe=1}
|
||||
else
|
||||
@ -465,7 +465,7 @@ minetest.register_node(nodename_sensor_empty, {
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
if mesecon then
|
||||
mesecon.receptor_off(pos, rules)
|
||||
mesecon.receptor_off(pos, rules)
|
||||
end
|
||||
end,
|
||||
selection_box = {
|
||||
@ -504,7 +504,7 @@ minetest.register_node(nodename_sensor_loaded, {
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
if mesecon then
|
||||
mesecon.receptor_on(pos, rules)
|
||||
mesecon.receptor_on(pos, rules)
|
||||
end
|
||||
end,
|
||||
selection_box = {
|
||||
@ -626,7 +626,7 @@ minetest.register_node(nodename_fountain_empty, {
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
if mesecon then
|
||||
mesecon.receptor_on(pos, rules)
|
||||
mesecon.receptor_on(pos, rules)
|
||||
end
|
||||
end,
|
||||
selection_box = {
|
||||
@ -661,7 +661,7 @@ minetest.register_node(nodename_fountain_loaded, {
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
if mesecon then
|
||||
mesecon.receptor_on(pos, rules)
|
||||
mesecon.receptor_on(pos, rules)
|
||||
end
|
||||
end,
|
||||
selection_box = {
|
||||
|
@ -1,10 +1,6 @@
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local fs_helpers = pipeworks.fs_helpers
|
||||
|
||||
local function delay(x)
|
||||
return (function() return x end)
|
||||
end
|
||||
|
||||
local function set_filter_infotext(data, meta)
|
||||
local infotext = S("@1 Filter-Injector", data.wise_desc)
|
||||
if meta:get_int("slotseq_mode") == 2 then
|
||||
|
2
init.lua
2
init.lua
@ -6,8 +6,6 @@
|
||||
|
||||
pipeworks = {}
|
||||
|
||||
local DEBUG = false
|
||||
|
||||
pipeworks.worldpath = minetest.get_worldpath()
|
||||
pipeworks.modpath = minetest.get_modpath("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
|
@ -194,6 +194,7 @@ minetest.register_entity("pipeworks:tubed_item", {
|
||||
|
||||
from_data = function(self, itemstring)
|
||||
local stack = ItemStack(itemstring)
|
||||
--[[
|
||||
local itemtable = stack:to_table()
|
||||
local itemname = nil
|
||||
if itemtable then
|
||||
@ -205,6 +206,7 @@ minetest.register_entity("pipeworks:tubed_item", {
|
||||
item_texture = minetest.registered_items[itemname].inventory_image
|
||||
item_type = minetest.registered_items[itemname].type
|
||||
end
|
||||
--]]
|
||||
self.object:set_properties({
|
||||
is_visible = true,
|
||||
textures = {stack:get_name()}
|
||||
|
20
pipes.lua
20
pipes.lua
@ -11,11 +11,11 @@ local new_flow_logic_register = pipeworks.flowables.register
|
||||
local polys = ""
|
||||
if pipeworks.enable_lowpoly then polys = "_lowpoly" end
|
||||
|
||||
local vti = {4, 3, 2, 1, 6, 5}
|
||||
--~ local vti = {4, 3, 2, 1, 6, 5}
|
||||
local cconnects = {{}, {1}, {1, 2}, {1, 3}, {1, 3, 5}, {1, 2, 3}, {1, 2, 3, 5}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}}
|
||||
for index, connects in ipairs(cconnects) do
|
||||
local outsel = {}
|
||||
|
||||
|
||||
local jx = 0
|
||||
local jy = 0
|
||||
local jz = 0
|
||||
@ -30,11 +30,13 @@ for index, connects in ipairs(cconnects) do
|
||||
table.insert(outsel, pipeworks.pipe_selectboxes[v])
|
||||
end
|
||||
|
||||
--[[
|
||||
if #connects == 1 then
|
||||
local v = connects[1]
|
||||
v = v-1 + 2*(v%2) -- Opposite side
|
||||
end
|
||||
|
||||
--]]
|
||||
|
||||
local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1}
|
||||
local pipedesc = S("Pipe Segment").." "..dump(connects)
|
||||
|
||||
@ -42,11 +44,11 @@ for index, connects in ipairs(cconnects) do
|
||||
pgroups = {snappy = 3, tube = 1}
|
||||
pipedesc = S("Pipe Segment")
|
||||
end
|
||||
|
||||
|
||||
local outimg_e = { "pipeworks_pipe_plain.png" }
|
||||
local outimg_l = { "pipeworks_pipe_plain.png" }
|
||||
|
||||
if index == 3 then
|
||||
if index == 3 then
|
||||
outimg_e = { "pipeworks_pipe_3_empty.png" }
|
||||
outimg_l = { "pipeworks_pipe_3_loaded.png" }
|
||||
end
|
||||
@ -88,7 +90,7 @@ for index, connects in ipairs(cconnects) do
|
||||
check_for_horiz_pole = pipeworks.check_for_horiz_pipe,
|
||||
pipenumber = index
|
||||
})
|
||||
|
||||
|
||||
local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1}
|
||||
|
||||
minetest.register_node("pipeworks:pipe_"..index.."_loaded", {
|
||||
@ -123,7 +125,7 @@ for index, connects in ipairs(cconnects) do
|
||||
check_for_horiz_pole = pipeworks.check_for_horiz_pipe,
|
||||
pipenumber = index
|
||||
})
|
||||
|
||||
|
||||
local emptypipe = "pipeworks:pipe_"..index.."_empty"
|
||||
local fullpipe = "pipeworks:pipe_"..index.."_loaded"
|
||||
table.insert(pipes_empty_nodenames, emptypipe)
|
||||
@ -239,7 +241,7 @@ minetest.register_abm({
|
||||
nodenames = {"pipeworks:spigot","pipeworks:spigot_pouring"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
pipeworks.spigot_check(pos,node)
|
||||
end
|
||||
})
|
||||
@ -248,7 +250,7 @@ minetest.register_abm({
|
||||
nodenames = {"pipeworks:fountainhead","pipeworks:fountainhead_pouring"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
pipeworks.fountainhead_check(pos,node)
|
||||
end
|
||||
})
|
||||
|
@ -29,7 +29,7 @@ end
|
||||
|
||||
|
||||
|
||||
local formatvec = function(vec) local sep="," return "("..tostring(vec.x)..sep..tostring(vec.y)..sep..tostring(vec.z)..")" end
|
||||
--~ local formatvec = function(vec) local sep="," return "("..tostring(vec.x)..sep..tostring(vec.y)..sep..tostring(vec.z)..")" end
|
||||
|
||||
|
||||
|
||||
@ -69,11 +69,13 @@ end
|
||||
|
||||
|
||||
-- logging is unreliable when something is crashing...
|
||||
--[[
|
||||
local nilexplode = function(caller, label, value)
|
||||
if value == nil then
|
||||
error(caller..": "..label.." was nil")
|
||||
end
|
||||
end
|
||||
--]]
|
||||
|
||||
|
||||
|
||||
@ -185,13 +187,12 @@ flowlogic.balance_pressure = function(pos, node, currentpressure)
|
||||
-- local dname = "flowlogic.balance_pressure()@"..formatvec(pos).." "
|
||||
-- check the pressure of all nearby flowable nodes, and average it out.
|
||||
|
||||
-- pressure handles to average over
|
||||
local connections = {}
|
||||
-- unconditionally include self in nodes to average over.
|
||||
-- result of averaging will be returned as new pressure for main flow logic callback
|
||||
local totalv = currentpressure
|
||||
local totalc = 1
|
||||
|
||||
-- pressure handles to average over
|
||||
local connections = get_neighbour_positions(pos, node)
|
||||
|
||||
-- for each neighbour, add neighbour's pressure to the total to balance out
|
||||
@ -287,7 +288,7 @@ flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputd
|
||||
local upper = outputdef.upper
|
||||
local lower = outputdef.lower
|
||||
local result = currentpressure
|
||||
local threshold = nil
|
||||
local threshold
|
||||
if finitemode then threshold = lower else threshold = upper end
|
||||
if currentpressure > threshold then
|
||||
local takenpressure = outputdef.outputfn(pos, node, currentpressure, finitemode)
|
||||
|
@ -26,8 +26,8 @@ local insertbase = function(nodename)
|
||||
end
|
||||
|
||||
local regwarning = function(kind, nodename)
|
||||
local tail = ""
|
||||
if pipeworks.toggles.pipe_mode ~= "pressure" then tail = " but pressure logic not enabled" end
|
||||
--~ local tail = ""
|
||||
--~ if pipeworks.toggles.pipe_mode ~= "pressure" then tail = " but pressure logic not enabled" end
|
||||
--pipeworks.logger(kind.." flow logic registry requested for "..nodename..tail)
|
||||
end
|
||||
|
||||
|
@ -1,10 +1,6 @@
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local assumed_eye_pos = vector.new(0, 1.5, 0)
|
||||
|
||||
local function vector_copy(v)
|
||||
return { x = v.x, y = v.y, z = v.z }
|
||||
end
|
||||
|
||||
local function delay(x)
|
||||
return (function() return x end)
|
||||
end
|
||||
@ -353,7 +349,7 @@ if pipeworks.enable_node_breaker then
|
||||
{pos=pointed_thing.under, gain=sound.gain})
|
||||
end
|
||||
wieldstack = virtplayer:get_wielded_item()
|
||||
else
|
||||
--~ else
|
||||
--pipeworks.logger(dname.."couldn't dig node!")
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user