Jan can you elaborate a bit about how that works and how you would apply that?
Sure, I'll try to explain how it works:
I assume you know what os.pullEventRaw is, it is a function that is called by nearly every other function, that takes an event from the eventrow.
Even when you call sleep(), sleep will start a timer, and call os.pullEventRaw!
Make computer A and computer B.
On computer A, we will make a program called 'server'
local real={}
real.os={}
this makes the 'real' tables. It will contain the original system functions
real.os.pullEventRaw = os.pullEventRaw
Since functions are just variables, we copy the original os.pullEventRaw to real.os.pullEventRaw
(Note you should not use pullEventRaw(), but pullEventRaw, otherwise you 'call' the function)
os.pullEventRaw = function()
Here we overwrite os.pullEventRaw, with a
fake function
The contents of that function are below, till the last end.
local a,b,c,d,e =real.os.pullEventRaw()
Since we stored the original function previously,
we can now call it, to get the real event!
if a=="rednet_message" then
if c=="some_command" then
rednet.send(b,"some_answer")
end
end
You should be able to understand the code above.
It's a simple bit of server code that checks if a 'some_command' message was sent.
Remember we are still in the fake os.pullEventRaw function? So this check will run everytime os.pullEventRaw had run
return a,b,c,d,e
end
However this is a fake function, we should still return the real results of os.pullEventRaw() because otherwise other programs wont run.
Note that the original os.pullEventRaw function gets refreshed when the computer restarts!
So we run the server program after the computer hat started to 'inject' the fake os.pullEventRaw.
After this program had run, the program will return to the shell, and you should be able to play 'worm' on the server computer.
Since the worm program is (obviously) calling os.pullEventRaw (direct or indirect), our server should respond to 'some_command'-messages.
You can try out if it work by running this on the second computer:
lua> rednet.send(ID,'some_command') print(rednet.receive(())
(dont forget to open the routers on both computers :(/>/>)
Hope this tutorial helped. If you have any questions, please qoute my name because then I get a notification.
Also note that I have not tested it yet :)/>/>
Jan