Working out with "sighted: event
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.
Working out with "sighted: event
Welcome again (or not).
I am still a newcomer to WML and I am working out with tag [event] and trying to make such a situation:
When my unit first time sees any other side unit, I make two branches. The first branch must show the unique response of the unit with side = 2, the second- another response of the unit with side = 3.
So, the question is, how should I check variable side in if statement, or is there any simpler method to do this with only filters?
[Below] My code:
I am still a newcomer to WML and I am working out with tag [event] and trying to make such a situation:
When my unit first time sees any other side unit, I make two branches. The first branch must show the unique response of the unit with side = 2, the second- another response of the unit with side = 3.
So, the question is, how should I check variable side in if statement, or is there any simpler method to do this with only filters?
[Below] My code:
Code: Select all
[event]
name=sighted
first_time_only=yes
[filter]
side=1
[/filter]
[filter_second]
side=2,3
[message]
speaker=unit
message= _"Oh! I see someone!"
[/message]
[if]
[variable]
name=side
equals=2
[/variable]
[then]
[message]
speaker=second_unit
message= _"Retain your swords. We don't want to fight!"
[/message]
[message]
speaker=Duncan
message= _"(Ok no matter what happens). Agreed. So, what's goi..."
[/message]
[/then]
[elseif]
[variable]
name=side
equals=3
[/variable]
[then]
[message]
speaker=second_unit
message= _"Ooppss... Those are not elves!"
[/message]
[message]
speaker=Duncan
message= _"We... Elves? ... What..?"
[/message]
[/then]
[/elseif]
[/if]
[/event]
Re: Working out with "sighted: event
Why not simply split that code into two different events?
Re: Working out with "sighted: event
Why do people always answer with quotes?
Everybody can read one line higher what I have written, why the repetition ?
Edit: I think the easiest solution is to use two events. Keep it simple.
Edit 2: the variable in your example must be variable=second_unit.side
Everybody can read one line higher what I have written, why the repetition ?
Edit: I think the easiest solution is to use two events. Keep it simple.
Edit 2: the variable in your example must be variable=second_unit.side
Last edited by Straff on November 23rd, 2021, 10:05 pm, edited 1 time in total.
- skeptical_troll
- Posts: 500
- Joined: August 31st, 2015, 11:06 pm
Re: Working out with "sighted: event
You're almost there. What you need to change is that the variable 'side' is not defined in the 'sighted' event, but you have the 'unit' and 'secon_unit' variables. So you need to use
instead of what you have, and I believe it should work. You can read the documentation about events to check this kind of things.
Also, I think you are better off posting this kind of questions in the 'WML workshop' section of the forum, which is more code-centered, rather than the scenario/campaign development.
Code: Select all
[variable]
name = second_unit.side
equals = 2
[/variable]
Also, I think you are better off posting this kind of questions in the 'WML workshop' section of the forum, which is more code-centered, rather than the scenario/campaign development.
Re: Working out with "sighted: event
Also, I didn't mention, after one of these two events has been triggered, the other should not fire never.
It means, I need to use [remove] in both of them, to avoid executing of remaining event?
It means, I need to use [remove] in both of them, to avoid executing of remaining event?
Re: Working out with "sighted: event
skeptical_troll, thank you too.
Now I know what to do))
Now I know what to do))
- skeptical_troll
- Posts: 500
- Joined: August 31st, 2015, 11:06 pm
Re: Working out with "sighted: event
Also note that with
Finally, note that according to the documentation, the sighting unit is the secondary one, and the unit who is sighted is the primary (the 'unit' variable).
first time only = yes
, the event will only trigger for the first one of the two sides. If you want it to trigger for both, you need two events as Straff suggests, or set it to 'no', but it would trigger multiple times for the same side.Finally, note that according to the documentation, the sighting unit is the secondary one, and the unit who is sighted is the primary (the 'unit' variable).
Re: Working out with "sighted: event
Yeah, I know about first time only. That's why I wished to do event in one [event], because if i use two events, it will be harder to define whether one of them is executed.skeptical_troll wrote: ↑November 23rd, 2021, 10:10 pm Also note that withfirst time only = yes
, the event will only trigger for the first one of the two sides. If you want it to trigger for both, you need two events as Straff suggests, or set it to 'no', but it would trigger multiple times for the same side.
Finally, note that according to the documentation, the sighting unit is the secondary one, and the unit who is sighted is the primary (the 'unit' variable).
Re: Working out with "sighted: event
And i also wanted to avoid creating additional flags...
Re: Working out with "sighted: event
In any case, thanks anyone for help. I will not forget all helpers and even will mention them in credits (when the time comes)...