Variable substitution broken usin [unit] to_variable=
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.
Variable substitution broken usin [unit] to_variable=
I have different result using 2 similar codes that I expected work equal.
I have use :debug and detected that in second case, the [filter] inside my [event] (with $x1 $y1 stuff) is not working with delayed substitution and takes unit values when unstored, making my event not work. ¿Is expected this behavior of to_variable= or is a bug?
I have used BfW 1.12.5
Code: Select all
[unit]
[insert_tag]
name=event
variable=my_event_variable
[/insert_tag]
[/unit]
Code: Select all
[unit]
to_variable=my_unit_variable
[insert_tag]
name=event
variable=my_event_variable
[/insert_tag]
[/unit]
[unstore_unit]
variable=my_unit_variable
[/unstore_unit]
I have used BfW 1.12.5
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: Variable substitution broken usin [unit] to_variable=
I do not know very much but perhaps, maybe, it could be that it converts the unit to a variable and then modifies the unit thereby not modifying the variable...
Do you get the same error if you rearrange the order of the code:
(i rarely use the insert_tag so this may not be the problem)
Do you get the same error if you rearrange the order of the code:
Code: Select all
[unit]
[insert_tag]
name=event
variable=my_event_variable
[/insert_tag]
# .... at the end
to_variable=my_unit_variable
[/unit]
[unstore_unit]
variable=my_unit_variable
[/unstore_unit]
Last edited by The_Gnat on November 17th, 2017, 8:46 am, edited 1 time in total.
Creator of: The Reign of The Lords Era,The Gnats Franken Dungeon.
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Variable substitution broken usin [unit] to_variable=
Posting all code related to this would be more helpful as well. So, what populates
my_event_variable
and my_unit_variable
?99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: Variable substitution broken usin [unit] to_variable=
This is extra stuff wich I considered less relevant, it is a copy paste from my addon and uses less generic names for variables and event
Code: Select all
[event]
id=wct_epic_AMLA_XP
name=post advance
first_time_only=no
[filter]
[filter_wml]
advances_to=$null
[modifications]
[trait]
id=epic
[/trait]
[/modifications]
[/filter_wml]
[/filter]
[modify_unit]
[filter]
x,y=$x1,$y1 ##here is where variable substitution changes using to_variable
[/filter]
max_experience=60
[/modify_unit]
[/event]
Code: Select all
[unit]
side=$unit.side
type=$wct.hero.type
x,y=$unit.x,$unit.y
generate_name=yes
random_gender=yes
overlays="misc/hero-icon.png"
role=just_created
[modifications]
[insert_tag]
name=trait
variable=wct.trait.heroic.trait
[/insert_tag]
[insert_tag]
name=trait
variable=wct.trait.$wct.hero.extra_trait|.trait
[/insert_tag]
[object]
{WCT_RECRUIT_EXPERIENCE_PENALTY}
[/object]
[/modifications]
[insert_tag]
name=event
variable=wct.trait.$wct.hero.extra_trait|.event ##here is where event is introduced and works fine not using to_variable
[/insert_tag]
[/unit]
Last edited by tekelili on November 17th, 2017, 9:56 pm, edited 2 times in total.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: Variable substitution broken usin [unit] to_variable=
I am setting variable value as literal, just in case could be relevant
Code: Select all
[set_variables]
name=wct
mode=merge
[literal]
[trait]
{WORLD_CONQUEST_II_ERA_TRAITS} ##here comes variable used in previous post
[/trait]
[heroes]
{WORLD_CONQUEST_II_ERA_HEROES_TYPES}
[/heroes]
[/literal]
[/set_variables]
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: Variable substitution broken usin [unit] to_variable=
looking at the code it seems like the 1.12 implementation of to_variable https://github.com/wesnoth/wesnoth/blob ... .cpp#L2432 just pasrses the whole wml content and operates on that. The good news is that that this was fixed in 1.13 long time ago. For 1.12, the only way to fix it it probably not to use to_variable, and just put a [store_unit] directly after that [unit]
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.
Re: Variable substitution broken usin [unit] to_variable=
Ty gfgtdf, now I know exactly what is going on
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II