Console

The console is basically divided into three distinct areas, the left sidebar contains a list of all the threads currently active. You can monitor in real time there states the script linked to it, and when name resolution is activated to which resource the thread is currently attached.

Each thread is running using a separate environment, only global variables are shared between them (_G in Lua). Keep that in mind when running custom commands as each local variables are running inside an isolated context.

In the log area (to the right) you can monitor in realtime all the Lua scripting commands that are sent/received over to the command server and executed locally and/or dispatched to the remote devices connected to the editor (if any).

At the bottom of the log, you have access to the command box; this area allows you to run Lua instructions directly to the thread activated in the thread list area. Depending on your requirements you either launch global commands (main thread) or local commands to a specific thread.

Menu


console_menu.png
Item Shortcut Action
Run Command Ctrl+R Execute locally on the selected thread the content of the command edit box.
Broadcast Command Ctrl+B Broadcast the content of the command box to all clients (local and remote).
Unlock Scroll Ctrl+E Continuously place scroll at the bottom of the console every time a new command is appended to the log.
Clear Console Ctrl+L Clear the backlog.
Thread List P Show/Hide the thread list. (only if the area have enough space to show the sidebar.)
Resolve Names M Resolve the name of the resource each thread is associated to.
Echo Mode Allow you to control the amount of log each command will generate. The default is Short Output that will truncate the scripting output commands if the become too long (fixed threshold).

Thread List


Once visible you can select on which thread you want to execute a command or inspect variables. Please keep in mind that each thread run inside their own environment so the same script might end up showing different results. Always double check which specific property and at which stage you want to inspect before running the command ensuring that you are selecting the right thread at the right time.

Note
If a thread label is set to (null) it means a thread has been created but it is waiting for a scripting entry. Its good practice to initialize once and re-use multiple time a thread, but in general, you should not waste resources by having idle threads. It is good practice to actually double confirm the thread will actually be used.

Log Output


Built-in the editor there is a command server, it is used to dispatch locally or to the other devices connected to the editor the same set of commands that you are executing locally while changing settings and properties, importing, adding object etc... It is also a good reference to learn how to write custom scripts and bundle them with an interface (commonly called Utility in NRG) to run within the IDE.

On a side note by default the server debug log is set to short so it will truncate long Lua command lines, however on top of reading and understanding the scripting documentation it is convenient to get references on the output that certain actions produce to change the server echo mode manually within your scripts take reference to command listed on the table below:

Command Echo mode
Dbg.server_echo=0 Disable the server echo mode. Commands will not be appended to the log.
Dbg.server_echo=1 Short server echo mode (truncate output command)
Dbg.server_echo=2 Long server echo mode; show the full output of each command.

Command


To run a command first you need to select a thread from the thread list then enter your command in the edit box and press enter. To have a spin at it type print("hello world!"), then press enter, next input a=1;b=2;c=a+b;print(c) and run it using Ctrl+R.

To broadcast the command to all connected clients (including the local connection) use Shift+enter or Ctrl+B. If you wish to send a command to a specific client; use the following syntax: 192.168.0.100@<your code here>. Take note that the command will only be excuted on the remote device and not locally.

Warning
Be careful while executing commands on the main thread as it is for expert only; it gives you access to the lowest level of the virtual machine. All calls are not protected by the VM and cannot be attached to the debugger. Make sure that you verify your scripting command(s) before executing them. In example; an infinite loop executed on the main thread is unrecoverable but for any other coroutine it will be detected by the VM daemon and halted by default and handled by the debugger (if attached).




NRGeditor - Manual 2022.3.383570 - Thu Jul 28 2022
Copyright © 2022 nrgcore.com. All Rights Reserved. Terms of Service - Privacy Policy - EULA