Event - Is Repeatable

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
Whicker
Posts: 664
Joined: Tue Jun 19, 2018 9:54 pm

Event - Is Repeatable

Post by Whicker »

When you create an event, what is the purpose of `is repeatable` within the context of playing the same scen multiple times (not saves)?

The second time you play the scen - from a fresh start, not a save, should it trigger if the trigger is set to on scen load and the event is not checked for is repeatable?

Or if your trigger is on scen load is it ok to have it repeat and it will only trigger when you first load the scen, but will do that each time you start from scratch?

My experience is if you have is repeatable unchecked, it will only run the very first time, if you go back to that same scen later and start it fresh it won't load.

I looked at `Hot Tamales - Caribbean fury` and it has this same behavior. I have 3 versions of it - cow, normal and normal with full fuel. If I look at the events and actions there is one for Fuel on Start that changes the fuel qty on several ships from full to not very full. I know the first time I played this (nice!) I ran out of fuel. If I load the same version now the fuel is not set, look at the event and the event is not active.

I loaded the other 2 and the one with Full Fuel doesn't have that event - I just wanted to make sure it wasn't just unchecked. The non cow one still didn't have the fuel change - but has the event. I probably started them both at some point.

My intention is to get stuff to run at scen load and never again, unless the player starts over (not a save). I don't want it to run on a save... would the scen loaded trigger trigger on a loaded save? even if the event was set to repeatable? do people intend for a not repeatable event to never trigger again even if the player starts from scratch?
User avatar
stilesw
Posts: 1569
Joined: Wed Jun 25, 2014 10:08 pm
Location: Hansville, WA, USA

RE: Event - Is Repeatable

Post by stilesw »

Say you set up an event to add 1 point to your score when you destroy an hostile aircraft. If the event is set to "repeatable" then you will get a point for every plane destroyed. If not repeatable then you will only get a point for the first occurrence no matter how many enemy aircraft you kill.

-Wayne
“There is no limit to what a man can do so long as he does not care a straw who gets the credit for it.”

Charles Edward Montague, English novelist and essayist
~Disenchantment, ch. 15 (1922)
User avatar
SeaQueen
Posts: 1432
Joined: Sat Apr 14, 2007 4:20 am
Location: Washington D.C.

RE: Event - Is Repeatable

Post by SeaQueen »

My intention is to get stuff to run at scen load and never again, unless the player starts over (not a save). I don't want it to run on a save... would the scen loaded trigger trigger on a loaded save? even if the event was set to repeatable? do people intend for a not repeatable event to never trigger again even if the player starts from scratch?

I almost always have a bunch of stuff happen at scenario load. My experience has been that if you load a savegame file then it doesn't execute again. If you're concerned about it, you could just as easily make the event based on time. You just need to make sure that you adjust the time if you ever change things in the editor.

You don't need to have a scenario load event repeatable, however, it's a pain if you don't because if you load the scenario in the editor, make some changes, and then save it again, you need to make sure that you make the event active again. Making it repeatable saves you the trouble.
Whicker
Posts: 664
Joined: Tue Jun 19, 2018 9:54 pm

RE: Event - Is Repeatable

Post by Whicker »

If the event is set to "repeatable" then you will get a point for every plane destroyed. If not repeatable then you will only get a point for the first occurrence no matter how many enemy aircraft you kill.

I get this, but my problem is that in my experience you will get one point period - the first time you play it, no matter how many times you run the scenario starting from the beginning (the next time you play that scenario from the start the event active checkbox will be unchecked). That logic seems bad to me.
You don't need to have a scenario load event repeatable, however, it's a pain if you don't because if you load the scenario in the editor, make some changes, and then save it again, you need to make sure that you make the event active again. Making it repeatable saves you the trouble.

Exactly - I had thought the purpose of the non repeating event was to control `on scen load` events - if it is not repeated then it won't fire on a save, if it is repeatable then it would fire on save reload. Not sure where I got that idea.

As long as the Scen Load event is once per game start (not save start) then I will make them repeatable.

This sort of goes along with SetKeyValue which seems to persist no matter what I do - I think it should persist when a save restarts, but it seems to persist even if I start as a fresh new scenario rather than a save.
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Event - Is Repeatable

Post by michaelm75au »

If a Event fires, and is not repeatable, then it should not be triggered again. This should apply even if a scenario save is restored.
The scenario score is independent of any events; it is a value that is saved. So it you have 100 points, and save the game, then you should have 100 points when it is reloaded.

The KeyStore should only be effective for the scenario and not bleed over to a different scenario. Using the KeyStore is the best way to keep data within a scenario as it is recorded in the save and will be restored when it is loaded.

If there is some sort of scenario setup action, then they should be part of the scenario load event which should fire each time a save is loaded. This 'set up' actions usually happens before the the scenario starts running.

There should be many examples of this in the Community Packs (esp the new ones) as well as the Live! scenarios if you look at them.
Michael
Whicker
Posts: 664
Joined: Tue Jun 19, 2018 9:54 pm

RE: Event - Is Repeatable

Post by Whicker »

If a Event fires, and is not repeatable, then it should not be triggered again. This should apply even if a scenario save is restored.

But what if you restart the scen from the start (scen file not save file) should the event trigger again? I would think so but it doesn't.

Maybe I'll make a test scen and post it to see if it works for others the same way it seems to for me. With the fuel example from Hot Tamales I would expect that the ships would be low on fuel the next time I play that scen from scratch (not a save) but they aren't.

Same with key store - I expect it to retain its value thru saves, but if the scen is played from the beginning again they should be nil but that doesn't seem to be the case.
Whicker
Posts: 664
Joined: Tue Jun 19, 2018 9:54 pm

RE: Event - Is Repeatable

Post by Whicker »

ok, I think everything is working as expected, my bad - I was having issues with Hot Tamales (ship fuel not changed on load) but I re-downloaded it and now it is ok. I also had some inconsistencies on my own little tests but I'll chalk that up to rookie mistakes.

My testing showed that if `is Repeatable` is on with a trigger set to On Scen Load, then it fires on both a save AND a fresh start. If it is not repeatable then it only fires on a fresh start. This is what I thought originally, but it threw me off that the event itself in the editor gets reset to inactive every time.

I also tested the SetKeyValue that I thought I was having issues with and it works fine too - it seems to resets to "" (not nil which is what I have read it is supposed to be) on every fresh load, but stays set thru saves.
Post Reply

Return to “Lua Legion”