tekelili advanced WML questions

The place to post your WML questions and answers.

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.
Post Reply
Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: tekelili WML noob questions

Post by Max »

untested, but might work: {VARIABLE_OP ($Victory+"_victory") add 1}
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: tekelili WML noob questions

Post by Sapient »

Max wrote:untested, but might work: {VARIABLE_OP ($Victory+"_victory") add 1}
No, the preprocessor will concatenate those two strings before variable interpolation occurs.
Instead you should use operator |, like so:

Code: Select all

[set_variable]
  name="$Victory|_victory"
  add=1
[/set_variable]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: tekelili WML noob questions

Post by tekelili »

I am getting this error message:
"<invalid WML found> possible deprecated [or] syntax: now forcing reinterpretation"

Code looks work ok anyway, and I didnt found in WML guide nothing to understand why I get this error.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: tekelili WML noob questions

Post by Max »

just a guess - might be caused by this years old change:

Code: Select all

Date: 15:37:18, Samstag, 14. Juli 2007
Message:
   * the syntax for logical OR-filters is now "cond1[or]cond2[/or]" 
     instead of "[or]cond1[/or][or]cond2[/or]"
SlowThinker
Posts: 876
Joined: November 28th, 2008, 6:18 pm

Re: tekelili WML noob questions

Post by SlowThinker »

tekelili wrote:I need a function (done with an event or anything else can work for it) to operate over an array (that I include as parameter when calling function). And I need can call recursively that function from inside itself. But as macros can not be called recursively,and {CALL_FUNTION} doesnt look accept arrays as parameter, I dont manage to imagine how do it. Can events be used for this in some way?
In past I decided whether to use fire_event or insert_tag for a recursion, and I felt insert_tag was better (and maybe also more powerfull, but I forgot why :doh: )

edit: the link has been replaced: more here, download the file and search for 'process_region_list_code'
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: tekelili WML noob questions

Post by tekelili »

I am unexperienced with pango. I used it once sucesfully in a message for 1.9, but I am now trying use it for a label on 1.8 and I am not able. Do pango works for labels?
In case answer is yes: what exactly I must write to change this label

Code: Select all

{SET_LABEL 1 1 "FACTION: $faction"}
so $faction is writen in white?
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: tekelili WML noob questions

Post by Anonymissimus »

This here just worked for me
wml_actions.label({ x = 15, y = 5, text = "<span foreground='blue'>blah</span>" })
So what you need is (untested)
{SET_LABEL 1 1 "FACTION: <span foreground='blue'>$faction|</span>"}

I dunno about variable substitution+pango though, perhaps they interfere.

EDIT
Of course you use the word white instead of blue.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: tekelili WML noob questions

Post by tekelili »

Anonymissimus wrote: I dunno about variable substitution+pango though, perhaps they interfere.
I still dont get pango working, so I guess variable substitution is problem :(
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
SlowThinker
Posts: 876
Joined: November 28th, 2008, 6:18 pm

Re: tekelili WML noob questions

Post by SlowThinker »

In my code <b>something</b> works with labels, and <b>should be a pango code (http://forums.wesnoth.org/viewtopic.php ... 74#p471974). So I think this should work:

Code: Select all

{SET_LABEL 1 1 "FACTION: <span color='#FFFFFF'>$faction</span>"}
Variable substitution doesn't interfere with pango.
SlowThinker wrote:In past I decided whether to use fire_event or insert_tag for a recursion, and I felt insert_tag was better (and maybe also more powerfull, but I forgot why :doh: )
The reason is: WML with insert_tag is a more powerful than WML without insert_tag.
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: tekelili WML noob questions

Post by Anonymissimus »

SlowThinker wrote:Variable substitution doesn't interfere with pango.
You never know...
I could imagine that pango could get applied first and afterwards the string gets variable-substituted. So the nicely colored variable name gets replaced by its uncolored value.

EDIT
Checked the source; variables in the text= attribute value are substituted upon constructing a label as you say.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: tekelili WML noob questions

Post by tekelili »

Sorry guys for keep bothering with this, but SlowThinker code neither works for me, I still get the pango code diplayed on map as if it where a string value :cry:

EDIT: Just for if it were important, I remember I am using BfW 1.8.5
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
SlowThinker
Posts: 876
Joined: November 28th, 2008, 6:18 pm

Re: tekelili WML noob questions

Post by SlowThinker »

Anonymissimus: Also from my experience the following code works as expected (edit: but not with labels):

Code: Select all

<span color='$color_action'>$faction</span>
Also I can't imagine the logic of applying the pango first: how would we apply a variable substitution to a formated text? I can imagine the variable substitution is applied to a code only.

*****************************************
Edit:
I just ran a test with my 1.8.5, and pango with <span> doesn't work with labels:
Line 1, line 2 don't work, line 3 works:

Code: Select all

{SET_LABEL 1 1 ("<span size='small'>$Scn_tot_gold Gold</span>      $Scn_tot_villas Villas")}
{SET_LABEL 1 1 ("<span size='small'>Total bonuses and villas</span>")}
{SET_LABEL 1 1 ("<b>Total bonuses and villas</b>")}
(So <b> is not a pango code maybe ...)
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: tekelili WML noob questions

Post by tekelili »

I guess this must be easy, but didnt manage to find out it:
¿Can default set_menu_item like "set label" and "next unit" be removed? if yes, how?

EDIT: As side nte to previous issue, if pango is some day enabled for labels, would be nice if also worked for description in set_menu_item. Or at least add a color variable.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: tekelili WML noob questions

Post by Sapient »

tekelili wrote:I guess this must be easy, but didnt manage to find out it:
¿Can default set_menu_item like "set label" and "next unit" be removed?
No
tekelili wrote: EDIT: As side nte to previous issue, if pango is some day enabled for labels, would be nice if also worked for description in set_menu_item. Or at least add a color variable.
Possibly... you should put in a feature request.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
SlowThinker
Posts: 876
Joined: November 28th, 2008, 6:18 pm

Re: tekelili WML noob questions

Post by SlowThinker »

Concerning set_menu_item:
  • "=" inside the description works like a <TAB>. For example

    Code: Select all

    description="Unboard=unreversible!"
  • items within the menu are ordered by id=
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
Post Reply