A script runs from the moment a bot starts it until something stops it, and it keeps little from one run to the next. States and controls describes the same buttons from the player's side.
Starting a script
| Where | Control | What it does |
|---|---|---|
| Package editor | Run | Saves the package, stops the script the chosen bot is running, sets this package as the bot's package, then starts it. |
| Bot's page, or its row in Bot Manager | Play | Starts the bot's package, or the inline script loaded last. It's disabled until the bot is connected to a game. When the bot has nothing to play, it opens Load a behavior selection instead. |
| Menu next to Play on the bot's page | Load a package and play it | Opens Load a behavior selection, then starts what you picked. |
Each start builds a new copy of the script from the files saved in the library at that moment, then calls its entry function. Saving in the editor doesn't change a script that's already running: click Run, or Stop then Play, to start the code you saved.
After a script has failed, Play starts a new copy right away. There's nothing to stop first.
Stopping a script
| What stops it | The game connection | Error shown |
|---|---|---|
| Stop | Stays open | No |
| Load a new package, once you confirm the dialog | Stays open | No |
| Unload package | Stays open | No |
| Disconnect | Closed | No |
| Delete bot | Closed | No |
| An error in the script | Stays open | Yes, that error |
The script calls disconnect() |
Closed | Yes, starting with behavior requested Game disconnect |
| The connection closes on its own, for example when the game server ends it, or when the Dofus client of a MITM bot (man-in-the-middle: the bot relays the game session of a Dofus client someone plays) closes | Gone | Yes, starting with Game session closed |
An error shown means the alert The behavior stopped with an error at the top of the bot's page, and Failed in the Behavior column of Bot Manager. Errors explains each text.
Once a script is stopped, its handlers receive nothing more and its interceptors aren't asked anymore, so messages go through unchanged. The calls it was still waiting on reject: a sleep(), wait(), send(), request() or game data call in progress. After Stop, their error is behavior runtime closed. If a catch in your script logs errors, that line can appear in the bot's console right after you stop it.
What starts over and what's kept
Each start is a fresh copy. Every variable in your modules starts again from its initial value, and top-level code runs again. The handlers, waits and sleeps of the previous run are gone, and the messages that arrived while no script was running are never delivered to the new one.
What survives lives outside the script: the game connection and the character's situation in the game, the package and version the bot is set to play, and the values on the bot's Package settings. launch.generation also keeps counting for as long as the connection stays open.
A script has nowhere to keep data for its next run. It can't write files, and values is read-only. Anything it needs again has to come from the game, or from a setting someone fills in.
Changing the code or the version
Save only changes what the next start loads, as described above.
When you switch the bot to another installed version of its package from the bot's page, the running script also keeps going. The toast says Now set to version followed by the version, and adds The running behavior keeps going until you play or reload. when a script is running. The next start uses the new version.
Settings you apply from Package settings are the exception: they reach the running script without a restart. See Read settings.
The "reload" launch reason
A start can replace a running script without stopping it first. The new copy then takes over the game connection directly, and the messages that arrive during the switch wait for it instead of being lost. That start's launch.reason is "reload".
No button in Asteroboard starts a script this way, and there's no Reload button. Run, Load a new package and Load a package and play it all stop the running script first, so the script that follows starts with "resume", or with "initial" on a Full socket connection where no script has started successfully yet. Handle "reload" like "resume" in your code.
When the connection drops
Nothing restarts by itself. When a Full socket bot connects again, or when a Dofus client connects through a MITM bot again, the bot shows Connected to game server with no script running. Click Play.
That start is the first one on a new connection: launch.generation is 1n, and launch.reason is "initial" on a Full socket bot, "resume" on a MITM bot.
After Asterobot restarts
When Asterobot starts again, every bot comes back disconnected and no script runs. Asterobot doesn't connect a bot or start a script on its own.
Each bot keeps the package and version it's set to play, whether that came from Run, from Load a new package with a library package, from the Add a bot dialog or from the bot's Settings. Its package settings are kept too. An inline script isn't: load it again after the restart.
Closing Asteroboard stops nothing, because scripts run inside Asterobot. Disconnect, delete and restart covers these cases from the player's side.
Next, Modules and imports.
Aucun avis à afficher.