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 "Script:Flip Tokens"

From Roll20 Wiki

Jump to: navigation, search
(new)
 
m
Line 1: Line 1:
The following script creates the API command <tt>!flip</tt>
+
The following script creates the API command <code>!flip</code>
  
 
==== Syntax ====
 
==== Syntax ====

Revision as of 01:36, 31 August 2013

The following script creates the API command !flip

Syntax

!flip

Code

/**
 * If a player or GM uses the `!flip' command, all graphics they have selected
 * will flip horizontally. Try creating a macro button for this and making it
 * visible to all players!
 */
on('chat:message', function(msg) {
    if(msg.type == 'api' && msg.selected && msg.content.indexOf('!flip') == 0)
    {
        var selectedObjs = msg.selected;
        _.each(selectedObjs, function(obj) {
            if(obj._type == 'graphic')
            {
                var token = getObj('graphic', obj._id);
                token.set('fliph', !token.get('fliph'));
            }
        });
    }
});