Mindustry

Mindustry

Unit Counter
14 Comments
facosa_rap 30 Jan, 2022 @ 9:16am 
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 @ 10:53am 
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  [author] 19 Apr, 2021 @ 12:27pm 
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 @ 11:18am 
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  [author] 18 Apr, 2021 @ 2:04pm 
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 @ 12:21pm 
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 @ 1:03pm 
Useful stuff, wish it could be added to the HUD :D
Micmac87 28 Feb, 2021 @ 2:17pm 
looks like a bug...
Micmac87 28 Feb, 2021 @ 1:50pm 
i found the origin of the problem : it work as soon as i dont use "set" comand
Micmac87 28 Feb, 2021 @ 9:35am 
if you can take a look to see what's wrong
Micmac87 28 Feb, 2021 @ 9:18am 
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  [author] 28 Feb, 2021 @ 7:48am 
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 @ 6:31am 
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