forked from Roll20/roll20-api-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'MonsterHitDice5e/' content from commit c2ae699
git-subtree-dir: MonsterHitDice5e git-subtree-split: c2ae699c4bcc8635aef6c610f6fc03456bfa35e6
- Loading branch information
0 parents
commit 74cda76
Showing
2 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Github: https://github.com/shdwjk/Roll20API/blob/master/MonsterHitDice/MonsterHitDice5e.js | ||
// By: The Aaron, Arcane Scriptomancer | ||
// Contact: https://app.roll20.net/users/104025/the-aaron | ||
|
||
on('ready', function(){ | ||
on('add:graphic',function(obj){ | ||
if( | ||
'graphic' == obj.get('type') | ||
&& 'token' == obj.get('subtype') | ||
&& '' != obj.get('represents') | ||
) | ||
{ | ||
setTimeout(_.bind(function(id){ | ||
var obj=getObj('graphic',id) | ||
|
||
if( | ||
undefined != obj | ||
&& '' == obj.get('bar2_link') | ||
) | ||
{ | ||
var attrib = findObjs({ | ||
_type: 'attribute', | ||
_characterid:obj.get('represents'), | ||
name: 'npc_HP_hit_dice' | ||
}) | ||
if( attrib.length ) | ||
{ | ||
sendChat('','/r '+attrib[0].get('current'),function(r){ | ||
var hp=0; | ||
_.each(r,function(subr){ | ||
var val=JSON.parse(subr.content); | ||
if(_.has(val,'total')) | ||
{ | ||
hp+=val.total; | ||
} | ||
}); | ||
obj.set({ | ||
bar2_value: hp, | ||
bar2_max: hp | ||
}) | ||
}); | ||
} | ||
} | ||
|
||
},this,obj.id), 100); | ||
} | ||
}); | ||
});/ GIST: https://gist.github.com/shdwjk/7377de58100f4e813432 | ||
|
||
on('ready', function(){ | ||
on('add:graphic',function(obj){ | ||
if( | ||
'graphic' == obj.get('type') | ||
&& 'token' == obj.get('subtype') | ||
&& '' != obj.get('represents') | ||
) | ||
{ | ||
setTimeout(_.bind(function(id){ | ||
var obj=getObj('graphic',id) | ||
|
||
if( | ||
undefined != obj | ||
&& '' == obj.get('bar2_link') | ||
) | ||
{ | ||
var attrib = findObjs({ | ||
_type: 'attribute', | ||
_characterid:obj.get('represents'), | ||
name: 'npc_HP_hit_dice' | ||
}) | ||
if( attrib.length ) | ||
{ | ||
sendChat('','/r '+attrib[0].get('current'),function(r){ | ||
var hp=0; | ||
_.each(r,function(subr){ | ||
var val=JSON.parse(subr.content); | ||
if(_.has(val,'total')) | ||
{ | ||
hp+=val.total; | ||
} | ||
}); | ||
obj.set({ | ||
bar2_value: hp, | ||
bar2_max: hp | ||
}) | ||
}); | ||
} | ||
} | ||
|
||
},this,obj.id), 100); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "MonsterHitDice5e", | ||
"version": "", | ||
"description": "Set Monster hit dice on add, usually via drag from journal. Configured for Dungeons and Dragons 5e Character Sheet", | ||
"authors": "The Aaron", | ||
"roll20userid": "104025", | ||
"dependencies": { | ||
}, | ||
"modifies": { | ||
"attribute.current": "read" | ||
"attribute.name": "read", | ||
"attribute.type": "read", | ||
"character.represents": "read", | ||
"graphic.bar2_link": "read", | ||
"graphic.bar2_max": "write", | ||
"graphic.bar2_value": "write", | ||
"graphic.represents": "read", | ||
"graphic.subtype": "read", | ||
"graphic.type": "read" | ||
}, | ||
"conflicts": [ | ||
] | ||
} |