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:
Guillaume Melquiond 2010-08-04 19:37:24 +00:00
parent ed57aeb786
commit d82d68e1f1
2 changed files with 14 additions and 23 deletions

View File

@ -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

View File

@ -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)
{