Listing the units on a side
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.
Listing the units on a side
I want to know whether or not it is possible to use WML to store a sides units(other than the leader) into variables, then set those units as options in a menu. The main problem I have with this is getting the number of units a side has, and then having the menu list the units.
I need this is for an mp scenario, which has a structure somewhat like this:
Two players who have to beat an ai enemy 3 times, while being unable to recruit(having only a small army fitted to the particular leader they chose), but recieving reinforcements and access to shops containing upgrades and healing, then after completing this, get too choose from their units 4 which they want to take to a final round, in which they battle the other human player to win the game. If they do not have 4, or for some reason do not want any of their troops, they will recieve random units.
I know that the first part(storing the units) could be done via store unit with a filter to select all the units of the side, but I don't know how I would go about adding these as menu options for the player to select. Can someone please tell me whether this is possible, and if so, how would I do it?
I need this is for an mp scenario, which has a structure somewhat like this:
Two players who have to beat an ai enemy 3 times, while being unable to recruit(having only a small army fitted to the particular leader they chose), but recieving reinforcements and access to shops containing upgrades and healing, then after completing this, get too choose from their units 4 which they want to take to a final round, in which they battle the other human player to win the game. If they do not have 4, or for some reason do not want any of their troops, they will recieve random units.
I know that the first part(storing the units) could be done via store unit with a filter to select all the units of the side, but I don't know how I would go about adding these as menu options for the player to select. Can someone please tell me whether this is possible, and if so, how would I do it?
Even as the fingers of the two hands are equal, so are human beings equal to one another. No one has any right, nor any preference to claim over another. You are brothers. - Muhammed
It might be possible to store all the WML required to build the option menu into a single variable then pass the value of the variable as an argument of a macro, but I don't think the pain would be worth it.
Hope springs eternal.
Wesnoth acronym guide.
Wesnoth acronym guide.
I really doubt what scott suggested would work... the variable would never be expanded.
Since Option cannot take a variable number of options, you would have to do something like this:
Menu 1. Choose level of unit.
Menu 2. Choose type of unit/go back.
Menu 3. Is it one of these 5 units?/no/go back
Menu 4. One of these 5?/no/go back
etc...
Since Option cannot take a variable number of options, you would have to do something like this:
Menu 1. Choose level of unit.
Menu 2. Choose type of unit/go back.
Menu 3. Is it one of these 5 units?/no/go back
Menu 4. One of these 5?/no/go back
etc...
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
And I hate stupid people.
The World of Orbivm
This is what I tried:turin wrote:I really doubt what scott suggested would work... the variable would never be expanded.
Code: Select all
#define EXECUTE_CODE VAR
{VAR}
#enddef
[event]
name=turn 2
{VARIABLE code_2_exe ("[unit]
side=1
x,y=10,10
type=Spearman
[/unit]")}
{EXECUTE_CODE $code_2_exe}
[/event]
Hope springs eternal.
Wesnoth acronym guide.
Wesnoth acronym guide.
scott wrote:This is what I tried:Code: Select all
#define EXECUTE_CODE VAR {VAR} #enddef[/quote] What you have to remember is that WML is processed into pseudo-WML code before actually being used in-game... After that, keys and tags don't mean anything. In other words, strings which happen to contain keys are completely unrelated to the keys themselves...
OK, after reading this,am I correct in saying that what I want is impossible/extremely hard to to do atm?
Because of this, I can probably use a simpler approach, because the scenario is set up with every leader having the same size army(9 units other than leader), and the problem of the reinforcements changing this number can be solved by placing them under command of an ai. So, using this, could I store the units in an array and have the variables for each of the 9 units set as options? Also, what is the syntax for using a variable from an array(I didn't understand how to use them after looking at the wiki page)?
Because of this, I can probably use a simpler approach, because the scenario is set up with every leader having the same size army(9 units other than leader), and the problem of the reinforcements changing this number can be solved by placing them under command of an ai. So, using this, could I store the units in an array and have the variables for each of the 9 units set as options? Also, what is the syntax for using a variable from an array(I didn't understand how to use them after looking at the wiki page)?
Even as the fingers of the two hands are equal, so are human beings equal to one another. No one has any right, nor any preference to claim over another. You are brothers. - Muhammed
It shouldn't be that hard really, the main limitation is that your option menu cannot contain an arbitrarily long list. In other words, you will have to allow the user to choose from (to use turin's example) five or so units at a time, or proceed to the next five.
If you want to filter these units based on choices of level or type, that is another possibility, but not mandatory.
If you want to filter these units based on choices of level or type, that is another possibility, but not mandatory.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."