ai_helper.put_labels: add two optional parameters
This commit is contained in:
parent
fdb3f2e71a
commit
891ca93710
1 changed files with 8 additions and 2 deletions
|
@ -89,11 +89,17 @@ function ai_helper.put_labels(map, cfg)
|
||||||
-- - keys: (array) if the value to be displayed is a subelement of the LS data,
|
-- - keys: (array) if the value to be displayed is a subelement of the LS data,
|
||||||
-- use these keys to access it. For example, if we want to display data[3]
|
-- use these keys to access it. For example, if we want to display data[3]
|
||||||
-- set keys = { 3 }, if it's data.arg[3], set keys = { 'arg', 3 }
|
-- set keys = { 3 }, if it's data.arg[3], set keys = { 'arg', 3 }
|
||||||
|
-- - clear=true: (boolean) if set to 'false', do not clear existing labels
|
||||||
|
-- - color=nil: (string) the color string to be used for the output
|
||||||
|
|
||||||
cfg = cfg or {}
|
cfg = cfg or {}
|
||||||
local factor = cfg.factor or 1
|
local factor = cfg.factor or 1
|
||||||
|
|
||||||
ai_helper.clear_labels()
|
local clear_labels = cfg.clear
|
||||||
|
if (clear_labels == nil) then clear_labels = true end
|
||||||
|
if clear_labels then
|
||||||
|
ai_helper.clear_labels()
|
||||||
|
end
|
||||||
|
|
||||||
map:iter(function(x, y, data)
|
map:iter(function(x, y, data)
|
||||||
local out
|
local out
|
||||||
|
@ -111,7 +117,7 @@ function ai_helper.put_labels(map, cfg)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(out) == 'number') then out = out * factor end
|
if (type(out) == 'number') then out = out * factor end
|
||||||
wesnoth.label { x = x, y = y, text = out }
|
wesnoth.label { x = x, y = y, text = out, color = cfg.color }
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue