[solved] [have_unit], count, recall list, WFL syntax and wildcards
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.
-
- Posts: 1253
- 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
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)
(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]
- 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.
- Does WFL use wildcards? Seems like it should, but I can't find it on the wiki page. Like "x=* and y=*"
- Does WFL support "x,y=M,N" style syntax (as in "x,y=recall,recall")
- Is recall a string or a keyword (do I need x='recall' or x=recall)?
- 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.
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.
Re: [have_unit], count, recall list, WFL syntax and wildcards
Don't you need a search_recall_list there?
-
- Posts: 1253
- 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
Ah, hadn't seen that. Thanks.
Speak softly, and carry Doombringer.
- Celtic_Minstrel
- Developer
- Posts: 2258
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [have_unit], count, recall list, WFL syntax and wildcards
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).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?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=*"
(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.)
You can probably writewhite_haired_uncle wrote: ↑April 14th, 2024, 4:06 pm Does WFL support "x,y=M,N" style syntax (as in "x,y=recall,recall")
[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.I haven't verified, but I believe thewhite_haired_uncle wrote: ↑April 14th, 2024, 4:06 pm Is recall a string or a keyword (do I need x='recall' or x=recall)?
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.-
- Posts: 1253
- 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
Thanks. The WFL stuff looks quite useful, but I think I'll just stick to lua.
Speak softly, and carry Doombringer.