Mindustry mass driver5/4/2023 That would also be a great opportunity for a "sleep x" function: since there is no need to busy-wait polling ubind to find a unit to control, put the script to sleep for x milliseconds instead of burning virtual CPU ticks if there is some sort of global budget for them. You call "subind" (single unit bind), subind refreshes the unit this already controls or most recently controlled whenever possible, a fresh unit with controlled = 0 if one is available when the old one isn't for whatever reason (could even have a "replaced" return parameter to test against instead of having to save the old unit to detect the unit swap and reset the script) or null otherwise so you know there are no free units available and can quit trying for a while instead of spamming ubind. My variant would eliminate most of that busywork. If there are no free units whatsoever, I'm guessing the only way to find out is to save the unit you start the search with and compare it with each future iteration to detect whether you may have looped around, though this may not work if the starting unit gets destroyed along the way and no longer be in the ubind list. If 20 units of a given type exist and 19 of them are under control, you may need to call ubind and check ntrolled=0 20 times to find the one available unit depending on where along the list you were the last time you spammed ubind. You have to do all of the additional checking to avoid hijacking units from other controllers yourself. Ubind simply walks the list of existing units of a given type. unless it doesn't check for hijacking, this should be perfect (although it doesn't check in the middle of the prog, but the same would be true for your special ubind). I cannot help with the other problems, but this is 3 lines of code. Would save a dozen lines of code (check if the unit may have died, check for loss of control, flagging, a retry mechanism to bind until a free unit is discovered, internal bound state tracking, etc.) in a typical single-unit control script. I wish there was a ubind variant that only changed the if the previously controlled was lost: set it to a new free if available when the old either died or got hijacked, otherwise to simultanously signal loss of control and no replacement available. I wrote one for myself (still working out some kinks) and a large chunk of the code is just dealing with the lack of a convenient facility to avoid ripping control from other controllers. That way, you get a steady stream of air drops wherever you need them with container/vault storage to accommodate burst supply during waves. I think at least the first method would be feasible to implement.Īn alternative to using mass drivers for shipping items to places where other routing methods aren't practical is to use Flare/Poly/Mega to run air mail from core to a conveniently located container, vault or other block with internal storage.
0 Comments
Leave a Reply. |