Don't duplicate the split function logic in [modify_unit]
This commit is contained in:
parent
f0bdd01918
commit
818aabdbc5
1 changed files with 5 additions and 4 deletions
|
@ -7,12 +7,13 @@ local wml_actions = wesnoth.wml_actions
|
||||||
-- in the first part of this file and the fallback (old) implementation in the
|
-- in the first part of this file and the fallback (old) implementation in the
|
||||||
-- second part of this file
|
-- second part of this file
|
||||||
|
|
||||||
local function split_to_array(str, sep)
|
local function split_to_array(str)
|
||||||
-- Split string @str into a table using the delimiter @sep (default: ',')
|
-- Split string @str into a table using the delimiter @sep (default: ',')
|
||||||
|
|
||||||
local sep, fields = sep or ",", {}
|
local fields = {}
|
||||||
local pattern = string.format("([^%s]+)", sep)
|
for c in utils.split(str) do
|
||||||
string.gsub(str, pattern, function(c) fields[#fields+1] = c end)
|
fields[#fields+1] = c
|
||||||
|
end
|
||||||
return fields
|
return fields
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue