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
m
m
 
(10 intermediate revisions by one user not shown)
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.3
 +
|dependencies={{api repository link|splitArgs}}
 +
|lastmodified=2016-03-09}}
  
==== Syntax ====
+
'''Flip Tokens''' 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|Flip Tokens}}
/**
+
{{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}}
 +
 
 +
=== Changelog ===
 +
{{changelog version|2.3|2016-03-09|* Update for one-click install}}
 +
{{changelog version|2.2|2015-01-24|* [bugfix] no-arg crash}}
 +
{{changelog version|2.1|2015-01-22|* Fixed transcription error}}
 +
{{changelog version|2.0|2015-01-08|* Release}}

Latest revision as of 04:49, 13 April 2016

API ScriptAuthor: Brian
Version: 2.3
Last Modified: 2016-03-09
Code: Flip Tokens
Dependencies: splitArgs
Conflicts: None

Flip Tokens creates the API command !flip, which flips the selected graphics horizontally or vertically (or both).

[edit] 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.

[edit] Changelog

v2.3 (2016-03-09)

  • Update for one-click install


v2.2 (2015-01-24)

  • [bugfix] no-arg crash


v2.1 (2015-01-22)

  • Fixed transcription error


v2.0 (2015-01-08)

  • Release