Meeple
Meeple is a JavaScript library for interacting with the Roll20 Scripting API, focused on token behavior. Using Meeple, you can create a scene and then script tokens to interact with the scene as meeples.
Example Usage
Meeple is designed to help reduce the overhead for scripting behavior. As an example, let's look at the "Patrolling Token" example given in the Advanced Examples documentation for the Roll20 Scripting API. In the example, you're writing a script to simulate a guard patrolling back and forth in a hallway. Here's how you could do it with Meeple.
import { Meeple, Scene } from 'meeple';
const guard = new Meeple('Guard A', () => {
if (this.stepsTaken > 3) {
this.walkingRight = !this.walkingRight;
this.stepsTaken = 0;
}
if (this.walkingRight) {
this.token.move(0, 1);
} else {
this.token.move(0, -1);
}
this.stepsTaken++;
});
guard.stepsTaken = 0;
guard.walkingRight = true;
const scene = new Scene([guard], {
clockSpeed: 5000,
});
scene.start();