Skip to content

Commit

Permalink
Squashed 'MonsterHitDice5e/' content from commit c2ae699
Browse files Browse the repository at this point in the history
git-subtree-dir: MonsterHitDice5e
git-subtree-split: c2ae699c4bcc8635aef6c610f6fc03456bfa35e6
  • Loading branch information
shdwjk committed Feb 1, 2015
0 parents commit 74cda76
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
93 changes: 93 additions & 0 deletions MonsterHitDice5e.js
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);
}
});
});
23 changes: 23 additions & 0 deletions package.json
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": [
]
}

0 comments on commit 74cda76

Please sign in to comment.