Difference between revisions of "Bot Playground/Examples/Region restart"

From SmartBots Developers Docs
Jump to: navigation, search
(Created page with "The following script uses commands and events to work with region restarts: # It restarts region # Sleeps for 10 seconds # Then cancels restart # All restart events are being...")
 
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
 
# Then cancels restart
 
# Then cancels restart
 
# All restart events are being logged as well
 
# All restart events are being logged as well
 +
 +
== Code ==
  
 
<syntaxhighlight lang="javascript">
 
<syntaxhighlight lang="javascript">
Line 21: Line 23:
 
console.log("Region restart requested");
 
console.log("Region restart requested");
  
await sleep(10);
+
await sleep(10 * 1000);
  
 
Bot.regionRestartCancel();
 
Bot.regionRestartCancel();
 
console.log("Region restart cancelled");
 
console.log("Region restart cancelled");
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 18:00, 6 October 2022

The following script uses commands and events to work with region restarts:

  1. It restarts region
  2. Sleeps for 10 seconds
  3. Then cancels restart
  4. All restart events are being logged as well

Code

console.log(`${process.name} started`);

Bot.on("region_restart", (event) => {
	console.log(`region_restart:`, event);
});


Bot.on("region_restart_cancelled", (event) => {
	console.log(`region_restart_cancelled:`, event);
});

Bot.regionRestart(240);
console.log("Region restart requested");

await sleep(10 * 1000);

Bot.regionRestartCancel();
console.log("Region restart cancelled");