mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-28 12:56:36 +00:00
Add a couple more WML utility functions
This commit is contained in:
parent
d4e08359dd
commit
68d545c3be
@ -99,6 +99,28 @@ function wml.child_array(cfg, tag)
|
||||
return result
|
||||
end
|
||||
|
||||
--! Removes the first matching child tag from @a cfg
|
||||
function wml.remove_child(cfg, tag)
|
||||
ensure_config(cfg)
|
||||
for i,v in ipairs(cfg) do
|
||||
if v[1] == tag then
|
||||
table.remove(cfg, i)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--! Removes all matching child tags from @a cfg
|
||||
function wml.remove_children(cfg, ...)
|
||||
for i = #cfg, 1, -1 do
|
||||
for _,v in ipairs(...) do
|
||||
if cfg[i] == v then
|
||||
table.remove(cfg, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--[========[WML Tag Creation Table]========]
|
||||
|
||||
local create_tag_mt = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user