• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

In-game console commands

slojanko

Member
GM Version: GMS
Target Platform: Windows (Mac & Ubuntu not tested but should work)
Source: Link
Extension: Link
Summary:

This package contains a set of scripts that help you create an in-game console.

Tutorial:
The following image shows the default look of the console. Each input line is broken down into segments which are then used to determine the command and the arguments/parameters.


The console may be customized in a few places and get a different look, such as:

The following variables may be changed through scripts, after the console is already created:
border width, background color, background alpha, input line background, input line alpha, font, line separate distance, font color and font alpha.
Explanation of border width and font separate distance:

Border width works as an outline around the console itself and the input line. You must take this into account when defining the size of the console. The size is defined as: top left corner position, width in pixels and height. The height is expressed in the number of lines the console may display at any time.

Line separate distance is equal to the distance between all the sequential lines inside the console. Knowing this value and the height of the console (= number of lines) you can calculate the absolute height of the console in pixels.

To get a new command to be recognized you have to do 3 things:
-add a new case into the switch statement in gc_commands
-define the command check script
-define the command itself

The check script is a set of instructions that test the command if it was called incorrectly (not enough arguments, invalid types, ...). For more information check the premade check scripts which enable the following commands: spawn, destroy, set_scale, game_quit.

I hope someone finds this useful and has something nice to say. Ideas or #burns are also accepted.
 
Last edited:

chance

predictably random
Forum Staff
Moderator
I tried the gmx file you provided, and it works fine. And after looking through the code, I'd say it's organized and reasonably easy to follow. So that's fine.

I can see the considerable amount of effort you put into this. But I'm not really sure how it could be used. Maybe you can give some suggestions for use.
 

slojanko

Member
I tried the gmx file you provided, and it works fine. And after looking through the code, I'd say it's organized and reasonably easy to follow. So that's fine.

I can see the considerable amount of effort you put into this. But I'm not really sure how it could be used. Maybe you can give some suggestions for use.
The first thing that comes to my mind are cheats or any sort of modifications. RTS games could use this for getting resources through commands, physics based games could have an easter egg by enabling moon gravity or just use it for debugging when the default debug_message is not available. There is probably a lot more you could use it for but that's for users to find out.
 
H

Heretic Game Studios

Guest
Any way to make it so you can toggle the console on and off with the touch of a button, like in alot of older games?
 
Top