Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function MainScreen()
- Clear()
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,1)
- print("Frequency: "..Port)
- term.setBackgroundColor(colors.red)
- for I = 1, 26 do
- term.setCursorPos(I,19)
- term.write(" ")
- end
- term.setCursorPos(12,19)
- term.write("Exit")
- term.setBackgroundColor(colors.green)
- for I = 1, 26 do
- term.setCursorPos(I,2)
- term.write(" ")
- end
- term.setCursorPos(10,2)
- term.write("Log In")
- for I = 1, 26 do
- term.setCursorPos(I,4)
- term.write(" ")
- end
- term.setCursorPos(5,4)
- term.write("Create New Account")
- end
- function Clear()
- term.setBackgroundColor(colors.black)
- shell.run("clear")
- end
- function Init()
- shell.run("clear")
- loop = true
- Mode = "MainMode"
- modem = peripheral.wrap("back")
- ID = os.getComputerID()
- Port = ID + 12345
- modem.open(Port)
- end
- function MenuLogin()
- Clear()
- modem.transmit(12345, Port, ID)
- print("Please enter your password.")
- Pass = read("*")
- modem.transmit(12345, Port, Pass)
- event, side, x, y, success = os.pullEvent("modem_message")
- if success == "true" then
- print("Login successful.")
- Mode = "LoggedIn"
- else
- print("Login Failed.")
- end
- sleep(1)
- end
- function MenuNewAcc()
- Clear()
- modem.transmit(12345, Port, ID)
- print("Requesting new account...")
- print("Please set a password: ")
- Pass = read("*")
- modem.transmit(12345, Port, Pass)
- event, side, x, y, message = os.pullEvent("modem_message")
- if message == "Used" then
- print("There already is an account for this pc.")
- else
- print("Created new account!")
- end
- sleep(1)
- end
- function LoggedInScreen()
- print("Receiving currency...")
- modem.transmit(12345, Port, "getCurrency")
- modem.transmit(12345, Port, ID)
- event, side, x, y, currency = os.pullEvent("modem_message")
- Clear()
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(1,1)
- print("Frequency: "..Port.." ")
- print("Currency: "..currency.." ")
- print("ID: "..ID.." ")
- term.setBackgroundColor(colors.red)
- for I = 1, 26 do
- term.setCursorPos(I,19)
- term.write(" ")
- end
- term.setCursorPos(11,19)
- term.write("Log Out")
- term.setBackgroundColor(colors.green)
- for I = 1, 26 do
- term.setCursorPos(I,5)
- term.write(" ")
- end
- term.setCursorPos(6,5)
- term.write("Update Currency")
- for I = 1, 26 do
- term.setCursorPos(I,7)
- term.write(" ")
- end
- term.setCursorPos(10,7)
- term.write("Transfer")
- end
- function MenuTransfer()
- Clear()
- sleep(0.3)
- modem.transmit(12345, Port, "Transfer")
- sleep(0.3)
- modem.transmit(12345, Port, ID)
- print("Please select ID to send to:")
- ToUser = read()
- modem.transmit(12345, Port, ToUser)
- print("Amount to transfer: ")
- Amount = read()
- modem.transmit(12345, Port, Amount)
- event, side, x,y, message = os.pullEvent("modem_message")
- if message == "NotEnough" then
- print("Not enough Currency.")
- elseif message == "InvalidUser" then
- print("Invalid User ID.")
- else
- print("Successful transfer of "..Amount.." to "..ToUser)
- end
- sleep(1)
- end
- function Main()
- Init()
- while loop do
- if Mode == "MainMode" then
- MainScreen()
- elseif Mode == "LoggedIn" then
- LoggedInScreen()
- end
- event, button, x, y = os.pullEvent("mouse_click")
- if Mode == "MainMode" then
- if y == 2 then
- modem.transmit(12345, Port, "LogIn")
- MenuLogin()
- elseif y == 4 then
- modem.transmit(12345, Port, "CreateNew")
- MenuNewAcc()
- elseif y == 19 then
- loop = false
- modem.close(Port)
- end
- elseif Mode == "LoggedIn" then
- if y == 5 then
- modem.transmit(12345, Port, "getCurrency")
- sleep(0.3)
- modem.transmit(12345, Port, ID)
- event, side, x, y, currency = os.pullEvent("modem_message")
- elseif y == 7 then
- MenuTransfer()
- elseif y == 19 then
- Mode = "MainMode"
- end
- end
- end
- end
- Main()
- Clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement