RaySupreme Script API
 All Data Structures Functions Pages
Public Member Functions
ScriptContext Class Reference

Public Member Functions

void print (string str)
 
NodeGraphrootGraph (void)
 
NodeGraphcurrent (void)
 
void setCurrent (NodeGraph *graph)
 
NodeGraphListselected (void)
 
float randomFloat (float min, float max)
 
int randomInt (int min, int max)
 
void registerFunctionDesc (string decl, string description)
 
void registerMacro (string macro, string function)
 
int year (void)
 
void setYear (int year)
 

Detailed Description

The ScriptContext class provides a global context for scripts, it can be access via the global g_ctx variable and provides utility functions like print().

Member Function Documentation

NodeGraph* ScriptContext::current ( void  )

Returns the current NodeGraph. The current() / setCurrent() functions are mostly used by Shell function to store the hierarchy level the user is working on.

See Also
setCurrent()
Returns
The current NodeGraph which was set by setCurrent(), if none was set the root graph is returned.
void ScriptContext::print ( string  str)

Prints the given string to the console. Can be used for debug output or for showing progress to the user.

Parameters
strThe string to print.
float ScriptContext::randomFloat ( float  min,
float  max 
)

Returns a random float between min and max.

Parameters
minThe minimum value for the random float.
maxThe maximum value for the random float.
Returns
A random float between min and max.
int ScriptContext::randomInt ( int  min,
int  max 
)

Returns a random int between min and max.

Parameters
minThe minimum value for the random int.
maxThe maximum value for the random int.
Returns
A random int between min and max.
void ScriptContext::registerFunctionDesc ( string  decl,
string  description 
)

Registers a function and it's description. Used in registerFunctions() in Include files who want to make their functions and macros available to the Shell.

See Also
registerMacro()
Parameters
declThe declaration of the function, like "void meshStatistics( int )".
descriptionThe description of the function, like "Prints statistics for the mesh of the given NodeGraph.".
void ScriptContext::registerMacro ( string  macro,
string  function 
)

Registers a macro for a function in an Include file for use in the Shell.

See Also
registerFunctionDesc()
Parameters
macroThe macro, for example "mstats int". Currently only int, float and string macros at the end of the macro cmd are supported.
functionThe function name the macro expands in, like "meshStatistics(int);".
NodeGraph* ScriptContext::rootGraph ( void  )

Returns the root graph of the current project.

Returns
The root graph of the project.
NodeGraphList* ScriptContext::selected ( void  )

Returns a list of currently selected Objects / NodeGraphs in the current RaySupreme project.

Returns
List of currently selected Objects.
void ScriptContext::setCurrent ( NodeGraph graph)

Sets the current NodeGraph to the given graph. The graph can than be retrieved via current()

See Also
current()
Parameters
graphThe graph to be set as current.
void ScriptContext::setYear ( int  year)

Sets the year of the current context.

Parameters
Theyear to be set as the current year.
int ScriptContext::year ( void  )

Returns the year of the current context. Default is the current year.

Returns
The currently set year.