Advertisement
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"
- -- Liste des articles à surveiller
- local itemsToCheck = {
- "electrodynamics:motor"
- }
- 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 l'état de chaque article spécifique
- local line = 5
- for _, itemName in ipairs(itemsToCheck) do
- local isCrafting = me.isItemCrafting({ name = itemName })
- local status = isCrafting and "Crafting" or "Not Crafting"
- mon.setCursorPos(2, line)
- mon.write(itemName .. " - " .. status)
- line = line + 1
- end
- sleep(5) -- Attendez quelques secondes avant de rafraîchir la liste
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement