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
Line 1: Line 1:
The following script creates the API command <code>!flip</code>
+
{{script overview
 +
|name=Flip Tokens
 +
|author={{user profile|235259|Brian}}
 +
|version=2.0
 +
|lastmodified=2015-01-08}}
  
==== Syntax ====
+
The following script creates the API command <code>!flip</code>, which flips the selected graphics horizontally or vertically (or both).
<blockquote style="border:1px #0088ee solid;background:#eee;padding:0.5em">!flip</blockquote>
+
<br clear="all">
  
==== Code ====
+
=== Syntax ===
<pre data-language="javascript">
+
{{syntaxbox top|formal=true}}
/**
+
{{API command|flip}} {{API parameter|name=direction|optional=true}}
* If a player or GM uses the `!flip' command, all graphics they have selected
+
{{Formal API command|
* will flip horizontally. Try creating a macro button for this and making it
+
{{token|S}} {{rarr}} {{API command|flip}} {{token|directionList|-}}
* visible to all players!
+
{{token|directionList}} {{rarr}} {{epsilon}}
*/
+
{{token|directionList}} {{rarr}} horizontal {{token|directionList|-}}
on('chat:message', function(msg) {
+
{{token|directionList}} {{rarr}} vertical {{token|directionList}}
    if(msg.type == 'api' && msg.selected && msg.content.indexOf('!flip') == 0)
+
}}
    {
+
{{syntaxbox end}}
        var selectedObjs = msg.selected;
+
        _.each(selectedObjs, function(obj) {
+
            if(obj._type == 'graphic')
+
            {
+
                var token = getObj('graphic', obj._id);
+
                token.set('fliph', !token.get('fliph'));
+
            }
+
        });
+
    }
+
});
+
</pre>
+
  
[[Category:User API Scripts|Flip Tokens]]
+
{{param description top}}
[[Category:API Commands|Flip Tokens]]
+
{{param description|name=direction|value=The flip direction can be either <code>horizontal</code> or <code>vertical</code>. You can use any number of directions, which will be executed in order.}}
 +
{{param description bottom}}

Revision as of 22:09, 8 January 2015

API ScriptAuthor: Brian
Version: 2.0
Last Modified: 2015-01-08
Code: Flip Tokens
Dependencies: None
Conflicts: None

The following script creates the API command !flip, which flips the selected graphics horizontally or vertically (or both).

Syntax

!flip [direction]
Formally:

S

→ !flip directionList


directionList

→ ε

directionList

→ horizontal directionList


directionList

→ vertical directionList


Parameter Values
direction The flip direction can be either horizontal or vertical. You can use any number of directions, which will be executed in order.