Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script need BUTTON API by DIREWOLF20 !
- --Chargement API
- os.loadAPI("button")
- --Variable Global
- nbToCraft = 0
- nbToPrint = "0"
- selectedCraft = ""
- doingCrafting = false
- local craftingTable = {}
- craftingTable["Water"] = {"minecraft:water_bucket", "minecraft:kelp", "minecraft:snow_block"}
- craftingTable["Manip"] = {"minecraft:stone_button", "minecraft:clock", "minecraft:redstone"}
- craftingTable["Fire"] = {"minecraft:flint_and_steel", "minecraft:gunpowder", "minecraft:torch"}
- craftingTable["Earth"] = {"minecraft:dirt", "minecraft:iron_ingot", "minecraft:wheat_seeds"}
- craftingTable["Air"] = {"minecraft:feather", "minecraft:arrow", "ars_nouveau:wilden_wing"}
- craftingTable["Conju"] = {"minecraft:book", "ars_nouveau:wilden_horn", "ars_nouveau:starbuncle_shards"}
- craftingTable["Abjur"] = {"minecraft:milk_bucket", "minecraft:fermented_spider_eye", "minecraft:sugar"}
- local reactStore = "minecraft:barrel_1"
- local inOut = "minecraft:barrel_0"
- local imbuer = "ars_nouveau:imbuement_chamber_1"
- local pedest0 = "ars_nouveau:arcane_pedestal_3"
- local pedest1 = "ars_nouveau:arcane_pedestal_4"
- local pedest2 = "ars_nouveau:arcane_pedestal_5"
- local pedestTab = {pedest0, pedest1, pedest2}
- local reactStoreW = peripheral.wrap(reactStore)
- local imbuerW = peripheral.wrap(imbuer)
- local inOutW = peripheral.wrap(inOut)
- local pedest0W = peripheral.wrap(pedest0)
- local pedest1W = peripheral.wrap(pedest1)
- local pedest2W = peripheral.wrap(pedest2)
- local pedestWTab = {pedest0W, pedest1W, pedest2W}
- --math.floor(nbToCraft)
- --Prog:
- m = peripheral.wrap("back")
- function fillTable()
- button.setTable("Water",selector,"Water",2,8,2,4)
- button.setTable("Manip",selector,"Manip",11,18,2,4)
- button.setTable("Fire",selector,"Fire",21,28,2,4)
- button.setTable("Earth",selector,"Earth",2,8,6,8)
- button.setTable("Air",selector,"Air",11,18,6,8)
- button.setTable("Conju",selector,"Conju",21,28,6,8)
- button.setTable("Abjur",selector,"Abjur",11,18,10,12)
- button.setTable("--",subMultiple,"",2,5,16,18)
- button.setTable("-",subSimple,"",7,9,16,18)
- button.setTable("+",addSimple,"",21,23,16,18)
- button.setTable("++",addMultiple,"",25,28,16,18)
- button.setTable(nbToPrint,crafting,"",11,18,16,18)
- button.screen()
- end
- function getClic()
- event,side,x,y = os.pullEvent("monitor_touch")
- button.checkxy(x,y)
- end
- function suckAll()
- print("Empty Pedest")
- for _, pedestW in pairs(pedestWTab) do
- if pedestW.getItemDetail(1) ~= nil then
- pedestW.pushItems(reactStore, 1)
- end
- end
- end
- function nbConv()
- -- updating craft button
- if doingCrafting then
- button.toggleButton(nbToPrint)
- end
- nbToPrint = tostring(nbToCraft)
- -- updating selected craft
- if selectedCraft ~= "" then
- button.toggleButton(selectedCraft)
- end
- button.clearTable()
- fillTable()
- if selectedCraft ~= "" then
- button.toggleButton(selectedCraft)
- end
- -- updating the craft if craft there is
- if doingCrafting then
- button.toggleButton(nbToPrint)
- end
- button.screen()
- end
- function crafting()
- print("craft")
- button.toggleButton(nbToPrint)
- -- empty imbueur in case
- if imbuerW.getItemDetail(1) ~= nil then
- imbuerW.pushItems(inOut,1)
- end
- doingCrafting = true
- --keeping the name of the input
- local craftInput = "ars_nouveau:source_gem"
- --making gems
- while doingCrafting and nbToCraft ~= 0 do
- --cheking for the slot of gems
- local found = false
- local list = inOutW.list()
- local slot = 1
- while not found and slot <= #list do
- if list[slot]["name"] == craftInput then
- print("item found")
- found = true
- else
- slot = slot + 1
- end
- end
- -- making sure to have a gem
- if not found then
- print("no catalyser found")
- doingCrafting = false
- nbToCraft = nbToCraft + 1 --compense le -1 qui n'a pas lieux dans ce casd
- else
- -- puting gem in imbuer
- print("putting the item")
- print(inOutW.getItemDetail(slot)["name"])
- inOutW.pushItems(imbuer, slot)
- end
- while doingCrafting and imbuerW.getItemDetail(1)["name"] == craftInput do
- print("checking for craft")
- -- waiting for craft or cancel
- os.startTimer(3)
- local event = os.pullEvent()
- if event ~= "timer" then
- -- stoping craft
- print("crafting have been stoped")
- doingCrafting = false
- os.reboot()
- end
- end
- imbuerW.pushItems(inOut, 1)
- nbToCraft = nbToCraft - 1
- nbConv()
- end
- print("end crafting")
- doingCrafting = false
- button.toggleButton(nbToPrint)
- end
- function addSimple()
- print("+")
- button.flash("+")
- nbToCraft = nbToCraft + 1
- nbConv()
- end
- function addMultiple()
- print("++")
- button.flash("++")
- nbToCraft = nbToCraft + 5
- nbConv()
- end
- function selector(input)
- -- Affichage
- print(input)
- if selectedCraft == input then
- button.toggleButton(selectedCraft)
- selectedCraft = ""
- suckAll()
- else
- if selectedCraft ~= "" then
- button.toggleButton(selectedCraft)
- end
- selectedCraft = input
- button.toggleButton(selectedCraft)
- -- Item Move
- suckAll()
- local listItem = reactStoreW.list()
- local found = false
- for number, item in pairs(craftingTable[selectedCraft]) do
- found = false
- for slot, stored in ipairs(listItem) do
- if stored["name"] == item then
- reactStoreW.pushItems(pedestTab[number], slot)
- print("pushing "..item)
- found = true
- end
- end
- if not found then
- print("item "..item.." hasn't been found")
- end
- end
- end
- end
- function subSimple()
- print("-")
- button.flash("-")
- if nbToCraft >= 1 then
- nbToCraft = nbToCraft - 1
- end
- nbConv()
- end
- function subMultiple()
- print("--")
- button.flash("--")
- if nbToCraft >= 5 then
- nbToCraft = nbToCraft - 5
- else
- nbToCraft = 0
- end
- nbConv()
- end
- --Prog actif:
- if imbuerW.getItemDetail(1) ~= nil then
- imbuerW.pushItems(inOut, 1)
- end
- button.clearTable()
- fillTable()
- button.heading("Essence Crafting")
- --button.label(1,4,"Tutoriel")
- while true do
- getClic()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement