Extension In-game console commands

Discussion in 'Tutorials' started by slojanko, Feb 15, 2017.

  1. slojanko

    slojanko Member

    Joined:
    Jun 20, 2016
    Posts:
    113
    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.
    [​IMG]

    The console may be customized in a few places and get a different look, such as:
    [​IMG]
    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.
    [​IMG]
    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: Mar 20, 2017
    BenjiBenjamin123 and chance like this.
  2. chance

    chance predictably random Forum Staff Moderator

    Joined:
    Apr 22, 2016
    Posts:
    795
    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.
     
    Ethanicus likes this.
  3. slojanko

    slojanko Member

    Joined:
    Jun 20, 2016
    Posts:
    113
    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.
     
  4. Heretic Game Studios

    Heretic Game Studios Member

    Joined:
    Jul 25, 2016
    Posts:
    20
    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?
     
  5. slojanko

    slojanko Member

    Joined:
    Jun 20, 2016
    Posts:
    113
    If I'm not mistaken, the O letter is used for showing/hiding the command line.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice