time of day - useable for an event?

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
flava_clown
Posts: 79
Joined: September 24th, 2005, 10:46 am
Location: Spain
Contact:

time of day - useable for an event?

Post by flava_clown »

hi

i saw that i can define a time_of_the_day for the ai tag. can i use such a check for an event too? maybe like if time_of_day=dawn then blah.
i saw the workaround in UtbS but don't understand it :?

bye
Imagine there's no countries
It isn't hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Since as the scenario designer you know what the time of day cycle is, you also know what is the time of day of every turn. So, if we assume that the ToD cycle is the normal one (dawn-morning-afternoon-etc) all you need in order to make an event trigger on morning turns is to make the event trigger on turns 2,8,14, and so on. If you wish to check inside another event what ToD it currently is, you can either check for $turn_number in a similar manner or make an aforementioned-like event and just use it to set a variable (like is_morning) and another set to clear it on non-morning turns, so you can just check that variable to determine if it is morning in whatever event you wish to check for that.
flava_clown
Posts: 79
Joined: September 24th, 2005, 10:46 am
Location: Spain
Contact:

Post by flava_clown »

erm okay. to count the turns, is what i did. i am not sure if i understand the rest. but i will save it and read it later slowly...

i don't like to use variables, coz it seems that the "clear variable" command doesn't work. even if i clear a variable i'll find it with the latest value in the next save games. (maybe a bug? or just me?)

however thanx for the help.
Imagine there's no countries
It isn't hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace
zaimoni
Posts: 281
Joined: January 27th, 2005, 7:00 am
Location: Linn Valley, KS U.S.A.
Contact:

Post by zaimoni »

Not just you. I'm not yet able to build SVN, otherwise I'd have filed a bug report. If it's still there in 1.1.3 (and DNS is working for wesnoth.org at my primary ISP), I will file a bug report. [UTBS still is using the Wiki semantics, so I think it is a bug rather than an intentional change.]

This was one of the things I had to bypass to make Mystery Campaign work. The macros I used to implement the bypass are both here ( http://www.wesnoth.org/forum/viewtopic.php?t=10827), and in the dev Mystery Campaign's wesnoth/version.cfg. [stable version just forwards to the still working CLEAR_VARIABLE.]

CLEAR_VARIABLE only works properly on WML variables in the dev version. Regressions(?) from 1.0.2: tt does not work on key-value pairs at all [fix: CLEAR_KEY_VALUE], and only removes the first element of an array [fix: FLUSHARRAY].

EDIT: if what's sticking around in the savefile is something like

Code: Select all

side="1"
, that's a key-value pair; clear it with CLEAR_KEY_VALUE.
flava_clown
Posts: 79
Joined: September 24th, 2005, 10:46 am
Location: Spain
Contact:

Post by flava_clown »

no it's not side=1

an example:
i use a variable 'dam_owner_side' which can be 1,2,3 or 4 depending what happens, normaly it should be 3 if you leave the scenario. the variable should be cleared but 2 scenarios later it's still in the save game with 3 ...

second example:
we make use of a temp_string variable and the last used string can be seen in the following save games, while we use clear_variable directly after the use of the string.

however i will give your macro a try ;) and if it's a bug, then please report it!
Imagine there's no countries
It isn't hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace
Post Reply