#New version for the orbital cannon has
1 messages · Page 1 of 1 (latest)
I skimmed the code already, but do you have an explanation available?
It abusing the fact that spoiling items can trigger custom lua events, right?
It is made out of:
- assembling machine 1, uses a recipe to consume power (you can set this recipe, or use the default)
- assembling machine 2, wired into machine 1 and only runs if machine 1 is not working by being wired into its working signal (assumed that it is either out of power or the required fuel).
- machine 2 produces an item that is used as a timer, set to spoil in 2 seconds for performance
- when the item spoils, check if the machine consuming power is running or not, then raise an event according to that.
And you have exactly no reason to think about all of that (unless you also plan to manipulate the internal machines) because that event gives you the powered/unpowered toggle that you can do whatever you want with.
If you just want to set the active state of your entity, that is also supported by the library without raising an event.
You will also never get a "machine disabled" event if the machine was already disabled, the lib already keeps track of that.
You also start in a 2s active state, because that stabilizes the entire timer system.