can somebody help me make a command console
because im making an fps
and i want a cheat/command console
but im a noob so i dont know where to start :( plz help
thanks
I can guide you a bit!
First, you'll need a way to bring up the console. For this example, we'll assign it to a button. When the console's open, you'll also need a way to send commands and close the console. We can assign these actions to a button, too.
Next, you will need a way to get keyboard input from the user. You have a couple of ways to do this. You can use LINPUT, which is the easiest way to get string input from the user. You can also use INKEY$, which allows more freedom to do stuff with the keyboard, but it's a bit more difficult to use. For this example, we will stick to LINPUT.
After getting the string input with LINPUT, you will need to parse the string to turn it into a command. We will stick to simple logic for this example. The simplest way to interpret the string as a command is to compare it to existing command strings in a really big IF statement. If the string matches a command string, then you would execute certain code.
Since you will be using LINPUT, a button to send the command is already established. You will have to use the A button or the ENTER key. There is no button to close the console, though. This means you will have to write a command to explicitly close the console. This is simple enough to code, though. I will write you a simple code in the next comment.
You would write this inside your main game loop. You can add as many commands as you want. Just use more ELSEIFs.
IF BUTTON(2) AND #Y THEN
CEXIT=FALSE
WHILE !CEXIT
LINPUT "COMMAND: "; C$
IF C$=="EXIT" || C$=="CLOSE" THEN
CEXIT=TRUE
ELSEIF C$=="GODMODE" THEN
HP=10000
PRINT "HEALTH SET TO 10K"
ELSE
PRINT "UNKNOWN COMMAND"
ENDIF
WEND
ENDIF
I'll write code snippets between <>.
You forgot the <THEN> after <IF BUTTON(2) AND #Y>.
Also, You forgot <" ||> after <IF C$=="EXIT>.
Also, remember all that code must go within your game's main loop.
It's the button to the left of A. It looks like a weird vertical line split in half. Putting two of those together makes the logic OR operator, which evaluates as true if any of its operands evaluates as true.
Are you using OPTION STRICT? If so, you will have to declare your variables first. Do that with the VAR command. You should initialize the variables before your game's main loop. Like this...
VAR CEXIT
VAR C$
VAR HP 'YOU COULD ALSO JUST REMOVE THE GODMODE COMMAND
WHILE 1 'MAIN GAME LOOP
'CONSOLE CODE GOES HERE
WEND
Also, make sure to understand what you are writing. Just blindly copy-pasting code is a very bad programming practice. In case you don't understand something, don't hesitate to ask.
You weren't meant to copy that. It was just a representation of your main game loop, if you had it.
You need to develop this logic on your own. You won't always get to copy. If you don't understand this kind of logic yet, I'd suggest looking for a programming course online. Even if they use other programming languages, the main logic still applies. I'd suggest the course provided by Khan Academy.