Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- tous crédits de code d'origine à Adsl_Houba
- -- https://www.youtube.com/user/MrAdslHouba/
- -- adaptations faites pour la commande de spawners par Rakmaar
- -- commentaires par Rakmaar
- term=peripheral.find('monitor') -- cherche les moniteurs adjacents
- term.setBackgroundColor(colors.black) -- couleur de fond des moniteurs
- term.clear() -- vide le terminal
- premierX=1 -- Premier X --
- premierY=1 -- Premier Y --
- largeur=9 -- Largeur bouton -- definit les variable de positionnement de boutons
- hauteur=5 -- Hauteur bouton -- ne modifier qu'en cas de mauvais alignement
- ligneY=3 -- hauteur du texte --
- marge=1 -- Marge entre deux boutons --
- coteRed="front"
- liste={ -- definit les boutons: nom affiché et couleur du canal redstone cible
- {
- nom='Endermen',
- color=colors.yellow,
- choix=true
- },
- {
- nom='Emeraude',
- color=colors.blue,
- choix=true
- },
- {
- nom='Moutons',
- color=colors.white,
- choix=true
- },
- {
- nom='Wither',
- color=colors.red,
- choix=true
- },
- }
- function actuWin(i) -- fonction d'actualisation des moniteurs sur clic
- if liste[i].choix then
- liste[i].win.setBackgroundColor(colors.red) -- couleur quand signal redstone envoyé
- else -- = spawner off
- liste[i].win.setBackgroundColor(colors.green) -- couleur quand pas de signal redstone sortant
- end -- = spawner on
- liste[i].win.clear()
- liste[i].win.setCursorPos(1+math.floor((largeur-string.len(liste[i].nom))/2),ligneY)
- liste[i].win.write(liste[i].nom)
- end
- function actuRed() -- controle d'etat, ne pas toucher
- redsTous=0 -- si vous ne savez pas ce que vous faites
- table.foreach(liste,function(i,data)
- if liste[i].choix==false then
- redsTous=redsTous+liste[i].color
- end
- end)
- redstone.setBundledOutput(coteRed,redsTous)
- end
- table.foreach(liste,function(i,data)
- file=fs.open(tostring(i),"r")
- if file~=nil then
- if file.readLine()=='true' then
- liste[i].choix=true
- else
- liste[i].choix=false
- end
- file.close()
- else
- file=fs.open(tostring(i),"w")
- file.write(liste[i].choix)
- file.close()
- end
- liste[i].win=window.create(term,premierX+((i-1)*(largeur+marge)),premierY,largeur,hauteur,true)
- actuWin(i)
- end)
- actuRed()
- while true do -- controle du clic tactile
- event, side, xPos, yPos = os.pullEvent("monitor_touch") -- si le tactile est décalé
- if (xPos-premierX)%(largeur+marge)<largeur then -- préférer bouger les variables en tete de fichier
- u=math.floor((xPos-premierX)/(largeur+marge))+1
- if liste[u] then
- if liste[u].choix then
- liste[u].choix=false
- else
- liste[u].choix=true
- end
- file=fs.open(tostring(u),"w")
- file.write(liste[u].choix)
- file.close()
- actuWin(u)
- actuRed()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement