Filterning terrains without overlay doesn't work as intended?
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.
Filterning terrains without overlay doesn't work as intended?
According to the wiki:
All terrains got matched.
Next, I tried:
No terrain got matched. Is there a way of implicitly filtering out terrains with no overlays?
So I tried:The overlay (including the preceding ^) is optional; if omitted, only terrains without overlays can be matched.
Code: Select all
terrain=*
Next, I tried:
Code: Select all
[not]
terrain=*^*
[/not]
Re: Filterning terrains without overlay doesn't work as intended?
Confirmed. Seems you have to filter by terrain code.
Code: Select all
$ #wesnoth.get_locations{formula="1-contains_string(id, '^')"}
636
$ #wesnoth.get_locations{formula="contains_string(id, '^')"}
234
$ #wesnoth.get_locations{}
870
- Spannerbag
- Posts: 537
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Filterning terrains without overlay doesn't work as intended?
Edited out because of Ravana's far superior method below
FWIW you can replicate Ravana's logic in WML, I've done some brief testing and here's what happened on v1.16.8...
Cheers!
-- Spannerbag
FWIW you can replicate Ravana's logic in WML, I've done some brief testing and here's what happened on v1.16.8...
Cheers!
-- Spannerbag
Last edited by Spannerbag on June 24th, 2023, 3:19 pm, edited 1 time in total.
Re: Filterning terrains without overlay doesn't work as intended?
You dont need such tricks, standard location filter is same logic no matter if you call it from wml or Lua.
So formula="1-contains_string(id, '^')" instead of terrain=
So formula="1-contains_string(id, '^')" instead of terrain=
- Spannerbag
- Posts: 537
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Filterning terrains without overlay doesn't work as intended?
Ah, cool. The code below worked first time
Code: Select all
[store_locations]
terrain=*^*
variable=terrain_all
include_borders=no
[/store_locations]
[store_locations]
formula="contains_string(id, '^')"
variable=terrain_with_overlays
include_borders=no
[/store_locations]
[store_locations]
formula="1 - contains_string(id, '^')"
variable=terrain_without_overlays
include_borders=no
[/store_locations]
Cheers!
-- Spannerbag
- Celtic_Minstrel
- Developer
- Posts: 2241
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Filterning terrains without overlay doesn't work as intended?
Note: I recommend using
not
instead of 1 -
in that formula. It has the same effect but gets the intended meaning across better.