mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-07 12:22:33 +00:00
Moved [hide_unit] and [unhide_unit] implementations to Lua.
Added support for standard unit filters along the way. (Partial fix for bug #16358.)
This commit is contained in:
parent
ed57aeb786
commit
d82d68e1f1
@ -452,3 +452,17 @@ function wml_actions.store_locations(cfg)
|
||||
wesnoth.set_variable(string.format("%s[%d]", var, i - 1), res)
|
||||
end
|
||||
end
|
||||
|
||||
function wml_actions.hide_unit(cfg)
|
||||
for i,u in ipairs(wesnoth.get_units(cfg)) do
|
||||
u.hidden = true
|
||||
end
|
||||
wml_actions.redraw {}
|
||||
end
|
||||
|
||||
function wml_actions.unhide_unit(cfg)
|
||||
for i,u in ipairs(wesnoth.get_units(cfg)) do
|
||||
u.hidden = false
|
||||
end
|
||||
wml_actions.redraw {}
|
||||
end
|
||||
|
@ -1604,29 +1604,6 @@ WML_HANDLER_FUNCTION(removeitem, event_info, cfg)
|
||||
}
|
||||
}
|
||||
|
||||
WML_HANDLER_FUNCTION(hide_unit, /*event_info*/, cfg)
|
||||
{
|
||||
// Hiding units
|
||||
const map_location loc = cfg_to_loc(cfg);
|
||||
unit_map::iterator u = resources::units->find(loc);
|
||||
if (u.valid()) {
|
||||
u->set_hidden(true);
|
||||
resources::screen->invalidate(loc);
|
||||
resources::screen->draw();
|
||||
}
|
||||
}
|
||||
|
||||
WML_HANDLER_FUNCTION(unhide_unit, /*event_info*/, cfg)
|
||||
{
|
||||
const map_location loc = cfg_to_loc(cfg);
|
||||
// Unhide all for backward compatibility
|
||||
foreach (unit &u, *resources::units) {
|
||||
u.set_hidden(false);
|
||||
resources::screen->invalidate(loc);
|
||||
resources::screen->draw();
|
||||
}
|
||||
}
|
||||
|
||||
// Adding new items
|
||||
WML_HANDLER_FUNCTION(item, /*event_info*/, cfg)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user