mirror of
https://github.com/mt-mods/pipeworks.git
synced 2025-06-29 23:00:49 +02:00
Compare commits
6 Commits
2021-01-30
...
2021-02-19
Author | SHA1 | Date | |
---|---|---|---|
a735d1a155 | |||
a2c0dd1130 | |||
f0ef43823c | |||
17a602a5a1 | |||
2294a23582 | |||
b2d2ccbcba |
@ -47,7 +47,7 @@ local function autocraft(inventory, craft)
|
|||||||
end
|
end
|
||||||
-- consume material
|
-- consume material
|
||||||
for itemname, number in pairs(consumption) do
|
for itemname, number in pairs(consumption) do
|
||||||
for i = 1, number do -- We have to do that since remove_item does not work if count > stack_max
|
for _ = 1, number do -- We have to do that since remove_item does not work if count > stack_max
|
||||||
inventory:remove_item("src", ItemStack(itemname))
|
inventory:remove_item("src", ItemStack(itemname))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -73,7 +73,7 @@ local function run_autocrafter(pos, elapsed)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
for step = 1, math.floor(elapsed/craft_time) do
|
for _ = 1, math.floor(elapsed/craft_time) do
|
||||||
local continue = autocraft(inventory, craft)
|
local continue = autocraft(inventory, craft)
|
||||||
if not continue then return false end
|
if not continue then return false end
|
||||||
end
|
end
|
||||||
@ -106,7 +106,6 @@ local function after_recipe_change(pos, inventory)
|
|||||||
inventory:set_stack("output", 1, "")
|
inventory:set_stack("output", 1, "")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local recipe_changed = false
|
|
||||||
local recipe = inventory:get_list("recipe")
|
local recipe = inventory:get_list("recipe")
|
||||||
|
|
||||||
local hash = minetest.hash_node_position(pos)
|
local hash = minetest.hash_node_position(pos)
|
||||||
|
@ -81,7 +81,7 @@ local function tube_autoroute(pos)
|
|||||||
local basename = nodedef.basename
|
local basename = nodedef.basename
|
||||||
if nodedef.style == "old" then
|
if nodedef.style == "old" then
|
||||||
local nsurround = ""
|
local nsurround = ""
|
||||||
for i, n in ipairs(active) do
|
for _, n in ipairs(active) do
|
||||||
nsurround = nsurround..n
|
nsurround = nsurround..n
|
||||||
end
|
end
|
||||||
nctr.name = basename.."_"..nsurround
|
nctr.name = basename.."_"..nsurround
|
||||||
|
@ -114,7 +114,7 @@ local fs_helpers = {}
|
|||||||
pipeworks.fs_helpers = fs_helpers
|
pipeworks.fs_helpers = fs_helpers
|
||||||
function fs_helpers.on_receive_fields(pos, fields)
|
function fs_helpers.on_receive_fields(pos, fields)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
for field, value in pairs(fields) do
|
for field in pairs(fields) do
|
||||||
if pipeworks.string_startswith(field, "fs_helpers_cycling:") then
|
if pipeworks.string_startswith(field, "fs_helpers_cycling:") then
|
||||||
local l = field:split(":")
|
local l = field:split(":")
|
||||||
local new_value = tonumber(l[2])
|
local new_value = tonumber(l[2])
|
||||||
@ -223,7 +223,7 @@ function pipeworks.create_fake_player(def, is_dynamic)
|
|||||||
return self._inventory:set_stack(def.wield_list,
|
return self._inventory:set_stack(def.wield_list,
|
||||||
self._wield_index, item)
|
self._wield_index, item)
|
||||||
end
|
end
|
||||||
_wielded_item = ItemStack(item)
|
self._wielded_item = ItemStack(item)
|
||||||
end,
|
end,
|
||||||
get_wielded_item = function(self, item)
|
get_wielded_item = function(self, item)
|
||||||
if self._inventory and def.wield_list then
|
if self._inventory and def.wield_list then
|
||||||
@ -242,17 +242,18 @@ function pipeworks.create_fake_player(def, is_dynamic)
|
|||||||
set_bone_position = delay(),
|
set_bone_position = delay(),
|
||||||
hud_change = delay(),
|
hud_change = delay(),
|
||||||
}
|
}
|
||||||
local _trash
|
|
||||||
-- Getter & setter functions
|
-- Getter & setter functions
|
||||||
p.get_inventory_formspec, p.set_inventory_formspec
|
p.get_inventory_formspec, p.set_inventory_formspec
|
||||||
= get_set_wrap("formspec", is_dynamic)
|
= get_set_wrap("formspec", is_dynamic)
|
||||||
p.get_breath, p.set_breath = get_set_wrap("breath", is_dynamic)
|
p.get_breath, p.set_breath = get_set_wrap("breath", is_dynamic)
|
||||||
p.get_hp, p.set_hp = get_set_wrap("hp", is_dynamic)
|
p.get_hp, p.set_hp = get_set_wrap("hp", is_dynamic)
|
||||||
p.get_pos, p.set_pos = get_set_wrap("pos", is_dynamic)
|
p.get_pos, p.set_pos = get_set_wrap("pos", is_dynamic)
|
||||||
_trash, p.move_to = get_set_wrap("pos", is_dynamic)
|
|
||||||
p.get_wield_index, p.set_wield_index = get_set_wrap("wield_index", true)
|
p.get_wield_index, p.set_wield_index = get_set_wrap("wield_index", true)
|
||||||
p.get_properties, p.set_properties = get_set_wrap("properties", false)
|
p.get_properties, p.set_properties = get_set_wrap("properties", false)
|
||||||
|
|
||||||
|
-- For players, move_to and get_pos do the same
|
||||||
|
p.move_to = p.get_pos
|
||||||
|
|
||||||
-- Backwards compatibilty
|
-- Backwards compatibilty
|
||||||
p.getpos = p.get_pos
|
p.getpos = p.get_pos
|
||||||
p.setpos = p.set_pos
|
p.setpos = p.set_pos
|
||||||
|
@ -65,7 +65,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
|
|
||||||
open_chests[pn] = nil
|
open_chests[pn] = nil
|
||||||
for k, v in pairs(open_chests) do
|
for _, v in pairs(open_chests) do
|
||||||
if v.pos.x == pos.x and v.pos.y == pos.y and v.pos.z == pos.z then
|
if v.pos.x == pos.x and v.pos.y == pos.y and v.pos.z == pos.z then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -230,7 +230,7 @@ override.tiles = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Add the extra groups
|
-- Add the extra groups
|
||||||
for i,v in ipairs({override_protected, override, override_open, override_protected_open}) do
|
for _,v in ipairs({override_protected, override, override_open, override_protected_open}) do
|
||||||
v.groups.tubedevice = 1
|
v.groups.tubedevice = 1
|
||||||
v.groups.tubedevice_receiver = 1
|
v.groups.tubedevice_receiver = 1
|
||||||
end
|
end
|
||||||
|
@ -7,7 +7,7 @@ local DS = minetest.get_translator("default")
|
|||||||
|
|
||||||
local fs_helpers = pipeworks.fs_helpers
|
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 function active_formspec(fuel_percent, item_percent, pos, meta)
|
||||||
local formspec =
|
local formspec =
|
||||||
|
16
devices.lua
16
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
|
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 })
|
minetest.swap_node(pos, { name = newnode, param2 = new_param2 })
|
||||||
pipeworks.scan_for_pipe_objects(pos)
|
pipeworks.scan_for_pipe_objects(pos)
|
||||||
|
|
||||||
@ -36,9 +36,7 @@ function pipeworks.rotate_on_place(itemstack, placer, pointed_thing)
|
|||||||
local under = pointed_thing.under
|
local under = pointed_thing.under
|
||||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||||
local undernode = minetest.get_node(under)
|
local undernode = minetest.get_node(under)
|
||||||
local abovenode = minetest.get_node(above)
|
|
||||||
local uname = undernode.name
|
local uname = undernode.name
|
||||||
local aname = abovenode.name
|
|
||||||
local isabove = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
|
local isabove = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
|
||||||
local pos1 = above
|
local pos1 = above
|
||||||
|
|
||||||
@ -105,6 +103,7 @@ if minetest.get_modpath("mesecons") then
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
local pipes_devicelist = {
|
local pipes_devicelist = {
|
||||||
"pump",
|
"pump",
|
||||||
"valve",
|
"valve",
|
||||||
@ -120,14 +119,15 @@ local pipes_devicelist = {
|
|||||||
"storage_tank_9",
|
"storage_tank_9",
|
||||||
"storage_tank_10"
|
"storage_tank_10"
|
||||||
}
|
}
|
||||||
|
--]]
|
||||||
|
|
||||||
-- Now define the nodes.
|
-- Now define the nodes.
|
||||||
|
|
||||||
local states = { "on", "off" }
|
local states = { "on", "off" }
|
||||||
local dgroups = ""
|
|
||||||
|
|
||||||
for s in ipairs(states) do
|
for s in ipairs(states) do
|
||||||
|
|
||||||
|
local dgroups
|
||||||
if states[s] == "off" then
|
if states[s] == "off" then
|
||||||
dgroups = {snappy=3, pipe=1}
|
dgroups = {snappy=3, pipe=1}
|
||||||
else
|
else
|
||||||
@ -465,7 +465,7 @@ minetest.register_node(nodename_sensor_empty, {
|
|||||||
end,
|
end,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
if mesecon then
|
if mesecon then
|
||||||
mesecon.receptor_off(pos, rules)
|
mesecon.receptor_off(pos, pipeworks.mesecons_rules)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
@ -504,7 +504,7 @@ minetest.register_node(nodename_sensor_loaded, {
|
|||||||
end,
|
end,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
if mesecon then
|
if mesecon then
|
||||||
mesecon.receptor_on(pos, rules)
|
mesecon.receptor_on(pos, pipeworks.mesecons_rules)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
@ -626,7 +626,7 @@ minetest.register_node(nodename_fountain_empty, {
|
|||||||
end,
|
end,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
if mesecon then
|
if mesecon then
|
||||||
mesecon.receptor_on(pos, rules)
|
mesecon.receptor_on(pos, pipeworks.mesecons_rules)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
@ -661,7 +661,7 @@ minetest.register_node(nodename_fountain_loaded, {
|
|||||||
end,
|
end,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
if mesecon then
|
if mesecon then
|
||||||
mesecon.receptor_on(pos, rules)
|
mesecon.receptor_on(pos, pipeworks.mesecons_rules)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
local S = minetest.get_translator("pipeworks")
|
local S = minetest.get_translator("pipeworks")
|
||||||
local fs_helpers = pipeworks.fs_helpers
|
local fs_helpers = pipeworks.fs_helpers
|
||||||
|
|
||||||
local function delay(x)
|
|
||||||
return (function() return x end)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function set_filter_infotext(data, meta)
|
local function set_filter_infotext(data, meta)
|
||||||
local infotext = S("@1 Filter-Injector", data.wise_desc)
|
local infotext = S("@1 Filter-Injector", data.wise_desc)
|
||||||
if meta:get_int("slotseq_mode") == 2 then
|
if meta:get_int("slotseq_mode") == 2 then
|
||||||
@ -326,7 +322,8 @@ local function punch_filter(data, filtpos, filtnode, msg)
|
|||||||
end
|
end
|
||||||
local pos = vector.add(frompos, vector.multiply(dir, 1.4))
|
local pos = vector.add(frompos, vector.multiply(dir, 1.4))
|
||||||
local start_pos = vector.add(frompos, dir)
|
local start_pos = vector.add(frompos, dir)
|
||||||
local item1 = pipeworks.tube_inject_item(pos, start_pos, dir, item, fakePlayer:get_player_name())
|
pipeworks.tube_inject_item(pos, start_pos, dir, item,
|
||||||
|
fakePlayer:get_player_name())
|
||||||
return true -- only fire one item, please
|
return true -- only fire one item, please
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
2
init.lua
2
init.lua
@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
pipeworks = {}
|
pipeworks = {}
|
||||||
|
|
||||||
local DEBUG = false
|
|
||||||
|
|
||||||
pipeworks.worldpath = minetest.get_worldpath()
|
pipeworks.worldpath = minetest.get_worldpath()
|
||||||
pipeworks.modpath = minetest.get_modpath("pipeworks")
|
pipeworks.modpath = minetest.get_modpath("pipeworks")
|
||||||
local S = minetest.get_translator("pipeworks")
|
local S = minetest.get_translator("pipeworks")
|
||||||
|
@ -42,7 +42,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
tube_item_count = {}
|
tube_item_count = {}
|
||||||
for id, entity in pairs(luaentity.entities) do
|
for _, entity in pairs(luaentity.entities) do
|
||||||
if entity.name == "pipeworks:tubed_item" then
|
if entity.name == "pipeworks:tubed_item" then
|
||||||
local h = minetest.hash_node_position(vector.round(entity._pos))
|
local h = minetest.hash_node_position(vector.round(entity._pos))
|
||||||
tube_item_count[h] = (tube_item_count[h] or 0) + 1
|
tube_item_count[h] = (tube_item_count[h] or 0) + 1
|
||||||
@ -194,6 +194,7 @@ minetest.register_entity("pipeworks:tubed_item", {
|
|||||||
|
|
||||||
from_data = function(self, itemstring)
|
from_data = function(self, itemstring)
|
||||||
local stack = ItemStack(itemstring)
|
local stack = ItemStack(itemstring)
|
||||||
|
--[[
|
||||||
local itemtable = stack:to_table()
|
local itemtable = stack:to_table()
|
||||||
local itemname = nil
|
local itemname = nil
|
||||||
if itemtable then
|
if itemtable then
|
||||||
@ -205,6 +206,7 @@ minetest.register_entity("pipeworks:tubed_item", {
|
|||||||
item_texture = minetest.registered_items[itemname].inventory_image
|
item_texture = minetest.registered_items[itemname].inventory_image
|
||||||
item_type = minetest.registered_items[itemname].type
|
item_type = minetest.registered_items[itemname].type
|
||||||
end
|
end
|
||||||
|
--]]
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
is_visible = true,
|
is_visible = true,
|
||||||
textures = {stack:get_name()}
|
textures = {stack:get_name()}
|
||||||
@ -391,7 +393,7 @@ if minetest.get_modpath("mesecons_mvps") then
|
|||||||
for _, n in ipairs(moved_nodes) do
|
for _, n in ipairs(moved_nodes) do
|
||||||
moved[minetest.hash_node_position(n.oldpos)] = vector.subtract(n.pos, n.oldpos)
|
moved[minetest.hash_node_position(n.oldpos)] = vector.subtract(n.pos, n.oldpos)
|
||||||
end
|
end
|
||||||
for id, entity in pairs(luaentity.entities) do
|
for _, entity in pairs(luaentity.entities) do
|
||||||
if entity.name == "pipeworks:tubed_item" then
|
if entity.name == "pipeworks:tubed_item" then
|
||||||
local pos = entity:get_pos()
|
local pos = entity:get_pos()
|
||||||
local rpos = vector.round(pos)
|
local rpos = vector.round(pos)
|
||||||
|
@ -969,7 +969,7 @@ for white = 0, 1 do
|
|||||||
can_go = function(pos, node, velocity, stack)
|
can_go = function(pos, node, velocity, stack)
|
||||||
local src = {name = nil}
|
local src = {name = nil}
|
||||||
-- add color of the incoming tube explicitly; referring to rules, in case they change later
|
-- add color of the incoming tube explicitly; referring to rules, in case they change later
|
||||||
for color, rule in pairs(rules) do
|
for _, rule in pairs(rules) do
|
||||||
if (-velocity.x == rule.x and -velocity.y == rule.y and -velocity.z == rule.z) then
|
if (-velocity.x == rule.x and -velocity.y == rule.y and -velocity.z == rule.z) then
|
||||||
src.name = rule.name
|
src.name = rule.name
|
||||||
break
|
break
|
||||||
@ -993,7 +993,7 @@ for white = 0, 1 do
|
|||||||
on_blast = function(pos, intensity)
|
on_blast = function(pos, intensity)
|
||||||
if not intensity or intensity > 1 + 3^0.5 then
|
if not intensity or intensity > 1 + 3^0.5 then
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
return {string.format("%s_%s", name, dropname)}
|
return
|
||||||
end
|
end
|
||||||
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||||
pipeworks.scan_for_tube_objects(pos)
|
pipeworks.scan_for_tube_objects(pos)
|
||||||
@ -1070,7 +1070,7 @@ minetest.register_node(BASENAME .. "_burnt", {
|
|||||||
on_blast = function(pos, intensity)
|
on_blast = function(pos, intensity)
|
||||||
if not intensity or intensity > 1 + 3^0.5 then
|
if not intensity or intensity > 1 + 3^0.5 then
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
return {string.format("%s_%s", name, dropname)}
|
return
|
||||||
end
|
end
|
||||||
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||||
pipeworks.scan_for_tube_objects(pos)
|
pipeworks.scan_for_tube_objects(pos)
|
||||||
|
@ -318,19 +318,20 @@ end
|
|||||||
function luaentity.get_objects_inside_radius(pos, radius)
|
function luaentity.get_objects_inside_radius(pos, radius)
|
||||||
local objects = {}
|
local objects = {}
|
||||||
local index = 1
|
local index = 1
|
||||||
for id, entity in pairs(luaentity.entities) do
|
for _, entity in pairs(luaentity.entities) do
|
||||||
if vector.distance(pos, entity:get_pos()) <= radius then
|
if vector.distance(pos, entity:get_pos()) <= radius then
|
||||||
objects[index] = entity
|
objects[index] = entity
|
||||||
index = index + 1
|
index = index + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return objects
|
||||||
end
|
end
|
||||||
|
|
||||||
local move_entities_globalstep_part2 = function(dtime)
|
local move_entities_globalstep_part2 = function(dtime)
|
||||||
if not luaentity.entities then
|
if not luaentity.entities then
|
||||||
luaentity.entities = read_entities()
|
luaentity.entities = read_entities()
|
||||||
end
|
end
|
||||||
for id, entity in pairs(luaentity.entities) do
|
for _, entity in pairs(luaentity.entities) do
|
||||||
local master = entity._attached_entities_master
|
local master = entity._attached_entities_master
|
||||||
local master_def = master and entity._attached_entities[master]
|
local master_def = master and entity._attached_entities[master]
|
||||||
local master_entity = master_def and master_def.entity
|
local master_entity = master_def and master_def.entity
|
||||||
|
@ -11,7 +11,7 @@ local new_flow_logic_register = pipeworks.flowables.register
|
|||||||
local polys = ""
|
local polys = ""
|
||||||
if pipeworks.enable_lowpoly then polys = "_lowpoly" end
|
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}}
|
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
|
for index, connects in ipairs(cconnects) do
|
||||||
local outsel = {}
|
local outsel = {}
|
||||||
@ -30,10 +30,12 @@ for index, connects in ipairs(cconnects) do
|
|||||||
table.insert(outsel, pipeworks.pipe_selectboxes[v])
|
table.insert(outsel, pipeworks.pipe_selectboxes[v])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
if #connects == 1 then
|
if #connects == 1 then
|
||||||
local v = connects[1]
|
local v = connects[1]
|
||||||
v = v-1 + 2*(v%2) -- Opposite side
|
v = v-1 + 2*(v%2) -- Opposite side
|
||||||
end
|
end
|
||||||
|
--]]
|
||||||
|
|
||||||
local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1}
|
local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1}
|
||||||
local pipedesc = S("Pipe Segment").." "..dump(connects)
|
local pipedesc = S("Pipe Segment").." "..dump(connects)
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ local formatvec = function(vec) local sep="," return "("..tostring(vec.x)..sep..
|
|||||||
local check_for_liquids_v2 = function(pos, limit)
|
local check_for_liquids_v2 = function(pos, limit)
|
||||||
local coords = make_coords_offsets(pos, false)
|
local coords = make_coords_offsets(pos, false)
|
||||||
local total = 0
|
local total = 0
|
||||||
for index, tpos in ipairs(coords) do
|
for _, tpos in ipairs(coords) do
|
||||||
if total >= limit then break end
|
if total >= limit then break end
|
||||||
local name = minetest.get_node(tpos).name
|
local name = minetest.get_node(tpos).name
|
||||||
if name == "default:water_source" then
|
if name == "default:water_source" then
|
||||||
@ -69,11 +69,13 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- logging is unreliable when something is crashing...
|
-- logging is unreliable when something is crashing...
|
||||||
|
--[[
|
||||||
local nilexplode = function(caller, label, value)
|
local nilexplode = function(caller, label, value)
|
||||||
if value == nil then
|
if value == nil then
|
||||||
error(caller..": "..label.." was nil")
|
error(caller..": "..label.." was nil")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -151,7 +153,7 @@ local get_neighbour_positions = function(pos, node)
|
|||||||
|
|
||||||
-- then, check each possible neighbour to see if they can be reached from this node.
|
-- then, check each possible neighbour to see if they can be reached from this node.
|
||||||
local connections = {}
|
local connections = {}
|
||||||
for index, offset in ipairs(candidates) do
|
for _, offset in ipairs(candidates) do
|
||||||
local npos = vector.add(pos, offset)
|
local npos = vector.add(pos, offset)
|
||||||
local neighbour = minetest.get_node(npos)
|
local neighbour = minetest.get_node(npos)
|
||||||
local nodename = neighbour.name
|
local nodename = neighbour.name
|
||||||
@ -185,13 +187,12 @@ flowlogic.balance_pressure = function(pos, node, currentpressure)
|
|||||||
-- local dname = "flowlogic.balance_pressure()@"..formatvec(pos).." "
|
-- local dname = "flowlogic.balance_pressure()@"..formatvec(pos).." "
|
||||||
-- check the pressure of all nearby flowable nodes, and average it out.
|
-- 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.
|
-- unconditionally include self in nodes to average over.
|
||||||
-- result of averaging will be returned as new pressure for main flow logic callback
|
-- result of averaging will be returned as new pressure for main flow logic callback
|
||||||
local totalv = currentpressure
|
local totalv = currentpressure
|
||||||
local totalc = 1
|
local totalc = 1
|
||||||
|
|
||||||
|
-- pressure handles to average over
|
||||||
local connections = get_neighbour_positions(pos, node)
|
local connections = get_neighbour_positions(pos, node)
|
||||||
|
|
||||||
-- for each neighbour, add neighbour's pressure to the total to balance out
|
-- 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 upper = outputdef.upper
|
||||||
local lower = outputdef.lower
|
local lower = outputdef.lower
|
||||||
local result = currentpressure
|
local result = currentpressure
|
||||||
local threshold = nil
|
local threshold
|
||||||
if finitemode then threshold = lower else threshold = upper end
|
if finitemode then threshold = lower else threshold = upper end
|
||||||
if currentpressure > threshold then
|
if currentpressure > threshold then
|
||||||
local takenpressure = outputdef.outputfn(pos, node, currentpressure, finitemode)
|
local takenpressure = outputdef.outputfn(pos, node, currentpressure, finitemode)
|
||||||
@ -316,7 +317,7 @@ flowlogic.run_transition = function(node, currentpressure)
|
|||||||
local nodename_prev = simplesetdef[1].nodename
|
local nodename_prev = simplesetdef[1].nodename
|
||||||
local result_nodename = node.name
|
local result_nodename = node.name
|
||||||
|
|
||||||
for index, element in ipairs(simplesetdef) do
|
for _, element in ipairs(simplesetdef) do
|
||||||
-- find the highest element that is below the current pressure.
|
-- find the highest element that is below the current pressure.
|
||||||
local threshold = element.threshold
|
local threshold = element.threshold
|
||||||
if threshold > currentpressure then
|
if threshold > currentpressure then
|
||||||
@ -338,7 +339,9 @@ flowlogic.run_transition = function(node, currentpressure)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not found then
|
if not found then
|
||||||
pipeworks.logger("flowlogic.run_transition() BUG no transition definitions found! nodename="..nodename.." currentpressure="..tostring(currentpressure))
|
pipeworks.logger("flowlogic.run_transition() BUG no transition " ..
|
||||||
|
"definitions found! node.name=" .. node.name ..
|
||||||
|
" currentpressure=" .. tostring(currentpressure))
|
||||||
end
|
end
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -26,8 +26,8 @@ local insertbase = function(nodename)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local regwarning = function(kind, nodename)
|
local regwarning = function(kind, nodename)
|
||||||
local tail = ""
|
--~ local tail = ""
|
||||||
if pipeworks.toggles.pipe_mode ~= "pressure" then tail = " but pressure logic not enabled" end
|
--~ if pipeworks.toggles.pipe_mode ~= "pressure" then tail = " but pressure logic not enabled" end
|
||||||
--pipeworks.logger(kind.." flow logic registry requested for "..nodename..tail)
|
--pipeworks.logger(kind.." flow logic registry requested for "..nodename..tail)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ register.directional_horizonal_rotate = function(nodename, doubleended)
|
|||||||
end
|
end
|
||||||
local directionfn = function(node, direction)
|
local directionfn = function(node, direction)
|
||||||
local result = false
|
local result = false
|
||||||
for index, endvec in ipairs(getends(node)) do
|
for _, endvec in ipairs(getends(node)) do
|
||||||
if vector.equals(direction, endvec) then result = true end
|
if vector.equals(direction, endvec) then result = true end
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
|
@ -23,7 +23,7 @@ end
|
|||||||
local function migrate_tube_db()
|
local function migrate_tube_db()
|
||||||
local tmp_db = {}
|
local tmp_db = {}
|
||||||
tp_tube_db.version = nil
|
tp_tube_db.version = nil
|
||||||
for key, val in pairs(tp_tube_db) do
|
for _, val in pairs(tp_tube_db) do
|
||||||
if(val.channel ~= "") then -- skip unconfigured tubes
|
if(val.channel ~= "") then -- skip unconfigured tubes
|
||||||
tmp_db[hash(val)] = val
|
tmp_db[hash(val)] = val
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
local S = minetest.get_translator("pipeworks")
|
local S = minetest.get_translator("pipeworks")
|
||||||
local assumed_eye_pos = vector.new(0, 1.5, 0)
|
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)
|
local function delay(x)
|
||||||
return (function() return x end)
|
return (function() return x end)
|
||||||
end
|
end
|
||||||
@ -353,7 +349,7 @@ if pipeworks.enable_node_breaker then
|
|||||||
{pos=pointed_thing.under, gain=sound.gain})
|
{pos=pointed_thing.under, gain=sound.gain})
|
||||||
end
|
end
|
||||||
wieldstack = virtplayer:get_wielded_item()
|
wieldstack = virtplayer:get_wielded_item()
|
||||||
else
|
--~ else
|
||||||
--pipeworks.logger(dname.."couldn't dig node!")
|
--pipeworks.logger(dname.."couldn't dig node!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user