Character Vault
Any Concept / Any System
Compendium
Your System Come To Life
Roll20 for Android
Streamlined for your Tablet
Roll20 for iPad
Streamlined for your Tablet

Personal tools

Difference between revisions of "Mod:Basic Examples"

From Roll20 Wiki

Jump to: navigation, search
m
Line 1: Line 1:
 +
{{apibox}}
 +
 
The Cookboox provides some examples of simple scripts that can help you get started. Feel free to take them and modify them for use in your own campaigns.
 
The Cookboox provides some examples of simple scripts that can help you get started. Feel free to take them and modify them for use in your own campaigns.
  

Revision as of 20:33, 23 April 2013


The Cookboox provides some examples of simple scripts that can help you get started. Feel free to take them and modify them for use in your own campaigns.

Bloodied and Dead Status Markers (Contributed by Ken Bauer)

This script automatically adds the Red marker to represent the "bloodied" state for any tokens that drop below half their health, and the "dead" market for any that drop to 0 or less. It's assumed that health is stored in Bar 1.

on("change:graphic", function(obj) {
    if(obj.get("bar1_max") === "") return;
   
    if(obj.get("bar1_value") <= obj.get("bar1_max") / 2) {
        obj.set({
              status_redmarker: true
        });
    }
    else{
        obj.set({
            status_redmarker: false
        })
    }

    if(obj.get("bar1_value") <= 0) {
      obj.set({
         status_dead: true
      });
    }
    else {
      obj.set({
        status_dead: false
      });
    }
});

The Darkness is Closing In...

This script reduces the light radius of a token by 10% every time that token moves. Great for simulating "lamps running out of oil" or similar high-stress situations.

on("change:token", function(obj) {
    //Only do this if we actually moved.
    if(obj.get("left") == obj.previous("left") && obj.get("top") == obj.previous("top")) return;
    obj.set({
        light_radius: Math.floor(obj.get("light_radius") * 0.90)
    });
});