Difference between revisions of "Bot Playground/Built-in Functions/localStorage.set"
From SmartBots Developers Docs
Line 25: | Line 25: | ||
Also note that localStorage supports string values only. To save something more complicated, use JSON.stringify(var). | Also note that localStorage supports string values only. To save something more complicated, use JSON.stringify(var). | ||
+ | == Inter-script communication == | ||
+ | |||
+ | Executing localStorage.set() will cause [[Bot Playground/Built-in Functions/localStorage.on|localStorage.on("update")]] event to fire on ''other scripts of this bot''. | ||
{{NavMenu}} | {{NavMenu}} |
Revision as of 21:57, 14 July 2018
Puts a string value into a persistent storage. Also check localStorage.get().
localStorage.set(name, value);
Reference
This command accepts the following parameters:
Variable | Required | Description
| |
---|---|---|---|
Input: | |||
name | yes | the name of the persistent value you would like to store | |
value | yes | the value you want to save. | |
Output: | |||
result | This function does not return anything |
Comments
This function works similar to browser JavaScript localStorage.set(). It saves value into a persistent storage.
localStorage is shared by all scripts of the same bot. Thus, you can set values in one bot script and retrieve it in another script.
Also note that localStorage supports string values only. To save something more complicated, use JSON.stringify(var).
Inter-script communication
Executing localStorage.set() will cause localStorage.on("update") event to fire on other scripts of this bot.