Input value, variable grammar
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.
Input value, variable grammar
I admit I don't know it, because I never needed it so far.
Is there a way to allow the player to freely input a variable that I can save?
e.g. - Enter your name here ...
Also I wonder if there is a description of how wml variables can be manipulated in a better way.
So far I use things like this: $({PRICE}/2) --> it will take the macro placeholder price and divide it and put out its value.
Is there a description for the syntax, somewhere?
For example is it possible to set several single variables at the same time?
Array handling with wml would be useful, too.
Is there a way to allow the player to freely input a variable that I can save?
e.g. - Enter your name here ...
Also I wonder if there is a description of how wml variables can be manipulated in a better way.
So far I use things like this: $({PRICE}/2) --> it will take the macro placeholder price and divide it and put out its value.
Is there a description for the syntax, somewhere?
For example is it possible to set several single variables at the same time?
Array handling with wml would be useful, too.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Input value, variable grammar
[message] has a [text_input] that is iirc also used in a mainline scenario. But ofc you can also use wesnoth.show_dialogHeindal wrote:I admit I don't know it, because I never needed it so far.
Is there a way to allow the player to freely input a variable that I can save?
e.g. - Enter your name here ...
You mean a docuemtation about formula? afaik there is teh formulaai wikipage. Also celmin recently wokred on the formula implementation so maybe the wiki pages were improves aswell.Heindal wrote: Also I wonder if there is a description of how wml variables can be manipulated in a better way.
So far I use things like this: $({PRICE}/2) --> it will take the macro placeholder price and divide it and put out its value.
Is there a description for the syntax, somewhere?
Not sure what you mean here.Heindal wrote: For example is it possible to set several single variables at the same time?
Array handling with wml would be useful, too.
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: Input value, variable grammar
Thanks gfgtdf,
I will try out to use the suggested method, however I feel like I've already found a better solution.
I will look into the wiki page than. I've already browsed through that, but never found something like that.
The last question is something that is a basic in every coding language.
For example in javascript you use a comma seperated list to set variables to a specific value (0 or 1 or meatrolls). This also defines these 'variables', so they exist and can be addressed and manipulated.
You might have looked into Strange Legacy and maybe realized that I'm defining a lot variables right from the start. Even so this is not necessary, as a variable in WML get's a value and is defined when manipulated the first time, I've used this features to generate a list of several consumable rpg items. This way I can assure that the list/overview shows '0' from the start. So the question is - is that possible:
[set_variables]
name=variable1,variable2,variable3
value=0
[/set_variables]
I will try out to use the suggested method, however I feel like I've already found a better solution.
I will look into the wiki page than. I've already browsed through that, but never found something like that.
The last question is something that is a basic in every coding language.
For example in javascript you use a comma seperated list to set variables to a specific value (0 or 1 or meatrolls). This also defines these 'variables', so they exist and can be addressed and manipulated.
You might have looked into Strange Legacy and maybe realized that I'm defining a lot variables right from the start. Even so this is not necessary, as a variable in WML get's a value and is defined when manipulated the first time, I've used this features to generate a list of several consumable rpg items. This way I can assure that the list/overview shows '0' from the start. So the question is - is that possible:
[set_variables]
name=variable1,variable2,variable3
value=0
[/set_variables]
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Re: Input value, variable grammar
No, [set_variable] can't set multiple variables at once, and [set_variables] only operates on arrays.Heindal wrote:So the question is - is that possible:
[set_variables]
name=variable1,variable2,variable3
value=0
[/set_variables]
Re: Input value, variable grammar
I''m suprised to hear that since afaik these two are the only ways to get arbitary text input from the user, mabye you can explain how you have done it?Heindal wrote:Thanks gfgtdf,
I will try out to use the suggested method, however I feel like I've already found a better solution.
I dont remember having looked at strange legacys code, which doesn't mean i never did.Heindal wrote: I will look into the wiki page than. I've already browsed through that, but never found something like that.
The last question is something that is a basic in every coding language.
For example in javascript you use a comma seperated list to set variables to a specific value (0 or 1 or meatrolls). This also defines these 'variables', so they exist and can be addressed and manipulated.
You might have looked into Strange Legacy and maybe realized that I'm defining a lot variables right from the start. Even so this is not necessary, as a variable in WML get's a value and is defined when manipulated the first time, I've used this features to generate a list of several consumable rpg items. This way I can assure that the list/overview shows '0' from the start. So the question is - is that possible:
No [set_variable] cannot do that but you can alwas use lua/wml to define your own wml tag/macro to do this.Heindal wrote:
[set_variables]
name=variable1,variable2,variable3
value=0
[/set_variables]
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: Input value, variable grammar
See the documentation for Special attribute values, specifically: key = "$(formula-expression)". If you have a more specific question, just ask.Heindal wrote: I wonder if there is a description of how wml variables can be manipulated in a better way.
So far I use things like this: $({PRICE}/2) --> it will take the macro placeholder price and divide it and put out its value.
Is there a description for the syntax, somewhere?
The easiest way to initialize a bunch of variables at the start of a scenario is probably with the [variables] tag.Heindal wrote: For example is it possible to set several single variables at the same time?
Code: Select all
[variables]
variable1,variable2,variable3=0,0,0
[/variables]
There is a sticky post at the top of the WML Workshop about array handling. It is slightly outdated, but the information is still useful. If you have a more specific question, just ask.Heindal wrote: Array handling with wml would be useful, too.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Input value, variable grammar
I reccomend not to do this, it is efectlveley undefined how this behaves if there are already varaibles from the previous scenario, in particular it might happen that this discards all variables from the previous scenario.Sapient wrote: The easiest way to initialize a bunch of variables at the start of a scenario is probably with the [variables] tag.
Code: Select all
[variables] variable1,variable2,variable3=0,0,0 [/variables]
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: Input value, variable grammar
Wow that sounds like a great way to clear variables! Just kidding, that sounds horrible... surely a merge would be more useful?gfgtdf wrote:I reccomend not to do this, it is efectlveley undefined how this behaves if there are already varaibles from the previous scenario, in particular it might happen that this discards all variables from the previous scenario.Sapient wrote: The easiest way to initialize a bunch of variables at the start of a scenario is probably with the [variables] tag.
Code: Select all
[variables] variable1,variable2,variable3=0,0,0 [/variables]
Still, it should be valid for 1st scenario... if it's broken for 1st scenario that's definitely a bug.
Thanks for the tip.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Input value, variable grammar
Not sure, it might interfere with the variables creates bySapient wrote: Still, it should be valid for 1st scenario...
[options]
https://wiki.wesnoth.org/OptionWML (i wonder why that page called OptionWML instead of OptionsWML ?). Didn't test that though.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: Input value, variable grammar
Hi Sapient and gfgtdf,
I will see if I can use variables, maybe in a test campaign. According the input idea that I had: I like to think out of the box - its a terrible curse.
I made several buttons which can influence a variable. I'm not quite sure if that is possible for a name (in javascript you can add text to a string variable with +=""), but I just wanted the player to quickly buy and sell a number of products. This is something you probably have seen on consoles or devices without keyboard.
Thanks
Heindal
I will see if I can use variables, maybe in a test campaign. According the input idea that I had: I like to think out of the box - its a terrible curse.
I made several buttons which can influence a variable. I'm not quite sure if that is possible for a name (in javascript you can add text to a string variable with +=""), but I just wanted the player to quickly buy and sell a number of products. This is something you probably have seen on consoles or devices without keyboard.
Thanks
Heindal
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer