Plazter

DemonPortal CC

Sep 6th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.49 KB | None | 0 0
  1. os.loadAPI("cc")
  2.  
  3. c = peripheral.find("chest")
  4. mon = peripheral.find("monitor")
  5. active = true
  6. sleepTime = 5
  7. if peripheral.isPresent("c") then
  8.   print("Peripheral wrapped!")
  9.   sleep(2)
  10. end
  11. function reset()
  12.   c.pullItem("west", 1)
  13. end
  14.  
  15.  
  16. function chest(press)
  17. --[[
  18. print("Front of shop: Foran")
  19. print("Behind the shop: bagved")
  20. print("Manuvela's place: Manu")
  21. print("Sus, Kezza and Plazter's base: Sus/Kezza/Plaz")
  22.  
  23. print("Robert's place: rob")
  24. input = read()
  25. --]]
  26.   for i = 1, c.getInventorySize() do
  27.     cSlot = c.getStackInSlot(i)
  28.       if (cSlot) then -- why the ()?
  29.         for name, data in pairs(cSlot) do
  30.           if data == press then
  31.             c.pushItem("west", i, 1)
  32.             sleep(sleepTime)
  33.             c.pullItem("west", 1)
  34.           end
  35.         end
  36.       end
  37.   end
  38. end
  39.  
  40. function button(text, yLine, charm)
  41.   if x >=  1 and x < 30 and y == yLine then
  42.     mon.setCursorPos(1,yLine)
  43.     mon.setBackgroundColor(colors.lime)
  44.     cc.mWrite(text)
  45.     chest(charm)
  46.     sleep(.3)
  47.   end
  48. end
  49.  
  50. function but()
  51.   mon.setBackgroundColor(colors.red)
  52. end
  53.  
  54. function spacer()
  55.  mon.setBackgroundColor(colors.black)
  56. end
  57.  
  58. function text()
  59. spacer()
  60. mon.clear()
  61. mon.setCursorPos(1,1)
  62. mon.setTextColor(colors.white)
  63. cc.mWrite("-----------------------")
  64. mon.setCursorPos(1,2)
  65. cc.mWrite("| Destination chooser |")
  66. mon.setCursorPos(1,3)
  67. cc.mWrite("-----------------------")
  68. mon.setCursorPos(1,5)
  69. but()
  70. cc.mWrite(" Plaz & Sus & Kezza ")
  71. mon.setCursorPos(1,6)
  72. spacer()
  73. cc.mWrite("---------------------")
  74. mon.setCursorPos(1,8)
  75. but()
  76. cc.mWrite(" Manuvela ")
  77. mon.setCursorPos(1,9)
  78. spacer()
  79. cc.mWrite("---------------------")
  80. mon.setCursorPos(1,11)
  81. but()
  82. cc.mWrite(" N0se ")
  83. mon.setCursorPos(1,12)
  84. spacer()
  85. cc.mWrite("---------------------")
  86. mon.setCursorPos(1,14)
  87. but()
  88. cc.mWrite(" Zathanial ")
  89. mon.setCursorPos(1,15)
  90. spacer()
  91. cc.mWrite("---------------------")
  92. mon.setCursorPos(1,17)
  93. but()
  94. cc.mWrite(" Rob_ert ")
  95. mon.setCursorPos(1,18)
  96. spacer()
  97. cc.mWrite("---------------------")
  98. mon.setCursorPos(1,20)
  99. but()
  100. cc.mWrite(" Ellors ")
  101. mon.setCursorPos(1,21)
  102. spacer()
  103. cc.mWrite("---------------------")
  104. end
  105.  
  106. function click()
  107.   event, side , x, y = os.pullEvent("monitor_touch")
  108.   button(" Plaz & Sus & Kezza ", 5, "Sus/Kezza/Plaz")
  109.   button(" Manuvela ", 8, "Manu")
  110.   button(" N0se ", 11, "nose")
  111.   button(" Zathanial ", 14, "zat")
  112.   button(" Rob_ert ", 17, "rob")
  113.   button(" Ellors ", 20, "el")
  114. end
  115.  
  116. reset()
  117. while active do
  118.   text()
  119.   click()
  120. end
Add Comment
Please, Sign In to add comment