Make event trigger in a certain time interval
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.
Make event trigger in a certain time interval
How can I make an event trigger once per turn or once every second turn?
I know I can use "turn X" but then I'll need to write one event for each turn. "new turn" will trigger for each side once so that won't work either. "side turn" should work for once per turn, but how do I check against the side number?
I tried this:
But it seems to never trigger.
I know I can use "turn X" but then I'll need to write one event for each turn. "new turn" will trigger for each side once so that won't work either. "side turn" should work for once per turn, but how do I check against the side number?
I tried this:
Code: Select all
[event]
name=side turn
first_time_only=no
[filter]
side_number=4
[/filter]...
Wesnoth
The developer says "no".
The developer says "no".
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Make event trigger in a certain time interval
read the reference wml what can go inside [filter]
Code: Select all
[event]
name=side turn
first_time_only=no
[if]
[variable]
name=side_number
numerical_equals=4
[/variable]
[then]
...
[/then]
[/if]
[/event]
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Re: Make event trigger in a certain time interval
Ok thanks, and what to do for "every second turn"?
Wesnoth
The developer says "no".
The developer says "no".
- solsword
- Code Contributor
- Posts: 291
- Joined: January 12th, 2009, 10:21 pm
- Location: Santa Cruz, CA
- Contact:
Re: Make event trigger in a certain time interval
Something like this (warning: untested code):
If you're not familiar with it, the '%' operator gets the remainder after division, so %2 will be 1 for odd numbers and 0 for even numbers (where 1 evaluates to 'yes' and 0 to 'no' for boolean comparison).
Code: Select all
[event]
name=side turn
first_time_only=no
[set_variable]
name=oddturn
value="$($turn_number%2)"
[/set_variable]
[if]
[variable]
name=oddturn
boolean_equals=yes
[/variable]
[then]
...
[/then]
[/if]
[/event]
The Knights of the Silver Spire campaign.
http://www.cs.hmc.edu/~pmawhorter - my website.
Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?
http://www.cs.hmc.edu/~pmawhorter - my website.
Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?
Re: Make event trigger in a certain time interval
Can I also check on two variables at once? For example to say "Every turn of side 4 if the turn count is higher than 20".
Edit: I just noticed that "new turn" only triggers once too... the documentation however says it triggers each time someone ends his turn.
Edit: I just noticed that "new turn" only triggers once too... the documentation however says it triggers each time someone ends his turn.
Wesnoth
The developer says "no".
The developer says "no".
- solsword
- Code Contributor
- Posts: 291
- Joined: January 12th, 2009, 10:21 pm
- Location: Santa Cruz, CA
- Contact:
Re: Make event trigger in a certain time interval
You can use [and] tags to check as many things as you want inside the [if] tag.
If you're reading the same documentation I am (the wiki) you'll notice that it says "new turn" triggers when the *last* player ends their turn. The event you want is probably "side turn" which fires at the beginning of each side's turn. It's confusing because there are two concepts of turn: the "side turn" which is one side moving all of their units, and the "turn", in which every side gets its "side turn" and then the time of day advances.
If you're reading the same documentation I am (the wiki) you'll notice that it says "new turn" triggers when the *last* player ends their turn. The event you want is probably "side turn" which fires at the beginning of each side's turn. It's confusing because there are two concepts of turn: the "side turn" which is one side moving all of their units, and the "turn", in which every side gets its "side turn" and then the time of day advances.
The Knights of the Silver Spire campaign.
http://www.cs.hmc.edu/~pmawhorter - my website.
Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?
http://www.cs.hmc.edu/~pmawhorter - my website.
Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?
Re: Make event trigger in a certain time interval
All side initialization events fire pretty much the same time. I don't know why it was worded that weird in the wiki but I fixed that now.solsword wrote:If you're reading the same documentation I am (the wiki) you'll notice that it says "new turn" triggers when the *last* player ends their turn.
"If gameplay requires it, they can be made to live on Venus." -- scott
Re: Make event trigger in a certain time interval
An alternative would be to add 1 to a variable every turn, and execute the event and set the variable to 0 if the variable is 2.solsword wrote:Something like this (warning: untested code):
If you're not familiar with it, the '%' operator gets the remainder after division, so %2 will be 1 for odd numbers and 0 for even numbers (where 1 evaluates to 'yes' and 0 to 'no' for boolean comparison).Code: Select all
[event] name=side turn first_time_only=no [set_variable] name=oddturn value="$($turn_number%2)" [/set_variable] [if] [variable] name=oddturn boolean_equals=yes [/variable] [then] ... [/then] [/if] [/event]
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.