Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Config-Cunfigurator
- --valid types are: boolean (true|false), int (0-9), String (*), Side (right, left, top, bottom, front, back)
- local x,y = term.getSize()
- local vars = {}
- -- Variablenname Variablentyp angezeigte Nachricht
- vars[1] = {"monSide" , "Side" , "Bitte Monitorseite auswählen"}
- vars[2] = {"rSide" , "Side" , "Bitte Redstoneseite auswählen"}
- vars[3] = {"frequency" , "Side" , "Bitte Frequenzseite auswählen"}
- vars[4] = {"number" , "int" , "Bitte eine Zahl eingeben"}
- vars[5] = {"boolean" , "boolean" , "Bitte einen Wahrheitswert eingeben"}
- vars[6] = {"string" , "String" , "Bitte eine Zeichenkette eingeben"}
- function select(varName, varType, varMsg)
- for i=1,y do
- term.setBackgroundColor(colors.blue)
- term.setCursorPos(1,i)
- for j=1,x do
- term.write(" ")
- end
- end
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.white)
- term.setCursorPos(5,3)
- term.write(varMsg)
- term.setCursorPos(5,5)
- term.write(varName)
- term.setCursorPos(15,5)
- term.write(varType)
- if varType == "int" or varType == "String" then
- while true do
- term.setCursorPos(5,8)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- for i=1,20 do term.write(" ") end
- term.setCursorPos(5,8)
- input = read()
- if varType == "String" then break end
- if tonumber(input)~=nil then
- input = tonumber(input)
- break
- end
- term.setCursorPos(5,8)
- term.setTextColor(colors.red)
- term.write("Bitte nur Zahlen eingeben.")
- sleep(2)
- end
- else
- if varType == "Side" then auswahl = {"right", "left", "top", "bottom", "front", "back"} else auswahl = {"true", "false"} end
- actual = 1
- max = #auswahl
- while true do
- for i=0,(max*2) do
- term.setCursorPos(5,6+i)
- term.setBackgroundColor(colors.lightGray)
- term.write(" ")
- end
- for i=1, max do
- term.setCursorPos(7,5+(i*2))
- if actual == i then term.setBackgroundColor(colors.blue) else term.setBackgroundColor(colors.gray) end
- term.write(" ")
- term.setCursorPos(6 + (6-(#auswahl[i])/2),5+(i*2))
- term.setTextColor(colors.white)
- term.write(auswahl[i])
- end
- event, k = os.pullEvent()
- if k== 28 then
- input = auswahl[actual]
- break
- elseif k == 200 then
- if actual == 1 then actual = max else actual = actual-1 end
- elseif k == 208 then
- if actual == max then actual = 1 else actual = actual+1 end
- else
- term.setCursorPos(2,7)
- term.setTextColor(colors.red)
- term.setBackgroundColor(colors.blue)
- term.write("Bitte Pfeiltasten nutzen und mit <ENTER> bestaetigen.")
- sleep(2)
- end
- end
- end
- return input
- end
- for i=1, #vars do
- if vars[i][2] == "String" or vars[i][2] == "Side" then
- vars[i][4] = "\""..select(vars[i][1], vars[i][2], vars[i][3]).."\""
- else
- vars[i][4] = select(vars[i][1], vars[i][2], vars[i][3])
- end
- end
- file = fs.open("config", "w")
- for i=1, #vars do
- file.writeLine(vars[i][1].." = "..vars[i][4])
- end
- file.close()
Add Comment
Please, Sign In to add comment