Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Recherchez la périphérie ME Bridge
- me = peripheral.wrap("meBridge_1")
- -- Recherchez la périphérie Monitor
- mon = peripheral.wrap("top")
- label = "CPU's Crafting"
- function prepareMonitor()
- mon.clear()
- CenterT(label, 1, colors.black, colors.white, "head", false)
- end
- -- Une fonction pour imprimer le texte centré sur le moniteur
- function CenterT(text, line, txtback, txtcolor, pos, clear)
- monX, monY = mon.getSize()
- mon.setTextColor(txtcolor)
- length = string.len(text)
- dif = math.floor(monX - length)
- x = math.floor(dif / 2)
- if pos == "head" then
- mon.setCursorPos(x + 1, line)
- mon.write(text)
- elseif pos == "left" then
- if clear then
- clearBox(2, 2 + length, line, line)
- end
- mon.setCursorPos(2, line)
- mon.write(text)
- elseif pos == "right" then
- if clear then
- clearBox(monX - length - 8, monX, line, line)
- end
- mon.setCursorPos(monX - length, line)
- mon.write(text)
- end
- end
- -- Une fonction pour effacer une zone spécifique
- function clearBox(xMin, xMax, yMin, yMax)
- mon.setBackgroundColor(colors.black)
- for xPos = xMin, xMax, 1 do
- for yPos = yMin, yMax do
- mon.setCursorPos(xPos, yPos)
- mon.write(" ")
- end
- end
- end
- prepareMonitor()
- while true do
- mon.clear()
- CenterT(label, 1, colors.black, colors.white, "head", false)
- CenterT("Crafting Items:", 3, colors.black, colors.yellow, "left", false)
- -- Vérifiez si la méthode listCraftingJobs existe
- if me.listCraftingJobs then
- -- Obtenez la liste des articles en cours de craft
- local craftingJobs = me.listCraftingJobs()
- -- Vérifiez si la liste n'est pas nulle avant de l'afficher
- if craftingJobs then
- -- Affichez la liste des articles en cours de craft
- local line = 5
- for _, job in ipairs(craftingJobs) do
- local isCrafting = me.isItemCrafting({ name = job.name })
- local status = isCrafting and "Crafting" or "Not Crafting"
- mon.setCursorPos(2, line)
- mon.write(job.name .. " - " .. status)
- line = line + 1
- end
- else
- CenterT("No crafting jobs.", 5, colors.black, colors.red, "left", false)
- end
- else
- CenterT("Whoula la metode que j’appelle n'ai pas dispo.. Connard !", 5, colors.black, colors.red, "left", false)
- end
- sleep(5) -- Attendez quelques secondes avant de rafraîchir la liste
- end
Advertisement
Add Comment
Please, Sign In to add comment