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

Script:Flip Tokens

From Roll20 Wiki

Revision as of 17:59, 8 January 2015 by Brian (Talk | contribs)

Jump to: navigation, search

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'));
            }
        });
    }
});