Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local haltestellen = {}
- haltestellen["hbf_u_gruen_1"] = "HBF 1"
- haltestellen["hbf_u_gruen_2"] = "HBF 2"
- haltestellen["ubahn_arena_1"] = "Fraser Ave 1"
- haltestellen["ubahn_arena_2"] = "Fraser Ave 2"
- haltestellen["ubahn_larsen_ave_1"] = "Larsen Ave 1"
- haltestellen["ubahn_larsen_ave_2"] = "Larsen Ave 2"
- haltestellen["u_bibliothek_1"] = "Harbour St 1"
- haltestellen["u_bibliothek_2"] = "Harbour St 2"
- haltestellen["uni_u_gruen_1"] = "Uni 1"
- haltestellen["uni_u_gruen_2"] = "Uni 2"
- if not fs.exists("./icons/TRIS.icon") then
- local handle = fs.open("./icons/TRIS.icon","w")
- handle.writeLine(" 70 7b 70 70 80")
- handle.writeLine(" 7bs70v70b70 7b")
- handle.writeLine(" 70 80 70 7b 70")
- handle.close()
- end
- local xsize, ysize = term.getSize()
- function drawTopBar()
- paintutils.drawFilledBox(1,1,xsize,2,colors.lightBlue)
- term.setCursorPos(3,2)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.lightBlue)
- term.write("Transportinfo")
- end
- function drawCardsPage()
- drawTopBar()
- paintutils.drawFilledBox(1,3,xsize,ysize,colors.white)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.lightGray)
- paintutils.drawLine(1,3,xsize,3, colors.white)
- local newsicon = " 0e 0e 0e 0e 0e 0e 0e\n 0e 0e 0e 0e 0e 00 0e\n 0e 0e 0e 00 0e 00 0e\n 0e 00 0e 00 0e 00 0e\n 0e 0e 0e 0e 0e 0e 0e"
- png.drawImageString(4,7,newsicon)
- local stationicon = " 0d 0d 0d 0d 0d 0d 0d\n 0d 0b 0d 0d 0d 0d 0d\n 0d 00 0d 0e 0e 0e 0d\n 0d 00 0d 00 0d 00 0d\n 0d 0d 0d 0d 0d 0d 0d"
- png.drawImageString(17,7,stationicon)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.setCursorPos(2,13)
- term.write("Nachrichten Station")
- term.setCursorPos(xsize/2-1,ysize)
- term.setTextColor(colors.lightGray)
- term.setBackgroundColor(colors.white)
- term.write("()")
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- if x == xsize-1 and y == 2 then
- drawAddCardPage()
- return
- elseif (x == xsize/2-1 or x == xsize/2) and y == ysize then
- return
- elseif x >= 4 and x <= 11 and y >= 7 and y <= 12 then
- drawNewsPage()
- return
- elseif x >= 17 and x <= 21 and y >= 7 and y <= 12 then
- drawStationPage()
- return
- end
- end
- end
- function drawNewsPage()
- drawTopBar()
- paintutils.drawFilledBox(1,3,xsize,ysize,colors.white)
- term.setCursorPos(1,2)
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.white)
- term.write("<")
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.lightGray)
- paintutils.drawLine(1,3,xsize,3, colors.lightGray)
- term.setCursorPos(3,3)
- term.write("Nachrichten aendern")
- term.setCursorPos(2,6)
- term.setTextColor(colors.blue)
- term.setBackgroundColor(colors.white)
- term.write("Text:")
- paintutils.drawLine(2,8,25,8,colors.gray)
- term.setCursorPos(math.ceil(xsize/2)-3,10)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.write("Senden")
- term.setCursorPos(xsize/2-1,ysize)
- term.setTextColor(colors.lightGray)
- term.setBackgroundColor(colors.white)
- term.write("()")
- local text = ""
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- if x == 1 and y == 2 then
- drawCardsPage()
- return
- elseif (x == xsize/2-1 or x == xsize/2) and y == ysize then
- return
- elseif x >= 2 and x <= 25 and y == 8 then
- term.setCursorPos(2,8)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.lightGray)
- text = read()
- elseif x >= math.ceil(xsize/2)-3 and x <= math.ceil(xsize/2)+3 and y == 10 then
- local tablex = {}
- tablex["Protocol"] = "ctOS"
- network.send("center.transport.ctOS","News.send",text,nil,tablex)
- drawCardsPage()
- return
- end
- end
- end
- function drawStationPage()
- local stations = {}
- local i = 0
- for k,v in pairs(haltestellen) do
- stations[i] = k
- i=i+1
- end
- drawTopBar()
- paintutils.drawFilledBox(1,3,xsize,ysize,colors.white)
- term.setCursorPos(1,2)
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.white)
- term.write("<")
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.lightGray)
- paintutils.drawLine(1,3,xsize,3, colors.lightGray)
- term.setCursorPos(3,3)
- term.write("Fahrt eintragen")
- paintutils.drawLine(2,5,25,5,colors.gray)
- term.setCursorPos(2,5)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.lightGray)
- term.write("Haltestelle waehlen v")
- term.setCursorPos(2,7)
- term.setTextColor(colors.blue)
- term.setBackgroundColor(colors.white)
- term.write("Uhrzeit:")
- paintutils.drawLine(15,7,19,7,colors.gray)
- term.setCursorPos(2,9)
- term.setTextColor(colors.blue)
- term.setBackgroundColor(colors.white)
- term.write("Minuten:")
- paintutils.drawLine(15,9,17,9,colors.gray)
- term.setCursorPos(2,11)
- term.setTextColor(colors.blue)
- term.setBackgroundColor(colors.white)
- term.write("Text:")
- paintutils.drawLine(2,13,25,13,colors.gray)
- term.setCursorPos(math.ceil(xsize/2)-3,15)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.write("Senden")
- term.setCursorPos(xsize/2-1,ysize)
- term.setTextColor(colors.lightGray)
- term.setBackgroundColor(colors.white)
- term.write("()")
- local text = ""
- local uhrzeit = nil
- local delay = nil
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- if x == 1 and y == 2 then
- drawCardsPage()
- return
- elseif (x == xsize/2-1 or x == xsize/2) and y == ysize then
- return
- elseif x >= 2 and x <= 25 and y == 13 then
- term.setCursorPos(2,13)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.lightGray)
- text = read()
- elseif x >= 15 and x <= 19 and y == 7 then
- term.setCursorPos(15,7)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.lightGray)
- uhrzeit = read()
- elseif x >= 15 and x <= 17 and y == 9 then
- term.setCursorPos(15,9)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.lightGray)
- delay = read()
- elseif x >= 2 and x <= 25 and y == 5 then
- paintutils.drawLine(2,5,25,5,colors.blue)
- term.setCursorPos(2,5)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.write(haltestellen[stations[0]])
- i = 0
- while true do
- local e, k, isHeld = os.pullEvent("key")
- if k == 28 then
- paintutils.drawLine(2,5,25,5,colors.gray)
- term.setCursorPos(2,5)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.lightGray)
- term.write(haltestellen[stations[i]])
- break
- end
- if k == 200 then
- i = i - 1
- elseif k == 208 then
- i = i + 1
- end
- if i < 0 then
- i = 0
- elseif i > table.getn(stations) then
- i = table.getn(stations)
- end
- paintutils.drawLine(2,5,25,5,colors.blue)
- term.setCursorPos(2,5)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.write(haltestellen[stations[i]])
- end
- elseif x >= math.ceil(xsize/2)-3 and x <= math.ceil(xsize/2)+3 and y == 15 then
- local tablex = {}
- tablex["Protocol"] = "ctOS"
- local data = {}
- data[1] = stations[i]
- data[2] = text
- if not uhrzeit == nil then
- request = "Arrivals.ByTime.send"
- data[3] = uhrzeit
- else
- request = "Arrivals.ByDelay.send"
- data[3] = tonumber(delay)
- end
- network.send("center.transport.ctOS",request,data,nil,tablex)
- drawCardsPage()
- return
- end
- end
- end
- function drawAddCardPage()
- drawTopBar()
- paintutils.drawFilledBox(1,3,xsize,ysize,colors.white)
- term.setCursorPos(1,2)
- term.setBackgroundColor(colors.lime)
- term.setTextColor(colors.white)
- term.write("<")
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.lightGray)
- paintutils.drawLine(1,3,xsize,3, colors.lightGray)
- term.setCursorPos(3,3)
- term.write("Konto hinzufuegen")
- term.setCursorPos(2,6)
- term.setTextColor(colors.blue)
- term.setBackgroundColor(colors.white)
- term.write("Kontonummer:")
- paintutils.drawLine(15,6,22,6,colors.gray)
- term.setCursorPos(2,8)
- term.setTextColor(colors.blue)
- term.setBackgroundColor(colors.white)
- term.write("PIN:")
- paintutils.drawLine(15,8,18,8,colors.gray)
- term.setCursorPos(math.ceil(xsize/2)-5,10)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.white)
- term.write("Hinzufuegen")
- term.setCursorPos(xsize/2-1,ysize)
- term.setTextColor(colors.lightGray)
- term.setBackgroundColor(colors.white)
- term.write("()")
- local pin = nil
- local knummer = nil
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- if x == 1 and y == 2 then
- drawCardsPage()
- return
- elseif (x == xsize/2-1 or x == xsize/2) and y == ysize then
- return
- elseif x >= 15 and x <= 22 and y == 6 then
- term.setCursorPos(15,6)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.lightGray)
- knummer = read()
- if pin and knummer then
- term.setCursorPos(math.ceil(xsize/2)-5,10)
- term.setBackgroundColor(colors.lime)
- term.setTextColor(colors.white)
- term.write("Hinzufuegen")
- end
- elseif x >= 15 and x <= 18 and y == 8 then
- term.setCursorPos(15,8)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.lightGray)
- pin = read("o")
- if pin and knummer then
- term.setCursorPos(math.ceil(xsize/2)-5,10)
- term.setBackgroundColor(colors.lime)
- term.setTextColor(colors.white)
- term.write("Hinzufuegen")
- end
- elseif x >= math.ceil(xsize/2)-5 and x <= math.ceil(xsize/2)+5 and y == 10 then
- if pin and knummer then
- term.setCursorPos(9,10)
- term.setBackgroundColor(colors.white)
- term.clearLine()
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.write("Pruefen...")
- local tablex = {}
- tablex["ResponseID"] = rid
- tablex["Protocol"] = "ctOS"
- local rid = network.send("server.bankomat.ctOS","User.getData",knummer,nil,tablex)
- while true do
- local event, mSide, channel, rchannel, message = network.receive(10)
- if event == "modem_message" and message["Request"] == "User.getData.Response" and message["Sender"] == "server.bankomat.ctOS" and message["nMessageID"] == rid then
- if type(message["Data"]) ~= "nil" then
- if pin == tostring(message["Data"]["PIN"]) then
- local tablex = {}
- tablex["name"] = knummer
- tablex["pin"] = tostring(message["Data"]["PIN"])
- table.insert(cards, tablex)
- local h = fs.open("storage/bankomat/."..knummer..".bankomat", "w")
- h.write(pin)
- h.close()
- term.setCursorPos(8,10)
- term.setBackgroundColor(colors.white)
- term.clearLine()
- term.setBackgroundColor(colors.lime)
- term.setTextColor(colors.white)
- term.write("Hinzugefuegt")
- sleep(5)
- drawAddCardPage()
- break
- else
- term.setCursorPos(9,10)
- term.setBackgroundColor(colors.white)
- term.clearLine()
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- term.write("Inkorrekt")
- sleep(5)
- drawAddCardPage()
- break
- end
- else
- term.setCursorPos(9,10)
- term.setBackgroundColor(colors.white)
- term.clearLine()
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- term.write("Inkorrekt")
- sleep(5)
- drawAddCardPage()
- break
- end
- elseif event == "timer" then
- term.setCursorPos(7,10)
- term.setBackgroundColor(colors.white)
- term.clearLine()
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- term.write("Netzwerkfehler")
- sleep(5)
- drawAddCardPage()
- break
- end
- end
- end
- end
- end
- end
- term.setBackgroundColor(colors.white)
- term.clear()
- drawCardsPage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement