Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local turhost
- local procPlacer
- local retryTimes = 10
- print("pls appoint proc")
- rednet.open("back")
- procPlacer = io.read()
- -- procPlacer = io.stdin()
- local function init()
- while 1 do
- turhost = rednet.lookup(procPlacer)
- if (turhost ~= nil) then
- print("find target!")
- return true
- end
- end
- print("target not found")
- return false
- end
- local function key_check()
- while true do
- local event, key, isHeld = os.pullEvent("key")
- if(turhost ~= nil) then
- local kvalue = keys.getName(key)
- rednet.send(turhost,kvalue,procPlacer)
- if (kvalue == "l") then
- print("procgram shutdown")
- os.sleep(3)
- return
- end
- end
- end
- end
- local function net_check()
- while 1 do
- local event, sender, message, protocol = os.pullEvent("rednet_message")
- print(message)
- end
- end
- if(init()) then
- parallel.waitForAny(net_check,key_check)
- end
- term.clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement