Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Settings()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Setup-Modus für Fachtechniker")
- local pin = "----"
- repeat
- term.setCursorPos(1,2)
- term.write("Bitte Fachtechniker-PIN eingeben:")
- term.setCursorPos(1,3)
- term.write("(zum Verlassen ENTER drücken)")
- term.setCursorPos(1,4)
- pin = io.read()
- if pin == "" then
- return false
- elseif pin ~= "0000" then
- term.setCursorPos(1,4)
- term.clearLine()
- term.setCursorPos(1,1)
- term.clearLine()
- term.write("FALSCHER PIN")
- end
- until (pin == "0000")
- local connectors = {}
- local okKey
- local id
- local color
- repeat
- id, color = selectionMenu.selectionMenu("Farbe für Silo1 auswählen", {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768},{"Weiß","Orange","Magenta","Hellblau","Gelb","Hellgrün","Rosa","Grau","Hellgrau","Türkis","Violett","Blau","Braun","Grün","Rot","Schwarz"})
- connectors["silo1"] = color
- id, color = selectionMenu.selectionMenu("Farbe für Silo2 auswählen", {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768},{"Weiß","Orange","Magenta","Hellblau","Gelb","Hellgrün","Rosa","Grau","Hellgrau","Türkis","Violett","Blau","Braun","Grün","Rot","Schwarz"})
- connectors["silo2"] = color
- id, color = selectionMenu.selectionMenu("Farbe für Silo3 wählen", {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768},{"Weiß","Orange","Magenta","Hellblau","Gelb","Hellgrün","Rosa","Grau","Hellgrau","Türkis","Violett","Blau","Braun","Grün","Rot","Schwarz"})
- connectors["silo3"] = color
- id, color = selectionMenu.selectionMenu("Farbe für Silo4 unten wählen", {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768},{"Weiß","Orange","Magenta","Hellblau","Gelb","Hellgrün","Rosa","Grau","Hellgrau","Türkis","Violett","Blau","Braun","Grün","Rot","Schwarz"})
- connectors["silo4"] = color
- id, color = selectionMenu.selectionMenu("Farbe für Silo5 wählen", {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768},{"Weiß","Orange","Magenta","Hellblau","Gelb","Hellgrün","Rosa","Grau","Hellgrau","Türkis","Violett","Blau","Braun","Grün","Rot","Schwarz"})
- connectors["silo5"] = color
- id, color = selectionMenu.selectionMenu("Farbe für Silo6 wählen", {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768},{"Weiß","Orange","Magenta","Hellblau","Gelb","Hellgrün","Rosa","Grau","Hellgrau","Türkis","Violett","Blau","Braun","Grün","Rot","Schwarz"})
- connectors["silo6"] = color
- id, color = selectionMenu.selectionMenu("Farbe für Silo7 wählen", {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768},{"Weiß","Orange","Magenta","Hellblau","Gelb","Hellgrün","Rosa","Grau","Hellgrau","Türkis","Violett","Blau","Braun","Grün","Rot","Schwarz"})
- connectors["silo7"] = color
- id, color = selectionMenu.selectionMenu("Farbe für Silo8 wählen", {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768},{"Weiß","Orange","Magenta","Hellblau","Gelb","Hellgrün","Rosa","Grau","Hellgrau","Türkis","Violett","Blau","Braun","Grün","Rot","Schwarz"})
- connectors["silo8"] = color
- id, color = selectionMenu.selectionMenu("Farbe für Silo9 wählen", {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768},{"Weiß","Orange","Magenta","Hellblau","Gelb","Hellgrün","Rosa","Grau","Hellgrau","Türkis","Violett","Blau","Braun","Grün","Rot","Schwarz"})
- connectors["silo9"] = color
- id, color = selectionMenu.selectionMenu("Farbe für Silo10 wählen", {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768},{"Weiß","Orange","Magenta","Hellblau","Gelb","Hellgrün","Rosa","Grau","Hellgrau","Türkis","Violett","Blau","Braun","Grün","Rot","Schwarz"})
- connectors["silo10"] = color
- id, color = selectionMenu.selectionMenu("Seite für Kabel wählen", "left", "right", "top", "bottom", "front", "back")
- connectors["kabel"] = color
- id, color = selectionMenu.selectionMenu("Seite für Kiste wählen", "left", "right", "top", "bottom", "front", "back")
- connectors["kiste"] = color
- id, color = selectionMenu.selectionMenu("Seite für Modem wählen", "left", "right", "top", "bottom", "front", "back")
- connectors["modem"] = color
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(connectors["silo1"])
- print("Silo 1")
- term.setTextColor(connectors["silo2"])
- print("Silo 2")
- term.setTextColor(connectors["silo3"])
- print("Silo 3")
- term.setTextColor(connectors["silo4"])
- print("Silo 4")
- term.setTextColor(connectors["silo5"])
- print("Silo 5")
- term.setTextColor(connectors["silo6"])
- print("Silo 6")
- term.setTextColor(connectors["silo7"])
- print("Silo 7")
- term.setTextColor(connectors["silo8"])
- print("Silo 8")
- term.setTextColor(connectors["silo9"])
- print("Silo 9")
- term.setTextColor(connectors["silo10"])
- print("Silo 10")
- term.setTextColor(colors.white)
- print("Kabel: " .. connectors["kabel"])
- print("Kiste: " .. connectors["kiste"])
- print("Modem: " .. connectors["modem"])
- print()
- print("Auswahl OK ? (j/n)")
- okKey = io.read()
- until(okKey == "j")
- local file = fs.open("/lager/redstone/connectors","w")
- file.write(textutils.serialize(connectors))
- file.close()
- return true
- end
- function checkChest()
- print("Kiste wird überwacht")
- local kiste = peripheral.wrap(Connectors["kiste"])
- while true do
- item = kiste.getItemDetail(1)
- if item ~= nil then
- print(item["displayName"] .. " - Lager voll")
- print("Rückführung in Zug")
- rednet.send(0, item["displayName"], "lager_voll")
- redstone.setBundledOutput(Connectors["kabel"], bander)
- end
- end
- end
- function checkRednet()
- print("Rednet wird überwacht")
- while true do
- local event = {os.pullEvent("rednet_message")}
- if event[4] == "beladen" then
- print("Beladen aus " .. event[3])
- redstone.setBundledOutput(Connectors["kabel"], (bander - Connectors[event[3]]))
- rednet.receive("lager_ok", 400)
- redstone.setBundledOutput(Connectors["kabel"], 0)
- print("Beladen beendet")
- elseif event[4] == "block" then
- print("Blockiere Fließbänder")
- redstone.setBundledOutput(Connectors["kabel"], bander)
- rednet.receive("lager_ok", 400)
- redstone.setBundledOutput(Connectors["kabel"], 0)
- print("Blockieren beendet")
- elseif event[4] == "entladen_ok" then
- redstone.setBundledOutput(Connectors["kabel"], 0)
- print("Lager wieder bereit")
- end
- end
- end
- os.loadAPI("selectionMenu")
- if not fs.exists("/lager/redstone/connectors") then
- if not Settings() then
- term.clear()
- return
- end
- end
- local file = fs.open("/lager/redstone/connectors","r")
- Connectors = textutils.unserialize(file.readAll())
- file.close()
- term.clear()
- print("Lager bereit")
- rednet.open(Connectors["modem"])
- bander = Connectors["silo1"] + Connectors["silo2"] + Connectors["silo3"] + Connectors["silo4"] + Connectors["silo5"] + Connectors["silo6"] + Connectors["silo7"] + Connectors["silo8"] + Connectors["silo9"] + Connectors["silo10"]
- parallel.waitForAny(checkChest, checkRednet)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement