Appending to a variable

Discussion and development of scenarios and campaigns for the game.

Moderator: Forum Moderators

Post Reply
ImLittleJon
Posts: 8
Joined: July 2nd, 2004, 4:42 pm

Appending to a variable

Post by ImLittleJon »

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.
Dacyn
Posts: 1855
Joined: May 1st, 2004, 9:34 am
Location: Texas

Re: Appending to a variable

Post by Dacyn »

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.
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.

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"
leaving little trace of the dollar sign.
Last edited by Dacyn on July 2nd, 2004, 5:37 pm, edited 1 time in total.
ImLittleJon
Posts: 8
Joined: July 2nd, 2004, 4:42 pm

Re: Appending to a variable

Post by ImLittleJon »

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.
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
Posts: 1855
Joined: May 1st, 2004, 9:34 am
Location: Texas

Re: Appending to a variable

Post by Dacyn »

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?
The "recruit" key works the same way as the [allow_recruit] tag.
ImLittleJon wrote:If so, do I just leave off the recruit= param, or leave it blank?
Leaving it blank will work; I'm not sure about getting rid of it...
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Re: Appending to a variable

Post by Dave »

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 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.

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
Dacyn
Posts: 1855
Joined: May 1st, 2004, 9:34 am
Location: Texas

Re: Appending to a variable

Post by Dacyn »

Dave wrote:The only way a player can lose the ability to recruit a unit is if you specifically remove it, using [disallow_recruit].
what about [set_recruit]?
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Re: Appending to a variable

Post by Dave »

Dacyn wrote:
Dave wrote:The only way a player can lose the ability to recruit a unit is if you specifically remove it, using [disallow_recruit].
what about [set_recruit]?
Ermm yeah, or [set_recruit] :oops:

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Post Reply