[preload] [prestart] [start] events

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
denispir
Posts: 184
Joined: March 14th, 2013, 12:26 am

[preload] [prestart] [start] events

Post by denispir »

Hello,

I am a bit confused about [preload] [prestart] [start] events, like many probably ;-). I would like someone knowledgeable to clearly explain why each exists, what actually happens, how all is done in fact. Here is my present best guess, as I wrote inside a scenario intended to explain WML usage in practice (also to myself!):

In a scenario, the major phases are defined more or less in chronology:
* general scenario information
* Story text
(switch from story telling to game construction)
* Definition of startup sides
(the map and its content are defined in memory)
* Prestart: define objectives, place or recall units, change map...
(the map and its content are drawn onto the screen)
* Start: initial action (eg dialog, movement)
(now the player can play)
* Other events specific to the scenario: eg, an ally or ennemy troop arrives
(the player wins or loses)
* End-of-scenario (called "endlevel")

(Note that "preload" is missing.)

Now, more precise guesses about predefined events (also text from my scenario, except for preload):

* preload:
Only for Lua? (I have only seen it used in Lua context.) If yes, I would like to understand why and how.

* prestart:
This event is triggered after the story is told,
but before the user interface is drawn, especially the map.
But the map and all what is contains is defined in memory,
so that we can add, change, or remove elements (ex. units) in this event.
Here we can place companions of the hero or manipulate the recall list.
This is also a good event to define objectives??? (why not at top scenario level?)

* start:
This event is triggered after the user interface is drawn,
but before the player can actually play.
Here we can write startup dialogues, as well as help or info texts.
This is also a good event for units that arrive or leave at startup.

What is right or wrong about my guesses?
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [preload] [prestart] [start] events

Post by Ravana »

The difference between preload and prestart is that preload happens after reloading save. So you can use it to add check if reloading allowed at that time.
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: [preload] [prestart] [start] events

Post by gfgtdf »

There is afaik currently no real usecase for preload events, lua can be initialized in [lua] directly at [scenario], and ir you really want 'on-reload' events you must be extremely cautious since it is not synced. I reccomend simply not to use it for normal stuff.

Back in 1.10 preload events would be the way to initialize lua code.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [preload] [prestart] [start] events

Post by Ravana »

[lua] is not supported in [era], so preload is needed there.
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: [preload] [prestart] [start] events

Post by gfgtdf »

Ravana wrote: November 1st, 2019, 5:19 pm [lua] is not supported in [era], so preload is needed there.
At least in 1.14 and later, this is wrong
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [preload] [prestart] [start] events

Post by Ravana »

Added.
denispir
Posts: 184
Joined: March 14th, 2013, 12:26 am

Re: [preload] [prestart] [start] events

Post by denispir »

Thank you all!
Since there is no critic of my description (in first post) of these events and their uses, should I consider that it is correct anough? Others may read that, especially novice campaign authors, who I do not want to mislead...
User avatar
octalot
General Code Maintainer
Posts: 786
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: [preload] [prestart] [start] events

Post by octalot »

The main place for these docs would be the wiki's EventWML page. For the first message in this thread, I think (but I'm not sure) that the definition of sides takes place before the [story].
denispir
Posts: 184
Joined: March 14th, 2013, 12:26 am

Re: [preload] [prestart] [start] events

Post by denispir »

octalot wrote: November 2nd, 2019, 11:24 am The main place for these docs would be the wiki's EventWML page. For the first message in this thread, I think (but I'm not sure) that the definition of sides takes place before the [story].
Thank you Octalot. This last info is relevant for another task, namely defining player troops for a "trial mode", thank to which we'd jump to a given scenario. I need to know what, especially which hero or other special units, are defined or not before my jump event (which cant take place before the 1st [preload]). Ideally, they would be all defined or all undefined, so that I can process all the same way: by either creating or modifying them.
Post Reply