TitaniumTrout -> RE: Advise on modifying a Time Trigger (3/13/2020 12:57:33 AM)
|
Further the rabbit hole takes us! I think we'll run into issues with static names. So I've got it set to the guid. But say that same unit gets triggered again, the script will fail as it's trying to add events that already exist. So either we need to check if it's not nil, or we trash collect and delete the trigger, action, and event. If you go the if route you'll have to 'update' the trigger with a different time. Trash collecting might still be a good idea as a large scenario could quickly get a huge list of guid triggers, actions, and events. Trash collecting would be done by using \r\n to get new lines on the ScriptText part of the SetAction. Then when the new time trigger fires it will delete everything and the script can start fresh. Once I work it into a scenario I'll post it up as an example. local detectingunit = ScenEdit_UnitY() print(detectingunit.unit.guid) local currtime = ScenEdit_CurrentTime() print(currtime) local futuretime = currtime + 300 print(futuretime) local convtime = (os.date('%m-%d-%Y %H:%M:%S %p', futuretime)) print(convtime) local triggerunit = detectingunit.unit.guid ScenEdit_SetTrigger({mode='add',type='Time', name='trigger'.. triggerunit, time = convtime}) ScenEdit_SetAction({mode='add', type='LuaScript', name= 'triggerunitAction'..triggerunit, ScriptText ="ScenEdit_SetEMCON('Group', 'VisbyGroup', 'Inherit;Radar=Passive')"}) ScenEdit_SetEvent('TimeTest Event'..triggerunit, {mode='add', isActive=True}) ScenEdit_SetEventTrigger('TimeTest Event'..triggerunit, {mode='add', name='trigger'.. triggerunit}) ScenEdit_SetEventAction('TimeTest Event'..triggerunit, {mode='add', name='triggerunitAction'..triggerunit})
|
|
|
|