App

General functions related to the whole application.

About

This is a global object that can always be accessed.

Usage

local gameTicks = GetApp:GetGameTick();
LogMsg("The game's age is: " .. gameTicks);

Member Functions

GetEngineVersion

number GetEngineVersion()

Returns

The current engine version in numerical form, for example, 0.16.

GetEngineVersionAsString

string GetEngineVersionAsString()

Returns

The current engine version in string form, for example, “0.16”

GetPlatform

number GetPlatform()

Returns

One of the C_PLATFORM_CONSTANTS.

SetWindowTitle

nil SetWindowTitle(string newTitle)

If you don’t like the default window text, you can specify your own.  Only visible when tabbed out or in windowed mode.

SetCursorVisible

nil SetCursorVisible(boolean bVisible)

Parameters: bVisible - If true, the system cursor (this means the mouse pointer in most cases btw) will be shown, otherwise it’s made invisible.

GetCursorVisible

boolean GetCursorVisible()

Returns: True if the system cursor is currently visible.

GetScreenSize

Vector2 GetScreenSize()

Returns a Vector2 object with the current screen size.

SetScreenSize

boolean SetScreenSize(number x, number y);

Allows on-the-fly screen size changes by script.  Up to you to specify valid resolutions if you’re currently fullscreen.

Parameters

xThe desired screen width
yThe desired screen height

Returns

True on success.  Except it doesn’t detect errors yet, so I guess always true.

GetPreLaunchScreenSize

Vector2 GetPreLaunchScreenSize()

Returns a Vector2 object with the size of the screen before novashell was launched.  Returns 0,0 if unsupported on the current OS.

GetIsWindowed

boolean GetIsWindowed()

Returns

Returns true if the screen is currently in windowed mode

SetIsWindowed

nil SetIsWindowed(boolean bWindowed)

Changes the video resolution to full screen or windowed mode.  Up to you to make sure the video card can handle it currently...

ParmExists

boolean ParmExists(string parmToFind)

Allows you to check if the game was run with a certain command line parameter or not.

Parameters

parmToFindThe parm you want to check for, for example, “-cheatmode” or something.

Returns

True if the parm was found.

GetTick

number GetTick()

The current system time.  Generally, you want to use GetGameTick instead.

Returns

The current system time in milliseconds.

GetGameTick

number GetGameTick()

This is what you use to time things.

  • This always starts at 0 when a new game/profile is started
  • It’s persistent, ie, it’s automatically saved and loaded with the profile
  • Is aware of pausing and changing the game speed.  If the game is running at 2X, this advances twice as fast too.

Returns

The current game time in milliseconds.

SetSimulationSpeedMod

nil SetSimulationSpeedMod( number speedModifier)

Setting this to 2 means the game will operate twice as fast.  Setting to 0.5 would mean half speed (slow mooootion).

Game Design Note

By default, TAB is assigned to make the game run fast using this, it’s good for testing and I recommend that you leave it in as it’s handy for skipping slow sequences for players too.

Worried people will run super fast and cheat?

It can’t be used to cheat, because, well, everything is going fast, not just the player.

GetSimulationSpeedMod

number GetSimulationSpeedMod()

Return

Gets the current simulation speed mod.

AddCallbackOnResolutionChange

nil AddCallbackOnResolutionChange(string callbackName, number entityID)

Allows you to have an entity or global function notified if the screen resolution changes.  The callback is automatically deleted when an Entity dies.  In the case of a global function, there is no way to unregister it.

Usage

//Inside of the an entities OnInit()
GetApp:AddCallbackOnResolutionChange("OnResChange", this:GetID());

//Then, elsewhere in the script, define the function "OnResChange"...

function OnResChange()
LogMsg("interface.lua>> Hey, the screen resolution changed to " .. C_SCREEN_X .. " " .. C_SCREEN_Y .. "!");
//Do stuff like move the GUI or whatever
end

Parameters

string callBackNameThe name of the callback function that should be called.  (Must exist in your code)
entityIDIf it’s an Entity function and not a global function, you’ll need to enter the Entity’s ID here.  Otherwise, <C_ENTITY_NONE>.

Related Constants

C_PLATFORM_CONSTANTS

C_PLATFORM_WINDOWS

C_PLATFORM_OSX

C_PLATFORM_LINUX

The Vector2 object.
The Entity object.