Reputation: 41
Here is an example
local CustomLoad = function(l) loadstring(l) end
CustomLoad("print('hi')")
Please let me know, beacuse I got into this like a week ago, and I've been trying to make it, yet I coudln't. Can some of you tell me if it's even possible?
Upvotes: 1
Views: 1155
Reputation: 46
If you aren't trying to run "print('hi')" in that example, then I do believe you're missing a return statement.
local CustomLoad = function(l) return loadstring(l) end
But if you are, then:
local CustomLoad = function(l) return loadstring(l) end
CustomLoad("print('hi')")()
or
local CustomLoad = function(l) local f = loadstring(l); f() end
CustomLoad("print('hi')")
Because loadstring creates a function, which, when run, executes the code in the string. Hope that helped!
Upvotes: 1