How to create a console
Author: | Sumo148
|
Submitted: | 6th July, 2009
|
Views: | 5457
| Rated: |
|
|
Okay so I just created a console for my Assassination game, and I thought it was pretty useful so I'm going to tell you how to create one! Your lucky day. If you dont know what a console is, it's usually a pop-up window where you can enter commands (a.k.a cheats). An example of this is vavle's Portal
What you'll need:
-A list box
-A rich edit object
-An edit box
-A button or active system box
-A string
Okay so set up your items so the rich edit box takes up most of the screen. Right under it put the edit box and to the right of that, the button. This is the general layout. Keep the list box and the string out of the frame.
Double click the list box and add all your commands here. Make sure each command has it's own line. Also I prefer to check the 1-index under the properties if it isn't checked already. Alright, here comes the coding part. The code will be using fast loops by the way
The Code
Go into the event editor and enter this code: (I will explain everything)
+Start of Frame
-Set edit box focus ON
-Set current line of list to 1
+Edittext$( Edit Box )<> ""
+Enter button clicked
OR
+Edittext$( Edit Box )<> ""
+Upon pressing Enter
-Start loop search for List Nb Lines( commands ) number of times
-Set current line of list to 1
+On loop search
-set alterable string to List Select$( commands )
+On loop search
+string$( (command check) )= Edittext$( Edit Box )
-Stop loop search
-Set font color of rich edit box to 0,0,0
-Set text of rich edit box to string$( (command check) )+ entered successfully+NewLine$
-Set alterable string to
-Set text of edit box to
-Set edit box focus ON
+On loop search
+List Nb Lines( commands )= List Select( commands )
+string$( (command check) )<> Edittext$( Edit Box )
-Stop loop search
-Set rich edit italics to ON
-Set font color of rich edit box to 209,24,24
-Set text of rich edit box to '+Edittext$( Edit Box )+'+ is not a command+NewLine$
-Set rich edit italics to OFF
-Set alterable string to
-Set text of edit box to
-Set edit box focus ON
+On loop search
-string$( (command check) )<> Edittext$( Edit Box )
-Set current line of list to List Select( commands )+1
Okay, so pretty much, when you press enter button or press the enter key and the edit box actually has something in it, it will start a loop. That loop will search each line of the list and compare it to the edit box of what the person typed in. If nothing equals it, it will say that there is no such command, but if it does match up, it will say that it was entered successfully.
All you have to do left is compare the edit box text to each code and create actions for it! Hope you enjoyed this short easy tutorial.
Example File: http://www.mediafire.com/download.php?fujowe0y02h
|
|
|