I have found this example but this doesn't work for me... What's wrong?
function foofunc ()
print ("foo")
end
x='foofunc'
_G[x]()
I'm getting "attempt to call nil" for _G[x]()
Posted 26 May 2013 - 07:11 AM
function foofunc ()
print ("foo")
end
x='foofunc'
_G[x]()
Posted 26 May 2013 - 07:46 AM
function foofunc ()
print ("foo")
end
x = loadstring("foofunc()")
x()
-- Or just:
loadstring("foofunc()")()
Posted 26 May 2013 - 07:57 AM
Bomb Bloke, on 26 May 2013 - 07:46 AM, said:
function foofunc ()
print ("foo")
end
x = loadstring("foofunc()")
x()
-- Or just:
loadstring("foofunc()")()function _G['foobar']()
print("foo")
end
_G["foobar"]()
local functions = {}
function functions['foobar']()
print("foobar")
end
local x = 'foobar'
functions[x]()
Posted 26 May 2013 - 08:44 AM
Posted 26 May 2013 - 12:05 PM
Calimore, on 26 May 2013 - 12:01 PM, said:
functions["some name"] = function()
print("foo")
end
function functions.other name()
print("bar")
end
Posted 26 May 2013 - 03:12 PM
Posted 28 May 2013 - 03:08 AM
function myfunc()
print("Hello World")
end
fname = "myfunc"
getfenv()[fname]()
0 members, 1 guests, 0 anonymous users