Console Commands
In addition to supporting all API calls, The in-game console also allows you to call your own functions and methods. While your function/method can be defined in any file, it must be imported into main.py
and added as an entry to a special object, js_global
, which holds references to all API prototypes, objects, constants, and so on.
You can call anything defined in js_global
like you would a normal function. If you want to instantiate and class and call a method from the console, make all the necessary calls to the class from a function, and then store a reference to that function in js_global
like you would a normal function call.
Example
controller_properties.py
main.py
js_global
js_global
is a reference to a JavaScript global
object, which is a globally scoped object that is always available to be referenced. Because global
is already a keyword in Python, this alternate version is used. You can check the contents of js_global
in-game at any time by entering global
in the in-game console, but any time you want to reference it in your code, js_global
must be used instead.
Last updated
Was this helpful?