minetest-mods / mesecons

Mod for Minetest that adds digital circuitry [=Minecraft redstone]
https://mesecons.net
Other
211 stars 121 forks source link

fix 1-tick pulses causing delayers to get stuck in the on state #663

Closed lolbinarycat closed 10 months ago

lolbinarycat commented 11 months ago

Fixes #656

i believe the cause of this bug is a chain of events as such:

SmallJoker commented 10 months ago

How can I reproduce the issue to then test this PR's fix?

SmallJoker commented 10 months ago
2024-01-06 12:43:08: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod '??' in callback environment_Step(): MT/builtin/common/item_s.lua:229: bad argument #1 to '__index' (string expected, got nil)
2024-01-06 12:43:08: ERROR[Main]: stack traceback:
2024-01-06 12:43:08: ERROR[Main]:   [C]: in function '__index'
2024-01-06 12:43:08: ERROR[Main]:   MT/builtin/common/item_s.lua:229: in function <MT/builtin/common/item_s.lua:228>
2024-01-06 12:43:08: ERROR[Main]:   [C]: in function 'swap_node'
2024-01-06 12:43:08: ERROR[Main]:   MT/mods/mesecons/mesecons_delayer/init.lua:20: in function 'action_off'
2024-01-06 12:43:08: ERROR[Main]:   MT/mods/mesecons/mesecons/internal.lua:207: in function <MT/mods/mesecons/mesecons/internal.lua:200>
2024-01-06 12:43:08: ERROR[Main]:   MT/mods/mesecons/mesecons/actionqueue.lua:137: in function 'execute'
2024-01-06 12:43:08: ERROR[Main]:   MT/mods/mesecons/mesecons/actionqueue.lua:111: in function <MT/mods/mesecons/mesecons/actionqueue.lua:73>
2024-01-06 12:43:08: ERROR[Main]:   MT/builtin/common/register.lua:26: in function <MT/builtin/common/register.lua:12>

when placing an inverter into the indicated location: error reproducer

lolbinarycat commented 10 months ago

@SmallJoker thanks, should be fixed now!

SmallJoker commented 10 months ago

@lolbinarycat Thank you. I can no longer reproduce that error. However, I'd still like to know which circuit bug this PR aims to fix. Where can I see the change in behaviour?

lolbinarycat commented 10 months ago

@SmallJoker i didn't find a 100% reliable way to replicate it, but what i did was make a 1 tick piston clock (a sticky piston with a switch on its face, then use wire to connect the switch to the piston), then take a line from the clock to the back of a delayer.

if you destroy the wire directly behind the delayer with the correct timing, the delayer will get stuck in the "on" position despite there being no wire leading into it. also when i was doing that i was also intentionally lagging the game, which may or may not be required.

after this change, i was unable to replicate the bug with this method.

SmallJoker commented 10 months ago

The singleplayer server tick is a bit too fast for this type of oscillator. OpenAL is not too happy about it. However, with this setup I did reproduce the bug and the PR does indeed fix it.

grafik