forked from minetest-mods/mesecons
Use vector helper functions instead of old builtin cmpPos and addPosRule functions
This commit is contained in:
parent
6b54f025c1
commit
809192f353
@ -23,7 +23,7 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior
|
|||||||
-- Otherwise, add the action to the queue
|
-- Otherwise, add the action to the queue
|
||||||
if overwritecheck then -- check if old action has to be overwritten / removed:
|
if overwritecheck then -- check if old action has to be overwritten / removed:
|
||||||
for i, ac in ipairs(mesecon.queue.actions) do
|
for i, ac in ipairs(mesecon.queue.actions) do
|
||||||
if(mesecon.cmpPos(pos, ac.pos)
|
if(vector.equals(pos, ac.pos)
|
||||||
and mesecon.cmpAny(overwritecheck, ac.owcheck)) then
|
and mesecon.cmpAny(overwritecheck, ac.owcheck)) then
|
||||||
toremove = i
|
toremove = i
|
||||||
break
|
break
|
||||||
|
@ -74,7 +74,7 @@ mesecon.queue:add_function("receptor_on", function (pos, rules)
|
|||||||
|
|
||||||
-- if area (any of the rule targets) is not loaded, keep trying and call this again later
|
-- if area (any of the rule targets) is not loaded, keep trying and call this again later
|
||||||
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
||||||
local np = mesecon.addPosRule(pos, rule)
|
local np = vector.add(pos, rule)
|
||||||
-- if area is not loaded, keep trying
|
-- if area is not loaded, keep trying
|
||||||
if minetest.get_node_or_nil(np) == nil then
|
if minetest.get_node_or_nil(np) == nil then
|
||||||
mesecon.queue:add_action(pos, "receptor_on", {rules}, nil, rules)
|
mesecon.queue:add_action(pos, "receptor_on", {rules}, nil, rules)
|
||||||
@ -84,7 +84,7 @@ mesecon.queue:add_function("receptor_on", function (pos, rules)
|
|||||||
|
|
||||||
-- execute action
|
-- execute action
|
||||||
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
||||||
local np = mesecon.addPosRule(pos, rule)
|
local np = vector.add(pos, rule)
|
||||||
local rulenames = mesecon.rules_link_rule_all(pos, rule)
|
local rulenames = mesecon.rules_link_rule_all(pos, rule)
|
||||||
for _, rulename in ipairs(rulenames) do
|
for _, rulename in ipairs(rulenames) do
|
||||||
mesecon.turnon(np, rulename)
|
mesecon.turnon(np, rulename)
|
||||||
@ -101,7 +101,7 @@ mesecon.queue:add_function("receptor_off", function (pos, rules)
|
|||||||
|
|
||||||
-- if area (any of the rule targets) is not loaded, keep trying and call this again later
|
-- if area (any of the rule targets) is not loaded, keep trying and call this again later
|
||||||
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
||||||
local np = mesecon.addPosRule(pos, rule)
|
local np = vector.add(pos, rule)
|
||||||
if minetest.get_node_or_nil(np) == nil then
|
if minetest.get_node_or_nil(np) == nil then
|
||||||
mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules)
|
mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules)
|
||||||
return
|
return
|
||||||
@ -109,7 +109,7 @@ mesecon.queue:add_function("receptor_off", function (pos, rules)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
||||||
local np = mesecon.addPosRule(pos, rule)
|
local np = vector.add(pos, rule)
|
||||||
local rulenames = mesecon.rules_link_rule_all(pos, rule)
|
local rulenames = mesecon.rules_link_rule_all(pos, rule)
|
||||||
for _, rulename in ipairs(rulenames) do
|
for _, rulename in ipairs(rulenames) do
|
||||||
if not mesecon.connected_to_receptor(np, mesecon.invertRule(rule)) then
|
if not mesecon.connected_to_receptor(np, mesecon.invertRule(rule)) then
|
||||||
|
@ -374,7 +374,7 @@ function mesecon.turnon(pos, link)
|
|||||||
|
|
||||||
-- call turnon on neighbors: normal rules
|
-- call turnon on neighbors: normal rules
|
||||||
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
||||||
local np = mesecon.addPosRule(f.pos, r)
|
local np = vector.add(f.pos, r)
|
||||||
|
|
||||||
-- area not loaded, postpone action
|
-- area not loaded, postpone action
|
||||||
if not minetest.get_node_or_nil(np) then
|
if not minetest.get_node_or_nil(np) then
|
||||||
@ -420,7 +420,7 @@ function mesecon.turnoff(pos, link)
|
|||||||
|
|
||||||
-- call turnoff on neighbors: normal rules
|
-- call turnoff on neighbors: normal rules
|
||||||
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
||||||
local np = mesecon.addPosRule(f.pos, r)
|
local np = vector.add(f.pos, r)
|
||||||
|
|
||||||
-- area not loaded, postpone action
|
-- area not loaded, postpone action
|
||||||
if not minetest.get_node_or_nil(np) then
|
if not minetest.get_node_or_nil(np) then
|
||||||
@ -458,7 +458,7 @@ function mesecon.connected_to_receptor(pos, link)
|
|||||||
for _, rule in ipairs(mesecon.rule2meta(link, rules)) do
|
for _, rule in ipairs(mesecon.rule2meta(link, rules)) do
|
||||||
local links = mesecon.rules_link_rule_all_inverted(pos, rule)
|
local links = mesecon.rules_link_rule_all_inverted(pos, rule)
|
||||||
for _, l in ipairs(links) do
|
for _, l in ipairs(links) do
|
||||||
local np = mesecon.addPosRule(pos, l)
|
local np = vector.add(pos, l)
|
||||||
if mesecon.find_receptor_on(np, mesecon.invertRule(l)) then
|
if mesecon.find_receptor_on(np, mesecon.invertRule(l)) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -485,7 +485,7 @@ function mesecon.find_receptor_on(pos, link)
|
|||||||
|
|
||||||
-- call turnoff on neighbors: normal rules
|
-- call turnoff on neighbors: normal rules
|
||||||
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
||||||
local np = mesecon.addPosRule(f.pos, r)
|
local np = vector.add(f.pos, r)
|
||||||
|
|
||||||
local links = mesecon.rules_link_rule_all_inverted(f.pos, r)
|
local links = mesecon.rules_link_rule_all_inverted(f.pos, r)
|
||||||
for _, l in ipairs(links) do
|
for _, l in ipairs(links) do
|
||||||
@ -513,10 +513,10 @@ function mesecon.rules_link(output, input, dug_outputrules) --output/input are p
|
|||||||
|
|
||||||
for _, outputrule in ipairs(mesecon.flattenrules(outputrules)) do
|
for _, outputrule in ipairs(mesecon.flattenrules(outputrules)) do
|
||||||
-- Check if output sends to input
|
-- Check if output sends to input
|
||||||
if mesecon.cmpPos(mesecon.addPosRule(output, outputrule), input) then
|
if vector.equals(vector.add(output, outputrule), input) then
|
||||||
for _, inputrule in ipairs(mesecon.flattenrules(inputrules)) do
|
for _, inputrule in ipairs(mesecon.flattenrules(inputrules)) do
|
||||||
-- Check if input accepts from output
|
-- Check if input accepts from output
|
||||||
if mesecon.cmpPos(mesecon.addPosRule(input, inputrule), output) then
|
if vector.equals(vector.add(input, inputrule), output) then
|
||||||
return true, inputrule
|
return true, inputrule
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -526,7 +526,7 @@ function mesecon.rules_link(output, input, dug_outputrules) --output/input are p
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.rules_link_rule_all(output, rule)
|
function mesecon.rules_link_rule_all(output, rule)
|
||||||
local input = mesecon.addPosRule(output, rule)
|
local input = vector.add(output, rule)
|
||||||
local inputnode = minetest.get_node(input)
|
local inputnode = minetest.get_node(input)
|
||||||
local inputrules = mesecon.get_any_inputrules (inputnode)
|
local inputrules = mesecon.get_any_inputrules (inputnode)
|
||||||
if not inputrules then
|
if not inputrules then
|
||||||
@ -536,7 +536,7 @@ function mesecon.rules_link_rule_all(output, rule)
|
|||||||
|
|
||||||
for _, inputrule in ipairs(mesecon.flattenrules(inputrules)) do
|
for _, inputrule in ipairs(mesecon.flattenrules(inputrules)) do
|
||||||
-- Check if input accepts from output
|
-- Check if input accepts from output
|
||||||
if mesecon.cmpPos(mesecon.addPosRule(input, inputrule), output) then
|
if vector.equals(vector.add(input, inputrule), output) then
|
||||||
table.insert(rules, inputrule)
|
table.insert(rules, inputrule)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -545,7 +545,7 @@ end
|
|||||||
|
|
||||||
function mesecon.rules_link_rule_all_inverted(input, rule)
|
function mesecon.rules_link_rule_all_inverted(input, rule)
|
||||||
--local irule = mesecon.invertRule(rule)
|
--local irule = mesecon.invertRule(rule)
|
||||||
local output = mesecon.addPosRule(input, rule)
|
local output = vector.add(input, rule)
|
||||||
local outputnode = minetest.get_node(output)
|
local outputnode = minetest.get_node(output)
|
||||||
local outputrules = mesecon.get_any_outputrules (outputnode)
|
local outputrules = mesecon.get_any_outputrules (outputnode)
|
||||||
if not outputrules then
|
if not outputrules then
|
||||||
@ -554,7 +554,7 @@ function mesecon.rules_link_rule_all_inverted(input, rule)
|
|||||||
local rules = {}
|
local rules = {}
|
||||||
|
|
||||||
for _, outputrule in ipairs(mesecon.flattenrules(outputrules)) do
|
for _, outputrule in ipairs(mesecon.flattenrules(outputrules)) do
|
||||||
if mesecon.cmpPos(mesecon.addPosRule(output, outputrule), input) then
|
if vector.equals(vector.add(output, outputrule), input) then
|
||||||
table.insert(rules, mesecon.invertRule(outputrule))
|
table.insert(rules, mesecon.invertRule(outputrule))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -577,7 +577,7 @@ function mesecon.is_powered(pos, rule)
|
|||||||
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
||||||
local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule)
|
local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule)
|
||||||
for _, rname in ipairs(rulenames) do
|
for _, rname in ipairs(rulenames) do
|
||||||
local np = mesecon.addPosRule(pos, rname)
|
local np = vector.add(pos, rname)
|
||||||
local nn = minetest.get_node(np)
|
local nn = minetest.get_node(np)
|
||||||
if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname))
|
if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname))
|
||||||
or mesecon.is_receptor_on (nn.name)) then
|
or mesecon.is_receptor_on (nn.name)) then
|
||||||
@ -588,7 +588,7 @@ function mesecon.is_powered(pos, rule)
|
|||||||
else
|
else
|
||||||
local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule)
|
local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule)
|
||||||
for _, rname in ipairs(rulenames) do
|
for _, rname in ipairs(rulenames) do
|
||||||
local np = mesecon.addPosRule(pos, rname)
|
local np = vector.add(pos, rname)
|
||||||
local nn = minetest.get_node(np)
|
local nn = minetest.get_node(np)
|
||||||
if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname))
|
if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname))
|
||||||
or mesecon.is_receptor_on (nn.name)) then
|
or mesecon.is_receptor_on (nn.name)) then
|
||||||
|
@ -16,7 +16,7 @@ mesecon.on_placenode = function (pos, node)
|
|||||||
-- also call receptor_on if itself is powered already, so that neighboring
|
-- also call receptor_on if itself is powered already, so that neighboring
|
||||||
-- conductors will be activated (when pushing an on-conductor with a piston)
|
-- conductors will be activated (when pushing an on-conductor with a piston)
|
||||||
for _, s in ipairs(sources) do
|
for _, s in ipairs(sources) do
|
||||||
local rule = {x = pos.x - s.x, y = pos.y - s.y, z = pos.z - s.z}
|
local rule = vector.subtract(pos, s)
|
||||||
mesecon.turnon(pos, rule)
|
mesecon.turnon(pos, rule)
|
||||||
end
|
end
|
||||||
--mesecon.receptor_on (pos, mesecon.conductor_get_rules(node))
|
--mesecon.receptor_on (pos, mesecon.conductor_get_rules(node))
|
||||||
|
@ -50,7 +50,7 @@ function mesecon.rule2bit(findrule, allrules)
|
|||||||
end
|
end
|
||||||
for m,metarule in ipairs( allrules) do
|
for m,metarule in ipairs( allrules) do
|
||||||
for _, rule in ipairs(metarule ) do
|
for _, rule in ipairs(metarule ) do
|
||||||
if mesecon.cmpPos(findrule, rule) then
|
if vector.equals(findrule, rule) then
|
||||||
return m
|
return m
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -69,7 +69,7 @@ function mesecon.rule2metaindex(findrule, allrules)
|
|||||||
|
|
||||||
for m, metarule in ipairs( allrules) do
|
for m, metarule in ipairs( allrules) do
|
||||||
for _, rule in ipairs(metarule ) do
|
for _, rule in ipairs(metarule ) do
|
||||||
if mesecon.cmpPos(findrule, rule) then
|
if vector.equals(findrule, rule) then
|
||||||
return m
|
return m
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -133,15 +133,7 @@ function mesecon.set_bit(binary,bit,value)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.invertRule(r)
|
function mesecon.invertRule(r)
|
||||||
return {x = -r.x, y = -r.y, z = -r.z}
|
return vector.multiply(r, -1)
|
||||||
end
|
|
||||||
|
|
||||||
function mesecon.addPosRule(p, r)
|
|
||||||
return {x = p.x + r.x, y = p.y + r.y, z = p.z + r.z}
|
|
||||||
end
|
|
||||||
|
|
||||||
function mesecon.cmpPos(p1, p2)
|
|
||||||
return (p1.x == p2.x and p1.y == p2.y and p1.z == p2.z)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.tablecopy(table) -- deep table copy
|
function mesecon.tablecopy(table) -- deep table copy
|
||||||
|
@ -22,7 +22,7 @@ local wire_getconnect = function (from_pos, self_pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for _, r in ipairs(mesecon.flattenrules(rules)) do
|
for _, r in ipairs(mesecon.flattenrules(rules)) do
|
||||||
if (mesecon.cmpPos(mesecon.addPosRule(self_pos, r), from_pos)) then
|
if (vector.equals(vector.add(self_pos, r), from_pos)) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -35,7 +35,7 @@ local wire_updateconnect = function (pos)
|
|||||||
local connections = {}
|
local connections = {}
|
||||||
|
|
||||||
for _, r in ipairs(mesecon.rules.default) do
|
for _, r in ipairs(mesecon.rules.default) do
|
||||||
if wire_getconnect(pos, mesecon.addPosRule(pos, r)) then
|
if wire_getconnect(pos, vector.add(pos, r)) then
|
||||||
table.insert(connections, r)
|
table.insert(connections, r)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -83,7 +83,7 @@ local update_on_place_dig = function (pos, node)
|
|||||||
if (not rules) then return end
|
if (not rules) then return end
|
||||||
|
|
||||||
for _, r in ipairs(mesecon.flattenrules(rules)) do
|
for _, r in ipairs(mesecon.flattenrules(rules)) do
|
||||||
local np = mesecon.addPosRule(pos, r)
|
local np = vector.add(pos, r)
|
||||||
if minetest.registered_nodes[minetest.get_node(np).name]
|
if minetest.registered_nodes[minetest.get_node(np).name]
|
||||||
and minetest.registered_nodes[minetest.get_node(np).name].mesecon_wire then
|
and minetest.registered_nodes[minetest.get_node(np).name].mesecon_wire then
|
||||||
wire_updateconnect(np)
|
wire_updateconnect(np)
|
||||||
|
@ -42,8 +42,8 @@ local vertical_updatepos = function (pos)
|
|||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if minetest.registered_nodes[node.name]
|
if minetest.registered_nodes[node.name]
|
||||||
and minetest.registered_nodes[node.name].is_vertical_conductor then
|
and minetest.registered_nodes[node.name].is_vertical_conductor then
|
||||||
local node_above = minetest.get_node(mesecon.addPosRule(pos, vertical_rules[1]))
|
local node_above = minetest.get_node(vector.add(pos, vertical_rules[1]))
|
||||||
local node_below = minetest.get_node(mesecon.addPosRule(pos, vertical_rules[2]))
|
local node_below = minetest.get_node(vector.add(pos, vertical_rules[2]))
|
||||||
local namestate = minetest.registered_nodes[node.name].vertical_conductor_state
|
local namestate = minetest.registered_nodes[node.name].vertical_conductor_state
|
||||||
|
|
||||||
local above = minetest.registered_nodes[node_above.name]
|
local above = minetest.registered_nodes[node_above.name]
|
||||||
@ -67,8 +67,8 @@ end
|
|||||||
|
|
||||||
local vertical_update = function (pos, node)
|
local vertical_update = function (pos, node)
|
||||||
vertical_updatepos(pos) -- this one
|
vertical_updatepos(pos) -- this one
|
||||||
vertical_updatepos(mesecon.addPosRule(pos, vertical_rules[1])) -- above
|
vertical_updatepos(vector.add(pos, vertical_rules[1])) -- above
|
||||||
vertical_updatepos(mesecon.addPosRule(pos, vertical_rules[2])) -- below
|
vertical_updatepos(vector.add(pos, vertical_rules[2])) -- below
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Vertical wire
|
-- Vertical wire
|
||||||
|
@ -175,7 +175,7 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
|
|||||||
|
|
||||||
-- add nodes
|
-- add nodes
|
||||||
for _, n in ipairs(nodes) do
|
for _, n in ipairs(nodes) do
|
||||||
local np = mesecon.addPosRule(n.pos, movedir)
|
local np = vector.add(n.pos, movedir)
|
||||||
|
|
||||||
minetest.add_node(np, n.node)
|
minetest.add_node(np, n.node)
|
||||||
minetest.get_meta(np):from_table(n.meta)
|
minetest.get_meta(np):from_table(n.meta)
|
||||||
@ -186,7 +186,7 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
|
|||||||
for i in ipairs(nodes) do
|
for i in ipairs(nodes) do
|
||||||
moved_nodes[i] = {}
|
moved_nodes[i] = {}
|
||||||
moved_nodes[i].oldpos = nodes[i].pos
|
moved_nodes[i].oldpos = nodes[i].pos
|
||||||
nodes[i].pos = mesecon.addPosRule(nodes[i].pos, movedir)
|
nodes[i].pos = vector.add(nodes[i].pos, movedir)
|
||||||
moved_nodes[i].pos = nodes[i].pos
|
moved_nodes[i].pos = nodes[i].pos
|
||||||
moved_nodes[i].node = nodes[i].node
|
moved_nodes[i].node = nodes[i].node
|
||||||
moved_nodes[i].meta = nodes[i].meta
|
moved_nodes[i].meta = nodes[i].meta
|
||||||
@ -207,12 +207,8 @@ end)
|
|||||||
function mesecon.mvps_move_objects(pos, dir, nodestack)
|
function mesecon.mvps_move_objects(pos, dir, nodestack)
|
||||||
local objects_to_move = {}
|
local objects_to_move = {}
|
||||||
|
|
||||||
-- Move object at tip of stack
|
-- Move object at tip of stack, pushpos is position at tip of stack
|
||||||
local pushpos = mesecon.addPosRule(pos, -- get pos at tip of stack
|
local pushpos = vector.add(pos, vector.multiply(dir, #nodestack))
|
||||||
{x = dir.x * #nodestack,
|
|
||||||
y = dir.y * #nodestack,
|
|
||||||
z = dir.z * #nodestack})
|
|
||||||
|
|
||||||
|
|
||||||
local objects = minetest.get_objects_inside_radius(pushpos, 1)
|
local objects = minetest.get_objects_inside_radius(pushpos, 1)
|
||||||
for _, obj in ipairs(objects) do
|
for _, obj in ipairs(objects) do
|
||||||
@ -223,7 +219,7 @@ function mesecon.mvps_move_objects(pos, dir, nodestack)
|
|||||||
if tonumber(minetest.setting_get("movement_gravity")) > 0 and dir.y == 0 then
|
if tonumber(minetest.setting_get("movement_gravity")) > 0 and dir.y == 0 then
|
||||||
-- If gravity positive and dir horizontal, push players standing on the stack
|
-- If gravity positive and dir horizontal, push players standing on the stack
|
||||||
for _, n in ipairs(nodestack) do
|
for _, n in ipairs(nodestack) do
|
||||||
local p_above = mesecon.addPosRule(n.pos, {x=0, y=1, z=0})
|
local p_above = vector.add(n.pos, {x=0, y=1, z=0})
|
||||||
local objects = minetest.get_objects_inside_radius(p_above, 1)
|
local objects = minetest.get_objects_inside_radius(p_above, 1)
|
||||||
for _, obj in ipairs(objects) do
|
for _, obj in ipairs(objects) do
|
||||||
table.insert(objects_to_move, obj)
|
table.insert(objects_to_move, obj)
|
||||||
@ -234,7 +230,7 @@ function mesecon.mvps_move_objects(pos, dir, nodestack)
|
|||||||
for _, obj in ipairs(objects_to_move) do
|
for _, obj in ipairs(objects_to_move) do
|
||||||
local entity = obj:get_luaentity()
|
local entity = obj:get_luaentity()
|
||||||
if not entity or not mesecon.is_mvps_unmov(entity.name) then
|
if not entity or not mesecon.is_mvps_unmov(entity.name) then
|
||||||
local np = mesecon.addPosRule(obj:getpos(), dir)
|
local np = vector.add(obj:getpos(), dir)
|
||||||
|
|
||||||
--move only if destination is not solid
|
--move only if destination is not solid
|
||||||
local nn = minetest.get_node(np)
|
local nn = minetest.get_node(np)
|
||||||
|
@ -57,7 +57,7 @@ end
|
|||||||
local piston_remove_pusher = function(pos, node)
|
local piston_remove_pusher = function(pos, node)
|
||||||
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||||
local dir = piston_get_direction(pistonspec.dir, node)
|
local dir = piston_get_direction(pistonspec.dir, node)
|
||||||
local pusherpos = mesecon.addPosRule(pos, dir)
|
local pusherpos = vector.add(pos, dir)
|
||||||
local pushername = minetest.get_node(pusherpos).name
|
local pushername = minetest.get_node(pusherpos).name
|
||||||
|
|
||||||
-- make sure there actually is a pusher (for compatibility reasons mainly)
|
-- make sure there actually is a pusher (for compatibility reasons mainly)
|
||||||
@ -78,7 +78,7 @@ local piston_on = function(pos, node)
|
|||||||
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||||
|
|
||||||
local dir = piston_get_direction(pistonspec.dir, node)
|
local dir = piston_get_direction(pistonspec.dir, node)
|
||||||
local np = mesecon.addPosRule(pos, dir)
|
local np = vector.add(pos, dir)
|
||||||
local maxpush = mesecon.setting("piston_max_push", 15)
|
local maxpush = mesecon.setting("piston_max_push", 15)
|
||||||
local success, stack, oldstack = mesecon.mvps_push(np, dir, maxpush)
|
local success, stack, oldstack = mesecon.mvps_push(np, dir, maxpush)
|
||||||
if success then
|
if success then
|
||||||
@ -719,12 +719,12 @@ end
|
|||||||
local piston_get_stopper = function (node, dir, stack, stackid)
|
local piston_get_stopper = function (node, dir, stack, stackid)
|
||||||
pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||||
dir = piston_get_direction(pistonspec.dir, node)
|
dir = piston_get_direction(pistonspec.dir, node)
|
||||||
local pusherpos = mesecon.addPosRule(stack[stackid].pos, dir)
|
local pusherpos = vector.add(stack[stackid].pos, dir)
|
||||||
local pushernode = minetest.get_node(pusherpos)
|
local pushernode = minetest.get_node(pusherpos)
|
||||||
|
|
||||||
if minetest.registered_nodes[node.name].mesecons_piston.pusher == pushernode.name then
|
if minetest.registered_nodes[node.name].mesecons_piston.pusher == pushernode.name then
|
||||||
for _, s in ipairs(stack) do
|
for _, s in ipairs(stack) do
|
||||||
if mesecon.cmpPos(s.pos, pusherpos) -- pusher is also to be pushed
|
if vector.equals(s.pos, pusherpos) -- pusher is also to be pushed
|
||||||
and s.node.param2 == node.param2 then
|
and s.node.param2 == node.param2 then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ pp_on_timer = function (pos, elapsed)
|
|||||||
if not basename then return end
|
if not basename then return end
|
||||||
|
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 1)
|
local objs = minetest.get_objects_inside_radius(pos, 1)
|
||||||
local two_below = mesecon.addPosRule(pos, {x = 0, y = -2, z = 0})
|
local two_below = vector.add(pos, vector.new(0, -2, 0))
|
||||||
|
|
||||||
if objs[1] == nil and node.name == basename .. "_on" then
|
if objs[1] == nil and node.name == basename .. "_on" then
|
||||||
minetest.add_node(pos, {name = basename .. "_off"})
|
minetest.add_node(pos, {name = basename .. "_off"})
|
||||||
|
@ -66,10 +66,10 @@ minetest.register_node("mesecons_random:ghoststone_active", {
|
|||||||
offstate = "mesecons_random:ghoststone"
|
offstate = "mesecons_random:ghoststone"
|
||||||
}},
|
}},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
--remove shadow
|
-- remove shadow
|
||||||
pos2 = {x = pos.x, y = pos.y + 1, z = pos.z}
|
shadowpos = vector.add(pos, vector.new(0, 1, 0))
|
||||||
if ( minetest.get_node(pos2).name == "air" ) then
|
if (minetest.get_node(shadowpos).name == "air") then
|
||||||
minetest.dig_node(pos2)
|
minetest.dig_node(shadowpos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -91,7 +91,7 @@ minetest.register_abm({
|
|||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
local is_powered = false
|
local is_powered = false
|
||||||
for _, rule in ipairs(torch_get_input_rules(node)) do
|
for _, rule in ipairs(torch_get_input_rules(node)) do
|
||||||
local src = mesecon.addPosRule(pos, rule)
|
local src = vector.add(pos, rule)
|
||||||
if mesecon.is_power_on(src) then
|
if mesecon.is_power_on(src) then
|
||||||
is_powered = true
|
is_powered = true
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user