add utility for extracting name parts.
add API function for splitting up an item identifier into its mod name and item name parts.
This commit is contained in:
parent
8dfccdd315
commit
0c5d4891b7
1 changed files with 18 additions and 0 deletions
|
@ -21,3 +21,21 @@ end
|
||||||
function blockgame.starts_with (str, start)
|
function blockgame.starts_with (str, start)
|
||||||
return string.sub(str, 1, string.len(start)) == start
|
return string.sub(str, 1, string.len(start)) == start
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function blockgame.extract_id_parts (name)
|
||||||
|
local basename
|
||||||
|
local modname
|
||||||
|
|
||||||
|
local colon_pos = string.find(name, ":")
|
||||||
|
if colon_pos then
|
||||||
|
modname = string.sub(name, 1, colon_pos - 1)
|
||||||
|
basename = string.sub(name, colon_pos + 1)
|
||||||
|
else
|
||||||
|
modname = minetest.get_current_modname()
|
||||||
|
basename = name
|
||||||
|
end
|
||||||
|
|
||||||
|
return basename, modname, modname .. ":" .. basename
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue