this program will allow you to open games (provided you tweak the code), play quick games vs the calculator, and learn facts.
the password is preset to 2110 but you can change it in the code.
this is what i have written so far (the rock paper and scissors wont work; if someone sees why, please tell me)


Code:
//"Boot" screen
ClrHome
Disp "BOOTING...
For(I,1,2500)
End
ClrHome
Disp "SYSTEM ONLINE"
For(I,1,500)
End
Disp "USER ONLINE"
For(I,1,500)
End
Disp "INITIALIZING..."
For(I,1,500)
End
ClrHome
Disp "MODULE READY"
For(I,1,500)
End

//Passcode
Input "AUTH CODE?",C
If C≠2110
Then
Disp "FAILURE"
Pause
Stop
Else
Goto P

//Greeting
Lbl P
ClrHome
Disp "GREETINGS"
Disp "STATUS: NOMINAL"
Disp "READY FOR INPUT"
Pause
ClrHome

//Main menu
Lbl D
Menu("MAIN","PLAY GAME",B,"CHAT",E,"QUIT",C)

//Gamescreen
Lbl B
Disp "NO GAMES YET"
Disp "INSTALLED"
Pause
Disp "GET GAMES HERE:"
Disp "CEMETECH.NET"
Pause
ClrHome
Goto D

//Quick quit
Lbl C
ClrHome
Stop

//Calc chat
Lbl E
Menu("WHAT DO U WANT TO DO?","FACTS",F,"PLAY GAME VS CALC",G,"BACK",I)

//Games to play
Lbl G
Menu("GAMES VS CALC","COIN TOSS",J,"R.P.S.",K,"BACK",I)

//Coin toss
Lbl J
Disp "COIN TOSS"
randInt(1,2)→Z
Pause
Disp
If Z=1
Then
Disp "ITS TAILS!"
Pause
ClrHome
Goto G
Else
Disp "ITS HEADS!"
Pause
ClrHome
Goto G

//Back
Lbl I
Goto D

//Rock, paper and scissors (in progress)
Lbl K
Disp "R.P.S"
randInt(1,3)→R
If R=1
Then
ROCK→Str1
If R=2
Then
PAPER→Str1
Else
SCISSORS→Str1
Disp "CHOOSE"
Input "1=R,2=P,3=S",T
Disp "CALC: "Str1
If T=1
Then
ROCK→Str2
If T=2
Then
PAPER→Str2
Else
SCISSORS→Str2
Disp "USER: "Str2
Pause
ClrHome
Goto G
If you are trying to make something password protected, if you want it to actually be secure, try implementing some kind of algorithm that encrypts and decrypts the password. Currently, all somebody would have to do to get the password would be to look inside of the program.
claculator wrote:
If you are trying to make something password protected, if you want it to actually be secure, try implementing some kind of algorithm that encrypts and decrypts the password. Currently, all somebody would have to do to get the password would be to look inside of the program.

i will, thx 🙂
do u know of any way to do this?

Code:
// random program stuff
Input "New password: ",Str1
// Caesar cipher, the stereotypical simple "encryption" method
"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890A"→Str0
" "→Str2
For(I,1,length(Str1))
Str2+sub(Str0,inString(Str0,sub(Str1,I,1))+1,1)→Str2
End
Str2→Str1
// Decryption
Input "Password: ", Str2
" "→Str3
For(I,1,length(Str2))
Str3+sub(Str0,inString(Str0,sub(Str2,I,1))+1,1)→Str3
End
If Str3=Str1:Then
// The rest of the program
// I wrote that off the top of my head in like a minute; there is *undoubtedly* a much more efficient way to do that

Of course, for any encryption method in TI-BASIC, anyone could still just look inside of your program and decipher how your password is encrypted, but the more encryption there is, the harder it is for some average Joe to decrypt it.
i made some progress but still need to make sure that the program does not ask for a new code each time, thank u for ur help!

the updated code

Code:
"Boot screen"
ClrHome
Disp "Booting...
For(I,1,2500)
End
ClrHome
Disp "System online"
For(I,1,500)
End
Disp "User online"
For(I,1,500)
End
Disp "Initializing..."
For(I,1,500)
End
ClrHome
Disp "Module ready"
For(I,1,500)
End

"random program stuff"
Input "New password: ",Str1
"Caesar cipher, the stereotypical simple encryption method"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890A"→Str0
" "→Str2
For(I,1,length(Str1))
Str2+sub(Str0,inString(Str0,sub(Str1,I,1))+1,1)→Str2
End
Str2→Str1
"Decryption"
Input "Password: ",Str2
" "→Str3
For(I,1,length(Str2))
Str3+sub(Str0,inString(Str0,sub(Str2,I,1))+1,1)→Str3
End
If Str3=Str1
Then
Goto D
Else
Stop

"Greeting"
Lbl P
ClrHome
Disp "Greetings"
Disp "Status: Nominal"
Disp "Ready for input"
Pause
ClrHome

"Main menu"
Lbl D
Menu("MAIN","Play game",B,"Chat",E,"Quit",C)

"Gamescreen"
Lbl B
Disp "No games yet"
Disp "Installed"
Pause
Disp "Get games here:"
Disp "cemetech.net"
Pause
ClrHome
Goto D

"Quick quit"
Lbl C
ClrHome
Stop

"Calc chat"
Lbl E
Menu("CALC CHAT","Facts",F,"Game vs calc",G,"Back",I)

"Games to play"
Lbl G
Menu("Games vs calc","Coin toss",J,"R.P.S.",K,"Back",I)

"Coin toss"
Lbl J
Disp "Coin toss"
randInt(1,2)→Z
Pause
Disp
If Z=1
Then
Disp "Its tails!"
Pause
ClrHome
Goto G
Else
Disp "Its heads!"
Pause
ClrHome
Goto G

"Back"
Lbl I
Goto D


something like this should work, right? (to make sure it does not ask for a new code each time)

Code:
"random program stuff"
If Str1=""
Then
Input "New password: ",Str1
I'm glad you kept my worthless comments 🙂
TI-BASIC is actually a little finicky about empty strings, so I'd use

Code:
If length(Str1)<1
Then
//I'd also add a label here for accessing password resetting from the main menu
Lbl P
//everything else

and then I'd also add the option in the menu to set up a new password.
i implemented it but i got an error ☹️
here is the code:

Code:
"Boot screen"
ClrHome
Disp "Booting...
For(I,1,2500)
End
ClrHome
Disp "System online"
For(I,1,500)
End
Disp "User online"
For(I,1,500)
End
Disp "Initializing..."
For(I,1,500)
End
ClrHome
Disp "Module ready"
For(I,1,500)
End


"Choose new passcode"
If length(Str1)<1
Then
Lbl Q   
Disp "Change your passcode"
Pause    
Input "New password: ",Str1
Goto D
   
"Encryption
"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890A"→Str0
" "→Str2
For(I,1,length(Str1))
Str2+sub(Str0,inString(Str0,sub(Str1,I,1))+1,1)→Str2
End
Str2→Str1
"Decryption"
Input "Password: ",Str2
" "→Str3
For(I,1,length(Str2))
Str3+sub(Str0,inString(Str0,sub(Str2,I,1))+1,1)→Str3
End
If Str3=Str1
Then
Goto D
Else
Stop

"Greeting"
Lbl P
ClrHome
Disp "Greetings"
Disp "Status: Nominal"
Disp "Ready for input"
Pause
ClrHome

"Main menu"
Lbl D
Menu("MAIN","Play game",B,"Chat",E,"Change password",Q,"Quit",C)

"Gamescreen"
Lbl B
Disp "No games yet"
Disp "Installed"
Pause
Disp "Get games here:"
Disp "cemetech.net"
Pause
ClrHome
Goto D

"Quick quit"
Lbl C
ClrHome
Stop

"Calc chat"
Lbl E
Menu("CALC CHAT","Facts",F,"Game vs calc",G,"Back",I)

"Games to play"
Lbl G
Menu("Games vs calc","Coin toss",J,"R.P.S.",K,"Back",I)

"Coin toss"
Lbl J
Disp "Coin toss"
randInt(1,2)→Z
Pause
Disp
If Z=1
Then
Disp "Its tails!"
Pause
ClrHome
Goto G
Else
Disp "Its heads!"
Pause
ClrHome
Goto G

"Back"
Lbl I
Goto D

Code:
Input "New password: ",Str1
Goto D

First, the Goto D should be after the decryption. Second, you need to be careful with Labels and Gotos because if you put them inside of an if statement or loop you can end up with memory leaks. I don't have the effort or time to explain that, so here: Memory Leaks

I'm not entirely sure, but my gut says that there's a memory leak since the Lbl Q is inside of an If statement. I'd put it right before the If statement and figure something out for resetting the password even if Str1 isn't empty. There are a number of other potential memory leaks but evidently none of them are significant enough to cause an error.

Let me know if you get any other errors. Or let ChatGPT know, frankly. Say what you will about it, but it probably understands TI-BASIC better than I do. My advice with AI programming is to always have a person check the code afterwards, though.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement