Misc

Miscellaneous functions useful for debugging (print to console, dump type information) and getting special objects and info.

Debug functions

print

Prints one or more objects to the CET console. Multiple objects will be printed separated by a space.

print("Hey", "there", 1, 2, true)

Dump

Dump(obj: GameDataType, detailed: bool) -> string

Returns a JSON-ish string with details about the members of obj:

  • Type name

  • Instance functions

  • Static functions

  • Properties

The listed functions include their signatures.

If detailed is true, function descriptions will include the function's full name hash, short name, and short name hash.

print(Dump(Game.GetPlayer(), false))

obj must be an instance of a wrapped game type, such as PlayerPuppet which is returned by Game.GetPlayer(). DumpAllTypeNames will dump the names of all such types.

GameDump

GameDump(obj: GameDataType) -> string

Returns the game's internal debug string for the given object. This string displays the object's properties and their values.

Beware that this string probably won't have any line breaks, so it's more advisable to open cyber_engine_tweaks/scripting.log in a text editor with line wrapping to view the output of this function.

print(GameDump(Game.GetPlayer()))

DumpType

DumpType(typeName: string, detailed: boolean) -> string

Like Dump, but takes a type name rather than an object instance. Use DumpAllTypeNames to get a list of all types.

print(DumpType("PlayerPuppet", false))

DumpAllTypeNames

DumpAllTypeNames() -> nil

Dump all type names to cyber_engine_tweaks/cyber_engine_tweaks.log and print to the console the number of types dumped.

DumpAllTypeNames()

Getters

GetDisplayResolution

GetDisplayResolution() -> float, float

Returns the width and height (respectively) of the game window in pixels.

width, height = GetDisplayResolution()

GetMod

GetMod(modName: string) -> object

Returns the return value of the mod with the given name.

mod = GetMod("MyMod")

If you don't return anything in your init.lua file, this function will return nil. This will often look like return MyMod:new() at the end of your file. See the Lua documentation for info about how classes can be implemented in Lua.

GetSingleton

GetSingleton(singletonTypeName: string) -> SingletonReference | nil

Returns the singleton for the given type name if it exists, otherwisenil.

gameTime = GetSingleton("gameTimeSystem")
print(gameTime:GetGameTime())
gameTime:SetGameTimeByHMS(12, 0, 0) -- 12h0m0s

A singleton is the sole instance of a type, often used for global operations.

GetVersion

GetVersion() -> string

Returns the current CET build's commit hash.

version_hash = GetVersion()