Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bg = colors.white
- txt = colors.blue
- rcol = colors.green
- gx, gy = term.getSize()
- gItem = "Iron Ingots"
- sFile = fs.open("Config_ActiveUser","w")
- sFile.writeLine("None")
- sFile.close()
- os.loadAPI("ocs/apis/sensor")
- sen = sensor.wrap("bottom")
- function u1()
- welcomeText = "Willkommen bei der " .. gItem .. "-Bank"
- term.setCursorPos((gx/2)-(string.len(welcomeText) / 2),1)
- term.write(welcomeText)
- end
- function setStart()
- term.setBackgroundColor(bg)
- term.setTextColor(txt)
- shell.run("clear")
- u1()
- setGUI()
- term.setCursorPos(2,gy - 1)
- end
- function cbut(cx,cy,text,bcol,tcol)
- u1()
- if bcol == nil then
- bcol = colors.white
- end
- if tcol == nil then
- tcol = colors.blue
- end
- term.setCursorPos(cx,cy)
- term.setBackgroundColor(bcol)
- term.setTextColor(tcol)
- term.write(text)
- term.setBackgroundColor(bg)
- term.setTextColor(txt)
- end
- function setGUI()
- lBtn = {15,3," LOGIN ",colors.white,colors.green}
- rBtn = {15,4," REGISTRIEREN ",colors.white,colors.red}
- cbut(lBtn[1],lBtn[2],lBtn[3],lBtn[4],lBtn[5])
- cbut(rBtn[1],rBtn[2],rBtn[3],rBtn[4],rBtn[5])
- end
- function pout()
- shell.run("clear")
- setStart()
- shell.run("clear")
- setStart()
- cbut(15,3,"Derzeitiges Eisen: " .. math.floor(curMoney))
- cbut(15,4,"Wie viel Eisen abheben?")
- term.setCursorPos(15,5)
- term.setTextColor(rcol)
- gIron = io.read()
- gIron = tonumber(gIron)
- term.setTextColor(txt)
- curMoney = tonumber(curMoney)
- if gIron > curMoney then
- cbut(2,gy-1,"Nicht genug Eisen auf der Bank",colors.white,colors.red)
- sleep(2)
- loggedIn()
- elseif gIron <= curMoney then
- for v = 1, gIron , 1 do
- curMoney = curMoney - 1
- cbut(15,3,"Derzeitiges Eisen: " .. curMoney)
- rs.setBundledOutput("back",colors.blue)
- sleep(0.3)
- rs.setBundledOutput("back",0)
- sleep(0.3)
- end
- sFile = fs.open(rName,"w")
- sFile.writeLine(rName)
- sFile.writeLine(rpw)
- sFile.writeLine(curMoney)
- sFile.close()
- end
- end
- function pin()
- shell.run("clear")
- setStart()
- cbut(15,3,"Derzeitiges Eisen: " .. math.floor(i))
- cbut(15,4,"Jetzt Eisenbarren einwerfen dann")
- cbut(15+33,4,"OK",colors.green,colors.black)
- cbut(15,5,"[R] zum Aktuallisieren!",colors.white,colors.red)
- cbut(15+26,8,"ABBRECHEN",colors.red,colors.black)
- evt, btn,x,y = os.pullEvent()
- if evt == "mouse_click" and btn == 1 then
- if x > 15+32 and x < gx - 2 and y == 4 then
- cbut(2,gy-1,"Eingezahlt",colors.white,colors.green)
- curMoney = curMoney + math.floor(i)
- sFile = fs.open(rName,"w")
- sFile.writeLine(rName)
- sFile.writeLine(rpw)
- sFile.writeLine(curMoney)
- sFile.close()
- cbut(15,3,"Derzeitiges Eisen: " .. math.floor(i))
- rs.setBundledOutput("back",colors.green)
- sleep(2)
- rs.setBundledOutput("back",0)
- sleep(2)
- loggedIn()
- elseif x > 15+25 and x < gx-2 and y == 8 then
- cbut(2,gy-1,"Abbgebrochen",colors.white,colors.red)
- for v = 1, i , 1 do
- cbut(15,3,"Derzeitiges Eisen: " .. math.floor(i))
- rs.setBundledOutput("back",colors.red)
- sleep(0.3)
- rs.setBundledOutput("back",0)
- sleep(0.3)
- end
- loggedIn()
- end
- elseif evt == "char" then
- if btn == "R" or btn == "r" then
- term.clearLine(3)
- cbut(15,3,"Derzeitiges Eisen: " .. math.floor(i))
- s = sen.getTargets()
- for v, k in pairs(s) do
- if k.Name == "Gold Chest" then
- targPos = k.Position.X .. "," .. k.Position.Y .. "," .. k.Position.Z
- end
- end
- term.setCursorPos(2,gy-1)
- targPos = tostring(targPos)
- s1 = sen.getTargetDetails(targPos)
- i = 0
- for v, k in pairs(s1.Slots) do
- if k.Name == "Iron Ingot" then
- i = i + k.Size
- end
- end
- print(i)
- cbut(2,gy-1,"Aktuallisiere Kiste",colors.white, colors.orange)
- sleep(0.2)
- pin()
- end
- end
- pin()
- end
- function chgPw()
- shell.run("clear")
- setStart()
- cbut(15,3,"Altes Password eintragen :")
- cbut(15,4,"Neues Password eintragen :")
- term.setCursorPos(15+27,3)
- oldPw = read("*")
- if oldPw ~= rpw then
- cbut(2,gy-1,"Falsches Password",colors.white,colors.red)
- sleep(2)
- loggedIn()
- else
- term.setCursorPos(15+27,4)
- newPw = read("*")
- sFile = fs.open(rName,"w")
- sFile.writeLine(rName)
- sFile.writeLine(newPw)
- sFile.writeLine(curMoney)
- sFile.close()
- rpw = newPw
- end
- end
- function loggedIn()
- shell.run("clear")
- cbut(2,gy-1,"Erfolgreich")
- cbut(15,3,"Willkommen " .. rName)
- cbut(15,4,"Derzeitiges Eisen: " .. math.floor(curMoney))
- cbut(15,6,"Einzahlen",colors.white,colors.green)
- cbut(15,7,"Auszahlen",colors.white,colors.blue)
- cbut(15,8,"Password aendern",colors.white,colors.orange)
- cbut(15,gy-2,"Ausloggen",colors.white,colors.red)
- evt, btn, x1,y1 = os.pullEvent()
- term.setCursorPos(2,gy-1)
- if evt == "mouse_click" and btn == 1 then
- if x1 > 14 and x1 < (14 + string.len("Einzahlen")) and y1 == 6 then
- term.clearLine(gy-1)
- cbut(2,gy-1,"Einzahlen")
- sleep(0.2)
- i = 0
- pin()
- elseif x1 > 14 and x1 < (14 + string.len("Auszahlen")) and y1 == 7 then
- term.clearLine(gy-1)
- cbut(2,gy-1,"Auszahlen")
- sleep(0.2)
- pout()
- elseif x1 > 14 and x1 < (14 + string.len("Password aendern")) and y1 == 8 then
- term.clearLine(gy-1)
- cbut(2,gy-1,"Password aendern")
- sleep(0.2)
- chgPw()
- setStart()
- start()
- elseif x1 > 14 and x1 < (14 + string.len("Ausloggen")) and y1 == gy-2 then
- sFile = fs.open("Config_ActiveUser","w")
- sFile.writeLine("None")
- sFile.close()
- cbut(2,gy-2,"Ausgeloggt...")
- sleep(0.2)
- setStart()
- start()
- end
- end
- sleep(0.2)
- loggedIn()
- end
- function userLoad()
- cbut(2,gy-1,"Files werden geladen")
- rFile = fs.open(rName,"r")
- user = rFile.readLine()
- rpw = rFile.readLine()
- curMoney = rFile.readLine()
- rFile.close()
- shell.run("clear")
- cbut(15,3,rName .. " gebe dein Password ein")
- term.setCursorPos(15,4)
- term.setTextColor(rcol)
- getPw = read("*")
- term.setTextColor(txt)
- if rpw == getPw then
- sFile = fs.open("Config_ActiveUser","w")
- sFile.writeLine(rName)
- sFile.close()
- loggedIn()
- else
- shell.run("clear")
- cbut(2,gy-1,"Password ist falsch",colors.white,colors.red)
- sleep(2)
- setStart()
- end
- end
- function loginStart()
- gFileA = fs.open("Config_ActiveUser","r")
- activeUser = gFileA.readLine()
- gFileA.close()
- if activeUser ~= "None" then
- loggedIn()
- else
- cbut(15,3,"Loginnamen eingeben:")
- term.setCursorPos(15,4)
- term.setTextColor(rcol)
- rName = io.read()
- term.setTextColor(txt)
- if fs.exists( rName) == true then
- userLoad()
- else
- shell.run("clear")
- u1()
- cbut(2,gy-1,"User konnte nicht geladen werden",colors.white,colors.red)
- sleep(4)
- setStart()
- start()
- end
- end
- end
- function regStart()
- cbut(15,3,"Namen waehlen:")
- term.setCursorPos(15,4)
- term.setTextColor(rcol)
- rName = io.read()
- term.setTextColor(txt)
- if fs.exists(rName) == true then
- cbut(2,gy-2, "Name existiert bereits",colors.white,colors.red)
- cbut(2,gy-1,"Bitte einen anderen Namen waehlen",colors.white,colors.red)
- sleep(4)
- shell.run("clear")
- setStart()
- else
- shell.run("clear")
- cbut(15,3,"Bitte waehle ein Password")
- term.setCursorPos(15,4)
- term.setTextColor(rcol)
- sPw = io.read()
- term.setTextColor(txt)
- shell.run("clear")
- cbut(2,gy-1,"User wird erstellt")
- cbut(15,3,"Zurueck zum Startbildschirm")
- cFile = fs.open(rName ,"w")
- cFile.writeLine(rName)
- cFile.writeLine(sPw)
- cFile.writeLine(0)
- cFile.close()
- sleep(4)
- shell.run("clear")
- setStart()
- end
- end
- fRead = false
- function timeGet()
- sTime = os.time()
- cbut(gx-6, 1,textutils.formatTime(sTime,true))
- sleep(1)
- end
- function start()
- term.setCursorPos(1,2)
- evt,btn, x,y = os.pullEvent("mouse_click")
- if evt == "mouse_click" and btn == 1 then
- if x > (lBtn[1] - 1) and x < (lBtn[1] + string.len(lBtn[3])) and y == lBtn[2] then
- shell.run("clear")
- u1()
- loginStart()
- elseif x > (rBtn[1] - 1) and x < (rBtn[1] + string.len(rBtn[3])) and y == rBtn[2] then
- shell.run("clear")
- u1()
- regStart()
- else
- setStart()
- start()
- end
- end
- end
- setStart()
- while true do
- start()
- --parallel.waitForAny(timeGet(),start())
- end
Add Comment
Please, Sign In to add comment