set_variable nested in "if then" using iteration: provisional results
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.
Re: set_variable nested in "if then" using iteration: provisional results
What he means is:
Don't do this:
Do this:
It's asking for the variable name to use/check/set/etc. So you want to give it the variable name. Only use the $ sign when you want the value of the variable.
Don't do this:
Code: Select all
[if]
[variable]
name=$variablename
Code: Select all
[if]
[variable]
name=variablename
-
- Posts: 33
- Joined: March 31st, 2018, 7:52 pm
- Location: USA
Re: set_variable nested in "if then" using iteration: provisional results
You are all awesome, Zookeeper's interpretation of what Ravanna was saying immediately fixed my problem. I can now dynamically pick up any specials as long as a mod uses the typical categories! I have been trying to figure this out for a few days now.
Code: Select all
#get all specials categories and ids in order to query based on either sub data or specials meta data
#create specials category list
[set_variables]
name=specials_categories
[value]
category="attacks" #0
[/value]
[value]
category="berserk" #1
[/value]
[value]
category="chance_to_hit" #2
[/value]
[value]
category="damage" #3
[/value]
[value]
category="disable" #4
[/value]
[value]
category="drains" #5
[/value]
[value]
category="dummy" #6
[/value]
[value]
category="firststrike" #7
[/value]
[value]
category="heal_on_hit" #8
[/value]
[value]
category="petrifies" #9
[/value]
[value]
category="plague" #10
[/value]
[value]
category="poison" #11
[/value]
[value]
category="slow" #12
[/value]
[value]
category="swarm" #13
[/value]
[/set_variables]
#if special exist, get it and store tag name along with id
{VARIABLE j 0}
[while]
[variable]
name="j"
less_than=$unit.attack.length
[/variable]
[do]
{VARIABLE k 0}
[while]
[variable]
name="k"
less_than=$specials_categories.length
[/variable]
[do]
{VARIABLE l 0}
[while]
[variable]
name="l"
less_than=3
[/variable]
[do]
{VARIABLE specials_category_content "$specials_categories[$k].category"}
{VARIABLE special_id_content "$unit.attack[$j].specials.$specials_categories[$k].category|[$l].id"}
[if]
[variable]
#used Ravanna's variable assignment and then used the interpretation of zookeeper
name=special_id_content
#implemented Sapient's advice on emptys
not_equals="$empty"
[/variable]
[then]
[set_variables]
name=specials_array
mode=insert
[value]
category=$specials_category_content
id=$specials_category_content
[/value]
[/set_variables]
[/then]
[/if]
{CLEAR_VARIABLE specials_category_content}
{CLEAR_VARIABLE special_id_content}
#check if special id procs using the in game inspector
{VARIABLE unit.variables.special_id_$j|$k|$l| $unit.attack[$j].specials.$specials_categories[$k].category|.length}
{VARIABLE_OP l add 1}
[/do]
[/while]
{CLEAR_VARIABLE l}
{VARIABLE_OP k add 1}
[/do]
[/while]
{CLEAR_VARIABLE k}
{VARIABLE_OP j add 1}
[/do]
[/while]
{CLEAR_VARIABLE j}
{CLEAR_VARIABLE specials_categories}
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: set_variable nested in "if then" using iteration: provisional results
@hyper_cubed: In the future, please don't doublepost.
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: set_variable nested in "if then" using iteration: provisional results
You correctly retrieve ids you underlined there, and then ask their value. You ask for variable named poison. It is not assigned any value.
-
- Posts: 33
- Joined: March 31st, 2018, 7:52 pm
- Location: USA
Re: set_variable nested in "if then" using iteration: provisional results
I think I understand what you are saying. When the engine querys for variable name, and then I use substitution to hook into name then I am setting the variable name to whatever dynamic value that my lookup yields, whereas, I should have omitted the $ to drill down to the actual variable name and not the value.
Okay.
Also, @Pentarctigon: Sorry about that, I thought that my last post left out a few things. Thanks for the kind notification.