Enfusion Script API
Loading...
Searching...
No Matches
ScriptModule Interface Reference

Module containing compiled scripts. More...

Public Member Functions

proto bool Call (Class inst, string function, bool async, out void returnVal, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
 Dynamic call of function.
 

Static Public Member Functions

static proto ref ScriptModule LoadScript (ScriptModule parentModule, string scriptFile)
 Load script and create ScriptModule for it.
 
static proto ref ScriptModule CompileScript (ScriptModule parentModule, string text, out string errorText, out int errorLine)
 Create ScriptModule from string input.
 

Detailed Description

Module containing compiled scripts.

string watch = "GetGame().InPlayMode()";
string code = string.Format("string WatchResult() { return string.ToString(%1); }", watch);
string logText;
int logLine;
ScriptModule mod = ScriptModule.CompileScript(GetGame().GetScriptModule(), code, logText, logLine);
if (mod)
{
string output;
mod.Call(null, "WatchResult", false, output);
Print(output);
}
else
{
Print(logText);
Print(logLine);
}
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
Module containing compiled scripts.
Definition ScriptModule.c:34
static proto ref ScriptModule CompileScript(ScriptModule parentModule, string text, out string errorText, out int errorLine)
Create ScriptModule from string input.
proto bool Call(Class inst, string function, bool async, out void returnVal, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Dynamic call of function.

Member Function Documentation

◆ Call()

proto bool ScriptModule.Call ( Class inst,
string function,
bool async,
out void returnVal,
void param1 = NULL,
void param2 = NULL,
void param3 = NULL,
void param4 = NULL,
void param5 = NULL,
void param6 = NULL,
void param7 = NULL,
void param8 = NULL,
void param9 = NULL )

Dynamic call of function.

when inst == NULL, it's global function call, otherwise it's method of class. If async is true, creates new thread (so it's legal to use sleep/wait). Otherwise main thread is used and call is blocking. Return value of called method is returned via returnVal (only when async is false!) Returns true, when success.

◆ CompileScript()

static proto ref ScriptModule ScriptModule.CompileScript ( ScriptModule parentModule,
string text,
out string errorText,
out int errorLine )
static

Create ScriptModule from string input.

Available in developer builds (workbench or diag) and in headless server.

Parameters
parentModuleModule
textto compile
errorTextoutput from compiler
errorLineoutput from compiler
Returns
Loaded scripted module

◆ LoadScript()

static proto ref ScriptModule ScriptModule.LoadScript ( ScriptModule parentModule,
string scriptFile )
static

Load script and create ScriptModule for it.

Available in developer builds (workbench or diag) and in headless server.

Parameters
parentModuleModule
scriptFileScript file path
Returns
Loaded scripted module

The documentation for this interface was generated from the following file: