Guardian MAIs: add syntax translation and deprecation message

So that the ai_type=guardian_unit guardian_type=... syntax still works
for the time being.
This commit is contained in:
mattsc 2013-10-22 12:39:22 -07:00
parent 276e1b8709
commit 23e4dda2e8

View file

@ -147,6 +147,14 @@ function wesnoth.wml_actions.micro_ai(cfg)
cfg.animal_type = nil
end
-- Add translation for old-syntax guardian MAIs to new syntax plus deprecation message
if (cfg.ai_type == 'guardian_unit') and (cfg.guardian_type) then
wesnoth.message("The syntax 'ai_type=guardian_unit guardian_type=" .. cfg.guardian_type .. "' is deprecated. Use 'ai_type=" .. cfg.guardian_type .. "' instead.")
cfg.ai_type = cfg.guardian_type
cfg.guardian_type = nil
end
-- Check that the required common keys are all present and set correctly
if (not cfg.ai_type) then H.wml_error("[micro_ai] is missing required ai_type= key") end
if (not cfg.side) then H.wml_error("[micro_ai] is missing required side= key") end