Fix mvps receptor_off issue (#627)

This commit is contained in:
Jude Melton-Houghton 2022-12-07 07:15:23 -05:00 committed by GitHub
parent c10ce2dbc5
commit 60240ba268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -99,7 +99,6 @@ mesecon.queue:add_function("receptor_off", function (pos, rules)
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.vm_begin() mesecon.vm_begin()
mesecon.changesignal(np, minetest.get_node(np), rulename, mesecon.state.off, 2)
-- Turnoff returns true if turnoff process was successful, no onstate receptor -- Turnoff returns true if turnoff process was successful, no onstate receptor
-- was found along the way. Commit changes that were made in voxelmanip. If turnoff -- was found along the way. Commit changes that were made in voxelmanip. If turnoff

View File

@ -542,11 +542,14 @@ function mesecon.turnoff(pos, link)
end end
for _, sig in ipairs(signals) do for _, sig in ipairs(signals) do
-- If sig.depth is 1, it has not yet been checked that the power source is actually off.
if sig.depth > 1 or not mesecon.is_powered(sig.pos, sig.link) then
mesecon.changesignal(sig.pos, sig.node, sig.link, mesecon.state.off, sig.depth) mesecon.changesignal(sig.pos, sig.node, sig.link, mesecon.state.off, sig.depth)
if mesecon.is_effector_on(sig.node.name) and not mesecon.is_powered(sig.pos) then if mesecon.is_effector_on(sig.node.name) and not mesecon.is_powered(sig.pos) then
mesecon.deactivate(sig.pos, sig.node, sig.link, sig.depth) mesecon.deactivate(sig.pos, sig.node, sig.link, sig.depth)
end end
end end
end
return true return true
end end

View File

@ -206,7 +206,7 @@ describe("node movement", function()
end) end)
-- Since turnon is called before turnoff when pushing, effectors may be incorrectly turned off. -- Since turnon is called before turnoff when pushing, effectors may be incorrectly turned off.
pending("does not overwrite turnon with receptor_off", function() it("does not overwrite turnon with receptor_off", function()
local pos = {x = 0, y = 0, z = 0} local pos = {x = 0, y = 0, z = 0}
local dir = {x = 1, y = 0, z = 0} local dir = {x = 1, y = 0, z = 0}
mesecon._test_place(pos, "mesecons:test_effector") mesecon._test_place(pos, "mesecons:test_effector")