Where is documentation for wesnoth.map.filter?
Moderator: Forum Moderators
-
- Posts: 484
- Joined: August 4th, 2019, 5:27 pm
Where is documentation for wesnoth.map.filter?
I'm trying to find documentation for wesnoth.map.filter() function but I fail to do so on the page https://wiki.wesnoth.org/LuaAPI/wesnoth/map
More to it, when I try to find a lua definition of this function in data/lua directory, I fail as well. Where to find docs and the definition?
More to it, when I try to find a lua definition of this function in data/lua directory, I fail as well. Where to find docs and the definition?
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Re: Where is documentation for wesnoth.map.filter?
It's implemented in C++ (over lots of functions and classes...) not in lua. Looks like it builds an internal representation of a terrain filter based on the lua table you hand in. What is called filter userdata on the wiki.
I think if you use wesnoth.map.filter_tags to generate the argument then you don't need to understand more about it. Though formula seems to be missing there.
I think if you use wesnoth.map.filter_tags to generate the argument then you don't need to understand more about it. Though formula seems to be missing there.
"If gameplay requires it, they can be made to live on Venus." -- scott
-
- Posts: 484
- Joined: August 4th, 2019, 5:27 pm
Re: Where is documentation for wesnoth.map.filter?
Well, for example here https://github.com/wesnoth/wesnoth/blob ... ine.lua#L5
it's not clear what the second argument t.filter_extra means. Is wesnoth.map.filter takes one argument, two arguments or a variable number? If several, what does it mean (AND for all filters or what?)
I just wanted to play around with custom map generators, there are useful examples such as the cave map generator but some things are still obscure
Code: Select all
function get_locations(t)
local filter = wesnoth.map.filter(t.filter, t.filter_extra or {})
return map:find(filter, t.locs)
end
I just wanted to play around with custom map generators, there are useful examples such as the cave map generator but some things are still obscure
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Re: Where is documentation for wesnoth.map.filter?
wesnoth.map.filter takes two arguments. Second argument is optional. A comment says "lua table that describes the filter resources". No clue what that means in practice. Hard to tell just from reading the code. I guess you can somehow use that table inside the filter.
"If gameplay requires it, they can be made to live on Venus." -- scott
- Celtic_Minstrel
- Developer
- Posts: 2207
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Where is documentation for wesnoth.map.filter?
The closest we have to documentation for it right now is the example here. The idea is to use various
For details on how to use the various
filter_tags
to build up the table, rather than manually constructing a filter table.For details on how to use the various
filter_tags
, you can check out their definition in data/lua/core/map.lua starting at line 346 – they're fully documented inline there.