NeoConsole
0.8.1.9
Important - Modders Please Read
Please do not share NeoConsole with end users.
Do not make it into a mod and do not distribute it.
Be careful not to leave it in a mod you're working on either.
For now please use it as a convenient tool to help you create and test mods and nothing more.
When it's stable enough and has achieved feature parity with the original console, we can release it for end users to do whatever they want with it.
Part of this code was taken from Gamerev Games videos.
This project wouldn't be a thing without him, so go check him out !
Description
NeoConsole is an ongoing project that is attempting to create a new developer console from scratch.
The project is still at an early stage, and the current goal is to get a working console up and running without having to alter the game's behaviour in any way.
The current state of NeoConsole is a working console with a multitude of scripts as well as various issues.
We are still missing features the original developer console had, but we're getting there.
Setup
Setting up NeoConsole takes anywhere from 5 to 20 minutes for someone familiar with UMT.
While this isn't a particularly long time, be aware that a single small mistake can force you to restart, losing several minutes.
In the long run, I'd like to introduce a UMT script to do all this delicate work for you, but for now, read thoroughly.
Scripts (Commands)
Warning
Due to limitations with UMT, currently, creating the scripts before anything that may call them is critically important.
As such, it's strongly recommended to import every single script FIRST, and only then implementing the scripts or gameobjects that call them.
If you don't, and for example you create the o_neoconsole
Step Event BEFORE creating the scr_neoconsole_log
script, UMT will be confused and will not find it, which will prevent the game from starting.
Importing the scripts
Importing the scripts is pretty straightforward :
- Download the .zip file below.
- Extract it anywhere.
- Use the
Scripts > Resources Repackers > ImportGML.csx
script in UMT for each of the folders. - Make sure to import them in order (Core, Required, Base, Post) or else you will run into issues.
NeoConsoleScripts.zip Version 9.3 - [11/6/2023]
Reminder - commandsMap
If you added any non-standard script, make sure to also add them to the commandsMap in scr_neoconsole_init
!
Otherwise, they won't be accessible through the console.
It may also be a good idea to add an entry to the help command there to indicate how to use it !
Core Console
1. Adding o_neoconsole
- Create a new gameobject and change its name to
o_neoconsole
. - When prompted, make sure to click on the
Change all occurences of this value
button. - Finally, make sure to click on the
Persistent
checkbox to enable it.
2. Registering in sessionDataInit
Find gml_GlobalScript_scr_sessionDataInit
in UMT and add the following highlighted code to it :
Code
Explanations
- The code we're adding in
sessionDataInit
creates theo_neoconsole
gameobject if it doesn't exist already. - It's run when a save is loaded or when a new game is started by the player.
- This is the only way the console is spawned into the world.
3. Register in persistentRoomController
Find gml_Object_persistentRoomController_Other_11
in UMT and add the following highlighted code to it :
Code
Explanations
- This code destroys the console when run.
- It's mainly called when going back to the main menu.
4. Registering in dataLoader
Find gml_Object_o_dataLoader_Other_10
in UMT and add the following highlighted code to it :
Code
gml_Object_o_dataLoader_Other_10 | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
Explanations
- This code initializes the console's global variables when run.
- It's called when you load load the game.
5. Adding Create Event in o_neoconsole
Add a Create
event for o_neoconsole
and add the following code to it :
Code
- This global variable defines whether the console is currently opened or not.
- Defines the key that needs to be pressed to toggle the console on or off.See this page for other valid keys.
- Defines the prompt for your console, the characters that are shown before you type in it.
- text_currentline holds the characters you're typing in the console.
- Cursor starting position.
- Delay in frames before your cursor blinks.
- Name of the font asset to use in your console.This one is included in Stoneshard by default.
- Width of your console window.
- Height of your console window.
- Background color of your console window.
- Opacity (alpha) of your console window's background.
- Text color in your console. See this page for more.
- Text opacity in your console.
- Text color in your input line.
- Opacity of your input line's background.
- Background color of your input line.
- Function that contains the shortname for all the commands as well as their documentation for the help command.
Explanations
This documentation uses annotations to provide line per line descriptions.
Make sure you read them to know what each variable does !
Feel free to modify some of these values !
They're mostly used for styling so you should be fine.
6. Adding Destroy Event in o_neoconsole
Add a Destroy
event for o_neoconsole
and add the following code to it :
o_neoconsole - Destroy Event | |
---|---|
- Destroys the ds_map holding the shortnames for scripts since we don't need it if the console is destroyed.
- Disabling the global variable as the console can't be opened if it's destroyed.
- Destroys the ds_map holding the syntax help for scripts since we don't need it if the console is destroyed.
- Destroys the ds_map holding the usage help for scripts since we don't need it if the console is destroyed.
7. Adding Alarm 0 Event in o_neoconsole
Add a Alarm 0
event for o_neoconsole
and add the following code to it :
o_neoconsole - Alarm 0 Event | |
---|---|
- Calls this code again after the amount of frames defined in
cursor_blink_delay
.
Explanations
This is the code responsible for blinking the console's cursor.
If you want to change what your cursor looks like, this is the place to do it.
Logic & Rendering
1. Adding Step Event in o_neoconsole
Add a Step
event for o_neoconsole
and add the following code to it :
Code
- This block is responsible for toggling the console on or off when the key defined in the Create Event is pressed.
- If the console is not opened, we stop here.
- This block is responsible for erasing characters when Backspace is pressed.
- Here
2
is the cooldown in frames between each character being erased. Should probably be its own variable in Create Event. - This block is responsible for parsing user input when the Enter key is pressed.
- Necessary black magic for the string to behave properly.I don't know either, don't ask.
- Looking up the ds_map we created in the Create Event to check if the command exists.If it does, we assign the full script name to the command variable.
- If the command doesn't exist, we log the line and a message to let the user know.
- If the command was found, we run it here.
- The list of all the keys we don't want to be interpreted as text input in the console.
- If the character the user inputted isn't part of the exception list, we add it to current_line.
- If the arrow up key is pressed, we replace the current line with whatever command was typed last.
2. Adding DrawGUI Event in o_neoconsole
Add a DrawGUI
event for o_neoconsole
and add the following code to it :
Code
- Draws the GUI for the console.
- Draws the GUI for the user input line.
- Draws the text and handles text-wrapping.
Input Isolation
Now that we have a working console, if you hop in-game right now, you will notice something annoying happening when you type into the console :
Your keys are still being read by the game and you're accidentally opening your inventory, character menu or even the map !
You're also resting or skipping turns while typing !
This is because the game checks only if the original console is opened or not before doing these things, but doesn't check if ours is.
The Choice
And this is the part where I have to warn you. There is an easy fix for this, but I don't like it. Let me explain :
By hijacking the global variable that the original console uses, we can prevent this issue.
But why is that bad, it works right ?
Yes, it does but that's missing the point :
The goal of NeoConsole is to be completely standalone, and to not rely on code from the original console, as the developers could remove it at any time.
They have already started doing this by removing all the scripts (godmode, enemyinfo, teleport...), and it's only a matter of time before they remove the rest of the original console including, you guessed it, the global variable we want to hijack.
The day this happens, NeoConsole will also stop working if we don't do anything about it.
Method 1 - Easy Fix (Not future-proof)
Open the scr_neoconsole_enable
script we created earlier, and add the following highlighted code to it :
scr_neoconsole_enable | |
---|---|
This will hijack and toggle the original console's global variable and prevent opening your inventory and such when your console is open.
Method 2 - Harder Fix (Standalone & future-proof)
We are going to be replacing the places in the game where it checks if the original console is opened to check if our console is opened instead.
The problem with this approach is that some of these scripts will simply not compile back when edited.
The only way to force it to compile is by editing the bytecode (assembly) instead of the decompiled code.
This is due to a limitation with UMT.
As it's using an outdated compiler, it cannot recognize some newer features of GML and won't be able to compile.
In the following scripts,
Replace if (!global.consoleEnabled)
with if (!global.consoleEnabled && !global.neoconsole_enabled)
:
- gml_GlobalScript_scr_is_pressed_key
- gml_GlobalScript_scr_is_key
- gml_GlobalScript_scr_keyboard_control
- gml_Object_oCamera_Step_1
- gml_Object_o_abilities_Step_0
- gml_Object_o_Attitude_Step_0
In gml_Object_o_music_button_Step_1 :
- Replace
if ((!global.consoleEnabled) && (!pressed))
- With
if ((!global.consoleEnabled) && (!global.neoconsole_enabled) && (!pressed))
In the gml_Object_o_inv_switch_Other_10,
- Replace
if global.consoleEnabled
- With
if global.consoleEnabled || global.neoconsole_enabled
Now come the 2 annoying scripts that will require you to edit bytecode :
In gml_Object_o_button_actionkey_Step_1 :
-
Replace
-
With
In gml_Object_o_player_Step_0 :
- Replace
- With
Issues
Issue Number | Priority | Complexity | Description |
---|---|---|---|
1 | Mid | ? | Deleting text in the console is inconsistent. Not sure what causes this. |
2 | Low | Hard | The log command currently only supports writing with the default color.Should add a way to write with any.Will require rewriting the entire rendering side of the console. |
3 | High | Hard | There is no scrolling feature for the console, the help command can't be displayed completely because of this. |
4 | Low | Medium | Importing scripts has gotten better, but it still takes time and isn't very convenient.Need to write a .csx script to import them in a given order. |
5 | Low | Hard | Some of the modifications are slow and painful, it would need to be fully automated with a .csx script. |
6 | Low | Medium | Some scripts don't work and need to be fixed. |