Make message speaker $unit or $second_unit during attack
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 message speaker $unit or $second_unit during attack
I have an event that fires when one of a side's units is involved in an attack (either the attacker or the one attacked). I would like this unit to be the speaker of a [message].
I have tried assigning the unit to a variable and using that, but it doesn't seem to work.
Does anyone know how I can do this?
I have tried assigning the unit to a variable and using that, but it doesn't seem to work.
Code: Select all
[event]
name=attack
[filter_condition]
[variable]
name=unit.side
equals=4
[/variable]
[or]
[variable]
name=second_unit.side
equals=4
[/variable]
[/or]
[/filter_condition]
[if]
[variable]
name=unit.side
equals=4
[/variable]
[then]
[set_variable]
name=ayndun_unit
equals=unit
[/set_variable]
[/then]
[else]
[set_variable]
name=ayndun_unit
equals=second_unit
[/set_variable]
[/else]
[/if]
[message]
speaker=ayndun_unit
message = _ "..."
[/message]
{CLEAR_VARIABLE ayndun_unit}
[/event]
Re: Make message speaker $unit or $second_unit during attack
Try equals=(second_)unit.id
Re: Make message speaker $unit or $second_unit during attack
Thanks Ravana! That was indeed part of the problem. I also realized I was using the wrong syntax. I needed to use "value" instead of "equals", and use $ to reference the variable. The final working code is:
Code: Select all
[event]
name=attack
[filter_condition]
[variable]
name=unit.side
equals=4
[/variable]
[or]
[variable]
name=second_unit.side
equals=4
[/variable]
[/or]
[/filter_condition]
[if]
[variable]
name=unit.side
equals=4
[/variable]
[then]
[set_variable]
name=ayndun_unit
value=$unit.id
[/set_variable]
[/then]
[else]
[set_variable]
name=ayndun_unit
value=$second_unit.id
[/set_variable]
[/else]
[/if]
[message]
speaker=$ayndun_unit
message = _ "..."
[/message]
{CLEAR_VARIABLE ayndun_unit}
[/event]