- en
- pl
OpenTTD GitHub
Contributing to OpenTTD - guidelines
OpenTTD Doxygen
Coding style
Compiling OpenTTD
Debugging
Add a setting
Add a squirrel function
Understanding the SaveGame handler
Bumping the savegame version
Doing an OpenTTD release
Manual of style
Format of langfiles
Using OpenTTD strings
List of special strings
Using the window system
Colour codes that exist in OpenTTD
Adding a text box
Understanding the widget focus system
GUI style guide
The OpenTTD TCP protocol
The OpenTTD UDP protocol
Debugging desyncs
Server Admin Port development
The console window
Console commands
Console variables
Using console scripting
Adding functions/commands to the console
Adding variables to the console
Console development history
Graphics and similar (NewGRF)
AI framework (NoAI)
GameScript framework (NoGO)
Social Integration
Map array (landscape grid)
Vehicles
Pathfinding
Train acceleration
Sound IDs
This document explains how to add variables to the console.
the first step
the first thing you ll need if you want to do anything within the console is
include "console.h"
this gives you the ability to access all IConsole functions and structures you will have to use if you are intending to add Commands/Functions/Variables to the Console.
adding a c++ variable
to add an c++ variable to the console variable list you only need to put this somewhere in your sourcecode where it is executed during the openttd initialization process:
IConsoleVarRegister("myvar",(void *) &my_static_var,ICONSOLE_VAR_BYTE);
ICONSOLE_VAR_BYTE can be replaced with another variable type according to your c++ variable definition.
adding a virtual c++ variable
this is as easy as the procedure for adding an c++ variable.
_iconsole_var * var; var = IConsoleVarAlloc(ICONSOLE_VAR_BOOLEAN); IConsoleVarInsert(var,"temp_bool"); var = IConsoleVarAlloc(ICONSOLE_VAR_INT16); IConsoleVarInsert(var,"temp_int16");
this adds two virtual variables.. virtual variables arent mapped to an c++ variable so they were only accessable over the console or from within c++ over
_iconsole_var * IConsoleVarGet(byte * name);
this allows the usage of instance based strings in c++. for a description of instance based strings read Using Console Scripting