Console

From A Township Tale Wiki
Jump to navigation Jump to search

Each server has a Console that can be connected to by server owners. The Console allows for spawning of items, teleporting of players, and many more abilities. It can be connected to via the Dashboard, or through a custom bot or tool using a library like js-tale or att-websockets.

All communication done with the Console is through 'statements', a line of text that can contain commands, or more advanced Console features.


Commands and Responses

At the core of the Console is a collection of commands. Commands may do things (eg. spawn an item), or simply access data. After a command has run, it returns a response. A response may contain information (eg. the ID of the spawned item), be empty (successful, but have no additional information), or contain an error.

Modules

Modules are collections of commands. They can also contain submodules to further categorize commands.

Command syntax

A command is invoked through is full path (modules and command name (if any)), as well as any arguments.

For instance, the module spawnhas a submodule called list, which has a command called materials. This command takes no arguments. To invoke this command, the following statement would be used: spawn list materials.

As a second example, the module `spawn` also has an unnamed (aka. 'default') command, with 3 parameters: the players, the prefab, and arguments. To invoke this command, the following statement could be used: spawn Joel stone 10

List of modules and commands

An up to date list of all modules, commands, and their parameters can be found on the right hand side in the dashboard after connecting to a server.

If you want to parse the data yourself, you can also invoke the command `help modules`.

Statements (Future Feature)

Note: This feature does not exist yet, but is planned for the future.

A statement can be much more than a single command. Statements can also include inner statements, data accessors, math operators, logic operators, and more.

Data accessors

In a basic statement, containing nothing but a single command, the command returns a result, and that result is then passed back as a response from the Console . For example, player list might return [ { "id":100, "username":"Joel" }, { "id":200, "username":"Narmdo" } ].

Data can be manipulated to return information in a format more useful for your situation. In this case, the data being dealt with is an array. If only the names were needed, the statement player list.select.usernamecould be used to return [ "Joel", "Narmdo" ].

Inner statements

A statement can be embedded within another statement to pass results from one into the other. To do this, wrap the inner statement with parenthesis (( and )). This can also be used to control order of operations while dealing with numbers or booleans within a statement.

spawn (player list.random.id) stone