[solved] [have_unit], count, recall list, WFL syntax and wildcards

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
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

[solved] [have_unit], count, recall list, WFL syntax and wildcards

Post by white_haired_uncle »

I want to print a message only if the number of undead, both on the map and on the recall list. This has led me to some questions. So many it's time to ask for help.

(I know, use lua. But I want to learn some stuff)

Code: Select all

                [message]
                    speaker=Efraim
                    message= _ "Good point.  Perhaps we should have brought more of them."
                    [show_if]
                        [have_unit]
                            side=1
                            formula="(x=recall or  x!=recall) and (y=recall or y!=recall)"  # also check recall.  Vahalla left as an exercise for the reader
                            race=undead
                            count=0-19    # No idea what the upper limit should be here, but pretty sure we have at least two.
                        [/have_unit]
                    [/show_if]
                [/message]
 
  1. Only somewhat related, can I ever use count as anything but a filter? Seems like it would be useful, if only to print a debug message.
  2. Does WFL use wildcards? Seems like it should, but I can't find it on the wiki page. Like "x=* and y=*"
  3. Does WFL support "x,y=M,N" style syntax (as in "x,y=recall,recall")
  4. Is recall a string or a keyword (do I need x='recall' or x=recall)?
  5. Is there a better way to control what [have_unit] searches? I was toying with trying to wrap "x,y=recall,recall" [or] [not] "x,y=recall,recall" into something I could [and] with side=1 and race=undead.
P.S.

Code: Select all

                [message]
                    speaker=Efraim
                    message= _ "Good point.  Perhaps we should have brought more of them."
                    [show_if] # No idea what the actual limit we should use here is.  Also checking Valahlla left as an exercise for the reader.
                        [lua]
                            code=<< return #wesnoth.units.find{side=1,race="undead"} < 20 >>
                        [/lua]
                    [/show_if]
                [/message]
Last edited by white_haired_uncle on April 15th, 2024, 1:22 pm, edited 1 time in total.
Speak softly, and carry Doombringer.
gnombat
Posts: 710
Joined: June 10th, 2010, 8:49 pm

Re: [have_unit], count, recall list, WFL syntax and wildcards

Post by gnombat »

Don't you need a search_recall_list there?
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: [have_unit], count, recall list, WFL syntax and wildcards

Post by white_haired_uncle »

Ah, hadn't seen that. Thanks.
Speak softly, and carry Doombringer.
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [have_unit], count, recall list, WFL syntax and wildcards

Post by Celtic_Minstrel »

white_haired_uncle wrote: April 14th, 2024, 4:06 pm Only somewhat related, can I ever use count as anything but a filter? Seems like it would be useful, if only to print a debug message.
count= is part of a filter tag, so naturally you can't use it anywhere else (that I know of).
white_haired_uncle wrote: April 14th, 2024, 4:06 pm Does WFL use wildcards? Seems like it should, but I can't find it on the wiki page. Like "x=* and y=*"
If you want to match when x and y have any value whatsoever, isn't that the same as not checking x and y at all?

(No, there's no such syntax in WFL, though if working with strings you do have access to the contains_string and find_string functions which could maybe get a similar effect in a more verbose way.)
white_haired_uncle wrote: April 14th, 2024, 4:06 pm Does WFL support "x,y=M,N" style syntax (as in "x,y=recall,recall")
You can probably write [x, y] = ['recall', 'recall'] if you really want. Obviously it's not going to work in this case, since x and y would never be equal to 'recall', but that's a separate issue.
white_haired_uncle wrote: April 14th, 2024, 4:06 pm Is recall a string or a keyword (do I need x='recall' or x=recall)?
I haven't verified, but I believe the x,y=recall,recall syntax is unique to WML unit filters. If you look at a recall list unit in Lua or WFL, its x and y will probably hold the last location it had when it was on the map, rather than some magic value. Even if you store a unit on the recall list, I believe you'll see the same thing. So your approach is probably never going to work.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: [have_unit], count, recall list, WFL syntax and wildcards

Post by white_haired_uncle »

Thanks. The WFL stuff looks quite useful, but I think I'll just stick to lua.
Speak softly, and carry Doombringer.
Post Reply