Time Trigger How to reset or remove the fired flag

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

Time Trigger How to reset or remove the fired flag

Post by KnightHawk75 »

Short of deleting a Time trigger and recreating it how does one clear the fired property? .

This is killing me during testing, as is (issue2) the automatic shifting of all the Times in the triggers when ever you touch the scenario date\time setting (if that's supposed to be a feature is there way to turn if off?).

The trigger entry printed:
{ Time = { Description = 'TweetReceivedTime', ID = '4FH7PU-0HM052ELT5RG2', Time = '638838450000000000', Fired = '1' } }
--
ScenEdit_SetTrigger({name='TweetReceivedTime',Type='Time',Time=os.date(dtFormat,1748248200)})
ScenEdit_SetTrigger({name='TweetReceivedTime',Type='Time',Time=os.date(dtFormat,1748248200), Fired=0})
The second will throw a unknown key error, and if I set the associated event to repeat it doesn't care, once fired is at 1.
Only way I have found is once it's been triggered is I have to remove it from the event. deleted it, create another, and reassign it. I would think resetting the time in the gui would at least clear it but doesn't.
User avatar
michaelm75au
Posts: 12465
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Time Trigger How to reset or remove the fired flag

Post by michaelm75au »

Can you create a scenario with that so I can try it? Not quite sure I understand what's shifting.
Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Time Trigger How to reset or remove the fired flag

Post by KnightHawk75 »

Yup attached. Basically when you go in and change the current time via the editor menu, or the start time, all the specific "time" trigger's set times get 'shifted' based on on the change, so set the time 4hr ahead...all the times get shifted 4hr ahead. It's as if the game is trying to "help me out" and adjust them based on the new time vs. the old.

You can also test the can't fire the message a second time issue even if you reset the time.

build 1146.2
Repo steps in the briefing
Attachments
Test_TimeU..Triggers.zip
(8.59 KiB) Downloaded 17 times
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Time Trigger How to reset or remove the fired flag

Post by KnightHawk75 »

For anyone running into either of the two issues.

Attached is a script with a couple helper functions to work around both issues less manually.
Sample usage:

Code: Select all

   local dtFormat = '!%m/%d/%Y %H:%M:%S';
 --just recreate it clearing the flag -will use existing .net storedtime in the new one. 
 --toward issue 1.
   DeleteAndReCreateTimeTrigger('NewsEvent1','SendMessage1Time'); 
 --normal sort of method, feed it string time. use that time during re-creation. rest are toward issue2 
   DeleteAndReCreateTimeTrigger('NewsEvent2','SendMessage2Time',os.date(dtFormat,1748248200));
 --feed it std unix time and it will handle the convert to .net tick time for you no need to convert to string.
   DeleteAndReCreateTimeTrigger('NewsEvent3','SendMessage3Time',1748248700);
 
 --Get the existing stored .net time but add 5 minutes(or whatever too it) when re-creating.
   local e = ScenEdit_GetEvent('NewsEvent4');
   DeleteAndReCreateTimeTrigger('NewsEvent4','SomeTrigger4', convertDotNetTickTimeToLuaTimestamp(tonumber(e.triggers[1].Time.Time) + 300));

One obvious known issue as is, if you feed it no time, but the trigger does not exist it will error I think, on the upside, if you feed it a non-existent trigger name and a time it'll create itand associate it for you, that's on purpose for my own needs. Adjust as needed. If you have a literal ton of Time triggers that need it you can just run though them all looking for time triggers and recreating them now without having to know the names ahead of time since michaelm added GetEvents() a few builds ago. Thanks again for that.

Attachment: DeleteReCreateTimeTriggers_local_withDotNet.txt
Attachments
DeleteReCr..thDotNet.txt
(2.84 KiB) Downloaded 22 times
User avatar
michaelm75au
Posts: 12465
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Time Trigger How to reset or remove the fired flag

Post by michaelm75au »

A 'Time' trigger is expected to fire only once which is why it has this. It is a protection against it continually firing after the time has passed. As such the 'fired' isn't exposed to be changed.
Still to look at rest of it...
Michael
User avatar
michaelm75au
Posts: 12465
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Time Trigger How to reset or remove the fired flag

Post by michaelm75au »

Quick check does show that when the current date/time is changed, it manually adjusts the event Time trigger by the difference (so it triggers relative to when it was set).

So when the current time is changed, it adjusts the Time trigger.
Logically what I think it should be doing is changing the Time trigger when the scenario start time is changed. So if a Trigger is supposed to fire 1 hour into the scenario at 8am, and you change the start time by 2 hours, then the Time trigger should be changed by 2 hours to keep it in sync.

Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Time Trigger How to reset or remove the fired flag

Post by KnightHawk75 »

ORIGINAL: michaelm75au

Quick check does show that when the current date/time is changed, it manually adjusts the event Time trigger by the difference (so it triggers relative to when it was set).

So when the current time is changed, it adjusts the Time trigger.
Logically what I think it should be doing is changing the Time trigger when the scenario start time is changed. So if a Trigger is supposed to fire 1 hour into the scenario at 8am, and you change the start time by 2 hours, then the Time trigger should be changed by 2 hours to keep it in sync.

On the first. Yes I get they're only meant to fire once, but if one wants to 'reset' a scenario to starting state, or otherwise re-enable it I think there should be a way to do that sort of having to recreate them, maybe changing the time in the gui shouldn't do it, but I think the facility to do so via lua should exist. That said at least there is a workaround at present however ugly.

On the second.
That would be better then when just changing the time at present, though I don't understand why it would touch any of them at all in the first place. If anything it's the last thing I want it doing if I'm moving the scenario start time back or forward by a couple hours to adjust for something. What you describe would prevent easily just changing the start time back\forward by a couple hours to provide more\less time for something to happen before all the existing set times. I could be wrong because I don't have any data\feedback beyond my own experience, but my thoughts are that the use cases where what you describe as being handy\useful are out numbered by those were it's not, ie someone just wants to change the start time and not have everything adjusted more often. It strikes me as having to fight the editor when trying to make a small change, and that's assuming one even knows\remembers that said feature exists. I'm interested if others have feedback about this with their own experiences. Perhaps in addition to not making it do it when setting current-time, a check box next to change start-time in the dialog like [x] adjust triggers with start-time would satisfy both cases?




User avatar
michaelm75au
Posts: 12465
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Time Trigger How to reset or remove the fired flag

Post by michaelm75au »

I have suggested that the 'adjustment' be removed as the trigger is for a specified time. If the designer changes the start/current times, then it is their responsibility to make any changes.
Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Time Trigger How to reset or remove the fired flag

Post by KnightHawk75 »

ORIGINAL: michaelm75au

I have suggested that the 'adjustment' be removed as the trigger is for a specified time. If the designer changes the start/current times, then it is their responsibility to make any changes.

Thank you for suggesting that change. [:)]
Post Reply

Return to “Lua Legion”