Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local loader = require("loader")
- local press = peripheral.wrap("left")
- local chest = peripheral.find("minecraft:chest")
- local me = peripheral.find("meBridge")
- local request = loader.menu()
- local nameAtual = request.name
- local nivelAtual = request.level
- local nbtAtual = request.nbt
- local toolAtual = request.tool
- local desejado = request.desejado
- while nivelAtual ~= desejado do
- print("Nivel Desejado: " .. desejado)
- print("Nivel Atual: " .. nivelAtual)
- for _, v in pairs(me.listItems()) do
- if v.nbt.tag and v.nbt.tag.reference then
- for __, v1 in pairs(v.nbt.tag.reference.tag.StoredEnchantments) do
- local nome = v1.id:match(":(.+)")
- -- loader.salvar(nome, v1.lvl, v.fingerprint)
- -- loader.salvar(nome, v1.lvl, v.fingerprint, "diamond_")
- if nameAtual == nome and nivelAtual == v1.lvl then
- -- print("DEBUG nivelAtual" .. nivelAtual .. " - " .. v1.lvl)
- local item = me.getItem({fingerprint = v.fingerprint})
- me.exportItem(item, "up")
- local toolItem = me.getItem({name = "minecraft:" .. toolAtual })
- me.exportItem(toolItem, "up")
- for slot, valor in pairs(chest.list()) do
- if valor.name == "sfm:form" then
- chest.pushItems(peripheral.getName(press), slot)
- break
- end
- end
- -- chest.pushItems(peripheral.getName(press),1)
- local booksCount = 0
- while booksCount < 2 do
- sleep(0.6)
- booksCount = booksCount + 1
- redstone.setOutput("back", true)
- sleep(0.6)
- redstone.setOutput("back", false)
- sleep(0.6)
- press.pushItems(peripheral.getName(chest),3)
- end
- press.pushItems(peripheral.getName(chest), 1)
- me.importItem(item, "up")
- -- print("Nivel " .. nivelAtual .. " finalizado")
- term.clear()
- term.setCursorPos(1,1)
- print("Esperando nova prensa...")
- sleep(5)
- local found = false
- while not found do
- for slot, item in pairs(chest.list()) do
- if item.name == "sfm:form" then
- print("Registrando...")
- local oldName = item.name
- local oldNBT = item.nbt
- me.importItem(item, "up")
- local newPress = me.getItem({name = oldName, nbt = oldNBT})
- if newPress.nbt.tag and newPress.nbt.tag.reference then
- for __, v1 in pairs(newPress.nbt.tag.reference.tag.StoredEnchantments) do
- local nome = v1.id:match(":(.+)")
- -- print("Nova prensa - " .. nome)
- -- print("DEBUG salvando" .. nivelAtual .. " - " .. nome)
- loader.salvar(nome, v1.lvl, newPress.fingerprint, "diamond_")
- end
- end
- found = true
- nivelAtual = nivelAtual + 1
- end
- end
- if not found then
- sleep(1)
- end
- end
- end
- end
- end
- end
- end
- if nivelAtual == desejado then
- for _, v in pairs(me.listItems()) do
- if v.nbt.tag and v.nbt.tag.reference then
- for __, v1 in pairs(v.nbt.tag.reference.tag.StoredEnchantments) do
- local nome = v1.id:match(":(.+)")
- if nameAtual == nome and nivelAtual == v1.lvl then
- local item = me.getItem({fingerprint = v.fingerprint})
- me.exportItem(item, "up")
- for slot, valor in pairs(chest.list()) do
- if valor.name == "sfm:form" then
- chest.pushItems(peripheral.getName(press), slot)
- break
- end
- end
- sleep(0.6)
- redstone.setOutput("back", true)
- sleep(0.6)
- redstone.setOutput("back", false)
- sleep(0.6)
- press.pushItems(peripheral.getName(chest),3)
- press.pushItems(peripheral.getName(chest), 1)
- me.importItem(item, "up")
- -- print("Nivel " .. nivelAtual .. " finalizado")
- term.clear()
- term.setCursorPos(1,1)
- end
- end
- end
- end
- end
- print("Feito " .. nameAtual .. " LVL " .. nivelAtual)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement