Added in current svn:
- added new cell trigger lua function to be able to detect when any unit enters or exits a region of cells:
int registerCellAreaTriggerEvent(Vec4i pos)
int triggeredEventAreaEntryUnitId()
int triggeredEventAreaExitUnitId()
The first registers a region from start xy to end x,y. Then ANY unit moving into OR out of the region triggers the event. To know which unit triggered the event check:
triggeredEventAreaEntryUnitId()
if this is <= 0 than the event is NOT an entry into the region but an Exit out of the region. The exit unit will be found in:
triggeredEventAreaExitUnitId()
So in the cell region trigger, the event is always going to set the entry or exit unit id so that you know if the unit is entering or exiting the region. The event is ONLY triggered when each unit enters or exits the region (not while walking around in it)
Example:
<startup>
-- Register a region from cell 0,0 to 100,100
cell_area_event1 = registerCellAreaTriggerEvent({0,0,100,100})
</startup>
<cellTriggerEvent>
-- is this our region 0,0 to 100,100 event
if triggeredCellEventId() == cell_area_event1 then
-- if this returns > 0 than its a region entry trigger
if triggeredEventAreaEntryUnitId() > 0 then
print('TEST cell_area_event1 ENTRY for unit: ' .. triggeredEventAreaEntryUnitId())
-- iotherwise its a region exit trigger
else
print('TEST cell_area_event1 EXIT for unit: ' .. triggeredEventAreaExitUnitId())
end
end
</cellTriggerEvent>