Update sPhone.lua
This commit is contained in:
parent
28952b3354
commit
483f110338
1 changed files with 96 additions and 19 deletions
115
src/sPhone.lua
115
src/sPhone.lua
|
@ -120,6 +120,55 @@ local function kernel()
|
||||||
sPhone.forceReboot()
|
sPhone.forceReboot()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function byte(string)
|
||||||
|
local newString = ""
|
||||||
|
for i = 1, #string do
|
||||||
|
addString = string.byte(string.sub(string, i))
|
||||||
|
newString = newString .. addString
|
||||||
|
end
|
||||||
|
return newString
|
||||||
|
end
|
||||||
|
|
||||||
|
function sPhone.yesNo(title, desc)
|
||||||
|
term.setBackgroundColor(colors.white)
|
||||||
|
term.clear()
|
||||||
|
term.setCursorPos(1,1)
|
||||||
|
term.setTextColor(colors.black)
|
||||||
|
local w, h = term.getSize()
|
||||||
|
paintutils.drawLine(1,1,w,1, colors.gray)
|
||||||
|
term.setTextColor(colors.white)
|
||||||
|
term.setCursorPos(1,1)
|
||||||
|
if not sPhone.user then
|
||||||
|
write(" sPhone")
|
||||||
|
else
|
||||||
|
write(" "..sPhone.user)
|
||||||
|
end
|
||||||
|
term.setCursorPos(1,3)
|
||||||
|
term.setBackgroundColor(colors.white)
|
||||||
|
term.setTextColor(colors.black)
|
||||||
|
sertextext.center(3, " "..title)
|
||||||
|
if desc then
|
||||||
|
sertextext.center(6, " "..desc)
|
||||||
|
end
|
||||||
|
paintutils.drawFilledBox(3, 16, 9, 18, colors.green)
|
||||||
|
paintutils.drawFilledBox(18, 16, 24, 18, colors.red)
|
||||||
|
term.setTextColor(colors.white)
|
||||||
|
term.setCursorPos(5,17)
|
||||||
|
term.setBackgroundColor(colors.green)
|
||||||
|
write("Yes")
|
||||||
|
term.setCursorPos(20,17)
|
||||||
|
term.setBackgroundColor(colors.red)
|
||||||
|
write("No")
|
||||||
|
while true do
|
||||||
|
local _,_,x,y = os.pullEvent("mouse_click")
|
||||||
|
if (x > 2 and y > 15) and (x < 10 and y < 19) then
|
||||||
|
return true
|
||||||
|
elseif (x > 17 and y > 15) and (x < 25 and y < 19) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function sPhone.winOk(fmessage, smessage, bg, side, text, button)
|
function sPhone.winOk(fmessage, smessage, bg, side, text, button)
|
||||||
if not fmessage then
|
if not fmessage then
|
||||||
fmessage = ""
|
fmessage = ""
|
||||||
|
@ -393,25 +442,53 @@ local function kernel()
|
||||||
sPhone.wrongPassword = true
|
sPhone.wrongPassword = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
term.clear()
|
local choose = sPhone.yesNo("Setup Sertex ID", "Do you a Sertex ID?")
|
||||||
term.setCursorPos(1,1)
|
if not choose then
|
||||||
local w, h = term.getSize()
|
term.clear()
|
||||||
paintutils.drawLine(1,1,w,1,colors.gray)
|
term.setCursorPos(1,1)
|
||||||
term.setTextColor(colors.black)
|
local w, h = term.getSize()
|
||||||
term.setBackgroundColor(colors.white)
|
paintutils.drawLine(1,1,w,1,colors.gray)
|
||||||
sertextext.center(3," Setup")
|
term.setTextColor(colors.black)
|
||||||
sertextext.center(7," Your Username")
|
term.setBackgroundColor(colors.white)
|
||||||
term.setCursorPos(3,10)
|
sertextext.center(3," Setup Sertex ID")
|
||||||
local name = read()
|
sertextext.center(7," Your Username")
|
||||||
local f = fs.open("/.sPhone/config/username","w")
|
term.setCursorPos(3,8)
|
||||||
f.write(name)
|
local name = read()
|
||||||
f.close()
|
while true do
|
||||||
sertextext.center(13," All Set!")
|
sertextext.center(9, " Your Password")
|
||||||
sertextext.center(14,"Have fun with sPhone")
|
term.setCursorPos(3,10)
|
||||||
sPhone.user = name
|
term.clearLine()
|
||||||
sleep(2)
|
local pw = read("*")
|
||||||
home()
|
sertextext.center(11, " Repeat")
|
||||||
|
term.setCursorPos(3,12)
|
||||||
|
term.clearLine()
|
||||||
|
local pwr = read("*")
|
||||||
|
if pw == pwr then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
print(" Wrong Password")
|
||||||
|
sleep(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local rServer = http.post("http://sertex.esy.es/register.php", "user="..name.."&password="..pw).readAll()
|
||||||
|
if rServer ~= "Success!" then
|
||||||
|
print("The server is down")
|
||||||
|
print("Retry later")
|
||||||
|
sleep(1)
|
||||||
|
end
|
||||||
|
local f = fs.open("/.sPhone/config/username","w")
|
||||||
|
f.write(name)
|
||||||
|
f.close()
|
||||||
|
local pwf = fs.open("/.sPhone/config/.sIDPw", "w")
|
||||||
|
pwf.write(pw)
|
||||||
|
pwf.close()
|
||||||
|
sertextext.center(13," All Set!")
|
||||||
|
sertextext.center(14,"Have fun with sPhone")
|
||||||
|
sPhone.user = name
|
||||||
|
sleep(2)
|
||||||
|
home()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue