Zum Inhalt

main

Quelle: api/tealdef/main.d.tl

Basic definitions for all APIs

Globale Namen

Felder

Name Typ Beschreibung
_rootData any Startparameter, die die Wurzel-GUI erhält. Das Hauptmenü liest sie als seine MainMenuParams (z. B. showNews), die Kampagnenseite leert ihr Feld campaign.

Funktionen

ug_require(string) : any api/tealdef/main.d.tl:6

Used instead of the regular lua require to include game related script

Rückgabe any

_(string) : string api/tealdef/main.d.tl:9

Used to mark strings localized string (eg. _("Some text to localize"))

Rückgabe string

nGetText(singularId : string, pluralId : string, n : integer) : string api/tealdef/main.d.tl:16

Returns a localized string, with plural handling

Parameter Typ Beschreibung
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)

Rückgabe string: localized string

pGetText(context : string, id : string) : string api/tealdef/main.d.tl:22

Returns a localized string associated with a context

Parameter Typ Beschreibung
context string localization context
id string the string (or id) to localize

Rückgabe 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 Typ Beschreibung
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)

Rückgabe 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 Typ Beschreibung
playstation string the string for playstation
xbox string the string for xbox
desktop string the string for desktop

Rückgabe string

getBuildVersion() : string api/tealdef/main.d.tl:39

Returns the build version

Rückgabe 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 Typ Beschreibung
relativePath string a relative path

Rückgabe 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)

Rückgabe 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!

Rückgabe string: modId string

addModifier<T>(fileName : string, data : T) : T api/tealdef/main.d.tl:59

Hinweise

Registriert eine Modifier-Funktion für einen Ressourcen-Loader. Der Modifier erhält jede geladene Ressource dieser Art und gibt sie zurück, bei Bedarf geändert.

Parameter Typ Beschreibung
fileName string In der Praxis die Ressourcenkategorie, z. B. loadModel oder loadConstruction.
data T In der Praxis die Modifier-Funktion: Sie erhält den Dateinamen und die geladenen Daten und gibt die Daten zurück.

Rückgabe T

Details

Mods rufen sie in der Funktion auf, die runScript in mod.json nennt (z. B. mods/release/urbangames_vehicles_no_end_year/content/mod.script.lua). Die Basisimplementierung in base/content/base/base/mod.lua erwartet eine Ressourcenkategorie und eine Modifier-Funktion, die Parameternamen in der Definition führen also in die Irre. Eine unbekannte Kategorie löst einen Fehler aus. Das Wiki empfiehlt, wo möglich postRunFn mit api.res zu nutzen.

Beispiel

-- aus base/base_mod.lua (runFn)
addModifier("loadModel", function(fileName, data)
  local tv = data.metadata.transportVehicle
  if tv then
    -- hier die Fahrzeug-Metadaten anpassen
  end
  return data
end)

game

record global api/tealdef/main.d.tl:61

global record game

Hinweise

Globale Tabelle, über die geladene Skripte und ihre Funktionen erreichbar sind. Das Basisskript scripts/util.tl (util.useFn) löst eine Referenz "<file>@<a.b.c>" auf, indem es game[file].a.b.c durchläuft.

Felder

Name Typ Beschreibung
res Res

Funktionen

metamethod __index(game, string) : game api/tealdef/main.d.tl:62

Hinweise

Erlaubt für die Typprüfung jeden Schlüssel auf game; das Ergebnis hat wieder den Typ game.

Rückgabe game

game.Res

record api/tealdef/main.d.tl:64

record Res

Die Spieldateien enthalten hierzu noch keine Beschreibung.

Felder

Name Typ Beschreibung
script table