main¶
Source: api/tealdef/main.d.tl
Basic definitions for all APIs
Globals¶
Fields
| Name | Type | Description |
|---|---|---|
_rootData |
any |
Start parameters handed to the root GUI. The main menu reads it as its MainMenuParams (e.g. showNews); the campaign page clears its campaign field. |
Functions
ug_require(string) : any api/tealdef/main.d.tl:6
Used instead of the regular lua require to include game related script
Returns any
_(string) : string api/tealdef/main.d.tl:9
Used to mark strings localized string (eg. _("Some text to localize"))
Returns string
nGetText(singularId : string, pluralId : string, n : integer) : string api/tealdef/main.d.tl:16
Returns a localized string, with plural handling
| Parameter | Type | Description |
|---|---|---|
singularId |
string |
singular text (or id) |
pluralId |
string |
plural text (or id) |
n |
integer |
number of object referred to in the plural text (for plural) |
Returns string: localized string
pGetText(context : string, id : string) : string api/tealdef/main.d.tl:22
Returns a localized string associated with a context
| Parameter | Type | Description |
|---|---|---|
context |
string |
localization context |
id |
string |
the string (or id) to localize |
Returns string: localized string
npGetText(context : string, singularId : string, pluralId : string, n : integer) : string api/tealdef/main.d.tl:30
Returns a localized string associated with a context, with plural handling
| Parameter | Type | Description |
|---|---|---|
context |
string |
localization context |
singularId |
string |
singular text (or id) |
pluralId |
string |
plural text (or id) |
n |
integer |
number of object referred to in the plural text (for plural) |
Returns string: localized string
getStringForPlatform(playstation : string, xbox : string, desktop : string) : string api/tealdef/main.d.tl:36
Returns the appropriate string based on the current platform
| Parameter | Type | Description |
|---|---|---|
playstation |
string |
the string for playstation |
xbox |
string |
the string for xbox |
desktop |
string |
the string for desktop |
Returns string
getBuildVersion() : string api/tealdef/main.d.tl:39
Returns the build version
Returns string
debugPrint(...: any) api/tealdef/main.d.tl:42
Prints text to the console/log file
resolve(relativePath : string) : string api/tealdef/main.d.tl:47
Resolves a file paths relative to the current file
| Parameter | Type | Description |
|---|---|---|
relativePath |
string |
a relative path |
Returns string: the full filepath
getCurrentModId() : string api/tealdef/main.d.tl:52
Returns the mod id of the current mod scope This is the outermost mod in the require hierarchy (i.e. the current file might belong to a different mod)
Returns string: modId string
getOwningModId() : string api/tealdef/main.d.tl:57
Returns the mod id of the mod owning the current file Note: This means you can not delegate calls to this function into helper files!
Returns string: modId string
addModifier<T>(fileName : string, data : T) : T api/tealdef/main.d.tl:59
Notes
Registers a modifier function for a resource loader. The modifier receives every loaded resource of that kind and returns it, possibly changed.
| Parameter | Type | Description |
|---|---|---|
fileName |
string |
In practice the resource category, e.g. loadModel or loadConstruction. |
data |
T |
In practice the modifier function: it gets the file name and the loaded data and returns the data. |
Returns T
Details
Mods call it in the function named by runScript in mod.json (e.g. mods/release/urbangames_vehicles_no_end_year/content/mod.script.lua). The base implementation in base/content/base/base/mod.lua takes a resource category and a modifier function, so the parameter names in the definition are misleading. An unknown category raises an error. The wiki recommends postRunFn with api.res where possible.
game¶
record global api/tealdef/main.d.tl:61
global record game
Notes
Global table under which loaded scripts and their functions are reachable; base script
scripts/util.tl (util.useFn) resolves a reference "<file>@<a.b.c>" by walking
game[file].a.b.c.
Fields
| Name | Type | Description |
|---|---|---|
res |
Res |
Functions
metamethod __index(game, string) : game api/tealdef/main.d.tl:62
Notes
Lets any key be indexed on game for type checking; the result is again typed as game.
Returns game
game.Res¶
record api/tealdef/main.d.tl:64
record Res
No description in the game files yet.
Fields
| Name | Type | Description |
|---|---|---|
script |
table |