Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: SF-Junky on February 02, 2020, 01:13:10 pm

Title: Help needed on variables editor
Post by: SF-Junky on February 02, 2020, 01:13:10 pm
This is beginner's stuff, indeed, but since the wiki page does not give explanation on the current version of the variables editor in FRED, I'm a little in the dark here. What exactly do "save on mission complete", "save on mission close", and "eternal" respectively do? The old "campaign-persistent" and "player-persistent" were a lot more self-explanatory imo.
Title: Re: Help needed on variables editor
Post by: General Battuta on February 02, 2020, 03:02:14 pm
Save on mission complete = the variable will only be altered permanently if you beat the mission and proceed in the campaign. (Right?)

Save on mission close = the variable will be altered no matter how the mission ends, whether in failure, success, or just an alt-f4. (Right?)

Eternal = uh I think changes are always saved and it persists across campaigns...?

Someone should check me on this.
Title: Re: Help needed on variables editor
Post by: wookieejedi on February 02, 2020, 04:21:19 pm
Those are correct, as far as I have tested and used them anyway.
Title: Re: Help needed on variables editor
Post by: 0rph3u5 on February 03, 2020, 09:01:00 pm
Save on mission complete = the variable will only be altered permanently if you beat the mission and proceed in the campaign. (Right?)

Correct.

Save on mission close = the variable will be altered no matter how the mission ends, whether in failure, success, or just an alt-f4. (Right?)

Add restart and "quit to mainhall" to that list.

I am not sure about Alt+F4.

Eternal = uh I think changes are always saved and it persists across campaigns...?

This moves the location where the variable is saved from "with the campaign save file" to "with the player data" (the files are still in the same folder, its just a different file). An Eternal variable will not be reset if the campaign that uses it is reset in the campaign-section of the main hall. If you want that to happen you have to make that happen yourself.


Note: Note on these work in the Mission Simulator. The variables will fall back to their default value.
Title: Re: Help needed on variables editor
Post by: Trivial Psychic on February 04, 2020, 08:07:55 am
I asked this in a different thread but it doesn't seem to be getting any attention, so I'll add it here.  Persistent variables, in this case the "Save on Mission Complete" ones, in order to pass this information from one mission to the next, I need to make the variable in mission 1, have some point when the data is acquired, flag it as save-on-mission-complete, then in a later mission create another variable in that mission with the exact same name, and then use the data?  Do I need to flag this as save-on-mission-complete as well?  As this is a numeric variable, do I need to do something special with its initial value?
Title: Re: Help needed on variables editor
Post by: 0rph3u5 on February 04, 2020, 07:30:11 pm
Persistent variables, in this case the "Save on Mission Complete" ones, in order to pass this information from one mission to the next, I need to make the variable in mission 1, have some point when the data is acquired, flag it as save-on-mission-complete, then in a later mission create another variable in that mission with the exact same name, and then use the data?

Yes

As this is a numeric variable, do I need to do something special with its initial value?

The initial value get's overriden in campaign mode, however in the Mission Simulator the campaign persistent variable will default to it initial value.

E.g. For the re-release of Light of Antares I added some inter-mission persistence to the cruisers. During one testing run I made the mistake of not including a "when variable = 0, ship-vanish" and 0 as default value for the persistence variable. The event that set the ship to the saved hull value then set the ship 0 percent hull causing it to explode almost instantly as the mission starts, when played in the Mission Simulator.
Title: Re: Help needed on variables editor
Post by: Trivial Psychic on February 04, 2020, 09:23:14 pm
Thanks for the top about the 0 thing.  I thought I was doing everything right.  I'll have to take another look at things again.
Title: Re: Help needed on variables editor
Post by: SF-Junky on February 05, 2020, 12:37:51 pm
Thanks for the replies. "save on mission complete" pretty much seems to be the old "campaign-persistent". Because I remembered I had old missions lying around which used "campaign-persistent" variables and those are flagged "save on mission complete" when you open them in FRED.

I still don't really understand how "eternal" works. I made a little test campaign in which I had a variable as "save on mission complete" plus "eternal" which resulted in the variable not storing changes between missions, i.e. it was back to default in the second mission. Are they not supposed to be used together or what?
Title: Re: Help needed on variables editor
Post by: Nightmare on February 05, 2020, 04:06:54 pm
I strongly belive that both variables have to be the same type.
Title: Re: Help needed on variables editor
Post by: 0rph3u5 on February 05, 2020, 08:35:31 pm
I still don't really understand how "eternal" works. I made a little test campaign in which I had a variable as "save on mission complete" plus "eternal" which resulted in the variable not storing changes between missions, i.e. it was back to default in the second mission. Are they not supposed to be used together or what?

Do both the "save" and "recall" events work properly? - I have had that issue with an unreleased version of Walking on Ashes (1.0.5). - Event.log is your friend here.
Title: Re: Help needed on variables editor
Post by: karajorma on February 13, 2020, 01:11:38 am
I still don't really understand how "eternal" works. I made a little test campaign in which I had a variable as "save on mission complete" plus "eternal" which resulted in the variable not storing changes between missions, i.e. it was back to default in the second mission. Are they not supposed to be used together or what?

That should have worked. Was the variable in the second mission also flagged as eternal? If not the game should throw up an error message in debug mode but in normal builds IIRC it will just silently use a new standard "save on mission complete" variable instead.
Title: Re: Help needed on variables editor
Post by: SF-Junky on February 14, 2020, 01:34:48 pm
Yes, the variables have the same name and the same flags on in both missions. Without "eternal" everything works as it should be.
Title: Re: Help needed on variables editor
Post by: karajorma on February 15, 2020, 09:36:10 pm
So let me get this straight, you have two missions in the same campaign, the first one creates a eternal, save on mission complete variable. The second mission calls the same variable but the value is reset to the default value, not the one set by the eternal variable. Are you running in debug mode without errors?
Title: Re: Help needed on variables editor
Post by: SF-Junky on February 16, 2020, 02:02:55 pm
Where is the fs2_open.log stored again?
Title: Re: Help needed on variables editor
Post by: Nightmare on February 17, 2020, 10:21:17 am
Doesn't Knossos have a button for that?