Advertisement
Zekrommaster110

[LUA | CC1.4.7] Elevator Server

Oct 22nd, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.64 KB | None | 0 0
  1. -- WHITE             1       0
  2. -- ORANGE            2       1
  3. -- MAGENTA           4       2
  4. -- LIGHT BLUE        8       3
  5. -- YELLOW           16       4
  6. -- LIME GREEN       32       5
  7. -- PINK             64       6
  8. -- GRAY            128       7
  9. -- LIGHT GRAY      256       8
  10. -- CYAN            512       9
  11. -- PURPLE         1024      10
  12. -- BLUE           2048      11
  13. -- BROWN          4096      12
  14. -- GREEN          8192      13
  15. -- RED            16384     14
  16. -- BLACK          32768     15    // R-SIGNAL
  17.  
  18. --os.sleep(5) //if your server is making trouble after restart with this program please activate this delay to solve
  19.  
  20. -- VARIABLES
  21. sideBundle = "right" --please enter here the side, where the elevator main cable gets into the server computer
  22.  
  23.  
  24. sides = {"top", "bottom", "front", "back", "left", "right"}
  25. i = 6
  26. while i >= 1 do
  27.     if peripheral.isPresent(sides[i]) == true then
  28.         rednet.open(sides[i])
  29.     end
  30.     i = i - 1
  31. end
  32.  
  33.  
  34. -- Automatic broadcast to give elevator clients servers id (can be disabled if you want manually enter server id)
  35. os.sleep(1)
  36. rednet.broadcast("547892135")
  37.  
  38. os.sleep(1)
  39.  
  40. shell.run("clear")
  41. print("[ELEVATOR SERVER] Server is running.")
  42.  
  43. while true do
  44.    
  45.     id, message, dist = rednet.receive()
  46.    
  47.     if tonumber(message) >= 1 then
  48.         redstone.setBundledOutput(sideBundle, 2^(tonumber(message)-1))
  49.         while redstone.testBundledInput(sideBundle, 32768) == false do
  50.             os.sleep(1)
  51.         end
  52.         os.sleep(1.5)
  53.         while redstone.testBundledInput(sideBundle, 32768) == false do
  54.             os.sleep(1)
  55.         end
  56.         redstone.setBundledOutput(sideBundle, 0)
  57.     end
  58.        
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement