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.
Examples
let state = {
[bot1.id]: bot1,
[bot2.id]: bot2
};
let 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;
}
Tags
Defines an interface that represents a set of tags and their related values.
interface Tags {
[tag: string]: any
}
Index Signature
Gets or sets the given tag on the bot.
[tag: string]: any
Examples
let color = thisBot.tags.color;
let rawTag = thisBot.raw.tag;
thisBot.tags.color = "red";
thisBot.masks.color = "red";
Listeners
An interface that maps tag names to compiled listener functions.
interface Listeners {
[tag: string]: (arg?: any) => any;
}
Mod
Defines a type that represents a mod. That is, a set of tags that can be applied to another bot.
ParsedBotLink
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.
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.
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
let tags = bot.tags;
let links = bot.links;
let onClick = bot.onClick;
let propertyToGet = 'tags';
let tags = bot[propertyToGet];
id: string
The ID of the bot.
link: string
The link to the bot.
Links
Defines an interface that represents the bot links a bot can have.
interface Links {
[link: string]: Bot | 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;
}
Index Signature
Gets or sets a variable on the bot.
[variable: string]: any
Examples
let variable = thisBot.vars.variable;
thisBot.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
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.
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.