Advertisement
Guest User

tren

a guest
Sep 18th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. local component = require("component")
  2. local sides = require("sides")
  3. local rs = component.redstone
  4. local gpu = component.gpu
  5. local event = require("event")
  6. local colours = require("colors")
  7.  
  8. function trainDirection(direction)
  9. if direction == "north" then
  10. return 0
  11. elseif direction == "east" then
  12. return 1
  13. elseif direction == "south" then
  14. return 2
  15. else
  16. return 3
  17. end
  18. end
  19.  
  20. function getStoredTrain()
  21. for i = 1, 16, 1 do
  22. if rs.getBundledInput(sides.north, i) == 1 then
  23. return i
  24. break
  25. end
  26. end
  27. end
  28.  
  29. function countTrains()
  30. local count = 0
  31. for i = 0, 16, 1 do
  32. if rs.getBundledInput(sides.north, i) == 1 then
  33. count = count + 1
  34. end
  35. end
  36. return count
  37. end
  38.  
  39. function releaseTrain(id)
  40. rs.setBundledOutput(sides.east, id, 1)
  41. os.sleep(2)
  42. rs.setBundledOutput(sides.east, id, 0)
  43. end
  44.  
  45. function setDestination(dire)
  46. rs.setBundledOutput(sides.bottom, dire, 1)
  47. end
  48.  
  49. function resetDestination()
  50. for i = 0, 16, 1 do
  51. rs.setBundledOutput(sides.bottom, i, 0)
  52. end
  53. end
  54.  
  55. function drawButtons()
  56. old = gpu.setBackground(colours.red)
  57. gpu.fill(10, 5, 20, 3, " ")
  58. gpu.setBackground(old)
  59. end
  60.  
  61. drawButtons()
  62. while true do
  63. local _, addr, x, y, but, player = event.pull("touch")
  64.  
  65. os.sleep(1)
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement