Advertisement
LatvianModder

LM_PathRemote

May 4th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. --LatvianRemote
  2.  
  3. function init()
  4.   clearTerm()
  5.   rednet.open("back")
  6.  
  7.   parallel.waitForAll(loopRead, loopRednet)
  8. end
  9.  
  10. function loopRednet()
  11.   while true do
  12.     event, p1, p2 = os.pullEvent("rednet_message")
  13.    
  14.     if stringStarts(p2, "latprint ") then
  15.         print("> " .. string.sub(p2, 10))
  16.     end
  17.   end
  18. end
  19.  
  20. function stringStarts(s, st)
  21.    return string.sub(s, 1, string.len(st)) == st
  22. end
  23.  
  24. function loopRead()
  25.   while true do
  26.     txt = read()
  27.    
  28.     if txt == "clear" then
  29.       return clearTerm()
  30.     end
  31.    
  32.     --print("> " .. txt)
  33.     rednet.broadcast("latpath " .. txt)
  34.   end
  35. end
  36.  
  37. function clearTerm()
  38.   term.clear()
  39.   term.setCursorPos(1, 1)
  40. end
  41.  
  42. init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement