プレイ日記
Ep17 EmPx17
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
0そうだね
プレイ済み
返信[1]
親投稿
Oscar PwnageBlock
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.
0そうだね
プレイ済み
返信[2]
親投稿
Oscar PwnageBlock
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.
0そうだね
プレイ済み
返信[3]
親投稿
Oscar PwnageBlock
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.
0そうだね
プレイ済み
返信[4]
親投稿
Oscar PwnageBlock
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.
0そうだね
プレイ済み
返信[5]
親投稿
Oscar PwnageBlock
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
1そうだね
プレイ済み
返信[6]
親投稿
Ep17 EmPx17
thanks oscar
0そうだね
プレイ済み
返信[7]
親投稿
Ep17 EmPx17
heres what i typed but it says syntax error about "CEXIT=FALSE"
0そうだね
プレイ済み
返信[8]
親投稿
Oscar PwnageBlock
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.
1そうだね
プレイ済み
返信[9]
親投稿
Ep17 EmPx17
ok but how do i make that "||" thing?
0そうだね
プレイ済み
返信[10]
親投稿
Oscar PwnageBlock
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.
1そうだね
プレイ済み
返信[11]
親投稿
Ep17 EmPx17
ok
0そうだね
プレイ済み
返信[12]
親投稿
Ep17 EmPx17
i think this right but it says "undifined variable in line 184"
0そうだね
プレイ済み
返信[13]
親投稿
Ep17 EmPx17
here's the screenshot i forgot it
0そうだね
プレイ済み
返信[14]
親投稿
Ep17 EmPx17
line 284 not 184
0そうだね
プレイ済み
返信[15]
親投稿
Oscar PwnageBlock
You forgot another <"> after <CLOSE> in line 287.
0そうだね
プレイ済み
返信[16]
親投稿
Ep17 EmPx17
it still says undefined variable in 284, and sorry for spamming your notifications but im not good at coding
0そうだね
プレイ済み
返信[17]
親投稿
Oscar PwnageBlock
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
0そうだね
プレイ済み
返信[18]
親投稿
Oscar PwnageBlock
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.
0そうだね
プレイ済み
返信[19]
親投稿
Ep17 EmPx17
ok i got the var thing to work but when i try put while 1 and wend at the end it says "while without wend"
0そうだね
プレイ済み
返信[20]
親投稿
Ep17 EmPx17
and i had to type some of the code then come back to miverse then leave again so thats why i had copy and paste errors
0そうだね
プレイ済み
返信[21]
親投稿
Oscar PwnageBlock
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.
0そうだね
プレイ済み
返信[22]
親投稿
Ep17 EmPx17
ok thanks for helping now i know how to use the var command
0そうだね
プレイ済み