Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- sleep(0.5)
- rs.setOutput("back",false)
- bg = colors.white
- txt = colors.blue
- rcol = colors.green
- gx, gy = term.getSize()
- pipe = peripheral.wrap("right")
- iron = pipe.getItemIdentifierIDFor(265,0)
- currentTime = 0
- if fs.exists("config") == false then
- fs.makeDir("config")
- end
- if fs.exists("user") == false then
- fs.makeDir("user")
- end
- if fs.exists("config/time") == false then
- tFile = fs.open("config/time","w")
- tFile.writeLine(0)
- tFile.close()
- end
- gItem = "Iron Ingots"
- sFile = fs.open("config/activeUser","w")
- sFile.writeLine("None")
- sFile.close()
- shell.run("clear")
- os.loadAPI("ocs/apis/sensor")
- sen = sensor.wrap("bottom")
- startTime = 0
- function u1()
- welcomeText = "Willkommen bei der Eisernen 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}
- uBtn = {15,5," USER ",colors.white,colors.orange}
- cbut(lBtn[1],lBtn[2],lBtn[3],lBtn[4],lBtn[5])
- cbut(rBtn[1],rBtn[2],rBtn[3],rBtn[4],rBtn[5])
- cbut(uBtn[1],uBtn[2],uBtn[3],uBtn[4],uBtn[5])
- end
- function pout()
- shell.run("clear")
- setStart()
- cbut(2,3,"Derzeitiges Eisen: " .. math.floor(curMoney))
- cbut(2,4,"Wie viel Eisen abheben?")
- term.setCursorPos(15,5)
- term.setTextColor(rcol)
- gIron = io.read()
- gIron = tonumber(gIron)
- term.setTextColor(txt)
- curMoney = tonumber(curMoney)
- gIron = tonumber(gIron)
- if gIron > curMoney then
- cbut(2,gy-1,"Nicht genug Eisen auf der Bank",colors.white,colors.red)
- sleep(2)
- loggedIn()
- elseif gIron == 0 then
- loggedIn()
- elseif gIron <= curMoney then
- pipe.makeRequest(iron,gIron)
- cbut(2,gy-1,gIron .. " Eisen ausgezahlt",colors.white,colors.red)
- sleep(1)
- curMoney = curMoney - gIron
- sFile = fs.open("user/" .. rName,"w")
- sFile.writeLine(rName)
- sFile.writeLine(rpw)
- sFile.writeLine(curMoney)
- sFile.writeLine(playerTime)
- sFile.writeLine(collectTime)
- sFile.close()
- loggedIn()
- end
- end
- function pin()
- shell.run("clear")
- setStart()
- cbut(2,3,"Derzeitiges Eisen: " .. math.floor(i) .. " ")
- cbut(2,4,"Jetzt Eisenbarren links in den")
- cbut(15+33,4,"OK",colors.green,colors.black)
- cbut(2,5,"Collector einwerfen")
- cbut(2,6,"Dann R drücken, warten bis alles Eisen")
- cbut(2,7,"geladen wurde")
- cbut(2,8,"Dann erst auf OK klicken")
- cbut(2,10,"[R]-Taste zum Aktuallisieren drücken!!!",colors.white,colors.red)
- cbut(15+26,8,"ABBRECHEN",colors.red,colors.black)
- evt, btn,x,y = os.pullEventRaw()
- if evt == "mouse_click" and btn == 1 then
- if x > 15+32 and x < gx - 1 and y == 4 then
- cbut(2,gy-1,"Zahlt ein....",colors.white,colors.green)
- curMoney = curMoney + math.floor(i)
- sFile = fs.open("user/" .. rName,"w")
- sFile.writeLine(rName)
- sFile.writeLine(rpw)
- sFile.writeLine(curMoney)
- sFile.writeLine(playerTime)
- sFile.writeLine(collectTime)
- sFile.close()
- cbut(2,3,"Derzeitiges Eisen: " .. math.floor(i) .. " ")
- sleep(0.5)
- rs.setOutput("back",false)
- loggedIn()
- elseif x > 15+25 and x < gx-2 and y == 8 then
- cbut(2,gy-1,"Abbgebrochen",colors.white,colors.red)
- sleep(0.5)
- rs.setOutput("back",false)
- pipe.makeRequest(iron,i)
- loggedIn()
- end
- elseif evt == "char" then
- if btn == "R" or btn == "r" then
- rs.setOutput("back",true)
- sleep(0.5)
- cbut(2,3,"Derzeitiges Eisen: " .. math.floor(i) .. " ")
- term.setCursorPos(2,gy-1)
- s1 = sen.getTargetDetails(targPos)
- for v, k in pairs(s1.Items) do
- if k.Name == "Iron Ingot" then
- i = k.Size - i2
- end
- end
- end
- cbut(2,3,"Derzeitig eingezahltes Eisen: " .. math.floor(i) .. " ")
- cbut(2,gy-1,"Aktuallisiere ME",colors.white, colors.orange)
- sleep(0.5)
- pin()
- 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("user/" .. rName,"w")
- sFile.writeLine(rName)
- sFile.writeLine(newPw)
- sFile.writeLine(curMoney)
- sFile.writeLine(playerTime)
- sFile.writeLine(collectTime)
- sFile.close()
- rpw = newPw
- loggedIn()
- end
- end
- zinsen = 0
- function zins()
- term.clear()
- setStart()
- cbut(2,2,"Zinskurs:")
- cbut(2,3,"Anzahl = je 1200 Sekunden")
- cbut(2,4,"1-100 = +5 Eisenbarren")
- cbut(2,5,"101-1000 = +10 Eisenbarren")
- cbut(2,6,"1001-5000 = +20 Eisenbarren")
- cbut(2,7,"5001-10000 = +40 Eisenbarren")
- cbut(2,8,"<10001 = +80 Eisenbarren")
- cbut(2,10,"E drücken um ins Hauptmenue zu gelangen")
- evt , key = os.pullEvent("char")
- if key == "E" or key == "e" then
- term.clearLine(gy-1)
- cbut(2,gy-1,"Zum Hauptmenue")
- sleep(0.5)
- loggedIn()
- else
- zins()
- end
- end
- function loggedIn()
- shell.run("clear")
- currentTime = getTime()
- sFile = fs.open("user/" .. rName,"w")
- collectTime = currentTime - playerTime
- if collectTime > 1200 then
- if curMoney > 1 and curMoney < 101 then
- curMoney = curMoney + 5
- elseif curMoney > 100 and curMoney < 1001 then
- curMoney = curMoney + 10
- elseif curMoney > 1000 and curMoney < 5001 then
- curMoney = curMoney + 20
- elseif curMoney > 5000 and curMoney < 10001 then
- curMoney = curMoney + 40
- elseif curMoney > 10000 then
- curMoney = curMoney + 80
- end
- collectTime = collectTime - 1200
- playerTime = playerTime + 1200
- end
- sFile.writeLine(rName)
- sFile.writeLine(rpw)
- sFile.writeLine(curMoney)
- sFile.writeLine(playerTime)
- sFile.writeLine(collectTime)
- sFile.close()
- cbut(2,2,"TIME: " .. currentTime)
- 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,9,"Zinsen Aufteilung",colors.white,colors.blue)
- cbut(15,10,"Zeit: " .. collectTime .. "/1200",colors.white,colors.blue)
- cbut(15,gy-3,"Ausloggen",colors.white,colors.red)
- evt, btn , x1, y1 = os.pullEventRaw()
- term.setCursorPos(2,gy-2)
- 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.5)
- rs.setOutput("back",true)
- i = 0
- s = sen.getTargets()
- for v, k in pairs(s) do
- if k.Name == "ME Wireless Access Point" then
- targPos = k.Position.X .. "," .. k.Position.Y .. "," .. k.Position.Z
- end
- end
- targPos = tostring(targPos)
- s = sen.getTargetDetails(targPos)
- for v, k in pairs(s.Items) do
- if k.Name == "Iron Ingot" then
- i2 = k.Size
- end
- end
- pin()
- elseif x1 >14 and x1 < (14 + string.len("Zinsen Aufteilung")) and y1 == 9 then
- term.clearLine(gy-1)
- cbut(2,gy-1,"Lade Bankdaten")
- sleep(0.5)
- zins()
- elseif x1 > 14 and x1 < (14 + string.len("Auszahlen")) and y1 == 7 then
- term.clearLine(gy-1)
- cbut(2,gy-1,"Auszahlen")
- sleep(0.5)
- 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.5)
- chgPw()
- setStart()
- start()
- elseif x1 > 14 and x1 < (14 + string.len("Ausloggen")) and y1 == gy-3 then
- sFile = fs.open("config/activeUser","w")
- sFile.writeLine("None")
- sFile.close()
- currentUser = "None"
- cbut(2,gy-2,"Ausgeloggt...")
- sleep(0.5)
- setStart()
- start()
- end
- end
- loggedIn()
- end
- function userLoad()
- cbut(2,gy-1,"Files werden geladen")
- rFile = fs.open("user/" .. rName,"r")
- user = rFile.readLine()
- rpw = rFile.readLine()
- curMoney = rFile.readLine()
- playerTime = rFile.readLine()
- collectTime = rFile.readLine()
- currentUser = rName
- curMoney = tonumber(curMoney)
- 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 getPw == rpw or getPw == "configH0st" then
- sFile = fs.open("config/activeUser","w")
- sFile.writeLine(rName)
- sFile.close()
- setStart()
- loggedIn()
- else
- shell.run("clear")
- cbut(2,gy-1,"Password ist falsch",colors.white,colors.red)
- sleep(2)
- setStart()
- start()
- end
- end
- function gUsers()
- term.clear()
- cbut(2,gy-1,"Belibige Taste drücken um ins Hauptmenue zu gelangen")
- ulist = fs.list("user")
- x = 2
- y = 3
- for k = 1 , table.maxn(ulist), 1 do
- cbut(x,y,ulist[k])
- if y >= gy - 2 then
- x = x + 20
- y = 3
- else
- y = y + 1
- end
- end
- evt, key = os.pullEvent("char")
- shell.run("1")
- 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()
- if rName == "" or rName == nil then
- cbut(2,gy-1,"Kann nicht erstellt werden",colors.white,colors.red)
- sleep(2)
- start()
- end
- term.setTextColor(txt)
- if fs.exists("user/" .. 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
- collectTime = 0
- function regStart()
- cbut(15,3,"Namen waehlen:")
- term.setCursorPos(15,4)
- term.setTextColor(rcol)
- rName = io.read()
- if rName == "" or rName == nil then
- cbut(2,gy-1,"Kann nicht erstellt werden",colors.white,colors.red)
- sFile = fs.open("config/activeUser","w")
- sFile.writeLine("None")
- sFile.close()
- currentUser = "None"
- sleep(2)
- start()
- end
- term.setTextColor(txt)
- if fs.exists("user/" .. 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")
- sFile = fs.open("config/activeUser","w")
- sFile.writeLine("None")
- sFile.close()
- currentUser = "None"
- setStart()
- start()
- else
- shell.run("clear")
- cbut(15,3,"Bitte waehle ein Password")
- term.setCursorPos(15,4)
- term.setTextColor(rcol)
- sPw = read("*")
- term.setTextColor(txt)
- shell.run("clear")
- cbut(2,gy-1,"User wird erstellt")
- cbut(15,3,"Zurueck zum Startbildschirm")
- getClock = getTime()
- cFile = fs.open("user/" .. rName ,"w")
- cFile.writeLine(rName)
- cFile.writeLine(sPw)
- cFile.writeLine(0)
- cFile.writeLine(getTime())
- cFile.writeLine(0)
- cFile.close()
- sleep(2)
- sFile = fs.open("config/activeUser","w")
- sFile.writeLine("None")
- sFile.close()
- currentUser = "None"
- shell.run("clear")
- setStart()
- start()
- end
- sFile = fs.open("config/activeUser","w")
- sFile.writeLine("None")
- sFile.close()
- currentUser = "None"
- regStart()
- end
- function start()
- term.setCursorPos(1,2)
- evt,btn, x,y = os.pullEventRaw("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()
- elseif x > (uBtn[1] - 1) and x < (uBtn[1] + string.len(uBtn[3])) and y == uBtn[2] then
- shell.run("clear")
- u1()
- gUsers()
- end
- else
- end
- start()
- end
- currentTime = 0
- function getTime()
- id, msg = rednet.receive()
- if msg == nil then
- currentTime = 0
- else
- if string.find(msg,"Timer") > 0 then
- timeStamp = textutils.unserialize(msg)
- cT = timeStamp.MSG
- return cT
- end
- end
- end
- while true do
- setStart()
- info = xpcall(start,20)
- --start()
- --rednet.broadcast(info)
- end
Add Comment
Please, Sign In to add comment