Event condition question

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
Posts: 503
Joined: Wed Nov 06, 2013 4:59 pm

Event condition question

Post by orca »

I want to activate strike when a unit is detected AND the unit is in a certain area.

Can I use a unit detected trigger and then make a condition using lua with unit enters area (or unit remains in area)?

Or use a unit enters area trigger and then lua unit is detected condition?

Or is there a way to create a trigger that requires 2 things to fire- unit enters area AND unit is detected?


User avatar
Posts: 1338
Joined: Sat Apr 14, 2007 4:20 am
Location: Washington D.C.

RE: Event condition question

Post by SeaQueen »

I would use the unit enters area as the trigger, just because it's easier/faster to use the built in code for determining if an object is in a polygon than to write your own in LUA.

Detection is fairly easy to work with in LUA using the ScenEdit_GetContact() and ScenEdit_GetContacts() functions. GetContacts() returns a list of contacts to loop over. Next, return the properties of each of the returned contacts using the GetContact() function. You can then determine if the thing you're interested in is on a side's contact list by referencing the contact's properties. The only thing to be careful about is that you must be conscious that the contact guid and the unit's guid are different. To reconcile the two, refer to the actualunitid of the contact after using the ScenEdit_GetContact() function.
Post Reply

Return to “Lua Legion”