Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = peripheral.wrap("back")
- modem.open(125)
- image0 = paintutils.loadImage("/aplikacje/Twitter/loadsc.nfp")
- image = paintutils.loadImage("/aplikacje/Twitter/lsc.nfp")
- image2 = paintutils.loadImage("/aplikacje/Twitter/lscr.nfp")
- image3 = paintutils.loadImage("/aplikacje/Twitter/mainsc.nfp")
- image4 = paintutils.loadImage("/aplikacje/Twitter/mainscw.nfp")
- message = nil
- function system()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- term.setCursorPos(1,1)
- term.clear()
- print(os.version())
- error()
- end
- function loginscreen()
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.blue)
- term.clear()
- paintutils.drawImage(image, 1, 1)
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- io.write("Twitter")
- term.setCursorPos(26,1)
- io.write("X")
- term.setCursorPos(9,7)
- io.write("Zarejestruj")
- term.setCursorPos(10,13)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.blue)
- io.write("Zaloguj")
- ekran = true
- while ekran == true do
- event, button, x, y = os.pullEvent("mouse_click")
- if (button == 1) and (x >= 6) and (x <= 21) and (y >= 5) and (y <= 8) then
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.blue)
- term.clear()
- paintutils.drawImage(image2, 1, 1)
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- io.write("<---")
- term.setCursorPos(26,1)
- io.write("X")
- term.setCursorPos(8,1)
- io.write("Rejestracja")
- term.setCursorPos(8,3)
- term.setBackgroundColor(colors.cyan)
- io.write("Login")
- term.setCursorPos(8,7)
- io.write("Haslo")
- term.setCursorPos(10,13)
- term.setBackgroundColor(colors.blue)
- io.write("Potwierdz")
- log = {}
- log2 = {}
- reg = {}
- reg2 = {}
- ekranreg = true
- while ekranreg == true do
- event, button, x, y = os.pullEvent("mouse_click")
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- if (button == 1) and (x >= 1) and (x <= 4) and (y == 1) then
- loginscreen()
- elseif (button == 1) and (x == 26) and (y == 1) then
- system()
- elseif (button == 1) and (x >= 8) and (x <= 19) and (y >= 4) and (y <= 5) then
- term.setCursorPos(8,17)
- term.setBackgroundColor(colors.cyan)
- io.write(" ")
- term.setBackgroundColor(colors.white)
- term.setCursorPos(8,5)
- io.write(" ")
- term.setCursorPos(8,5)
- reg[1] = io.read()
- elseif (button == 1) and (x >= 8) and (x <= 19) and (y >= 8) and (y <= 9) then
- term.setCursorPos(8,19)
- term.setBackgroundColor(colors.cyan)
- io.write(" ")
- term.setCursorPos(8,9)
- term.setBackgroundColor(colors.white)
- io.write(" ")
- term.setCursorPos(8,9)
- reg[2] = io.read()
- elseif (button == 1) and (x >= 9) and (x <= 18) and (y >= 12) and (y <= 13) then
- reg[3] = "R"
- reg[4] = os.computerID()
- LoginNum = #reg[1]
- HasloNum = #reg[2]
- if reg[1] == nil then
- term.setCursorPos(2,17)
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.white)
- print("Login nie moze byc pusty")
- end
- if reg[2] == nil then
- term.setCursorPos(2,17)
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.white)
- print("Haslo nie moze byc puste")
- end
- if (LoginNum > 12) then
- term.setCursorPos(8,17)
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.white)
- print("Za dlugi login")
- end
- if (HasloNum > 12) then
- term.setCursorPos(8,19)
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.white)
- print("Za dlugie haslo")
- end
- if (LoginNum <= 12) and (HasloNum <= 12) and (reg[1] ~= nil) and (reg[2] ~= nil) then
- msg = textutils.serialize(reg)
- modem.transmit(120, 9, msg)
- sleep(4)
- if message ~= nil then
- if message == "User exist" then
- loginscreen()
- else
- reg2 = textutils.unserialize(message)
- if (reg2[1] == reg[1]) and (reg2[2] == reg[2]) and (reg2[4] == reg[4])then
- settings.set("R", reg)
- print("Zarejestrowany")
- settings.save()
- sleep(1)
- premain()
- end
- end
- else
- term.setCursorPos(8,18)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.cyan)
- print("Wystapil blad")
- end
- elseif (button == 1) and (x == 26) and (y == 1) then
- system()
- end
- end
- end
- elseif (button == 1) and (x >= 6) and (x <= 21) and (y >= 11) and (y <= 14) then
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.blue)
- term.clear()
- paintutils.drawImage(image2, 1, 1)
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- io.write("<---")
- term.setCursorPos(26,1)
- io.write("X")
- term.setCursorPos(8,1)
- io.write("Logowanie")
- term.setCursorPos(8,3)
- term.setBackgroundColor(colors.cyan)
- io.write("Login")
- term.setCursorPos(8,7)
- io.write("Haslo")
- term.setCursorPos(10,13)
- term.setBackgroundColor(colors.blue)
- io.write("Potwierdz")
- log = {}
- log2 = {}
- reg = {}
- reg2 = {}
- ekranlog = true
- while ekranlog == true do
- event, button, x, y = os.pullEvent("mouse_click")
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- if (button == 1) and (x >= 1) and (x <= 4) and (y == 1) then
- loginscreen()
- elseif (button == 1) and (x == 26) and (y == 1) then
- system()
- elseif (button == 1) and (x >= 8) and (x <= 19) and (y >= 4) and (y <= 5) then
- term.setCursorPos(8,17)
- term.setBackgroundColor(colors.cyan)
- io.write(" ")
- term.setBackgroundColor(colors.white)
- term.setCursorPos(8,5)
- io.write(" ")
- term.setCursorPos(8,5)
- log[1] = io.read()
- elseif (button == 1) and (x >= 8) and (x <= 19) and (y >= 8) and (y <= 9) then
- term.setCursorPos(8,19)
- term.setBackgroundColor(colors.cyan)
- io.write(" ")
- term.setCursorPos(8,9)
- term.setBackgroundColor(colors.white)
- io.write(" ")
- term.setCursorPos(8,9)
- log[2] = io.read()
- elseif (button == 1) and (x >= 9) and (x <= 18) and (y >= 12) and (y <= 13) then
- log[3] = "Z"
- log[4] = os.computerID()
- LoginNum = #log[1]
- HasloNum = #log[2]
- if log[1] == nil then
- term.setCursorPos(2,17)
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.white)
- print("Login nie może być pusty")
- end
- if log[2] == nil then
- term.setCursorPos(2,17)
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.white)
- print("Hasło nie może być puste")
- end
- if (LoginNum > 12) then
- term.setCursorPos(8,17)
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.white)
- print("Za dlugi login")
- end
- if (HasloNum > 12) then
- term.setCursorPos(8,19)
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.white)
- print("Za dlugie haslo")
- end
- if (LoginNum <= 12) and (HasloNum <= 12) and (log[1] ~= nil) and (log[2] ~= nil) then
- msg = textutils.serialize(log)
- modem.transmit(120, 9, msg)
- sleep(4)
- if message ~= nil then
- settings.load()
- log2 = textutils.unserialize(message)
- if log2[2] == "Invalid User or password" then
- print("Logowanie nieudane")
- sleep(2)
- loginscreen()
- else
- print(message)
- if (log2[1] == log[1]) and (log2[2] == log[2]) then
- settings.set("R", log)
- print("Zalogowany")
- settings.save()
- sleep(1)
- premain()
- end
- end
- else
- term.setCursorPos(8,18)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.cyan)
- print("Wystapil blad")
- end
- end
- end
- end
- elseif (button == 1) and (x == 26) and (y == 1) then
- system()
- end
- end
- end
- function odbieraniezid()
- rlcheck = true
- i = 1
- while rlcheck == true do
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- rl = textutils.unserialize(message)
- if rl[4] == os.computerID() then
- rlcheck = false
- break
- elseif rl[4] ~= os.computerID() then
- message = nil
- sleep(0.5)
- i = i + 1
- end
- if i == 5 then
- break
- end
- end
- end
- function odbieranieref()
- odbref = true
- while odbref == true do
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- rl = textutils.unserialize(message)
- if rl[4] ~= os.computerID() then
- message = nil
- end
- end
- end
- function scroll()
- while true do
- event, scrollDirection, x, y = os.pullEvent("mouse_scroll")
- if scrollDirection == -1 then
- win2 = term.redirect(myWindow)
- term.scroll(2)
- term.redirect(win2)
- elseif scrollDirection == 1 then
- win2 = term.redirect(myWindow)
- term.scroll(-2)
- term.redirect(win2)
- end
- end
- end
- function loading()
- term.setCursorPos(1,1)
- term.clear()
- paintutils.drawImage(image0, 1, 1)
- term.setCursorPos(10,2)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.cyan)
- io.write("TWITTER")
- term.setCursorPos(6,20)
- end
- function probazalogowania()
- R = settings.get("R")
- R[3] = "Z"
- R[4] = os.computerID()
- probamsg = textutils.serialize(R)
- modem.transmit(120, 9, probamsg)
- sleep(3)
- if message ~= nil then
- if message == "Invalid User or password" then
- print("Logowanie nieudane")
- sleep(2)
- loginscreen()
- else
- probamsg2 = textutils.unserialize(message)
- if (R[1] == probamsg2[1]) and (R[2] == probamsg2[2]) then
- table.remove(probamsg2, 3)
- table.remove(R, 3)
- premain()
- end
- end
- else
- io.write("Wystapil blad")
- sleep(1)
- loginscreen()
- end
- end
- function wyslijwiad()
- term.setCursorPos(1,1)
- term.clear()
- paintutils.drawImage(image4, 1, 1)
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- io.write("<---")
- term.setCursorPos(26,1)
- io.write("X")
- term.setCursorPos(6,4)
- term.setBackgroundColor(colors.cyan)
- io.write("Wpisz wiadomosc")
- term.setCursorPos(6,15)
- io.write("Wyslij wiadomosc")
- wyswiad = true
- while wyswiad == true do
- event, button, x, y = os.pullEvent("mouse_click")
- if (button == 1) and (x >= 1) and (x <= 4) and (y == 1) then
- premain()
- elseif (button == 1) and (x == 26) and (y == 1) then
- system()
- elseif (button == 1) and (x >= 5) and (x <= 22) and (y >= 5) and (y <= 10) then
- term.setCursorPos(5,10)
- term.setBackgroundColor(colors.white)
- io.write(" ")
- term.setCursorPos(23,10)
- term.setBackgroundColor(colors.cyan)
- io.write(" ")
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.setCursorPos(5,10)
- wyswiadtxt = io.read()
- elseif (button == 1) and (x >= 5) and (x <= 22) and (y >= 14) and (y <= 16) then
- nick = settings.get("R")
- textwiad = nick[1]..":".." "..wyswiadtxt
- modem.transmit(124, 9, textwiad)
- premain()
- end
- end
- end
- function main()
- term.setCursorPos(1,1)
- term.clear()
- paintutils.drawImage(image3, 1, 1)
- term.setCursorPos(2,2)
- term.setBackgroundColor(colors.cyan)
- term.setTextColor(colors.white)
- io.write("@")
- term.setCursorPos(7,2)
- io.write("Napisz tweet'a")
- term.setCursorPos(25,2)
- io.write("X")
- term.setCursorPos(15,20)
- term.setBackgroundColor(colors.blue)
- io.write("Wyloguj sie")
- term.setCursorPos(6,19)
- myWindow = window.create(term.current(),4,5,20,14)
- myWindow.setBackgroundColor(colors.blue)
- myWindow.setCursorPos(1,1)
- myWindow.clear()
- odswiez()
- mcos = true
- while mcos == true do
- event, button, x, y = os.pullEvent("mouse_click")
- if (button == 1) and (x == 2) and (y == 2) then
- odswiez()
- elseif (button == 1) and (x == 25) and (y == 2) then
- system()
- elseif (button == 1) and (x >= 8) and (x <= 18) and (y == 2) then
- wyslijwiad()
- elseif (button == 1) and (x >= 15) and (x <= 25) and (y == 20) then
- settings.unset("R")
- settings.save()
- loginscreen()
- end
- end
- end
- function premain()
- parallel.waitForAll(odbieranieref, main)
- end
- function odswiez()
- ait = true
- ai = 1
- while ait == true do
- message = nil
- ref = {}
- refmsg = {}
- refmsg2 = {}
- ref[1] = "refresh"
- ref[4] = os.computerID()
- refmsg = textutils.serialize(ref)
- modem.transmit(122, 9, refmsg)
- sleep(2)
- if message ~= nil then
- myWindow.setBackgroundColor(colors.blue)
- myWindow.setCursorPos(1,1)
- myWindow.clear()
- refmsg2 = textutils.unserialize(message)
- win3 = term.redirect(myWindow)
- print(refmsg2[1])
- term.redirect(win3)
- ait = false
- break
- else
- ai = ai + 1
- if ai == 3 then
- ait = false
- break
- end
- end
- end
- end
- settings.load()
- if settings.get("R") == nil then
- loading()
- sleep(3)
- parallel.waitForAny(odbieranieref, loginscreen)
- else
- loading()
- message = nil
- parallel.waitForAny(odbieranieref, probazalogowania)
- end
Add Comment
Please, Sign In to add comment