How to reload a scenario 2 or 3 times in a campaign

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
winkr7
Posts: 53
Joined: May 16th, 2019, 2:09 pm

How to reload a scenario 2 or 3 times in a campaign

Post by winkr7 »

Hello;

My hero wanders in and out of a scenario as part of a SP campaign. He alters events and once altered wants to return to the scenario later as it was left. So the events need to know they have been triggered and not reloaded from scratch. Is there a way to save and load a scenario, including the units active in the scenario and the triggered events as triggered in a previous visit. IE exactly as it was left when the scenario was finished? I see save as part of a save game, but how do I load just the scenario?

thanks for your time
yours
winkr7
User avatar
Ravana
Forum Moderator
Posts: 3314
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How to reload a scenario 2 or 3 times in a campaign

Post by Ravana »

There is no simple way. For events you can set their id as variable and check for that variable with [filter_condition].
User avatar
winkr7
Posts: 53
Joined: May 16th, 2019, 2:09 pm

Re: How to reload a scenario 2 or 3 times in a campaign

Post by winkr7 »

Ravana;

Thankyou.

yours
winkr7
User avatar
beetlenaut
Developer
Posts: 2867
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: How to reload a scenario 2 or 3 times in a campaign

Post by beetlenaut »

winkr7 wrote: October 23rd, 2022, 1:14 pm Is there a way to save and load a scenario, including the units active in the scenario and the triggered events as triggered in a previous visit
Depending on what the events did, you can probably store the effects themselves when the hero leaves the scenario. You can store the whole map with [store_locations] if an event could have changed the map, and you can [store_items] if something could have gotten added. You also have [store_unit] and [store_villages]. Maybe that will help, though you will still need Ravana's solution or something similar for disabling previously-triggered events.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
winkr7
Posts: 53
Joined: May 16th, 2019, 2:09 pm

Re: How to reload a scenario 2 or 3 times in a campaign

Post by winkr7 »

Thanks beetlenaut;
I will consider the [store_unit] and [store_items]. To load them in I have to erase all the units and items loaded by the scenario at start correct?
Also, how do I access scenario.id? I have tried getting it from prestart events, start events and the scenario tag level and the side tag level and I always come up blank.

thanks for your time.
yours
winkr7
User avatar
beetlenaut
Developer
Posts: 2867
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: How to reload a scenario 2 or 3 times in a campaign

Post by beetlenaut »

winkr7 wrote: October 24th, 2022, 5:25 pm I have to erase all the units and items loaded by the scenario at start correct?
Yes, you would. It's only a few lines though.
winkr7 wrote: October 24th, 2022, 5:25 pm Also, how do I access scenario.id?
You can't just invent a variable like that. You can use :inspect to see all the variables that currently exist. A container called "scenario" will not be there. If you need it, you can set it as a variable or macro in the prestart event. You entered it at the top (probably) of the scenario, so you know what it is. It's probably also visible to the Lua API somewhere, but you still can't make up a name.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
winkr7
Posts: 53
Joined: May 16th, 2019, 2:09 pm

Re: How to reload a scenario 2 or 3 times in a campaign

Post by winkr7 »

beetlenaut;

Thanks for the help as always. I assumed id was part of scenario--a property of scenario. I assumed that id was what next_scenario referenced.

I will try to set a variable in prestart. A good suggestion, thanks.

yours
winkr7
User avatar
beetlenaut
Developer
Posts: 2867
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: How to reload a scenario 2 or 3 times in a campaign

Post by beetlenaut »

winkr7 wrote: October 24th, 2022, 6:35 pm I assumed id was part of scenario--a property of scenario.
And that's probably true in the engine's C++ code, but WML doesn't have access to those variables. There are only a handful of variables in WML that are stored automatically. You need to use the [store_*] tags to gain access to more of them, but there is no tag for storing the whole scenario. If you haven't been, you definitely should be using :inspect to see what the scenario structure looks like before and after you store variables. (I always set it as a menu item when I am testing.)

Code: Select all

[set_menu_item]
    id=inspection
    description="Inspect"
    [command]
        [inspect][/inspect]
    [/command]
[/set_menu_item]
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
winkr7
Posts: 53
Joined: May 16th, 2019, 2:09 pm

Re: How to reload a scenario 2 or 3 times in a campaign

Post by winkr7 »

beetlenaut;

Yeah, I got the menu for inspect from one of your earlier wml examples back in may--thanks. I didn't realize it showed every available variable, I thought it was a debug subset.

thanks for your time
yours
winkr7
Post Reply