Application - stingray.Application namespace reference - Stingray Lua API Reference

Description

Interface to access global application functionality.

Note that since the application is a singleton (there is only one application), you don't need to pass any Application object to any of the Application functions. All the functions operate on the application singleton.

Functions

Parameters
This function does not accept any parameters.
Returns

string*

Each of the command line arguments is returned as a separate string.

The * notation indicates that there may be zero or more instances of the specified type.
Parameters

window :

stingray.Window?

Optional; used only when rendering to multiple swap chains on PC.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns

number

The back buffer resolution width, in pixels.

number

The back buffer resolution height, in pixels.

Do not call the deprecated version of this named "resolution".

Parameters
This function does not accept any parameters.
Returns

integer

The offset from which to unload the autoloaded resources.

Parameters
This function does not accept any parameters.
Returns

string

One of the following strings: debug, dev or release.

Parameters
This function does not accept any parameters.
Returns

string

A string that identifies the build version number of the engine.

For example: 2437 branch:release2.

If you rebuild the engine on your own, you can set this build identifier in a post-processing step after you have built the engine executable. The built executable will contain the string a4e915264ceaa4424b3ed6d3d2fe5e1a, followed by 128 zero characters. You can replace the zero characters with whatever string you want this build_identifier() function to return.

Parameters

type :

string

The type of the resource to find.

name :

string

The name of the resource to find.

Returns

boolean

true if the specified resource is available, or false otherwise.

Parameters

type :

string

The type of the resource being overridden.

name :

string

The name of the resource being overridden.

Returns
This function does not return any values.
Parameters

name :

string

The flag that should be removed.

Returns
This function does not return any values.
Parameters

command :

string

The command to send to the console.

parameters :

string*

Zero or more additional command-line parameters to pass along with the command.

The * notation indicates that there may be zero or more instances of the specified type.
Returns
This function does not return any values.
Parameters
This function does not accept any parameters.
Returns

integer

The port number of the console.

Parameters

command :

console_commands

The information that you want to send to the console, expressed in a string-keyed table.

data :

string?

Optional pointer to binary data to send. If this is supplied then length must also be given.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

length :

number?

Length of binary data, if any.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns
This function does not return any values.

You can use this function to print messages, warnings and errors to the console, or send arbitrary messages to other clients of the engine's console server.

Parameters

world :

stingray.World

The world that will be rendered in the new viewport.

viewport_template :

string

The name of the viewport template that determines the characteristics of the viewport.

Returns

stingray.Viewport

The newly created Viewport.

When you are finished with this viewport, you should destroy it by calling destroy_viewport().

Parameters

world :

stingray.World

The world being rendered in the viewport you want to destroy.

viewport :

stingray.Viewport

The viewport you want to destroy.

Returns
This function does not return any values.
Parameters

offset :

integer

The offset from which to unload the autoloaded resources.

Returns
This function does not return any values.
Parameters
This function does not accept any parameters.
Returns

stingray.Entity

The Entity which owns the executing flow node.

Parameters
This function does not accept any parameters.
Returns

stingray.Level

The Level which owns the executing flow node.

Parameters
This function does not accept any parameters.
Returns

stingray.Unit

The Unit which owns the executing flow node.

Parameters
This function does not accept any parameters.
Returns

stingray.World

The World which owns the executing flow node.

Parameters

indices :

any(integer, string)+

One or more indices for the data, which may be integers or strings.

The + notation indicates that there may be one or more instances of the specified type.
The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses.
Returns

any

The data value stored at the specified sequence of indices, if any.

Parameters

indices :

any(integer, string)+

One or more indices for the data, which may be integers or strings.

The + notation indicates that there may be one or more instances of the specified type.
The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses.
Returns
This function does not return any values.
Parameters
This function does not accept any parameters.
Returns

stingray.World

The World that is determined to be the most important.

This is usually the world where stuff is happening, and in which you want to test particle effects, sounds, etc.

The "most important" world is defined as the world that was rendered last frame that contains the most units.

Parameters

values :

any+

The values to use when creating the hash. This list must contain at least one value. Accepts numbers, nil, strings, and hex numbers expressed as strings.

The + notation indicates that there may be one or more instances of the specified type.
Returns

string

A 64-bit hexadecimal hash.

Parameters

flags :

integer*

Any number of New World Flags that set up properties for the new world.

The * notation indicates that there may be zero or more instances of the specified type.
Returns

stingray.World

The newly created World.

You can have as many game worlds as you like. Multiple game worlds may be useful for things like loading screens or inventory rooms.

NOTE: Always remember to free every world you create by calling release_world() when you are done with it.

Parameters

url :

string

The URL to open.

Returns
This function does not return any values.
Parameters
This function does not accept any parameters.
Returns

string

One of the Application object's platform constants, such as WIN32 or ANDROID.

Parameters

exit_code :

integer?

If supplied, specifies the exit code of the application.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns
This function does not return any values.

This function does not exist on the PlayStation 3, since it is forbidden to exit without a termination request from the SDK.

Parameters

package :

stingray.ResourcePackage

The package to be destroyed.

Returns
This function does not return any values.
Parameters

world :

stingray.World

The World you want to destroy.

Returns
This function does not return any values.

You should call this when you are completely done with a particular world.

Parameters

caps :

string+

One or more render caps whose status will be retrieved.

The + notation indicates that there may be one or more instances of the specified type.
Returns

boolean+

Returns a separate boolean value for each argument.

The + notation indicates that there may be one or more instances of the specified type.
Parameters

world :

stingray.World

The World that you want to render.

camera :

stingray.Camera

The Camera that defines the point of view for the rendering.

viewport :

stingray.Viewport

The Viewport that will contain the rendering.

shading_environment :

stingray.ShadingEnvironment

The ShadingEnvironment that determines the characteristics of the rendering. NOTE: If a shading environment entity exists in any of the levels loaded into the world, this parameter is not used. The settings are read from the entity instead.

window :

stingray.Window?

Optional; used only when rendering to multiple swap chains on PC.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns
This function does not return any values.
Parameters

name :

string

The file name of the .package file to use when creating the new resource package.

Returns

stingray.ResourcePackage

The new resource package.

NOTE: Always remember to free every resource package you create by calling release_resource_package() when you are done with it.

Parameters

name :

string

The URL of the bundle file to use when creating the new resource package.

Returns

stingray.ResourcePackage

The new resource package.

NOTE: Always remember to free every resource package you create by calling release_resource_package() when you are done with it.

Parameters

local_filename :

string?

Optional. If specified, the new log will use this path. If not specified, the last log will be overwritten.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

remote_filename :

string?

Optional. If specified, the new remote log will use this path. If not specified, the last remote log will be overwritten.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns
This function does not return any values.

The paths and file names that you pass to this function can contain the following variables, which will be expanded automatically:

  • %%APPDATA%%: The platform-specific folder for storing user data. For example, on Windows, this is C:\Users\<username>\AppData, and on Mac OS this is ~/Library/Application Support.
  • %%HOSTNAME%%: The host name of the computer.
  • %%DATE%%: The current date, in the form YYYY-MM-DD.
  • %%TIME%%: The current time, in the form HH.MM.SS.
  • %%RANDOM%%: Eight random letters.
  • %%OBBPATH%%: On Android, the path to the OBB file directory.
Parameters
This function does not accept any parameters.
Returns
This function does not return any values.

The path and file name are determined by the key win32.user_settings or macosx.user_settings in the settings.ini file. The string %%APPDATA%% in the file name will be expanded to the user's AppData or Application Support folder. For example:

win32 = {
user_settings = "%%APPDATA%%\\CompanyName\\GameTitle\\user_settings.config"
}

macosx = {
user_settings = "%%APPDATA%%/CompanyName/GameTitle/user_settings.config"
}
Parameters
This function does not accept any parameters.
Returns

table

A table that contains data read from the script_data setting in the settings.ini file.

Parameters

isEnabled :

boolean

true to enable auto-loading, or false otherwise.

Returns
This function does not return any values.

If enabled, the package system will be disabled, and all resources will be automatically loaded as they are accessed.

Parameters

indices :

any(integer, string)

One or more indices for the data, which may be integers or strings.

The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses.

value :

any

The value to store.

Returns
This function does not return any values.

You can retrieve the data later by passing the same indices in a call to get_data().

Parameters

type :

string

The type of the resource to override.

name :

string

The name of the resource to override.

override :

string

The resource it should be replaced with.

Returns
This function does not return any values.

I.e. whenever any engine system requests the resource name, the resource override will be returned instead. To remove an override, use clear_resource_override().

Parameters

flag :

string

The flag whose priority we should set.

priority :

integer

The priority of the flag.

Returns
This function does not return any values.

These values are used when resource overrides have been compiled with runtime flags. When a resource is requested, the override that corresponds to the flag with the highest priority will be used. The base resource (with no flags) is considered to have a priority of 0. To remove an override flag, use clear_resource_override_flag()

Parameters

properties :

number

Can be any combination of the defined Pen Service Properties values. (e.g., stingray.Input.TabletPenServiceProperty.DISABLE_PRESSANDHOLD + Input.TabletPenServiceProperty.DISABLE_SMOOTHSCROLLING).

Returns
This function does not return any values.
Parameters

params :

any+

A list of configuration parameters and their corresponding values.

The + notation indicates that there may be one or more instances of the specified type.
Returns
This function does not return any values.

This function accepts the following parameters:

  • "variable": Configures the engine to use variable time stepping. This is the default time step setting.
  • "fixed", fps: Configures the engine to run with fixed time steps at the specified frame rate. This means that the time steps taken will always be a multiple of 1/fps. If the engine runs faster than the specified frame rate, it will compensate by taking zero-length time steps.
  • "throttle", fps: Throttles the engine to the specified frame rate. The engine will be slowed down to run at the requested rate. This can be used to debug problems that only appear when the frame rate is low.
  • "no_throttle": Disables throttling. This is the default setting.
  • "variable": Disables throttling. This is the default.
  • "smoothing", frames, outliers, lerp: Configures the engine to use time step smoothing. When variable time stepping is used, smoothing the time steps over a number of frames can make the game feel less jerky. The frames value specifies the number of frames that should be averaged. The outliers value specifies how many extreme values to remove. For example, with a value of 2, the two highest and the two lowest values are removed before the average is computed. The lerp value specifies how fast the value is allowed to change from the computed average. A low value means more smoothing, a higher value less smoothing. The defaults are 11, 2, 0.1.
  • "no_smoothing": Disables time step smoothing.
  • "debt_payback", frames: If set to a non-zero value, the timer will try to keep track of its time debt -- i.e. how much the game time has drifted from an external world clock (because of smoothing, etc.) -- and will try to pay that debt back over the specified number of frames by adding extra time to them. This can be useful if you need your game to stay in sync with an external clock (for example, for networking), because otherwise your game can "lose" time. The default is 0.
  • "external_step_range", min, max: Specifies that the external world time should be clamped to the specified range before it is put in to the system. This is useful for preventing the system from taking really large steps when you break in the debugger. The default values are 0, 0.2.
  • "external_multiplier", multiplier: Sets a multiplier that can be used to accelerate or slow down the time for debugging purposes. The default value is 1.
  • "system_step_range", min, max: Specifies the minimum and maximum steps that the game is allowed to take. The default values are 0, 0.2.
  • "clear_history": Clears the history of accumulated time debt, smoothing history, etc.
  • "jump", time: Jumps the timer forward in the next frame by the specified number of seconds. Useful for previewing lengthy animations.
Parameters
This function does not accept any parameters.
Returns

string

A string that describes the hardware the game runs on.

This is typically used in error messages in order to append some extra detail about the hardware on which the error occurred, in case that information would be helpful in diagnosing and correcting the error.

Parameters
This function does not accept any parameters.
Returns

number

The elapsed time, in seconds.

Parameters
This function does not accept any parameters.
Returns

boolean

true if the user settings file exists but could not be loaded, or false otherwise.

If this function returns true, the file may be corrupt. In this case, default strings will be used. Note that a missing data file is not considered a load error.

Parameters
This function does not accept any parameters.
Returns

stingray.World[]

A table of World objects.

The [] notation indicates that this type is an array: a table in which the keys of the members are sequential integers, and the value of each element is an instance of the type shown.

Development only

The elements in this group are only available in development builds.

Do not use them in your final builds.

Parameters

name :

string

The package to load.

Returns
This function does not return any values.

See also set_autoload_enabled().

Parameters
This function does not accept any parameters.
Returns

string

A new globally unique identifier.

Only available on Windows platforms and in development builds or on Xbox One.

Parameters

milliseconds :

number

The time to sleep, in milliseconds.

Returns
This function does not return any values.
Parameters

enabled :

boolean

True if development only warnings should be enabled

Returns
This function does not return any values.

New World Flags

The constants listed in this group can be passed as arguments in calls to Application.new_world().

If you pass this flag to Application.new_world(), you must also pass an additional argument that indicates the desired value for the resource budget.

Disables Apex cloth simulation in a world.

DISABLE_PHYSICS : integer

Disables physics in a world.
Disables rendering in a world.

DISABLE_SOUND : integer

Disables sound playback in a world.

Only available in development builds.

Platform IDs

IOS = "ios" : string

The string used internally to represent iOS platforms.

LINUX = "linux" : string

The string used internally to represent the Linux platform.

MACOSX = "macosx" : string

The string used internally to represent Mac OS platforms.

UWP = "uwp" : string

The string used internally to represent UWP platforms.

WEB = "web" : string

The string used internally to represent the Web platform.

Windows and Mac OS X

The functions in this group are only available on Windows and Mac OS X platforms.

Parameters
This function does not accept any parameters.
Returns
This function does not return any values.
Parameters
This function does not accept any parameters.
Returns

table

A table of Vector3 objects, each of which describes a single display mode. Each Vector3 stores the information as follows: (width, height, screen_index).

NOTE: This function is considered deprecated, and exists only to preserve backward compatibility. For all new development, use the DisplayAdapter interface instead.

Parameters
This function does not accept any parameters.
Returns

integer

The process ID.

Parameters
This function does not accept any parameters.
Returns
This function does not return any values.

New PS4 controllers connected to the PC are not automatically detected after startup. Use this function to detect and setup the connected controllers and remove references to disconnected controllers.

When calling this function the order of the controllers can change, so the different PS4Pad1 interfaces can represent different physical devices.

After calling this function the first found PS4 controller will be available as PS4Pad1, the second as PS4Pad2, etc. If you call this function multiple times, there is no guarantee that the order of controllers is preserved. I.e., a controller previously detected as PS4Pad3 may now be PS4Pad1.

This function only exists on Windows.

Parameters

frames :

number

The maximum number of frames, or -1 to disable frame stacking.

Returns
This function does not return any values.

This is implemented by issuing a D3D11_QUERY_EVENT once per frame in a round-robin fashion, and every frame waits for the oldest event in the queue.

This feature is intended to reduce "mouse lag" on slow machines. Available for Windows platforms only.

NOTE: It is highly recommended that you avoid using this function unless absolutely necessary. It should only be considered as a last resort.

Parameters

indices :

any(integer, string)

One or more indices for the data, which may be integers or strings.

The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses.

value :

any

The value to store.

Returns
This function does not return any values.

You can retrieve the data later by passing the same indices in a call to user_setting(). See also save_user_settings() to persist the change to disk.

Parameters

indices :

any(integer, string)+

One or more indices for the data, which may be integers or strings.

The + notation indicates that there may be one or more instances of the specified type.
The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses.
Returns
This function does not return any values.