Guest User

Untitled

a guest
Oct 12th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. c= require ("component")
  2. ct = c.transposer
  3. sides = require ("sides")
  4. gpu = c.gpu
  5. colors = require("colors")
  6. r1=c.proxy(c.get("b12"))
  7. r2=c.proxy(c.get("6df"))
  8. os= require ("os")
  9. tty = require("tty")
  10. -- ######################
  11.  
  12. local truhe = sides.east
  13. anzahl = ct.getInventorySize(truhe)
  14. -- ######################
  15.  
  16. i = 0
  17. x = 1
  18. er = 2
  19. rot = 0xFF0000
  20. weiss = 0x0000FF
  21.  
  22. f1=0
  23. f2=0
  24. f3=0
  25. f4=0
  26. f5=0
  27. f6=0
  28. f7=0
  29. f8=0
  30. f9=0
  31. f10=0
  32. f11=0
  33. f12=0
  34. f13=0
  35. f14=0
  36. f15=0
  37. f16=0
  38.  
  39.  
  40. -- ######################
  41.  
  42. function farbe(i)
  43. gpu.setBackground(i, true)
  44. tty.clear()
  45. end
  46.  
  47.  
  48.  
  49. function pulse(i)
  50. local an = 0
  51. -- print(i)
  52. if i then
  53. -- gpu.bind(c.get("2b51"))
  54. -- os.execute("resolution 80 25")
  55. farbe(i)
  56. -- gpu.bind(c.get("727"))
  57. -- os.execute("resolution 50 25")
  58. end
  59.  
  60.  
  61. while an < i do
  62. r2.setOutput(sides.south, 15)
  63. os.sleep(0.2)
  64. r2.setOutput(sides.south, 0)
  65. an = an+1
  66. end
  67. r2.setOutput(sides.east, 15)
  68. os.sleep(0.2)
  69. r2.setOutput(sides.east, 0)
  70. end
  71.  
  72.  
  73.  
  74. function foo (a)
  75.  
  76. item = ct.getStackInSlot(truhe, a)
  77.  
  78.  
  79.  
  80. if item then
  81. local name = item.label
  82. local anzahl = item.size
  83. -- print (name, ", ",anzahl)
  84.  
  85. if string.find(name, "Weiße Wolle") then
  86. f1 = item.size
  87. elseif string.find(name, "Orange Wolle") then
  88. f2 = item.size
  89. elseif string.find(name, "Magenta Wolle") then
  90. f3 = item.size
  91. elseif string.find(name, "Hellblaue Wolle") then
  92. f4 = item.size
  93. elseif string.find(name, "Gelbe Wolle") then
  94. f5 = item.size
  95. elseif string.find(name, "Hellgrüne Wolle") then
  96. f6 = item.size
  97. elseif string.find(name, "Rosa Wolle") then
  98. f7 = item.size
  99. elseif string.find(name, "Graue Wolle") then
  100. f8 = item.size
  101. elseif string.find(name, "Hellgraue Wolle") then
  102. f9 = item.size
  103. elseif string.find(name, "Türkise Wolle") then
  104. f10 = item.size
  105. elseif string.find(name, "Violette Wolle") then
  106. f11 = item.size
  107. elseif string.find(name, "Blaue Wolle") then
  108. f12 = item.size
  109. elseif string.find(name, "Braune Wolle") then
  110. f13 = item.size
  111. elseif string.find(name, "Grüne Wolle") then
  112. f14 = item.size
  113. elseif string.find(name, "Rote Wolle") then
  114. f15 = item.size
  115. elseif string.find(name, "Schwarze Wolle") then
  116. f16 = item.size
  117. end
  118.  
  119. else
  120.  
  121. --print (er)
  122. if er == anzahl then
  123. gpu.setForeground(rot)
  124. print("Das Inventar ist leer")
  125. gpu.setForeground(weiss)
  126. else
  127. er = er +1
  128. end
  129.  
  130. end
  131.  
  132. end
  133.  
  134. -- print ("Erkannte größe des Inventars: ", anzahl)
  135. -- print (" ")
  136. -- print ("Liste Inventar auf")
  137. -- print ("")
  138.  
  139. local a = 1
  140.  
  141.  
  142.  
  143. while (a < anzahl) do
  144.  
  145. foo(a)
  146. a = a+1
  147.  
  148. end
  149.  
  150. ins = r1.getInput(sides.north)
  151.  
  152. if ins == 15 and f1 == 0 then
  153. pulse(0)
  154. elseif ins == 15 and f2 == 0 then
  155. pulse(1)
  156. elseif ins == 15 and f3 == 0 then
  157. pulse(2)
  158. elseif ins == 15 and f4 == 0 then
  159. pulse(3)
  160. elseif ins == 15 and f5 == 0 then
  161. pulse(4)
  162. elseif ins == 15 and f6 == 0 then
  163. pulse(5)
  164. elseif ins == 15 and f7 == 0 then
  165. pulse(6)
  166. elseif ins == 15 and f8 == 0 then
  167. pulse(7)
  168. elseif ins == 15 and f9 == 0 then
  169. pulse(8)
  170. elseif ins == 15 and f10 == 0 then
  171. pulse(9)
  172. elseif ins == 15 and f11 == 0 then
  173. pulse(10)
  174. elseif ins == 15 and f12 == 0 then
  175. pulse(11)
  176. elseif ins == 15 and f13 == 0 then
  177. pulse(12)
  178. elseif ins == 15 and f14 == 0 then
  179. pulse(13)
  180. elseif ins == 15 and f15 == 0 then
  181. pulse(14)
  182. elseif ins == 15 and f16 == 0 then
  183. pulse(15)
  184. elseif ins == 15 then
  185.  
  186. mytable = {}
  187. mytable = {["f1"] = f1,
  188. ["f2"] = f2,
  189. ["f3"] = f3,
  190. ["f4"] = f4,
  191. ["f5"] = f5,
  192. ["f6"] = f6,
  193. ["f7"] = f7,
  194. ["f8"] = f8,
  195. ["f9"] = f9,
  196. ["f10"] = f10,
  197. ["f11"] = f11,
  198. ["f12"] = f12,
  199. ["f13"] = f13,
  200. ["f14"] = f14,
  201. ["f15"] = f15,
  202. ["f16"] = f16,
  203. }
  204.  
  205. local key = next(mytable)
  206. local max = mytable[key]
  207. for k, v in pairs(mytable) do
  208. if mytable[k] < max then
  209. key, max = k, v
  210. end
  211. end
  212.  
  213. -- print(key, max)
  214.  
  215. if key == "f1" then
  216. pulse(0)
  217. elseif key == "f2" then
  218. pulse(1)
  219. elseif key == "f3" then
  220. pulse(2)
  221. elseif key == "f4" then
  222. pulse(3)
  223. elseif key == "f5" then
  224. pulse(4)
  225. elseif key == "f6" then
  226. pulse(5)
  227. elseif key == "f7" then
  228. pulse(6)
  229. elseif key == "f8" then
  230. pulse(7)
  231. elseif key == "f9" then
  232. pulse(8)
  233. elseif key == "f10" then
  234. pulse(9)
  235. elseif key == "f11" then
  236. pulse(10)
  237. elseif key == "f12" then
  238. pulse(11)
  239. elseif key == "f13" then
  240. pulse(12)
  241. elseif key == "f14" then
  242. pulse(13)
  243. elseif key == "f15" then
  244. pulse(14)
  245. elseif key == "f16" then
  246. pulse(15)
  247. end
  248.  
  249.  
  250. end
Add Comment
Please, Sign In to add comment