Where is documentation for wesnoth.map.filter?

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Post Reply
dwarftough
Posts: 484
Joined: August 4th, 2019, 5:27 pm

Where is documentation for wesnoth.map.filter?

Post by dwarftough »

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?
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
Soliton
Site Administrator
Posts: 1685
Joined: April 5th, 2005, 3:25 pm
Location: #wesnoth-mp

Re: Where is documentation for wesnoth.map.filter?

Post by Soliton »

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.
"If gameplay requires it, they can be made to live on Venus." -- scott
dwarftough
Posts: 484
Joined: August 4th, 2019, 5:27 pm

Re: Where is documentation for wesnoth.map.filter?

Post by dwarftough »

Well, for example here https://github.com/wesnoth/wesnoth/blob ... ine.lua#L5

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
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
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
Soliton
Site Administrator
Posts: 1685
Joined: April 5th, 2005, 3:25 pm
Location: #wesnoth-mp

Re: Where is documentation for wesnoth.map.filter?

Post by Soliton »

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
User avatar
Celtic_Minstrel
Developer
Posts: 2207
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Where is documentation for wesnoth.map.filter?

Post by Celtic_Minstrel »

The closest we have to documentation for it right now is the example here. The idea is to use 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.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply