Utility Actions
animateTag(bot: (string | Bot | (string | Bot)[]), options: AnimateTagOptions): Promise<void>
Animates multiple tags on the given bot based on the specified parameters.
This works similarly to animateTag(bot, tag, options)
but instead of providing a tag name, you instead provide an object for the fromValue and toValue options which contains the tags that should be animated.
Returns a promise that resolves when the animation is finished and throws an error when the animation is canceled. This is useful for gradually changing a set of tags on a bot over time. For example, moving a bot from point A to point B without teleporting it.
Unlike calling animateTag(bot, tag, options)
multiple times, animations started with this function are grouped together. This means that canceling one animation in the group will also cancel the others.
This function is fully integrated with tag masks. This lets you animate tag values in the tempLocal, local, player, and shared spaces.
The first parameter is a (string | Bot | (string | Bot)[]) and is the bot, bot ID, or list of bots that the tag should be animated on.
The second parameter is a AnimateTagOptions and is the options that should be used to animate the tag. If null is used, then any active animations for the tag on these bots will be canceled.
Examples
await animateTag(bot, {
fromValue: {
homeX: 0,
homeY: 0,
},
toValue: {
homeX: 1,
homeY: 1
},
duration: 5
});
os.toast("Animation finished!");
await animateTag(bot, {
fromValue: {
homeX: 0,
homeY: 0,
},
toValue: {
homeX: 5,
homeY: 5
},
duration: 2,
tagMaskSpace: 'tempShared'
});
animateTag(bot: (string | Bot | (string | Bot)[]), tag: string, options: AnimateTagOptions): Promise<void>
Animates the tag on the given bot based on the specified parameters. Returns a promise that resolves when the animation is finished and throws an error when the animation is canceled. This is useful for gradually changing a tag on a bot over time. For example, moving a bot from point A to point B without teleporting it.
animateTag(bot, tag, options)
is fully integrated with tag masks. This lets you animate tag values in the tempLocal
, local
, player
, and shared
spaces.
The first parameter is a (string | Bot | (string | Bot)[]) and is the bot, bot ID, or list of bots that the tag should be animated on.
The second parameter is a string and is the tag that should be animated.
The third parameter is a AnimateTagOptions and is the options that should be used to animate the tag. If null is used, then any active animations for the tag on these bots will be canceled.
Examples
await animateTag(bot, "count", {
fromValue: 0,
toValue: 1,
duration: 5
});
os.toast("Animation finished!");
await animateTag(bot, "homeX", {
fromValue: 0,
toValue: 5,
duration: 2
});
await animateTag(bot, "homeY", {
fromValue: 0,
toValue: 5,
duration: 2
});
while(tags.loop) {
await animateTag(bot, "homeX", {
fromValue: 0,
toValue: 5,
duration: 2
});
}
await animateTag(bot, "homeX", {
fromValue: 0,
toValue: 5,
duration: 2,
easing: {
type: "elastic",
mode: "out"
}
});
await animateTag(bot, "homeX", {
fromValue: 0,
toValue: 5,
duration: 2,
easing: (k) => {
return Math.floor(k * 10) / 10;
}
});
await animateTag(bot, "homeX", {
fromValue: 0,
toValue: 5,
duration: 2,
startTime: os.localTime + 1000,
});
await animateTag(bot, "homeX", {
fromValue: 0,
toValue: 5,
duration: 2,
tagMaskSpace: 'tempShared'
});
animateTag(bot, "homeX", {
fromValue: 0,
toValue: 5,
duration: 2
}).then(() => {
os.toast("Animation Finished!");
}).catch(() => {
os.toast("Animation Canceled!");
});
await os.sleep(500);
animateTag(bot, "homeX", null);