Posted 30 January 2014 - 03:09 PM
[indent=1]Hello all! I have a few questions about functions and i guess the 'lua environment' ..
1.) Is it possible to get the string name of a local function from the running program?? example..
2.) How can i get the plain text of a function and not just a function value?? example
lets say i have a client and host connected.. The host asks the client to call a function on its local self that it doesnt have, so the client replys along the lines
of 'I dont know wtf that function is…'. Is it possable for the host to get the definition of a local function with its string name, so i can send it over rednet and loadstring it??
Keep in mind the function will be local to the host executing the file and will not be in _G
So basically I just want to be able to pull a function definition and assigned name from a currently running local environment… Is this possable?? If not, could you suggest a way to
serialize functions or point me in the right direction?? I realize there are a few apis for serializing functions, but i didnt understand them very well..
Thank you in advance for any help. -Mo[/indent]
1.) Is it possible to get the string name of a local function from the running program?? example..
I'm executing a program called 'myProgram',
local function a()
-- do stuff
end
local function b()
-- print( getFunctionName(a) ) -- <-- is this possable?? or will i allways get "function(address#)" Keep in mind it wont be in _G table cause its local to the program..
end
2.) How can i get the plain text of a function and not just a function value?? example
lets say i have a client and host connected.. The host asks the client to call a function on its local self that it doesnt have, so the client replys along the lines
of 'I dont know wtf that function is…'. Is it possable for the host to get the definition of a local function with its string name, so i can send it over rednet and loadstring it??
Keep in mind the function will be local to the host executing the file and will not be in _G
So basically I just want to be able to pull a function definition and assigned name from a currently running local environment… Is this possable?? If not, could you suggest a way to
serialize functions or point me in the right direction?? I realize there are a few apis for serializing functions, but i didnt understand them very well..
Thank you in advance for any help. -Mo[/indent]