我有一个功能,例如
function run()
print("hi")
end
我有一个名为 message 的字符串,其中包含单词“run”:
activity = message
print(activity) --returns run
但是我无法使用字符串活动来运行该函数run()
。我努力了:
func = loadstring(activity.."()")
func() -- I get an error on line 1 saying: attempt to call nil