Jump to content

[LUA] Checking if a Unit is perfectly healthy


Recommended Posts

Since the trigger condition does not have a condition that a unit is of perfect health, so I am looking at the use of LUA predicate:

I am thinking about using (Unit.Life == Unit.Life0), but how do I specify which Unit I am specifying?

Of course, if the above predicate is wrong, please kindly let me know.

Thank you.

VR Flight Guy in PJ Pants -- this is how I fly. We do not fly at treetop height, we fly between trees(TM)

YouTube: https://www.youtube.com/channel/UCc9BDi-STaqgWsjNiHbW0fA

My simple missions: https://forum.dcs.world/topic/284071-vr-flight-guy-in-pj-pants-simple-missions/

NSRI - National Strategy Research Institution, a fictional organisation based on wordplay of Strategic Naval Research Institution (SNRI), a fictional institution appears in Mobile Suit Gundam UC timeline.

Link to comment
Share on other sites

If you know the unit's name, it should be straightforward:

return Unit.getByName("aUnitName"):getLife() == Unit.getByName("aUnitName"):getLife0()

Note that the accessor functions are named getLife() and getLife0(). "aUnitName" is the name of the unit that is being looked at.

A slightly more readable version:

local theUnit = Unit.getByName("aUnitName")
return theUnit:getLife() == theUnit:getLife0()

 


Edited by cfrag
  • Thanks 1
Link to comment
Share on other sites

Thanks big time. Lua is no Perl, so the first one is fine.  Thanks.

VR Flight Guy in PJ Pants -- this is how I fly. We do not fly at treetop height, we fly between trees(TM)

YouTube: https://www.youtube.com/channel/UCc9BDi-STaqgWsjNiHbW0fA

My simple missions: https://forum.dcs.world/topic/284071-vr-flight-guy-in-pj-pants-simple-missions/

NSRI - National Strategy Research Institution, a fictional organisation based on wordplay of Strategic Naval Research Institution (SNRI), a fictional institution appears in Mobile Suit Gundam UC timeline.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...