Core Types
BotFilter
Defines a bot filter function.
Common bot filters are
byTag(tag, filter)
A BotFilter can be one of the following values:
(bot: Bot) => boolean
null
Space
The possible bot spaces.
"shared"
means that the bot is a normal bot."local"
means that the bot is stored in the local storage partition."tempLocal"
means that the bot is stored in the temporary partition."tempShared"
means that the bot is temporary and shared with other devices."remoteTempShared"
means that the bot is temporary and shared with this device from a remote device.
A Space can be one of the following values:
"shared"
"local"
"tempLocal"
"history"
"admin"
"tempShared"
"remoteTempShared"
"certified"
BotState
Defines an interface that contains a set of bots that have been indexed by their IDs.
Generally, this is only used when working with groups of bots. For example, the
diffSnapshots(first, second)
function takes two bot states and produces the difference between them.Members
Examples
Create a bot state with two botslet state = {
[bot1.id]: bot1,
[bot2.id]: bot2
};Get a bot by its ID from a bot statelet bot = state[botId];
TagMasks
Defines an interface for a map of tag masks to tag names.
Tag masks are special tags that can exist in a different space from the bot they are applied to. This makes it possible to have some local-only data applied to a shared bot for example.
The actual data structure is similar to the bot tags structure except that tags are additionally split by the space that they originated from. This makes it possible to identify which space a tag came from and also prevents cross-space conflicts.
interface TagMasks { [space: string]: Tags; }
Members
Tags
Defines an interface that represents a set of tags and their related values.
interface Tags { [tag: string]: any }
Members
Index Signature
Gets or sets the given tag on the bot.
[tag: string]: any
Examples
Get the #color on this botlet color = thisBot.tags.color;
Get a raw tag on this botlet rawTag = thisBot.raw.tag;
Set the #color tag to "red" on this botthisBot.tags.color = "red";
Set a tempLocal tag mask for #color on this botthisBot.masks.color = "red";
PartialBotState
Defines an interface that contains a set of partial bots that have been indexed by their IDs.
Generally, this is only used when working with differences between groups of bots. For example, the
applyDiffToSnapshot(snapshot, diff)
function takes a bot state and a partial bot state and produces a final state that contains the combined result.Members
Bot
Defines an interface for a bot in a script/formula.
The difference between this and Bot is that the tags are calculated values and raw is the original tag values.
i.e. tags will evaluate formulas while raw will return the formula scripts themselves.
Members
Index Signature
Gets the listener or bot property with the given name.
If given a property name, like
"tags"
or"vars"
, then it will return the value of that property. Alternatively, if the name does not match an existing property on the bot, then it will return the listener with the given name.[listenerOrProperty: string]: (((arg: any) => any) | any)
Examples
Get the tags of a botlet tags = bot.tags;
Get the links of a botlet links = bot.links;
Get theGet a property on a bot by a variablelet propertyToGet = 'tags';
let tags = bot[propertyToGet];id string
The ID of the bot.
link string
The link to the bot.
Variables
Defines an interface that represents the variables a bot can have. Variables are useful for storing data that is not able to be saved to a tag.
interface Variables { [variable: string]: any; }
Members
Index Signature
Gets or sets a variable on the bot.
[variable: string]: any
Examples
Get a variable on thisBotlet variable = thisBot.vars.variable;
Save a variable on thisBotthisBot.vars.variable = variable;
TagFilter
Defines the possible values that can be used as a tag filter.
A TagFilter can be one of the following values:
(value: any) => boolean
string
number
boolean
null
undefined
BotAnchorPoint
Defines the possible bot anchor points.
A BotAnchorPoint can be one of the following values:
"top"
"front"
"back"
"left"
"right"
"bottom"
"center"
readonly [number, number, number]
PortalType
The possible portal types.
A PortalType can be one of the following values:
"grid"
"miniGrid"
"menu"
"sheet"
"meet"
"system"
string
PseudoRandomNumberGenerator
Defines an interface for a random number generator.
Members
seed (string | number)
The seed used for this random number generator. If null then an unpredictable seed was used.
random(): number
Generates a random number between 0 and 1.
randomInt(min: number, max: number): number
Generates a random integer between the given min and max values.
The first parameter is a number and is the minimum output number.
The second parameter is a number and is the maximum output number.