mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-05 08:51:30 +00:00
Added two helper functions parsed and literal...
...for handling uniformly WML tables and vconfig objects.
This commit is contained in:
parent
b0957c3037
commit
ad61eba863
@ -271,4 +271,26 @@ function helper.distance_between(x1, y1, x2, y2)
|
||||
return math.max(hdist, vdist + math.floor(hdist / 2))
|
||||
end
|
||||
|
||||
function helper.literal(cfg)
|
||||
local t = type(cfg)
|
||||
if t == "table" then
|
||||
return cfg
|
||||
elseif t == "userdata" then
|
||||
return cfg.__literal
|
||||
else
|
||||
return cfg or {}
|
||||
end
|
||||
end
|
||||
|
||||
function helper.parsed(cfg)
|
||||
local t = type(cfg)
|
||||
if t == "table" then
|
||||
return tovconfig(cfg).__parsed
|
||||
elseif t == "userdata" then
|
||||
return cfg.__parsed
|
||||
else
|
||||
return cfg or {}
|
||||
end
|
||||
end
|
||||
|
||||
return helper
|
||||
|
Loading…
x
Reference in New Issue
Block a user