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:Exalted Successes"

From Roll20 Wiki

Jump to: navigation, search
(new)
 
(Api discontinued, link to closest replacement)
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
After posting a message with a roll (either regular or inline) which uses d10s, the script will echo the number of successes (or botches) using the dice system in ''Exalted''. This script does not take into account Sidereal Astrology modifying the target number, nor does it try to filter players posting a roll with modifiers and the like. This script does not scrutinize based on normal die rolls (10s count double) vs. damage rolls (10s don't count double).
+
#redirect[[Script:exaltScript]]
  
If this script is in the campaign, every roll which uses d10s will be reported.
+
Api discontinued, link to closest replacement
  
==== Code ====
+
script overview
<pre data-language="javascript">
+
|name=Exalted Successes
var exalted = exalted || {};
+
|author={{user profile|235259|Brian}}
+
|version=2.2
exalted.sendChat = function(name, id, msg)
+
|dependencies={{api repository link|Interpreted sendChat}}
{
+
|lastmodified=2016-03-09
    var characters = findObjs({_type: 'character'});
+
    var speaking;
+
    characters.forEach(function(chr) { if(chr.get('name') == name) speaking = chr; });
+
    if(speaking) sendChat('character|'+speaking.id, msg);
+
    else sendChat('player|'+id, msg);
+
};
+
+
on('chat:message', function(msg) {
+
    var json;
+
    var inline = false;
+
    try { json = JSON.parse(msg.content); }
+
    catch(e)
+
    {
+
        if(msg.inlinerolls) inline = true;
+
        else return;
+
    }
+
   
+
    var results = [];
+
    if(!inline)
+
    {
+
        json.rolls.forEach(function(j) {
+
            if(j.sides != 10) return;
+
            results.push(j.results);
+
        });
+
    }
+
    else
+
    {
+
        json = msg.inlinerolls;
+
        json.forEach(function(j) {
+
            var rolls = j.results.rolls;
+
            rolls.forEach(function(r) {
+
                if(r.sides != 10) return;
+
                results.push(r.results);
+
            });
+
        });
+
    }
+
   
+
    var successes = 0;
+
    var botches = 0;
+
    results.forEach(function(r) {
+
        r.forEach(function(d) {
+
            var die = d['v'];
+
            successes += die >= 7 ? 1 : 0
+
            successes += die == 10 ? 1 : 0;
+
            botches += die == 1 ? 1 : 0;
+
        });
+
    });
+
   
+
    if(successes == 0 && botches != 0)
+
    {
+
        exalted.sendChat(msg.who, msg.playerid, botches+' botch'+(botches>1?'es':''));
+
    }
+
    else if(successes == 0)
+
    {
+
        exalted.sendChat(msg.who, msg.playerid, 'Failure');
+
    }
+
    else
+
    {
+
        exalted.sendChat(msg.who, msg.playerid, successes+' success'+(successes>1?'es':''));
+
    }
+
});
+
</pre>
+
  
==== Notes ====
+
After posting a message with a roll (either regular or inline) which uses d10s, '''Exalted Successes''' will echo the number of successes (or botches) using the dice system in ''Exalted''. This script does not take into account Sidereal Astrology modifying the target number, nor does it try to filter players posting a roll with modifiers and the like. This script does not scrutinize based on normal die rolls (10s count double) vs. damage rolls (10s don't count double).
You can achieve similar results with rollable tables, without resorting to the scripts that require mentor-level accounts.
+
 
 +
If this script is in the game, every roll which uses d10s will be reported.
 +
<br clear="all">
 +
 
 +
=== Notes ===
 +
You can achieve similar results with rollable tables, without resorting to the scripts that require a '''Pro''' subscription.
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 80: Line 23:
 
! Weight
 
! Weight
 
|-
 
|-
| 0 b
+
| -1
 
| 1
 
| 1
 
|-
 
|-
Line 93: Line 36:
 
|}
 
|}
  
Assuming the table is named <tt>exalted</tt>, you can then roll on it with something like <tt>/roll 8t[exalted]</tt>. This solution won't accurately report botches, but you can check the roll itself after the fact if no successes were garnered.
+
Assuming the table is named <code>exalted</code>, you can then roll on it with something like <code>/roll 8t[exalted]</code> or <code>[[8t[exalted]]]</code> for inline rolling (useful if you want to create a macro to hide the ugly output that it gives). The result will be the number of "successes" that the roll has. This solution will also calculate botches (-1) into the result, negating the need to hand calculate the final result. If the number is less than 0, then the roll ended in a botch. If it is 0, then it is a simple failure.
  
 
For bonus points, you can make alternate tables for damage (1 weighted 4 and no 2) and for Sidereal shenaniganry. It also doesn't require any scripting to achieve.
 
For bonus points, you can make alternate tables for damage (1 weighted 4 and no 2) and for Sidereal shenaniganry. It also doesn't require any scripting to achieve.
  
[[Category:User API Scripts|Exalted Successes]]
+
=== Changelog ===
 +
{{changelog version|2.2|2016-03-09|* Update for one-click install}}
 +
{{changelog version|2.1|2015-03-14|* [bugfix] Fixed infinite loop chat message problem}}
 +
{{changelog version|2.0|2015-01-08|* Release}}

Latest revision as of 21:23, 20 September 2021

  1. redirectScript:exaltScript

Api discontinued, link to closest replacement

script overview |name=Exalted Successes |author=Brian |version=2.2 |dependencies=Interpreted sendChat |lastmodified=2016-03-09

After posting a message with a roll (either regular or inline) which uses d10s, Exalted Successes will echo the number of successes (or botches) using the dice system in Exalted. This script does not take into account Sidereal Astrology modifying the target number, nor does it try to filter players posting a roll with modifiers and the like. This script does not scrutinize based on normal die rolls (10s count double) vs. damage rolls (10s don't count double).

If this script is in the game, every roll which uses d10s will be reported.

[edit] Notes

You can achieve similar results with rollable tables, without resorting to the scripts that require a Pro subscription.

Name Weight
-1 1
0 5
1 3
2 1

Assuming the table is named exalted, you can then roll on it with something like /roll 8t[exalted] or [[8t[exalted]]] for inline rolling (useful if you want to create a macro to hide the ugly output that it gives). The result will be the number of "successes" that the roll has. This solution will also calculate botches (-1) into the result, negating the need to hand calculate the final result. If the number is less than 0, then the roll ended in a botch. If it is 0, then it is a simple failure.

For bonus points, you can make alternate tables for damage (1 weighted 4 and no 2) and for Sidereal shenaniganry. It also doesn't require any scripting to achieve.

[edit] Changelog

v2.2 (2016-03-09)

  • Update for one-click install


v2.1 (2015-03-14)

  • [bugfix] Fixed infinite loop chat message problem


v2.0 (2015-01-08)

  • Release