I need to use dynamically changing set of functions that must be called at "script_main(e)"
So I used next structure:
xrServiceFunctions = {}
function xrServiceFunctions.attach(func)
--if type(func)~="function" then
-- Prompt("argument of xrServiceFunctions.attach must be a function")
--end
--table.insert(xrServiceFunctions, func)
Prompt(type(func))
end
function xrServiceFunctions.detach(func)
if type(func)~="function" then
Prompt("argument of xrServiceFunctions.attach must be a function")
end
local deleteKey = -1
for key, item in pairs(xrServiceFunctions) do
if item == func then
deleteKey = key
break
end
end
if deleteKey~=-1 then
table.remove(xrServiceFunctions, deleteKey)
end
end
But if I trying next :
UIMode={}
function UIMode.show()
-- some code here
end
xrServiceFunctions.attach(UIMode.show)
I can see that type(func)=="nil", where func must be UIMode.show function.
When I trying to use same code in Lua 5.2 console (with defining
function Prompt(text)
print(text)
end
)
I getting type(func)=="function".
What I'm doing wrong?