Messages are full of numbers that stand for something: an item, a monster, a map, a line of text. asterobot:gamedata lets a script look those up in the game data Asterobot extracted from the bot's game version.
What a script can read
| Function | What it reads | Result |
|---|---|---|
text() |
One game text, by its numeric id or its text key | Returned right away |
record() |
One row of a table, by its key | Returned right away |
table() |
The rows of a table, a page at a time | A promise |
find() |
The rows of a table whose columns hold given values | A promise |
search() |
Records, by their name | A promise |
query() |
The result of a read-only SQL query | A promise |
Lookups covers the first five functions, and SQL queries the last one.
The tables hold what Asterobot extracted from the game: items, monsters, spells, sub-areas, maps and much more. Some mirror the game's own data. Others are derived by Asterobot to answer questions the game's files can't, such as which maps hold a given resource. Their names contain two underscores, like maps__interactive_elements. The _names table links every name to its record, in every extracted language.
To see which tables exist and what their columns are called, open the bot's game version from Game Manager and go to its Game data tab, described in Game data. The editor's Game panel has the same browser under Datacenter, but it shows the game version this Asterobot is tested against, which isn't always your bot's.
Table and column names come from the game's own data, so they can change when Ankama updates the game. After a game update explains how to keep scripts working through updates.
Which game version and which language
A script reads the game data of the bot's game version, the one set on the bot.
text() and search() answer in the language the script was started with, session.language. Right now that's fr for every start made from Asteroboard, whatever language the bot itself is set to, as Identify and run says. So these two functions return French texts and look for French names. To read another language, use query() on the _names table, which has a language column, or on the text table of that language: SQL queries shows how.
When game data is available
A game version has game data once it has been extracted, as Extract game data explains. A Full socket bot can't connect before that. A MITM bot (man-in-the-middle: the bot relays the game session of a Dofus client someone plays) can, so its script may run without any game data.
When a script starts, Asterobot opens the game data of the bot's game version, and the game's text file for the script's language. If one of them isn't there, the script starts anyway:
| Missing when the script started | What the script gets, until its next start |
|---|---|
| The extracted game data | record() returns undefined, and table(), find(), search() and query() resolve to undefined instead of results. |
| The game's text file for the script's language | text() returns undefined for every key. |
Extracting the game data while such a script runs doesn't change anything for that run: start the script again. The other way round works: when a game version is extracted again while a script runs, the script's next lookup reads the new data.
To tell missing game data apart from an empty result, compare with undefined:
const rows = await table("breeds", { limit: 1 });
if (rows === undefined) {
botWarn("This bot's game version has no extracted game data.");
}
Right away or with a promise
text() and record() return their result directly. The texts are already in memory, and a record is one indexed read, fast enough to call inside a loop. Their time still counts toward the 250 ms limit of the code calling them, described in Async and timing, so thousands of calls in a row can go over it.
table(), find(), search() and query() return promises. They can return thousands of rows, so their work happens outside your code, and the bot keeps handling messages while they run.
Limits every lookup shares
| Limit | Value | Past it |
|---|---|---|
Time for a table(), find(), search() or query() call |
30 seconds | The promise rejects. No option changes this time. |
Time for the SQL of a query() |
10 seconds | The query is interrupted and the promise rejects. |
| Rows returned by one call | 200 unless you pass a limit, 5,000 at most |
Only the first rows come back. query() sets truncated. |
| Calls in progress at once | 32, counted together with send() and request() |
The call rejects with behavior resource limit exceeded: maximum pending operations reached. |
| Queries running at once on one game version | 4, shared by every bot and every open SQL tab | Other queries wait for their turn, within their time limits. |
Limits lists every limit, and the asterobot:gamedata reference every function.
Next, Lookups.
Aucun avis à afficher.