Advertisement
Wyvern67

Bruteforcing enderchests

Jul 14th, 2014
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.25 KB | None | 0 0
  1. tickRate = 0.05
  2. fancyMode = true
  3.  
  4. mon = peripheral.wrap("top")
  5. for a,b in pairs(rs.getSides()) do
  6.     if peripheral.getType(b) == "ender_chest" then
  7.         chest = peripheral.wrap(b)
  8.         b1,b2,b3 = chest.getColors()
  9.         break
  10.     end
  11. end
  12.  
  13. function monClear()
  14.     mon.clear()
  15.     mon.setCursorPos(1,1)
  16. end
  17.  
  18. function drawButtons()
  19. for i= 1, y do
  20.     for k=1,x/3+1 do
  21.     mon.setCursorPos(k,i)
  22.     mon.setBackgroundColor(b1)
  23.     mon.write(" ")
  24.     end
  25. end
  26. for i=1, y do
  27.     for k=x/3+1,x/3*2+2 do
  28.     mon.setCursorPos(k,i)
  29.     mon.setBackgroundColor(b2)
  30.     mon.write(" ")
  31.     end
  32. end
  33. for i=1, y do
  34.     for k=x/3*2+2, x+2 do
  35.     mon.setCursorPos(k,i)
  36.     mon.setBackgroundColor(b3)
  37.     mon.write(" ")
  38.     end
  39. end
  40. for i=1, y do
  41.     mon.setBackgroundColor(colors.black)
  42.     mon.setCursorPos(x/3+1,i)
  43.     mon.write(" ")
  44. end
  45. for i=1, y do
  46.     mon.setBackgroundColor(colors.black)
  47.     mon.setCursorPos(x/3*2+1,i)
  48.     mon.write(" ")
  49. end
  50. end
  51.  
  52. chestList = {}
  53. event = ""
  54. x,y = mon.getSize()
  55.  
  56. for i=0,15 do -- 2^[0;15] = 1,2,4,8,16,32,64, ... , 32768
  57.     if event == "monitor_touch" then break end
  58.     b1 = 2^i
  59.     for i=0,15 do
  60.         if event == "monitor_touch" then break end
  61.         b2 = 2^i
  62.         for i=0,15 do
  63.             if event == "monitor_touch" then break end
  64.             b3= 2^i
  65.             chest.setColors(b1,b2,b3)
  66.             slot = chest.getStackInSlot(1)
  67.             if slot then
  68.                 table.insert(chestList, {b1,b2,b3})
  69.                 print(tostring(b1)..","..tostring(b2)..","..tostring(b3).." has some "..slot.name)
  70.             end
  71.             if fancyMode then
  72.                 drawButtons()
  73.             end
  74.             os.startTimer(tickRate)
  75.             event = os.pullEvent()
  76.         end
  77.     end
  78. end
  79.  
  80. chest.setColors(16,16,16)
  81. drawButtons()
  82. sleep(3)
  83.  
  84. h = fs.open("chestList", "w")
  85. h.write(textutils.serialize(chestList))
  86. h.close()
  87.  
  88. i=1
  89. while true do
  90.     x,y = mon.getSize()
  91.     event, param1, param2, param3 = os.pullEvent()
  92.     if event == "peripheral" and peripheral.getType(param1) == "ender_chest" then
  93.         chest = peripheral.wrap(param1)
  94.         b1,b2,b3 = chest.getColors()
  95.         mon.setBackgroundColor(colors.black)
  96.         monClear()
  97.         drawButtons()
  98.     elseif event == "peripheral_detach" then
  99.         monClear()
  100.     elseif event == "monitor_touch" then
  101.         goodChest = chestList[i]
  102.         if goodChest == nil then
  103.             i=1
  104.         end
  105.         b1 = goodChest[1]
  106.         b2 = goodChest[2]
  107.         b3 = goodChest[3]
  108.         i=i+1
  109.     end
  110.     chest.setColors(b1,b2,b3)
  111.     drawButtons()
  112. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement