here is a cleaned up full code, i had to replace some firebase info with "*" the last function "getlatestgamesave() isnt being used yet
SetErrorMode(2)
// set window properties
SetWindowTitle( "ghjghj" )
SetWindowSize( 1280, 720, 0 )
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )
// set window properties
type SavedData_type
data as string[]
endtype
global SavedData as SavedData_type
type cloudData_type
data as string[]
endtype
global cloudData as cloudData_type
type userdata_type
email as string
password as string
returnSecureToken as string
idToken as string
endtype
type useridtoken_type
idToken as string
endtype
global useridtoken as useridtoken_type
global userdata as userdata_type
global returndata as string[-1]
global teststring$ as string
global response$ as string
global statuscode as integer
global done as integer
global textid as string
global textid2 as string
global readtest as string
global file$ as string
global ThisFile as integer
global userdoc as string
global IHTTP as integer
global sendingstring as string
global infotext as string
global useread as integer
global userid as string
global user as string
global submitimg as integer
global newuserimg as integer
global signinimg as integer
global user$ as string
global password$ as string
global displaytext as string
global wf# as string
global otwf# as integer
global spaceimage as integer
global spaceback as integer
global getmessage as string
spaceimg = loadimage("vr-space-landscape.png")
spaceback = createsprite(spaceimg)
setspritesize(spaceback,GetVirtualWidth(),GetVirtualHeight())
wf# = "testdata.text"
otwf# = opentowrite(wf#)
file$ = "gamedata.txt"
ThisFile = opentoread(file$)
submitimg = loadimage("submit.png")
newuserimg = loadimage("new user.png")
signinimg = loadimage("sign in.png")
done = 0
loaddata()
#constant identitytoolkit "identitytoolkit.googleapis.com"
#constant realtdata "next-species-29059882-default-rtdb.firebaseio.com"
//main loop
do
if done = 0
if GetFileExists(Userdoc)=1
useread = OpenToRead(Userdoc)
userid = ReadLine(useread)
userinputbox()
else
userinputbox()
endif
done = 1
endif
sync()
loop
////
function getdatabase()
local result$ as string
local idtoken as string
IHTTP = CreateHTTPConnection()
SetHTTPHost(IHTTP, realtdata, 1)
AddHTTPHeader( iHTTP,"************",'create')
useridtoken.idToken = "***********"
//get file from database
sendingtest$ = SendHTTPRequest(IHTTP,saveddata.tojson())
while GetHTTPResponseReady( iHTTP ) = 0
print("connecting.....")
endwhile
response$ = GetHTTPResponse( iHTTP )
statuscode = GetHTTPStatusCode( iHTTP )
CloseHTTPConnection( iHTTP )
endfunction result$
////
function signin(email$ as string, password$ as string)
local result$ as string
IHTTP = CreateHTTPConnection()
SetHTTPHost(IHTTP, identitytoolkit, 1)
while GetHTTPResponseReady( iHTTP ) = 0
print("connecting.....")
sync()
endwhile
AddHTTPHeader( iHTTP,'Content-Type: application/json','POST')
userdata.email = email$
userdata.password = password$
userdata.returnSecureToken = "true"
result$ = SendHTTPRequest(IHTTP,"/v1/accounts:signInWithPassword?key=****************",userdata.tojson())
while GetHTTPResponseReady( iHTTP ) = 0
print("connecting.....")
sync()
endwhile
response$ = GetHTTPResponse( iHTTP )
statuscode = GetHTTPStatusCode( iHTTP )
RemoveHTTPHeader( iHTTP,'Content-Type: application/json')
CloseHTTPConnection( iHTTP )
endfunction result$
////
function createnewuser(email$ as string, password$ as string)
local sendingtest$ as string
local result$ as string
IHTTP = CreateHTTPConnection()
SetHTTPHost(IHTTP, identitytoolkit, 1)
while GetHTTPResponseReady( iHTTP ) = 0
print("connecting.....")
sync()
endwhile
AddHTTPHeader( iHTTP,'Content-Type: application/json','POST')
userdata.email = email$
userdata.password = password$
userdata.returnSecureToken = "true"
result$ = SendHTTPRequest(IHTTP,"/v1/accounts:signUp?key=***************",userdata.tojson())
while GetHTTPResponseReady( iHTTP ) = 0
print("connecting.....")
sync()
endwhile
response$ = GetHTTPResponse( iHTTP )
statuscode = GetHTTPStatusCode( iHTTP )
RemoveHTTPHeader( iHTTP,'Content-Type: application/json')
CloseHTTPConnection( iHTTP )
endfunction result$
/////
function userinputbox()
local returntext$ as string
local boxtext as integer
local box2text as integer
local submit as integer
local useroption as integer
local lastpointerx as float
local lastpointery as float
local firstclick as integer
local firstclick2 as integer
firstclick = 0
firstclick2 = 0
///
if GetEditBoxExists(1) = 0
CreateEditBox(1)
SetEditBoxSize(1,40,10)
SetEditBoxMultiLIne(1,1)
seteditboxtextsize(1,10)
SetEditBoxBorderSize(1,.5)
SetEditBoxBorderColor(1,0,250,0,255)
boxtext = createtext("Enter Email")
settextsize(boxtext,8)
SetEditBoxPosition(1,GetVirtualWidth()/2-GetEditBoxWidth(1)/2,GetVirtualHeight()/2-GetEditBoxHeight(1)*2+GetTextTotalHeight(boxtext)*2/2)
settextposition(boxtext,GetEditBoxX(1),GetEditBoxY(1)-GetTextTotalHeight(boxtext))
CreateEditBox(2)
SetEditBoxSize(2,40,10)
SetEditBoxPosition(2,GetVirtualWidth()/2-GetEditBoxWidth(1)/2,GetEditBoxY(1)+GetEditBoxHeight(1)+GetTextTotalHeight(boxtext))
SetEditBoxMultiLIne(2,1)
seteditboxtextsize(2,10)
SetEditBoxBorderColor(2,0,250,0,255)
SetEditBoxBorderSize(2,.5)
SetEditBoxPasswordMode(2,1)
boxtext2 = createtext("Enter password")
settextsize(boxtext2,8)
settextposition(boxtext2,GetEditBoxX(2),GetEditBoxY(2)-GetTextTotalHeight(boxtext))
submit = createtext("Sign in")
settextsize(submit,5)
SetTextBold(submit,1)
SetTextPosition(submit,geteditboxx(2)+geteditboxwidth(2)-gettexttotalwidth(submit),geteditboxy(2)+geteditboxheight(2))
useroption = createtext("Create User")
settextsize(useroption,5)
SetTextBold(useroption,1)
SetTextPosition(useroption,geteditboxx(2),geteditboxy(2)+geteditboxheight(2))
else
SetTextString(boxtext,infotext)
endif
displaytext = "none"
local stringcount as integer
do
if GetPointerState() = 1
lastpointerx = screentoworldx(GetPointerX ( ))
lastpointery = screentoworldy(GetPointerY ( ))
endif
if GetPointerReleased() = 1
user$ = GetEditBoxText(1)
password$ = GetEditBoxText(2)
if GetTextHitTest(useroption,lastpointerx, lastpointery) = 1
sendingtest$ = createnewuser(user$, password$)
sendingtest$ = StripString(sendingtest$," {}[]"+CHR(34))
stringcount = CountStringTokens(sendingtest$,"," )
for i = 1 to stringcount
returndata.length = returndata.length + 1
returndata[returndata.length] = getstringtoken(sendingtest$,",",i)
next i
for i = 0 to returndata.length
teststring$ = GetStringToken(returndata[i],":",1)
if teststring$ = "message"
getmessage = GetStringToken(returndata[i],":",2)
endif
next i
elseif GetTextHitTest(submit,lastpointerx, lastpointery) = 1
sendingtest$ = signin(user$, password$)
sendingtest$ = StripString(sendingtest$," {}[]"+CHR(34))
stringcount = CountStringTokens(sendingtest$,"," )
for i = 1 to stringcount
returndata.length = returndata.length + 1
returndata[returndata.length] = getstringtoken(sendingtest$,",",i)
next i
for i = 0 to returndata.length
teststring$ = GetStringToken(returndata[i],":",1)
if teststring$ = "message"
sendingtest$ = GetStringToken(returndata[i],":",2)
endif
next i
endif
endif
print(teststring$)
print(statuscode)
print(getmessage)
print(sendingtest$)
sync()
loop
deletetext(boxtext)
deletetext(boxtext2)
deletetext(submit)
deletetext(useroption)
DeleteEditBox(1)
DeleteEditBox(2)
endfunction
//////
function loaddata()
local savenum as integer
local i as integer
local p as integer
local s as integer
ThisFile =OpenToRead(file$)
Repeat
SavedData.data.Insert( ReadLine(ThisFile) )
Until FileEOF(ThisFile )
CloseFile(ThisFile)
endfunction
///
function getlatestgamesave()
local yeardiff as integer
local monthdiff as integer
local daydiff as integer
local hourdiff as integer
local minutediff as integer
local seconddiff as integer
local totaldiff as integer
local ogenergy as integer
local clouddate$ as string
local cloudtime$ as string
local cloudyear$ as string
local cloudmonth$ as string
local cloudday$ as string
local cloudhour$ as string
local cloudminute$ as string
local cloudsecond$ as string
local localdate$ as string
local localtime$ as string
local localyear$ as string
local localmonth$ as string
local localday$ as string
local localhour$ as string
local localminute$ as string
local localsecond$ as string
totaldiff = 0
clouddate$ = cloudData.data[0]
cloudtime$ = cloudData.data[1]
localdate$ = SavedData.data[0]
localtime$ = SavedData.data[1]
cloudyear$ = getstringtoken(clouddate$,"--",1)
cloudmonth$ = getstringtoken(clouddate$,"--",2)
cloudday$ = getstringtoken(clouddate$,"--",3)
cloudhour$ = getstringtoken(cloudtime$,"::",1)
cloudminute$ = getstringtoken(cloudtime$,"::",2)
cloudsecond$ = getstringtoken(cloudtime$,"::",3)
localyear$ = getstringtoken(localdate$,"--",1)
localmonth$ = getstringtoken(localdate$,"--",2)
localday$ = getstringtoken(localdate$,"--",3)
localhour$ = getstringtoken(localtime$,"::",1)
localminute$ = getstringtoken(localtime$,"::",2)
localsecond$ = getstringtoken(localtime$,"::",3)
yeardiff = val(cloudyear$) - val(localyear$)
if yeardiff > 0
endif
monthdiff = val(cloudmonth$) - val(localmonth$)
if monthdiff > 0
endif
daydiff = val(cloudday$) - val(localday$)
if daydiff > 0
endif
hourdiff = val(cloudhour$) - val(localhour$)
if hourdiff > 0
endif
if hourdiff < 0
//make it an + num
hourdiff = hourdiff -hourdiff-hourdiff
hourdiff = val(localhour$) -hourdiff
endif
endfunction
edit: i add "" around the messaage ti se if theres any characters im not seeing and the first " is in the line above when printing, does this mean a possible "enter" to the next line? print(CHR(34)+getstringtoken(returndata[i],":",1)+CHR(34))
another edit: it was an enter or new line (CHR(10)) thank you for the response i spend days on a problem and as soon as i post here i find the answer anyway