Merge branch 'feat-walk-override-container-elms' into 'master'
feat(walk): Allow overriding container elms See merge request luk3yx/minetest-formspec_ast!1
This commit is contained in:
commit
4836cb2fb1
@ -10,9 +10,10 @@ A Minetest mod library to make modifying formspecs easier.
|
|||||||
and returns a formspec string.
|
and returns a formspec string.
|
||||||
- `formspec_ast.interpret(string_or_tree)`: Returns a formspec string after
|
- `formspec_ast.interpret(string_or_tree)`: Returns a formspec string after
|
||||||
(optionally parsing) and unparsing the formspec provided.
|
(optionally parsing) and unparsing the formspec provided.
|
||||||
- `formspec_ast.walk(tree)`: Returns an iterator (use this directly in a for
|
- `formspec_ast.walk(tree, optional_container_set)`: Returns an iterator (use this directly in a for
|
||||||
loop) that will return all nodes in a tree, including ones inside
|
loop) that will return all nodes in a tree, including ones inside
|
||||||
containers.
|
containers. The containers are recognised by `type`, and can be overriden
|
||||||
|
with a table of `name` to `true` relationships in `optional_container_set`
|
||||||
- `formspec_ast.find(tree, node_type)`: Similar to `walk(tree)`, however only
|
- `formspec_ast.find(tree, node_type)`: Similar to `walk(tree)`, however only
|
||||||
returns `node_type` nodes.
|
returns `node_type` nodes.
|
||||||
- `formspec_ast.get_element_by_name(tree, name)`: Returns the first element in
|
- `formspec_ast.get_element_by_name(tree, name)`: Returns the first element in
|
||||||
|
@ -71,9 +71,9 @@ end
|
|||||||
|
|
||||||
-- Returns an iterator over all nodes in a formspec AST, including ones in
|
-- Returns an iterator over all nodes in a formspec AST, including ones in
|
||||||
-- containers.
|
-- containers.
|
||||||
local container_elems = {container = true, scroll_container = true}
|
local default_container_elems = {container = true, scroll_container = true}
|
||||||
function formspec_ast.walk(tree)
|
function formspec_ast.walk(tree, provided_container_elms)
|
||||||
return walk_inner(tree, container_elems)
|
return walk_inner(tree, provided_container_elms or default_container_elems)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Similar to formspec_ast.walk(), however only returns nodes which have a type
|
-- Similar to formspec_ast.walk(), however only returns nodes which have a type
|
||||||
|
Loading…
Reference in New Issue
Block a user