Okay so after looking through the code some I have some pointers on how to help you with some of the bugs you are seeing and help get you on your way to multitasking.
The reason why it currently takes you several attempts to receive the updates is you have two os.pullEvent()'s. One that has an if statement after if that discards anything other then a rednet message and one for monitor touches.
local event, param1, param2 = os.pullEvent()
if event == "rednet_message" then
--and
local event,p1,p2,p3 = os.pullEvent()
if event=="monitor_touch" then
The problem this creates is that if a rednet message is received while the program is running the part of the code waiting for the monitor touch, the rednet message is discarded and nothing done with it.
A solution would be to combine the both doing something like
local event, param1, param2 = os.pullEvent()
if event == "rednet_message" then
--do my rednet stuff
elseif event =="monitor_touch" then
--do that stuff
end
As far as your Door computers sending updates, Adding a small sleep inbetween the sends may help. But I would recommend changing to using channels for that portion of the code.
So on each PDA you would need to open the channel you are going to send to.
local channel = 1000 --whatever you want to use here
modem = peripheral.wrap(side)
modem.open(channel)
You will also need to update to listen for "modem_message" events instead of "rednet_message" events.
On your Door computer simply change to
local sendChannel = 1000 --same as in the PDA's
local myChannel = 1001
modem = peripheral.wrap(side)
modem.open(myChannel)
if door == change then
modem.transmit(sendChannel,myChannel,"mainDoor") --use transmit and you should not need to use a protocol for this now
end
That way every computer with that channel open with receive the message.
Some of your if usage could be improved some as well. Here are some examples.
if screent == 101 then
end
----===== loads home screen
if screent == 100 then
home()
end
--=======
----===== loads door screen
if screent == 101 then
door() -- changes screen to next page
doorc() -- checks to see what state the door is sending out
end
--can be simplified to
if screent == 100 then
home()
----===== loads door screen
elseif screent == 101 then
door() -- changes screen to next page
doorc() -- checks to see what state the door is sending out
end
--and
if screent == 100 then
homeClickPosition()
mouseHeight = 99 -- coz it press the same place which opens a door when page door loads
end
if screent == 101 then
doorClickPosition()
end
--down to
if screent == 100 then
homeClickPosition()
mouseHeight = 99 -- coz it press the same place which opens a door when page door loads
elseif screent == 101 then
doorClickPosition()
end
For the most part its always going to be best to use just 1 statement to do you checks. As you can see I've done that for everything here from the os.pullEvent() stuff to the screent if statements.
I will go through and see what I can do to try and figure out what your best approach is going to be in order to use the parallel.waitForAny() to accommodate your initial request.
EDIT: Before I do to much on that I would like to see what you end up with after making some of the possible changes I've suggested.