Lua controllers and lag

Lua controllers that use interrupts will continue running after the player leaves the area or logs off. Each time the interrupt fires, it force loads the mapblock and runs the lua code which probably sets up another interrupt. The mapblock is loaded as inactive so most stuff won’t work, but the lua controller can output signals which conduct through mesecon wires and can trigger events in other lua controllers. And these mapblocks keep reloading until the server restarts.

I wrote a script that can detect a loaded mapblock, and can be used to turn off “machines” when an area is unloaded. A node detetector is pointed at an adjacent mapblock that must not have lua controllers using interrupts in it or wires coming from luacontrollers outside the mapblock (otherwise it won’t unload and the script won’t work). When the mapblock unloads, the lua controller turns off its output and stops scheduling interrupts. The output signal can be used to turn on/off a larger “machine”. A blinking plant next to the lua controller will turn it back on when the area is loaded again.

There is an example on the back wall in the basement of my gold farm, for anyone who wants to use this.

Too complicated for me :smiley:
But does this mean one could run machines without being online?

I can help anyone set this up…

Depends on the machine, anything that uses an ABM won’t work (ore spawners, node detectors, crop growth, lava to stone, blinky plants). A node detector won’t perform checks and output a signal (easy mode), but a lua controller can use digilines to ask the node detector what it can see. It might be possible to bonemeal crops, but you need a more complicated bonemeal producing machine because the node detectors won’t work in easy mode. I imagine items would move through tubes, but I don’t know for a fact. Robots won’t spawn, it either checks or the game doesn’t allow entities to spawn in inactive mapblocks. It is also unlikely that entities receive updates in inactive mapblocks, that and entity spawn prevention would prevent items in tubes.

Node timers also shouldn’t work in inactive mapblocks, so no furnaces or technic machines will work. A while back mesecons added an option to make lua controller use node timers for interrrupts. That option could have solved this issue. Very few scripts (I haven’t seen any) use multiple simultaneous interrupts, but node timers would only allow a single active interrupt, breaking any scripts that need more than one. They took it one step further and banned the ‘iid’ when this option is enabled. Lack of iid breaks any script that only uses one interrupt at a time but has many different named interrupts with separate code for each. Turning on this option would break a lot of scripts on illuna. Mesecons 1.3 (sometime in the distant future) will unban iids.