1583 posts
Location
Germany
Posted 20 August 2013 - 06:52 PM
Now I'm playing for a while on Mackans server and Mack and I created to Companys. Both of them has a hosting service. I wan't that every user whobis using my service is able to upload and remove files and start,stop the firewolf server when he is on his plot. Now I need a program which runs parallel (my first question) to firewolf so I can simulate user input (my second question).
Here are the questions:
1.How can I run a program parallel to firewolf which can handle rednet messages and simulate user input
2.How can I simulate userinput like keypresses and mouse clicks?
Thx
Freack100
504 posts
Location
Seattle, WA
Posted 20 August 2013 - 07:58 PM
If you have your rednet handling in a function and load firewolf as a function, you can distribute events to either function when loaded as coroutines. (You could also use the parallel API, although I'm less familiar with that).
Example:
Spoiler
local function rednetHandling (...)
-- Handle rednet messages and your user input simulation here.
end
local fireWolfFunction = loadfile ("/firewolf") -- Path to firewolf if that isn't the right one.
local rednetHandlingThread = coroutine.create (rednetHandling)
local fireWolfThread = coroutine.create (fireWolfFunction)
-- Distribute events as long as firewolf is running.
while coroutine.status (fireWolfThread) ~= "dead" do
local eventData = { os.pullEvent() }
coroutine.resume (rednetHandlingThread, unpack (eventData))
coroutine.resume (fireWolfThread, unpack (evenetData))
end
You can simulate events by using
os.queueEvent.
Example for an enter key press:
os.queueEvent ("key", keys.return)
local event, key = os.pullEvent() -- Will catch the enter key press.
1583 posts
Location
Germany
Posted 20 August 2013 - 08:02 PM
Thank you very much Grim!