console_variable - ryzom/ryzomcore GitHub Wiki


title: Console Variables description: published: true date: 2023-03-01T05:17:35.182Z tags: editor: markdown dateCreated: 2022-03-07T11:05:26.767Z

NeL provides a variable management layer. This variable management is an extension of the command system explained earlier and comes in two flavors: basic and dynamic. All variables have a naming convention to match the NeL naming convention for public members such as: MyVariable, SomeValue or UsefulSetting.

Basic Variables

A basic NeL variable is a way to expose a concrete primitive to the command system for real-time interaction with the user. The following snippet of code allows the user to modify a variable using the command system as explained in the previous section:

uint32 MyVariable
NLMISC_VARIABLE(uint32, MyVariable, "MyVariable represents important runtime mechanics.");

This simple tidbit of code would allow a user to change the value of MyVariable by simply calling the ICommand execution method with "MyVariable 3" or to retrieve the current value by simply calling it with "MyVariable." In essence any variable you create with this macro becomes a simple command that can be called to set or display the value. You can see here that the basic variable macro takes three parameters: variable type, variable name (which must match a concrete variable name as in the example,) and a brief description of the variable which will be accessible under the variables category of the command help system.

Dynamic Variables

Dynamic variables provide you a little more flexibility in the process of getting and setting the value of the variable. One of the core goals of this is to provide you access to a variable which you do not have direct access to (such as a private member of a class.) With a dynamic variable you do not need a variable or class dedicated to the macro/command - you could use some other object within your simulation. If you use an existing class you must implement get and set methods which match the type that you will define in the NLMISC_DYNVARIABLE macro. One of the great advantages to this over the basic variable is that you as an implementor are allowed to define the getter and setter methods which allows you to perform some logic. You may want your setter method to check the limits of the value being passed or to clamp it to a reasonable value. Here's an example of a dynamic variable at work:

class CMyDynVar
{
	int m_SomePrivateVariable;
 public:
	int get() { return m_SomePrivateVariable; }
	void set(int val) { m_SomePrivateVariable=val; }
};

CMyDynVar myDynVar;

NLMISC_DYNVARIABLE(int,SomePrivVar,"Access the private variable inside of CMyDynVar")
{
	// check what type of command this is
	if(get)
		*pointer = myDynVar.get();
	else // !get is assumed to be set
		myDynVar.set(*pointer);
}

In the example above we created a class and then created an instance of it in the global scope. This could easily have been a class with static members or a singleton, we didn't have to create an instance at the global scope - it just has to be accessible in some way from the dynamic variable class/logic.

Built-In Variables

The NeL framework provides a variety of existing built-in variables for use. Below is a comprehensive list of the variables provided by the framework. In a later section specifically about the NeLNS system there will be even more built-in variables available for use that are specific to the various provided services.

Variable Name Variable Type Variable Description Help Category NeL Module
AvailableHDSpace std::string Hard drive space left in bytes nel NLMISC
AvailablePhysicalMemory std::string Physical memory available on this computer in bytes nel NLMISC
TotalPhysicalMemory std::string Total physical memory on this computer in bytes nel NLMISC
ProcessUsedMemory std::string Memory used by this process in bytes nel NLMISC
OS std::string OS used nel NLMISC
LSListenAddress std::string The listen address sent to the client to connect on this front_end nel NLNET
DefaultUserPriv std::string Default User priv for people who don't use the login system nel NLNET
NbNetworkTask uint32 Number of server and client thread nel NLNET
NbServerListenTask uint32 Number of server listen thread nel NLNET
NbServerReceiveTask uint32 Number of server receive thread nel NLNET
LaunchingDate std::string Date of the launching of the program nel NLNET
Uptime std::string Time from the launching of the program nel NLNET
CompilationDate std::string Date of the compilation nel NLNET
CompilationMode std::string Mode of the compilation nel NLNET
NbUserUpdate uint32 Number of time the user IService::update() called nel NLNET
Scroller std::string Current size in bytes of the sent queue size nel NLNET
State std::string Set this value to 0 to shutdown the service and 1 to start the service nel NLNET
ShardId uint32 Get value of shardId set for this particular service nel NLNET
CPULoad float Get instant CPU load of the server cpu NLNET
ProcessLoad float Get instant CPU load of the process/service cpu NLNET
CPUUserLoad float Get instant CPU user load of the server cpu NLNET
CPUSytemLoad float Get instant CPU system load of the server cpu NLNET
CPUNiceLoad float Get instant CPU nice processes load of the server cpu NLNET
CPUIOWaitLoad float Get instant CPU IO wait load of the server cpu NLNET
ProcessUserLoad float Get instant CPU user load of the process/service cpu NLNET
ProcessSystemLoad float Get instant CPU system load of the process/service cpu NLNET
MeanCPULoad float Get instant CPU load of the server cpu NLNET
MeanProcessLoad float Get instant CPU load of the process/service cpu NLNET
MeanCPUUserLoad float Get instant CPU user load of the server cpu NLNET
MeanCPUSytemLoad float Get instant CPU system load of the server cpu NLNET
MeanCPUNiceLoad float Get instant CPU nice processes load of the server cpu NLNET
MeanCPUIOWaitLoad float Get instant CPU IO wait load of the server cpu NLNET
MeanProcessUserLoad float Get instant CPU user load of the process/service cpu NLNET
MeanProcessSystemLoad float Get instant CPU system load of the process/service cpu NLNET
PeakCPULoad float Get instant CPU load of the server cpu NLNET
PeakProcessLoad float Get instant CPU load of the process/service cpu NLNET
PeakCPUUserLoad float Get instant CPU user load of the server cpu NLNET
PeakCPUSytemLoad float Get instant CPU system load of the server cpu NLNET
PeakCPUNiceLoad float Get instant CPU nice processes load of the server cpu NLNET
PeakCPUIOWaitLoad float Get instant CPU IO wait load of the server cpu NLNET
PeakProcessUserLoad float Get instant CPU user load of the process/service cpu NLNET
PeakProcessSystemLoad float Get instant CPU system load of the process/service nel NLNET
NbClientReceiveTask uint32 Number of client receive thread nel NLNET
TotalCallbackCalled uint32 Total callback called number on layer 5 nel NLNET
SendQueueSize uint64 Current size in bytes of all send queues nel NLNET
ReceiveQueueSize uint64 Current size in bytes of all receive queues nel NLNET
ReceivedBytes uint64 Total of bytes received by this service nel NLNET
SentBytes uint64 Total of bytes sent by this service nel NLNET
PacsRetrieveVerbose uint Allow retrieve position to dump info nel NLPACS

When developing your game or application you should keep a table of available variables similar to this for a quick reference.

Source

⚠️ **GitHub.com Fallback** ⚠️