Application API

From TargetWiki

External API

Application scripts have the following Lua APIs available:

Internal API

In addition, application scripts have access to the 'app' API, which is composed of:

app.version()
This returns a string containing the current Targetware version number.
app.eventhandler()
This returns a standard Targetware event handler. When the event handler's function(s) are called, the first argument indicates the type of event.
  • app.appquit. Targetware is about to quit. No additional arguments.
  • app.clientconnecting. Targetware is trying to connect to a game server. One additional argument, a string containing the IP address being connected to. It's possible to receive more than one of these messages before a connection is established if a server has more than one IP address.
  • app.clientconnected. Targetware has connected to a game server. No additional arguments.
  • app.clientloggedin. Targetware has successfully logged in to a game server. No additional arguments.
  • app.clientnetworkerror. The connection to the game server has failed. One additional argument, a number specifying the cause of the error, which will be one of the standard network errors.
  • app.clientscriptfailed. The client script specified by the game server couldn't be loaded.
  • app.clientquit. The client script has quit, returning control to the main application script.
  • app.serverquit. The local server script has quit.
app.quit()
This quits Targetware. The application script will receive an app.appquit event before termination.
app.create( <string>, <boolean> )
This creates a new server. The first argument is a string containing the name of the Lua script to run, and the second argument is a boolean indicating whether this server should register itself with the metaserver and accept connections from other players or not. If a server is created while running in non-dedicated mode, the application will also connect to it as a client.
app.join( <number> )
This attempts to joing a game server that is registered with the metaserver. The argument is the index to the list of servers in the Meta API, the same index that's passed to meta.ping() and meta.serverinfo().
Views