Advertisement
Guest User

Chock0S

a guest
Jun 25th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. if fs.exists("/Chock0Sfile") == false then
  2.   print("C> setting up")
  3.   fs.makeDir("Chock0S")
  4.   local file = fs.open("Chock0Sfile/config","w")
  5.   file.writeLine("modem placement")
  6.   file.writeLine("id")
  7.   file.writeLine("function")
  8.   file.close()
  9. end
  10. file = fs.open("Chock0Sfile/config","r")
  11. local fileData = {}
  12. local line = file.readLine()
  13. repeat
  14. table.insert(fileData,line)
  15. line = file.readLine()
  16. until line == nil
  17. file.close()
  18. print(fileData[1])
  19. print(fileData[2])
  20. print(fileData[3])
  21. modemplacement = fileData[1]
  22. id = fileData[2]
  23. funct = fileData[3]
  24. rednet.open(modemplacement)
  25. while true do
  26.   if funct == "dummy" then
  27.     mes = read()
  28.     prot = read()
  29.     rednet.broadcast(mes,prot)
  30.   end
  31.   if funct == "util" then
  32.     print("util")
  33.     sender,message,protocol = rednet.receive()
  34.     print(message..sender..protocol)
  35.     if message == "ping" then
  36.       rednet.broadcast("pingback",sender)
  37.       print("ping!")
  38.     end
  39.     if protocol == id then
  40.       if message == "open" then
  41.         print("open")
  42.         redstone.setBundledOutput("left",colors.white)
  43.       end
  44.     end
  45.   end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement