Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- INSTRUCTIONS
- 1. Modifier les cotåA5A9s en fonction d'ou sont placåA5A9 les påA5A9riphåA5A9riques.
- 2. Modifier la liste des aspects dans 'essentias', aucun autre aspect ne sera affichåA5A9 si il n'est pas dans cette liste
- 3. Modifier le tableau 'quantity' qui permet d'initialiser les valeurs des jars
- 4. DåA5A9finir les niveaux d'alerte
- 5. DåA5A9finir les couleurs d'affichage (choix uniquement avec les 'colors.choix' de l'api Colors de Computer Craft)
- --]]
- --[[
- Faire une initialisation pour våA5A9rifier que les niveaux soit bien dåA5A9finie et que tout soit possible
- --]]
- -- ## DåA5A9finition des variables
- -- påA5A9riphåA5A9riques
- coffre_side = "diamond_0"
- me_side = "appeng_me_tileterminal_0"
- coffreSFM = "north"
- monitor_side = "top"
- -- niveaux de couleurs d'essence
- maxValue = 256
- lowValue = maxValue * 25/100
- highValue = maxValue * 50/100
- -- couleurs d'affichage pour le niveau d'essence
- lowColor = colors.red
- mediumColor = colors.orange
- highColor = colors.green
- NaColor = colors.gray
- basicColor = colors.white
- backgroundColor = colors.black
- -- liste des essences
- essentias = {
- "Aer",
- "Alienis",
- "Aqua",
- "Arbor",
- "Auram",
- "Bestia",
- "Cognitio",
- "Corpus",
- "Desidia",
- "Exanimis",
- "Fabrico",
- "Fames",
- "Gelum",
- "Granum",
- "Gula",
- "Herba",
- "Humanus",
- "Ignis",
- "Infernus",
- "Instrumentum",
- "Invidia",
- "Ira",
- "Iter",
- "Limus",
- "Lucrum",
- "Lux",
- "Luxuria",
- "Machina",
- "Messis",
- "Metallum",
- "Meto",
- "Mortuus",
- "Motus",
- "Ordo",
- "Pannus",
- "Perditio",
- "Perfodio",
- "Permutatio",
- "Potentia",
- "Praecantatio",
- "Sano",
- "Saxum",
- "Sensus",
- "Spiritus",
- "Superbia",
- "Telum",
- "Tempestas",
- "Tempus",
- "Tenebrae",
- "Terra",
- "Tutamen",
- "Vacuos",
- "Venenum",
- "Victus",
- "Vinculum",
- "Vitium",
- "Vitreus",
- "Volatus"
- }
- -- initialisation de l'affichage des essences
- quantity = {
- ["Aer"] = "N/A",
- ["Alienis"] = "N/A",
- ["Aqua"] = "N/A",
- ["Arbor"] = "N/A",
- ["Auram"] = "N/A",
- ["Bestia"] = "N/A",
- ["Cognitio"] = "N/A",
- ["Corpus"] = "N/A",
- ["Desidia"] = "N/A",
- ["Exanimis"] = "N/A",
- ["Fabrico"] = "N/A",
- ["Fames"] = "N/A",
- ["Gelum"] = "N/A",
- ["Granum"] = "N/A",
- ["Gula"] = "N/A",
- ["Herba"] = "N/A",
- ["Humanus"] = "N/A",
- ["Ignis"] = "N/A",
- ["Infernus"] = "N/A",
- ["Instrumentum"] = "N/A",
- ["Invidia"] = "N/A",
- ["Ira"] = "N/A",
- ["Iter"] = "N/A",
- ["Limus"] = "N/A",
- ["Lucrum"] = "N/A",
- ["Lux"] = "N/A",
- ["Luxuria"] = "N/A",
- ["Machina"] = "N/A",
- ["Messis"] = "N/A",
- ["Metallum"] = "N/A",
- ["Meto"] = "N/A",
- ["Mortuus"] = "N/A",
- ["Motus"] = "N/A",
- ["Ordo"] = "N/A",
- ["Pannus"] = "N/A",
- ["Perditio"] = "N/A",
- ["Perfodio"] = "N/A",
- ["Permutatio"] = "N/A",
- ["Potentia"] = "N/A",
- ["Praecantatio"] = "N/A",
- ["Sano"] = "N/A",
- ["Saxum"] = "N/A",
- ["Sensus"] = "N/A",
- ["Spiritus"] = "N/A",
- ["Superbia"] = "N/A",
- ["Telum"] = "N/A",
- ["Tempus"] = "N/A",
- ["Tempestas"] = "N/A",
- ["Tenebrae"] = "N/A",
- ["Terra"] = "N/A",
- ["Tempus"] = "N/A",
- ["Tutamen"] = "N/A",
- ["Vacuos"] = "N/A",
- ["Venenum"] = "N/A",
- ["Victus"] = "N/A",
- ["Vinculum"] = "N/A",
- ["Vitium"] = "N/A",
- ["Vitreus"] = "N/A",
- ["Volatus"] = "N/A"
- }
- -- liste des aspects et les id correspondant
- essentiaId = {
- ["Alienis"] = 368,
- }
- -- liste des id åA5A0 approvisionner
- ressource = {
- [368] = {["Alienis"] = 4, ["Iter"] = 4, ["Praecantatio"]=2}
- }
- -- ## End DåA5A9finition
- -- ## VåA5A9rif des paramåA5A8tres
- print("Check settings...")
- local arret = {}
- local side = {"top", "bottom", "right", "left", "back", "front"}
- local colors = {colors.white, colors.orange, colors.magenta, colors.lightBlue, colors.yellow, colors.lime, colors.pink, colors.gray, colors.lightGray, colors.cyan, colors.purple, colors.blue, colors.brown, colors.green, colors.red, colors.black}
- -- test des couleurs
- local testLowColor = false
- local testMediumColor = false
- local testHighColor = false
- local testNaColor = false
- local testBasicColor = false
- local testBackgroundColor = false
- for index, color in pairs(colors) do
- if lowColor == color then
- testLowColor = true
- end
- if mediumColor == color then
- testMediumColor = true
- end
- if highColor == color then
- testHighColor = true
- end
- if NaColor == color then
- testNaColor = true
- end
- if basicColor == color then
- testBasicColor = true
- end
- if backgroundColor == color then
- testBackgroundColor = true
- end
- end
- if testLowColor == false then
- table.insert(arret, "lowColor")
- end
- if testMediumColor == false then
- table.insert(arret, "mediumColor")
- end
- if testHighColor == false then
- table.insert(arret, "highColor")
- end
- if testNaColor == false then
- table.insert(arret, "NaColor")
- end
- if testBasicColor == false then
- table.insert(arret, "basicColor")
- end
- if testBackgroundColor == false then
- table.insert(arret, "backgroundColor")
- end
- -- test des påA5A9riphåA5A9riques
- local testcoffre_side = false
- local testMonitor_side = false
- for index, side in pairs(side) do
- if coffre_side == side then
- testcoffre_side = true
- end
- if monitor_side == side then
- testMonitor_side = true
- end
- end
- if testcoffre_side == false then
- table.insert(arret, "coffre_side")
- end
- if testMonitor_side == false then
- table.insert(arret, "monitor_side")
- end
- -- test des niveaux d'alerte coloråA5A9s
- local testLowValue = false
- local testHighValue = false
- if lowValue < 0 then
- table.insert(arret, "lowValue")
- end
- if highValue < 0 then
- table.insert(arret, "highValue")
- end
- if lowValue > highValue then
- table.insert(arret, "lowValue & highValue")
- end
- -- affichage des erreurs
- if table.maxn(arret) ~= 0 then
- local erreurs = "failing setting on parameters:\n"
- for index, param in pairs(arret) do
- erreurs = erreurs.."- '"..param.."'\n"
- end
- -- error(erreurs)-- arrête du programme åA5A0 cause d'une erreur
- end
- print("Settings OK!")
- -- ## End VåA5A9rif des paramåA5A8tres
- -- ## Init
- chest = peripheral.wrap(coffre_side)
- me=peripheral.wrap(me_side)
- m = peripheral.wrap(monitor_side)
- m.setBackgroundColor(backgroundColor)
- m.setTextScale(1)
- m.clear()
- local largeurMax
- local tmpLargeur
- local x
- local y
- local affichage
- local lMon
- local hMon
- local tmpQuantity
- local largeurTotale
- -- ## End Init
- -- ## Function
- function refill(_name,_quantity)
- if redstone==true then
- if _quantity <= lowValue then
- idItem = essentiaId[_name]
- if idItem ~= nil then --au cas ou l'id n'a pas åA5A9tåA5A9 notåA5A9 pour cet aspect
- facteur = ressource[idItem][_name]
- if facteur ~= nil then --au cas ou la ressource n'as pas åA5A9tåA5A9 notåA5A9 dans le tableau
- wanted = (highValue - panier[_name]) / facteur
- for k,v in pairs(ressource[idItem ]) do --k = aspect et v = sa quantitåA5A9 dans l'item
- panier[k] = panier[k] + v * wanted --on update le panier total
- if me.containsItemType(idItem ,0) then --cas ou l'on n'a pas l'id dans le coffre
- if me.countOfItemType(idItem ,0) < wanted then -- si l'on a moins d'item dans la me que demandåA9
- wanted = me.countOfItemType(idItem ,0)
- print(wanted)
- end
- me.extractItem({id=idItem , dmg=0, qty=wanted},"north")
- end
- end
- end
- end
- end
- end
- end
- -- ## End Function
- -- ## Main
- local lTerm, hTerm = term.getSize()
- local mesTerm = "... in execution ..."
- term.setCursorPos(math.ceil((lTerm-string.len(mesTerm))/2), math.ceil(hTerm/2))
- term.clear()
- term.write(mesTerm)
- panier={}
- for k,v in pairs(quantity) do
- panier[k]=0
- end
- while true do
- lMon, hMon = m.getSize()
- redstone=true
- lstPeriph=peripheral.getNames() --on recupere la liste des peripheral dans un tableau
- for k,v in pairs(quantity) do --on remet toutes les valeurs des essences a 0 sur le tableau
- quantity[k]="N/A"
- end
- for k,periph in pairs(lstPeriph) do
- if periph == monitor_side then --on ne cherche evidement pas de jar sur le monitor
- elseif periph == "left" then
- elseif periph == "back" then
- elseif periph == coffre_side then --on ne cherche evidement pas de jar sur le coffre
- elseif periph == me_side then
- else --tous les autres peripheriques doivent etre des jars
- jar=peripheral.wrap(periph)
- local essentia = jar.getAspects()
- if (essentia[1] == nil or essentia[1] == '') then
- else
- local name = essentia[1]["name"]
- local quantityjar = jar.getAspectCount(name)
- if name and quantityjar then
- if quantity[name] == "N/A" then --cas ou la quantitåA5A9 est vide
- quantity[name] = quantityjar
- else
- quantity[name] = quantityjar + quantity[name]
- end
- -- print(name.." : "..quantityjar)
- end
- end
- end
- end
- lstPeriph=nil -- vidage de la table des peripheral en cas de changement des jars
- m.clear()
- largeurMax = 0
- tmpLargeur = 0
- largeurTotale = 0
- x = 1
- y = 1
- if quantity ~= nil then -- cas tableau vide
- for index, name in pairs(essentias) do
- tmpQuantity = quantity[name]
- if tmpQuantity ~= nil then -- cas essence non repertoriåA5A9
- m.setCursorPos(x,y)
- tmpLargeur = 0
- if x > 1 then
- m.setTextColor(basicColor)
- m.write("|")
- m.setCursorPos(x+1,y)
- tmpLargeur = 1
- end
- if tmpQuantity == "N/A" then
- m.setTextColor(NaColor)
- elseif tmpQuantity < lowValue then
- m.setTextColor(lowColor)
- elseif tmpQuantity > highValue then
- m.setTextColor(highColor)
- else
- m.setTextColor(mediumColor)
- end
- affichage = name.." "..tmpQuantity
- m.write(affichage) --Affichage sur le moniteur
- if tmpQuantity ~= "N/A" then
- refill(name,tmpQuantity) --fonction de la gestion du remplissage
- end
- tmpLargeur = tmpLargeur + string.len(affichage)
- if tmpLargeur > largeurMax then
- largeurMax = tmpLargeur
- end
- if y < hMon then
- y = y + 1
- else
- y = 1
- x = x + largeurMax
- largeurTotale = largeurTotale + largeurMax
- end
- if largeurTotale > (lMon + 10) then
- print("Plus de moniteur d'affichage requis")
- break
- end
- end
- end
- end
- sleep(5)
- end
- -- ## End Main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement