mirror of
https://github.com/minetest-mods/technic.git
synced 2024-12-26 10:50:33 +01:00
Add snippet to check if function exists.
This commit is contained in:
parent
5727a84bd8
commit
0e6b3ce86b
@ -25,3 +25,21 @@ function technic.refill_RE_charge(stack)
|
|||||||
stack:set_metadata(minetest.serialize(meta))
|
stack:set_metadata(minetest.serialize(meta))
|
||||||
return stack
|
return stack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
local function resolve_name(function_name)
|
||||||
|
local a = _G
|
||||||
|
for key in string.gmatch(function_name, "([^%.]+)(%.?)") do
|
||||||
|
if a[key] then
|
||||||
|
a = a[key]
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return a
|
||||||
|
end
|
||||||
|
|
||||||
|
function technic.function_exists(function_name)
|
||||||
|
return type(resolve_name(function_name)) == 'function'
|
||||||
|
end
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user