Space Engineers

Space Engineers

Not enough ratings
Debugger/Logger v3.0
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
1.036 KB
18 Feb, 2015 @ 1:57pm
20 Sep, 2015 @ 11:38am
3 Change Notes ( view )

Subscribe to download
Debugger/Logger v3.0

Description
** Introduction **

Debugging you scripts in Space Engineers can be quite complicated and especially annoying. To get rid of that, I created a new new standalone debugging script, which can be triggered by any programmable block.

So it is no longer necessary to copy the same script over and over again into different programms, but instead you can use the same script to do all the necessary debugging on one screen.

** What does this debugger (logging) offer **

- three log levels (INFO, WARNING AND ERROR)
- configure stack size (Default 23)
- Use of one single script which can be executed by several programmable blocks
- Easy installation

(I recommand font size 0.6, with 23 rows)

** How to install **

To install the script, you just need one programmable block with the script in it and a lcd panel where the log should be written to.

In the script, you need to configure the name of the lcd panel by editing the value of:
private static string DEBUG_PANEL_NAME = "Panel Debug";

"Panel Debug" is the default. if you just name your lcd panel like that you dont need to change the script.

** What else do you need to know **

Most of the time I develop software with Java, so I used the java bean convention for attributes, and method names in this programm. Unlike the c# conventions, methodnames start with a lowercase letter there. Example getBlocks() instead of GetBlocks()

** Here is a short example of using it **

--- Begin C# Code ---

private const string DEBUGGER = "Program Debugger"; //name of the block with the debugging script
private List<TerminalActionParameter> args = new List<TerminalActionParameter>();

void debug(IMyProgrammableBlock debugger, String argument) {

args.Clear();
args.Add(TerminalActionParameter.Get(argument));

debugger.ApplyAction("Run", args);
}

void Main() {

IMyProgrammableBlock debugger = getDebugger();

/*
* When Programmable block with debugscript was not found, it will be null.
* When null is not handeled your script might crash
*/
if(debugger != null) {

debug(debugger, "INFO||This is an information");

debug(debugger, "WARNING||This is a warning");

debug(debugger, "ERROR||This is an error");
}
}

public IMyProgrammableBlock getDebugger() {

IMyProgrammableBlock debugger = GridTerminalSystem.GetBlockWithName(DEBUGGER)
as IMyProgrammableBlock;

return debugger;
}

--- End C# Code ---


1 Comments
kruder 30 May, 2015 @ 5:30pm 
Thanks for this script, it has been very useful!