Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function split(str,splitter)
- if not splitter then return end
- if not str then return end
- words = {}
- i=0
- for part in string.gmatch(str, "[^%"..splitter.."]+") do -- get each part
- i=i+1
- words[i] = part
- end
- return words
- end
- string.split = split
- function call(func, ...)
- args = {...}
- if type(func) == "string" then
- func = getfenv(1)[func]
- end
- if type(func) == "function" then
- return func(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10])
- else
- error("Non-existant function")
- end
- end
- function remoteInterpret(message)
- args = string.split(message, ",")
- func = getfenv(1)[args[1]] -- getfenv(1) contains all non-local variables (so functions too) so getfenv(1)["test"] returns a function named test, if there's one.
- -- the input looks like that:
- -- functionName,param1,param2...
- -- getfenv(1)[args[1]] returns the function named after the first arg of the function
- return func(args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11])
- end
- function remoteCall(ID, func, ...)
- if type(ID) ~= "number" then
- error("expected an ID (number) as a first argument")
- end
- if type(func) ~= "string" then
- error("expected a function name (string) as a second argument")
- end
- args = {...}
- rednet.send(ID, func..","..table.concat(args, ","))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement