Mindustry

Mindustry

Unit Counter
14 kommentarer
facosa_rap 30. jan. 2022 kl. 9:16 
Quite useful for largy army management, know i know what kind of mecha needs more replacement units without having to count them or something.

Thanks
tom++ 21. apr. 2021 kl. 10:53 
Thank you very much for your help!
I didn't know that one could save a reference with set first @unit... .
This is unknown to many industry logic programmers because they often call ubind @... 50 or 100 times to be sure that they have bound each unit at least once..
killall -q  [ophavsmand] 19. apr. 2021 kl. 12:27 
By temporarily storing the reference to the first bound unit, then checking if the reference to the currently bound unit matches.
tom++ 19. apr. 2021 kl. 11:18 
Thank you very much for your answer!,

But how can you tell that you have the first unit of this type again?
As far as I know, the @unit object has no unique ID.
killall -q  [ophavsmand] 18. apr. 2021 kl. 14:04 
Each time ubind is called, it iterates to the next unit of that type in order. The logic loops until it re-encounters the first unit of that type, then goes to the next unit type.
tom++ 18. apr. 2021 kl. 12:21 
What is the trick in this code? It works great, but it is magic... :-)

When you bind a unit with ubind, you can't distinguish it from another unit of the same type, can you?

Thanks a lot, kind regards,
Thomas
lammaer 7. mar. 2021 kl. 13:03 
Useful stuff, wish it could be added to the HUD :D
Micmac87 28. feb. 2021 kl. 14:17 
looks like a bug...
Micmac87 28. feb. 2021 kl. 13:50 
i found the origin of the problem : it work as soon as i dont use "set" comand
Micmac87 28. feb. 2021 kl. 9:35 
if you can take a look to see what's wrong
Micmac87 28. feb. 2021 kl. 9:33 
Micmac87 28. feb. 2021 kl. 9:18 
i use the integrated editor in mindustry to add sensors commands to get the health and the maxhealth that i drag and drop just after the line
"jump 70 equal @unit null"
the the integrated editor should update the references?
killall -q  [ophavsmand] 28. feb. 2021 kl. 7:48 
The lines that operate on @counter must be updated whenever you add instructions above them. If you added 2 instructions above this instruction:

op add @counter tmp 77

Then you must add 2 to the 77, making it 79, etc. Those instructions are like jump statements, but using math to choose where to jump.
Micmac87 28. feb. 2021 kl. 6:31 
as you bind all possible unit type I wanted to use the structure of this script to identiy all damaged unit to bring them to a repair point .
I tryed added code after the check junp at unit null but the script don't work anymore as i add sensor code

can you help me? do you have a discord / mail