Advertisement
Guest User

juke

a guest
May 22nd, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.20 KB | None | 0 0
  1. --turns your turtle into a dj :3
  2.  
  3. --Variables--
  4. local fDiscs    = 0  --nr of found discs
  5. --discs: nr, name, namelength, found, turtleslot
  6. local discs     = {}
  7. --tSides: sides turtle can suck/drop stuff
  8. local tSides    = {"top","front","bottom"}
  9. --discNames: all vanilla music discs
  10. local discNames = {{name = "13"     },
  11.                    {name = "cat"    },
  12.                    {name = "blocks" },
  13.                    {name = "chirp"  },
  14.                    {name = "far"    },
  15.                    {name = "mall"   },
  16.                    {name = "mellohi"},
  17.                    {name = "stal"   },
  18.                    {name = "strad"  },
  19.                    {name = "ward"   },
  20.                    {name = "11"     },
  21.                    {name = "wait"   }}
  22.  
  23. local error = "\nYour momma"
  24.  
  25. --Peripheral Setup--
  26. --Monitor
  27. local mon, mon2 = peripheral.find("monitor", function(name, object) return object.isColor() end)
  28. assert(mon,"No advanced monitor found"..error)
  29. assert(not mon2,"Multiple advanced monitors found"..error)
  30. mon.setTextScale(.5)
  31. local mW, mH = mon.getSize()
  32. print(mW.." - "..mH) --test
  33. --Disk Drive
  34.  
  35.   -->hier<--
  36.  
  37. --Chest
  38.  
  39.  
  40. --Functions--
  41. -- sorting/filling/resetting discs table
  42. local function sortDiscs()
  43.   discs = discNames
  44.   local dump = true
  45.     for h=1,12 do
  46.     discs[h]["found"] = false
  47.   end
  48.   for i=1,16 do
  49.     local item = turtle.getItemDetail(i)
  50.     if item ~= nil then
  51.       -- get id
  52.       local id = string.sub(item.name,18)
  53.       -- compare to table
  54.       for j=1,12 do
  55.         if id == discs[j]["name"] then
  56.           -- safe it from being dumped
  57.           dump = false
  58.           if not discs[j]["found"] then
  59.             discs[j]["found"] = true
  60.             discs[j]["tslot"] = i
  61.             discs[j]["nlen"]  = string.len(discs[j]["name"])
  62.             fDiscs = fDiscs + 1
  63.           else
  64.             turtle.select(i)
  65.             turtle.dropUp()
  66.             turtle.select(1)
  67.           end
  68.         end
  69.       end
  70.       if dump then
  71.         turtle.select(i)
  72.         turtle.dropUp()
  73.         turtle.select(1)
  74.       end
  75.       dump = true
  76.     end
  77.   end
  78. end
  79. sortDiscs() --test
  80. print(textutils.serialize(discs[11])) -- table test
  81.  
  82. for i=1,fDiscs do
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement