diff --git a/mods/bg_api/util_string.lua b/mods/bg_api/util_string.lua index fe897a6..6650ecd 100644 --- a/mods/bg_api/util_string.lua +++ b/mods/bg_api/util_string.lua @@ -21,3 +21,21 @@ end function blockgame.starts_with (str, start) return string.sub(str, 1, string.len(start)) == start 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