Return first value of trim() within the function as opposed to at the call

This commit is contained in:
Charles Dang 2014-12-29 15:44:19 +11:00
parent cc0d274c73
commit fa079a1b3f

View file

@ -20,7 +20,8 @@ local location_set = wesnoth.require "lua/location_set.lua"
local wml_actions = wesnoth.wml_actions
local function trim(s)
return string.gsub(s, "^%s*(.-)%s*$", "%1")
-- use (f(a)) to get first argument
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end
local function split(s)
@ -105,7 +106,7 @@ function wml_actions.clear_variable(cfg)
local names = cfg.name or
helper.wml_error "[clear_variable] missing required name= attribute."
for w in split(names) do
wesnoth.set_variable((trim(w))) -- use (f(a)) to get first argument
wesnoth.set_variable(trim(w))
end
end