local needMessage = false
while true do
local e = {os.pullEvent()}
if e[1] == "mouse_click" then
needMessage = true
elseif e[1] == "rednet_message" and needMessage then
print("Hey you hit the monitor and I needed a message")
needMessage = false
end
end
This would not do what i need i have something run at start of loop that isnt os.pullEvent and then after that it waits until a monitor_touch but doesnt run that begining bit until got monitor_touch and during this whole time get rednet msges and do stuff with them
Well first off, I can't really understand what you are saying. But if you are saying what I think you are then:
1) You run something, perhaps a draw function at the start of a loop if and only if a monitor_touch event has been received
2) The loop waits until it receives a monitor_touch and then runs the draw function?
3) During that time it receives rednet messages.
Well here is how you could easily go about that.
local status = false
while true do
if status then
doFunc() --Do your function
end
local e = {os.pullEvent()}
if e[1] == "monitor_touch" then
status = true
elseif e[2] == "rednet_message" then
--handle that
end
end
What part of this does not work for your situation? Does the function it runs have sleep or take time to complete? If so, then you could still modify the code to use timers instead.
My point is not that you should never use parallels. For some purposes it is well suited. I am just arguing that, no matter the situation, there is a way to use regular events instead of parallels.