Meta API

From TargetWiki

The Meta API is for talking to the Metaserver. The Metaserver manages a list of all online Targetware servers, as well as version status and download locations for mods and other downloads.

meta.name()
This returns your Targetware user name.
meta.setname( <string> )
Use this to set the user name you wish to log in to Targetware with.
meta.password()
This returns your Targetware password.
meta.setpassword( <string> )
Use this to set the password you wish to log in to Targetware with.
meta.metaserver()
Returns the hostname and port of the metaserver.
meta.setmetaserver( <string>, <number> )
Sets the hostname and port of the metaserver.
meta.fetchservers()
This updates the list of online Targetware servers. Information about those servers will be returned through the meta event handler during the update, and is available through meta.servercount() and meta.serverinfo() at any time.
meta.ping( <number> )
This refreshes the information for a single server. The number specified is the index to the server you wish to update, and should be between 1 and server.count(). Once available, the results will be returned through the meta event handler with a meta.serverdata message, after which they will also be available from meta.serverinfo().
meta.servers()
Returns an array of the available servers. Each array entry is a table containing five values: "owner", a string containing the name of the server's operator; "latency", the latency to the server in seconds; "members", the number of players currently logged in; "maxmembers", the maximum number of players allowed; and "message", a string containing a server specific message.
meta.fetchdata()
This updates the metadata table. The metadata table is a table received from the metaserver that contains information about available downloads, and where to download them.
meta.data()
This returns the metadata table itself, as a Lua table.
meta.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.
  • meta.connecting. One additional argument, which is a string containing the IP address being connected to.
  • meta.connected. No additional arguments.
  • meta.loggedin. No additional arguments.
  • meta.error. No additional arguments. The metaserver connection has shut down.
  • meta.networkerror. The connection to the metaserver has failed. One additional argument, a number specifying the cause of the error, which will be one of the standard network errors.
  • meta.servercount. One additional argument, a number specifying the total number of servers to expect to be added. This message is received before the information for any servers is actually received.
  • meta.serveradd. Two additional arguments. The first is the index for this server, the number that would be passed to meta.serverinfo() or meta.ping(). The second is a string containing the name of the server operator.
  • meta.serverdata. Six additional arguments. The first is the index for this server, the number that would be passed to meta.serverinfo() or meta.ping(). The remaining five are the same five returned by meta.serverinfo().
  • meta.serverscomplete. No additional arguments. This indicates that a meta.serveradd message has been received for every available server. More specific information for servers will be available as meta.serverdata messages arrive.
  • meta.datacomplete. No additional arguments. Received after a call to meta.fetchdata(), this indicates that the metadata table is complete and available from meta.data().
  • meta.refreshed. No additional arguments. Your server was already registered with the metaserver, and has refreshed its entry.
  • meta.registered. No additional arguments. Your server has successfully registered with the metaserver.
  • meta.registerednat. No additional arguments. Your server has registered with the metaserver, but the metaserver thinks it's possible your server is behind a firewall and is unreachable. If you've opened a port to your server through your firewall already, you can ignore this message.
  • meta.unregister. No additional arguments. Your server has unregistered with the metaserver.
  • meta.unregisterfailed. No additional arguments. Your server tried to unregister with the metaserver, but the metaserver didn't think you were registered in the first place.
  • meta.downloadconnectfailed. No additional arguments. You've tried to download something, but were unable to connect to the download server.
  • meta.downloadprogress. Four additional arguments. The first is a string containing the name of the file being downloaded, the second is the length of the file in bytes, the third is the percentage of the file that's been downloaded already, and the fourth is the current speed of the download in kilobytes per second.
  • meta.downloadcomplete. Your download has finished successfully.
  • meta.downloaderror. Your download has failed. The portion of the download that was successful will be kept, so that if you try the download again, it will pick up from where it left off.
meta.download( <string> )
Download or update a package from the metaserver. The string passed in is not a filename or a URL, but a reference to the metatable. The string should consist of the category name, a slash, and then the package name, for example: "Mods/Richthofen's Skies".
meta.stopdownload()
This stops the current download. The portion you have downloaded so far will be kept, so that if you try the download again, it will pick up from where it left off.
Views