THEJean_Kevin

Music yami

Feb 16th, 2017
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.12 KB | None | 0 0
  1. os.loadAPI("button")
  2. m = peripheral.wrap("top")
  3. m.clear()
  4. sl = 0
  5. function check()
  6. if sl >= 17 then
  7.    sl = sl-1
  8.   end
  9.  sl = sl+1
  10.  if sl <= 16 then
  11.   turtle.select(sl)
  12.   while turtle.getItemSpace() ~= 0 and sl <= 16 do
  13.     sl = sl+1
  14.     if sl <= 16 then
  15.    turtle.select(sl)
  16.    end
  17.   end
  18.   if turtle.getItemSpace() == 0 then
  19.   det = turtle.getItemDetail().name
  20.   end
  21.  end
  22. end
  23. function fillTable()
  24. check()
  25.   print(det)
  26. if sl <= 16 then
  27.     but1n, but1s = show(), turtle.getSelectedSlot()
  28.     button.setTable(but1n, d1, 3,38,3,3)
  29. end
  30.   check()
  31.     print(det)
  32. if sl <= 16 then  
  33.     but2n = show()
  34.    button.setTable(but2n, d2, 3,38,4,4)
  35.     but2s = turtle.getSelectedSlot()
  36. end
  37.   check()
  38. print(det)  
  39. if sl <= 16 then
  40.      but3n = show()
  41.    button.setTable(but3n, d3, 3,38,5,5)
  42.  
  43.     but3s = turtle.getSelectedSlot()
  44. end
  45.   check()
  46.   print(det)
  47. if sl <= 16 then
  48. but4n = show()
  49.    button.setTable(but4n, d4, 3,38,6,6)
  50.    
  51.     but4s = turtle.getSelectedSlot()
  52. end
  53.   check()
  54.   print(det)
  55. if sl <= 16 then
  56. but5n = show()
  57.    button.setTable(but5n, d5, 3,38,7,7)
  58.  
  59.     but5s = turtle.getSelectedSlot()
  60. end
  61.   check()
  62. if sl <= 16 then
  63. but6n = show()
  64.    button.setTable(but6n, d6, 3,38,8,8)
  65.  
  66.     but6s = turtle.getSelectedSlot()
  67. end
  68.   check()
  69. if sl <= 16 then
  70. but7n = show()
  71.    button.setTable(but7n, d7, 3,38,9,9)
  72.    
  73.     but7s = turtle.getSelectedSlot()
  74. end
  75.   check()
  76. if sl <= 16 then
  77. but8n, but8s =  show(), turtle.getSelectedSlot()
  78.    button.setTable(but8n, d8, 3,38,10,10)
  79.    
  80. end
  81.   check()
  82. if sl <= 16 then
  83. but9n =  show()
  84.    button.setTable(but9n, d9, 3,38,11,11)
  85.     but9s = turtle.getSelectedSlot()
  86. end
  87.   check()
  88. if sl <= 16 then
  89. but10n = show()
  90.    button.setTable(but10n, d10, 3,38,12,12)
  91.     but10s = turtle.getSelectedSlot()
  92. end
  93.   check()
  94. if sl <= 16 then
  95.  but11n = show()
  96.    button.setTable(but11n, d11, 3,38,13,13)
  97.     but11s = 0+turtle.getSelectedSlot()
  98. end
  99.   check()
  100. if sl <= 16 then
  101. but12n =  show()
  102.    button.setTable(but12n, d12, 3,38,14,14)
  103.     but12s = 0+turtle.getSelectedSlot()
  104. end
  105.   check()
  106. if sl <= 16 then
  107. but13n =  show()
  108.    button.setTable(but13n, d13, 3,38,15,15)
  109.     but13s = 0+turtle.getSelectedSlot()
  110. end
  111.   check()
  112. if sl <= 16 then
  113.      but14n =  show()
  114.     but14s = turtle.getSelectedSlot()
  115. button.setTable(but14n, d14, 3,38,16,16)
  116. end
  117.   check()
  118. if sl <= 16 then
  119.    but15n =  show()
  120.     but15s = turtle.getSelectedSlot()
  121.     button.setTable(but15n, d15, 3,38,17,17)
  122. end
  123.   check()
  124. if sl <= 16 then
  125.    but16n =  show()
  126.     but16s = turtle.getSelectedSlot()
  127.     button.setTable(but16n, d16, 3,38,18,18)
  128. end
  129.    button.screen()
  130. end
  131. function getClick()
  132.    event,side,x,y = os.pullEvent("monitor_touch")
  133.    button.checkxy(x,y)
  134. end
  135. function d1()
  136.    button.flash(but1n)
  137.    turtle.select(but1s)
  138.    dj()
  139. end
  140. function d2()
  141.    button.flash(but2n)
  142.    turtle.select(but2s)
  143.    dj()
  144. end
  145. function d3()
  146.    button.flash(but3n)
  147.    turtle.select(but3s)
  148.    dj()
  149. end
  150. function d4()
  151.    button.flash(but4n)
  152.    turtle.select(but4s)
  153.    dj()
  154. end
  155. function d5()
  156.    button.flash(but5n)
  157.    turtle.select(but5s)
  158.    dj()
  159. end
  160. function d6()
  161.    button.flash(but6n)
  162.    turtle.select(but6s)
  163.    dj()
  164. end
  165. function d7()
  166.    button.flash(but7n)
  167.    turtle.select(but7s)
  168.    dj()
  169. end
  170. function d8()
  171.    button.flash(but8n)
  172.    turtle.select(but8s)
  173.    dj()
  174. end
  175. function d9()
  176.    button.flash(but9n)
  177.    turtle.select(but9s)
  178.    dj()
  179. end
  180. function d10()
  181.    button.flash(but10n)
  182.    turtle.select(but10s)
  183.    dj()
  184. end
  185. function d11()
  186.    button.flash(but11n)
  187.    turtle.select(but11s)
  188.    dj()
  189. end
  190. function d12()
  191.    button.flash(but12n)
  192.    turtle.select(but12s)
  193.    dj()
  194. end
  195. function d13()
  196.    button.flash(but13n)
  197.    turtle.select(but13s)
  198.    dj()
  199. end
  200. function d14()
  201.    button.flash(but14n)
  202.    turtle.select(but14s)
  203.    dj()
  204. end
  205. function d15()
  206.    button.flash(but15n)
  207.    turtle.Select(but15s)
  208.    dj()
  209. end
  210. function d16()
  211.    button.flash(but16n)
  212.    turtle.select(but16s)
  213.    dj()
  214. end
  215. function dj()
  216.  turtle.drop()
  217.  sleep(0,5)
  218.  rs.setOutput("front", true)
  219.  sleep(0,5)
  220.  rs.setOutput("front", false)
  221.  turtle.suck()
  222. end
  223.  
  224.  
  225. function show()
  226. string = turtle.getItemDetail().name
  227. result = split(string,":")
  228. result[2] = string.gsub(result[2],"record_","")
  229. result[2] = string.gsub(result[2],"RecordWantYouGone","Want You Gone")
  230. result[2] = string.gsub(result[2],"RecordRadioLoop","Radio Loop")
  231. result[2] = string.gsub(result[2],"RecordStillAlive","Still ALive")
  232. result[2] = string.gsub(result[2],"recordGaia1","Endure Emptiness")
  233. result[2] = string.gsub(result[2],"recordGaia2","Fight For Quiescence")
  234. return result[2]
  235. end
  236.  
  237.  
  238.  
  239. function split(str, pat)
  240.    local t = {}  -- NOTE: use {n = 0} in Lua-5.0
  241.    local fpat = "(.-)" .. pat
  242.    local last_end = 1
  243.    local s, e, cap = str:find(fpat, 1)
  244.    while s do
  245.       if s ~= 1 or cap ~= "" then
  246.          table.insert(t,cap)
  247.       end
  248.       last_end = e+1
  249.       s, e, cap = str:find(fpat, last_end)
  250.    end
  251.    if last_end <= #str then
  252.       cap = str:sub(last_end)
  253.       table.insert(t, cap)
  254.    end
  255.    return t
  256. end
  257. fillTable()
  258. button.heading("Jukbox list")
  259. print(but1s)
  260. print(but2s)
  261. print(but3s)
  262. while true do
  263.    getClick()
  264. end
Advertisement
Add Comment
Please, Sign In to add comment