Console Server
[Miscellaneous Subsystems]
Detailed Description
Introduction
The console is one of the most powerful features of Nebula. It's like working in a conventional console ('bash' for instance), but instead of inspecting and manipulating files one will inspect and manipulate living C++ objects directly by invoking script commands on them. Objects can be created, deleted, copied around, made persistent, or restored from persistency. Since the console is also a complete Tcl shell, one can run Tcl scripts at any time, or create Tk frontends which in turn can be used to query and manipulate the state of Nebula objects through a GUI.The console server implements an interactive console, which allows script commands to be executed on objects in the named object hierarchy and provides an output for messages. Functions are also given for creating and deleting objects, and navigating the named object hierarchy.
The console server is built around the gfx, input and script server and implements an ingame console. It reads keyboard data from the input server, sends command lines to the script server for evaluation and renders text through the gfx server. It's basically a command line shell layered over a realtime 3d view.
The next sections show you that how to use the console server.
Console Server Initialization
The console server depends on the following servers, which should be created before creating the console server.
/sys/servers/input/sys/servers/gfx/sys/servers/script
The console server can be created from C++ or from script code. The default location is /sys/servers/console.
nConServer* cs = (nConServer*) Kernelserver->New("nconserver", "/sys/servers/console");
new nconserver /sys/servers/console
Console Server Usage
The console server must be open before it can display anything or accept input. To open the console use nConServer::Open, and to close it use nConServer::Close, to switch the state of the console use nConServer::Toggle. These are also accessible via script as theopen, close, and toggle methods.
The console server should be triggered frequently, usually every frame, by calling nConServer::Trigger. nConServer::Trigger should be called before your application processes input events, to allow the console server to consume any key press events when it is open. By default (if the console server is at /sys/servers/console), the console server is triggered by nInputServer::Trigger(), so this needn't be manually triggered each frame.
The console server also offers the ability to display the value of any nEnv nodes under /sys/var. To do this call nConServer::Watch with a string pattern that matches the names of any nEnv nodes. See Watched Variables for further information about creating watched variables.
// display all vars conServer->Watch("*"); // display vars starting with 'gfx' conServer->Watch("gfx*"); // stop displaying vars conServer->Unwatch();
Or, in TCL:
# display all vars
/sys/server/console.watch *
# display vars starting with 'gfx'
/sys/server/console.watch gfx*
# stop displaying vars
/sys/servers/console.unwatch
Console Server Shutdown
The console server can be released in the normal manner.
Classes | |
| class | nConServer |
| Implements the Nebula ingame console. More... | |