Advertisement
jdroid91

chestGet

Dec 9th, 2023 (edited)
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.18 KB | None | 0 0
  1. local blocksAndChests = {
  2.     {"minecraft:chest_4", "minecraft:dirt"},
  3.     {"minecraft:chest_5", "minecraft:cobblestone"},
  4.     {"minecraft:chest_6", "minecraft:paper"},
  5.     {"minecraft:chest_7", "minecraft:wheat_seeds"},
  6.     {"minecraft:chest_8", "minecraft:cobbled_deepslate"},
  7.     {"minecraft:chest_9", "minecraft:deepslate"},
  8.     {"minecraft:chest_10", "minecraft:cherry_log"},
  9.     {"minecraft:chest_11", "minecraft:cherry_planks"},
  10.     {"minecraft:chest_12", "minecraft:bone"},
  11.     {"minecraft:chest_13", "minecraft:rotten_flesh"},
  12.     {"minecraft:chest_14", "minecraft:gold_ingot"},
  13.     {"minecraft:chest_15", "minecraft:iron_ingot"},
  14.     {"minecraft:chest_16", "minecraft:lapis_lazuli"},
  15.     {"minecraft:chest_17", "minecraft:redstone"},
  16.     {"minecraft:chest_18", "minecraft:white_wool"},
  17.     {"minecraft:chest_19", "minecraft:kelp"},
  18.     {"minecraft:chest_20", "minecraft:tuff"},
  19.     {"minecraft:chest_21", "minecraft:gravel"},
  20.     {"minecraft:chest_22", "minecraft:string"},
  21.     {"minecraft:chest_23", "minecraft:stick"},
  22.     {"minecraft:chest_24", "minecraft:spider_eye"},
  23.     {"minecraft:chest_25", "minecraft:quartz"},
  24.     {"minecraft:chest_26", "minecraft:gunpowder"},
  25.     {"minecraft:chest_27", "minecraft:blaze_rod"},
  26.     {"minecraft:chest_33", "minecraft:sand"},
  27.     {"minecraft:chest_34", "minecraft:netherrack"},
  28.     {"minecraft:chest_35", "minecraft:carrot"},
  29.     {"minecraft:chest_36", "minecraft:sugar_cane"},
  30.     {"minecraft:chest_37", "minecraft:beef"},
  31.     {"minecraft:chest_38", "minecraft:clay_ball"},
  32.     {"minecraft:chest_44", "minecraft:ender_pearl"},
  33.     {"minecraft:chest_45", "minecraft:leather"},
  34.     {"minecraft:chest_46", "minecraft:cod"},
  35.     {"minecraft:chest_47", "minecraft:salmon"},
  36.     {"minecraft:chest_48", "minecraft:cherry_sapling"},
  37.     {"minecraft:chest_49", "minecraft:oak_planks"},
  38.     {"minecraft:chest_50", "minecraft:glass_bottle"},
  39.     {"minecraft:chest_51", "minecraft:glass_pane"},
  40.     {"minecraft:chest_52", "minecraft:cherry_logs"},
  41.     {"minecraft:chest_53", "minecraft:tropical_fish"},
  42.     {"minecraft:chest_54", "minecraft:charcoal"},
  43.     {"minecraft:chest_55", "minecraft:obsidian"},
  44.     {"minecraft:chest_108", "minecraft:chorus_fruit"},
  45.     {"minecraft:chest_109", "minecraft:glowstone"},
  46.     {"minecraft:chest_110", "minecraft:gold_nugget"},
  47.     {"minecraft:chest_111", "minecraft:ender_eye"}
  48. }
  49.  
  50. local topChest = peripheral.wrap("ironchest:crystal_chest_4")
  51.  
  52. while (true)
  53. do
  54.     print("What do you want?")
  55.     desiredItem = "minecraft:"..io.read()
  56.     index = 1
  57.     while (index <= #blocksAndChests)
  58.     do
  59.         if (blocksAndChests[index][2] == desiredItem)
  60.         then
  61.             goalChest = peripheral.wrap(blocksAndChests[index][1])
  62.             index2 = 1
  63.             while (index2 < goalChest.size())
  64.             do
  65.                 itemDetail = goalChest.getItemDetail(index2)
  66.                 if (itemDetail ~= nil)
  67.                 then
  68.                     goalChest.pushItems(peripheral.getName(topChest), index2)
  69.                     break
  70.                 end
  71.                 index2 = index2 + 1
  72.             end
  73.         end
  74.         index = index + 1
  75.     end
  76.     print("Sent: "..desiredItem)
  77.     os.sleep(0.5)
  78. end
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement