Appending to a variable
Moderator: Forum Moderators
-
- Posts: 8
- Joined: July 2nd, 2004, 4:42 pm
Appending to a variable
I'm trying to build a campaign where the allowable recruits are determined by user actions. For instance, my first level has two opponents: an Orc with Wolf Riders, and an Elf with Elvish Scouts. In the next level, the user will be able to recruit either Wolf Riders or Elvish Scouts, depending on which opponent he defeats. The problem is it's going to be pretty cumbersome to figure out the list of recruits through a big series of [if] tags. It's doable, just cumbersome. So I'm hoping to define an allRecruits variable, and just append to it every time the user gets another unit to recruit. But I can't figure out how to append. I've tried:
[set_variable]
name=allRecruits
value="$allRecruits,{TYPE_LONG}"
[/set_variable]
I've tried leaving off the quotes, and replacing them with parens as well. I've looked through the WML online docs, but I can't find my answer. If anyone knows, please let me know both the correct syntax and where I should have gone to find it. Thanks.
[set_variable]
name=allRecruits
value="$allRecruits,{TYPE_LONG}"
[/set_variable]
I've tried leaving off the quotes, and replacing them with parens as well. I've looked through the WML online docs, but I can't find my answer. If anyone knows, please let me know both the correct syntax and where I should have gone to find it. Thanks.
Re: Appending to a variable
you don't need to do this. The "recruit" key specifies which units the player can recruit that could not be recruited previously, so you don't need to make a list.ImLittleJon wrote:The problem is it's going to be pretty cumbersome to figure out the list of recruits through a big series of [if] tags.
After testing, I found out that "$" doesn't have meaning in the "value" key; that is, "{VARIABLE list $value}" will set the variable "list" to "$value", not whatever the value of "value" is. However, if you display a message:
Code: Select all
message=$list
Code: Select all
message=$value
Code: Select all
message={VALUE}
#VALUE is the value of "value"
Last edited by Dacyn on July 2nd, 2004, 5:37 pm, edited 1 time in total.
-
- Posts: 8
- Joined: July 2nd, 2004, 4:42 pm
Re: Appending to a variable
I could be wrong, but I think I need to do this, so that the recruiting options carry over to the next scenario in the campaign. Within the scenario, it's all good. I can just use the [allow_recruit] tag. But for the next scenario, I still have to define the recruit= parameter in the [side] tag, don't I? Or does it default to whatever was allowed at the end of the previous scenario? If so, do I just leave off the recruit= param, or leave it blank?Dacyn wrote: you don't need to do this. The "recruit" key specifies which units the player can recruit that could not be recruited previously, so you don't need to make a list.
Re: Appending to a variable
The "recruit" key works the same way as the [allow_recruit] tag.ImLittleJon wrote:But for the next scenario, I still have to define the recruit= parameter in the [side] tag, don't I? Or does it default to whatever was allowed at the end of the previous scenario?
Leaving it blank will work; I'm not sure about getting rid of it...ImLittleJon wrote:If so, do I just leave off the recruit= param, or leave it blank?
Re: Appending to a variable
The units the player can recruit is the union of the units they could recruit last scenario, and the units specified by the recruit= key, if present. This means you can omit recruit= and it will simply use the units that can be recruited at the end of the last scenario.ImLittleJon wrote:Or does it default to whatever was allowed at the end of the previous scenario? If so, do I just leave off the recruit= param, or leave it blank?
The only way a player can lose the ability to recruit a unit is if you specifically remove it, using [disallow_recruit].
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Re: Appending to a variable
what about [set_recruit]?Dave wrote:The only way a player can lose the ability to recruit a unit is if you specifically remove it, using [disallow_recruit].
Re: Appending to a variable
Ermm yeah, or [set_recruit]Dacyn wrote:what about [set_recruit]?Dave wrote:The only way a player can lose the ability to recruit a unit is if you specifically remove it, using [disallow_recruit].
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming