Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions DrD2StatusMarkers/0.1.3/DrD2StatusMarkers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Github: TBD
// By: nesuprachy
// Contact: https://app.roll20.net/users/11071738/nesuprachy
//
// This script sets token markers based on relevant sheet attributes.
// Works with the DrD2 token marker set, icons must be named `RED`, `BLU`, `GRN`, `VIO`, `BLK`, `GRY`, `load` followed by corresponding values
// Uses TokenMod to set token markers from chat https://wiki.roll20.net/Script:Token_Mod

var DrD2StatusMarkers = DrD2StatusMarkers || (function() {
'use strict';

const version = '0.1.3';
const lastUpdate = 1731662174989;
const markerAttributes = ['body_scarred', 'spirit_scarred', 'influence_scarred', 'danger', 'advantages', 'companion_bond_scarred', 'load'];

checkInstall = function () {
log(`-=> DrD2StatusMarkers v${version} <=- [${new Date(lastUpdate)}]`);
},

handleMarkerAttributes = function (obj, prev) {
var attr = obj.get('name');
if(markerAttributes.includes(attr)) {
var prevVal, newVal;
if(attr === 'load') {
prevVal = prev.current;
newVal = obj.get('current');
}else {
prevVal = parseInt(prev.current)||0;
newVal = parseInt(obj.get('current'))||0;
}
var charId = obj.get('_characterid');
var marker = '';
//log(`${obj.get('name')} changed`);
//log(`prevVal ${prevVal} -> newVal ${newVal}`);
switch (attr) {
case markerAttributes[0]:
marker = 'RED';
break;
case markerAttributes[1]:
marker = 'BLU';
break;
case markerAttributes[2]:
marker = 'GRN';
break;
case markerAttributes[3]:
marker = 'VIO';
break;
case markerAttributes[4]:
marker = 'BLK';
break;
case markerAttributes[5]:
marker = 'GRY';
break;
case markerAttributes[6]:
marker= 'load';
break;
default:
break;
}
if(marker){
if(attr === 'load'){
sendChat('API', `!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-loadL|-loadS|-loadT|load${newVal}`, null, {noarchive:true});
//log(`!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-loadL|-loadS|-loadT|load${newVal}`);
} else if(newVal > 0 && newVal < 10) {
sendChat('API', `!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${marker}1|-${marker}2|-${marker}3|-${marker}4|-${marker}5|-${marker}6|-${marker}7|-${marker}8|-${marker}9|-${marker}9plus|${marker}${newVal}`, null, {noarchive:true} );
//log(`!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${marker}1|-${marker}2|-${marker}3|-${marker}4|-${marker}5|-${marker}6|-${marker}7|-${marker}8|-${marker}9|-${marker}9plus|${marker}${newVal}`);
} else if(newVal >= 10) {
sendChat('API', `!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${marker}1|-${marker}2|-${marker}3|-${marker}4|-${marker}5|-${marker}6|-${marker}7|-${marker}8|-${marker}9|${marker}9plus`, null, {noarchive:true} );
//log(`!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${marker}1|-${marker}2|-${marker}3|-${marker}4|-${marker}5|-${marker}6|-${marker}7|-${marker}8|-${marker}9|${marker}9plus`);
} else {
sendChat('API', `!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${marker}1|-${marker}2|-${marker}3|-${marker}4|-${marker}5|-${marker}6|-${marker}7|-${marker}8|-${marker}9|-${marker}9plus`, null, {noarchive:true} );
//log(`!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${marker}1|-${marker}2|-${marker}3|-${marker}4|-${marker}5|-${marker}6|-${marker}7|-${marker}8|-${marker}9|-${marker}9plus`);
}
}
}
},

registerEventHandlers = function () {
on('change:attribute:current', function(obj, prev){handleMarkerAttributes(obj, prev)});
};

return {
CheckInstall: checkInstall,
RegisterEventHandlers: registerEventHandlers
};

}());

on('ready', () => {
'use strict';

DrD2StatusMarkers.CheckInstall();
DrD2StatusMarkers.RegisterEventHandlers();
});
54 changes: 33 additions & 21 deletions DrD2StatusMarkers/DrD2StatusMarkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// Contact: https://app.roll20.net/users/11071738/nesuprachy
//
// This script sets token markers based on relevant sheet attributes.
// Works with the DrD2 token marker set, icons must be named `RED`, `BLU`, `GRN`, `VIO`, `BLK`
// Works with the DrD2 token marker set, icons must be named `RED`, `BLU`, `GRN`, `VIO`, `BLK`, `GRY`, `load` followed by corresponding values
// Uses TokenMod to set token markers from chat https://wiki.roll20.net/Script:Token_Mod

var DrD2StatusMarkers = DrD2StatusMarkers || (function() {
'use strict';

const version = '0.1.2';
const lastUpdate = 1725975609706;
const markerAttributes = ['body_scarred', 'spirit_scarred', 'influence_scarred', 'danger', 'advantages', 'companion_bond_scarred'];
const version = '0.1.3';
const lastUpdate = 1731662174989;
const markerAttributes = ['body_scarred', 'spirit_scarred', 'influence_scarred', 'danger', 'advantages', 'companion_bond_scarred', 'load'];

checkInstall = function () {
log(`-=> DrD2StatusMarkers v${version} <=- [${new Date(lastUpdate)}]`);
Expand All @@ -20,44 +20,56 @@ var DrD2StatusMarkers = DrD2StatusMarkers || (function() {
handleMarkerAttributes = function (obj, prev) {
var attr = obj.get('name');
if(markerAttributes.includes(attr)) {
var prevVal = parseInt(prev.current)||0;
var newVal = parseInt(obj.get('current'))||0;
var prevVal, newVal;
if(attr === 'load') {
prevVal = prev.current;
newVal = obj.get('current');
}else {
prevVal = parseInt(prev.current)||0;
newVal = parseInt(obj.get('current'))||0;
}
var charId = obj.get('_characterid');
var color = '';
var marker = '';
//log(`${obj.get('name')} changed`);
//log(`prevVal ${prevVal} -> newVal ${newVal}`);
switch (attr) {
case markerAttributes[0]:
color = 'RED';
marker = 'RED';
break;
case markerAttributes[1]:
color = 'BLU';
marker = 'BLU';
break;
case markerAttributes[2]:
color = 'GRN';
marker = 'GRN';
break;
case markerAttributes[3]:
color = 'VIO';
marker = 'VIO';
break;
case markerAttributes[4]:
color = 'BLK';
marker = 'BLK';
break;
case markerAttributes[5]:
color = 'GRY';
marker = 'GRY';
break;
case markerAttributes[6]:
marker= 'load';
break;
default:
break;
}
if(color){
if(newVal > 0 && newVal < 10) {
sendChat('API', `!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${color}1|-${color}2|-${color}3|-${color}4|-${color}5|-${color}6|-${color}7|-${color}8|-${color}9|-${color}9plus|${color}${newVal}`, null, {noarchive:true} );
//log(`!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${color}1|-${color}2|-${color}3|-${color}4|-${color}5|-${color}6|-${color}7|-${color}8|-${color}9|-${color}9plus|${color}${newVal}`);
if(marker){
if(attr === 'load'){
sendChat('API', `!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-loadL|-loadS|-loadT|load${newVal}`, null, {noarchive:true});
//log(`!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-loadL|-loadS|-loadT|load${newVal}`);
} else if(newVal > 0 && newVal < 10) {
sendChat('API', `!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${marker}1|-${marker}2|-${marker}3|-${marker}4|-${marker}5|-${marker}6|-${marker}7|-${marker}8|-${marker}9|-${marker}9plus|${marker}${newVal}`, null, {noarchive:true} );
//log(`!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${marker}1|-${marker}2|-${marker}3|-${marker}4|-${marker}5|-${marker}6|-${marker}7|-${marker}8|-${marker}9|-${marker}9plus|${marker}${newVal}`);
} else if(newVal >= 10) {
sendChat('API', `!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${color}1|-${color}2|-${color}3|-${color}4|-${color}5|-${color}6|-${color}7|-${color}8|-${color}9|${color}9plus`, null, {noarchive:true} );
//log(`!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${color}1|-${color}2|-${color}3|-${color}4|-${color}5|-${color}6|-${color}7|-${color}8|-${color}9|${color}9plus`);
sendChat('API', `!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${marker}1|-${marker}2|-${marker}3|-${marker}4|-${marker}5|-${marker}6|-${marker}7|-${marker}8|-${marker}9|${marker}9plus`, null, {noarchive:true} );
//log(`!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${marker}1|-${marker}2|-${marker}3|-${marker}4|-${marker}5|-${marker}6|-${marker}7|-${marker}8|-${marker}9|${marker}9plus`);
} else {
sendChat('API', `!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${color}1|-${color}2|-${color}3|-${color}4|-${color}5|-${color}6|-${color}7|-${color}8|-${color}9|-${color}9plus`, null, {noarchive:true} );
//log(`!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${color}1|-${color}2|-${color}3|-${color}4|-${color}5|-${color}6|-${color}7|-${color}8|-${color}9|-${color}9plus`);
sendChat('API', `!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${marker}1|-${marker}2|-${marker}3|-${marker}4|-${marker}5|-${marker}6|-${marker}7|-${marker}8|-${marker}9|-${marker}9plus`, null, {noarchive:true} );
//log(`!token-mod --ignore-selected --ids ${charId} --set statusmarkers|-${marker}1|-${marker}2|-${marker}3|-${marker}4|-${marker}5|-${marker}6|-${marker}7|-${marker}8|-${marker}9|-${marker}9plus`);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions DrD2StatusMarkers/script.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "DrD2StatusMarkers",
"script": "DrD2StatusMarkers.js",
"version": "0.1.2",
"previousversions": ["0.1.0", "0.1.1"],
"description": "Designed for use only with the Draci Doupe II sheet.\n\nThis script sets token markers based on relevant sheet attributes.\nWorks with the DrD2 token marker set, icons must be named `RED`, `BLU`, `GRN`, `VIO`, `BLK`, `GRY`.\nYou can download the token marker set [here](https://download-directory.github.io/?url=https%3A%2F%2Fgithub.com%2Fnesuprachy%2Froll20-character-sheets%2Ftree%2FDraci-doupe-II%2FDraci%2520doupe%2520II%2Fassets%2FDrD2-token_markers).",
"version": "0.1.3",
"previousversions": ["0.1.0", "0.1.1", "0.1.2"],
"description": "Designed for use only with the Draci Doupe II sheet.\n\nThis script sets token markers based on relevant sheet attributes.\nWorks with the DrD2 token marker set, icons must be named `RED`, `BLU`, `GRN`, `VIO`, `BLK`, `GRY`, `load` followed by corresponding values.\nYou can download the token marker set [here](https://download-directory.github.io/?url=https%3A%2F%2Fgithub.com%2Fnesuprachy%2Froll20-character-sheets%2Ftree%2FDraci-doupe-II%2FDraci%2520doupe%2520II%2Fassets%2FDrD2-token_markers).",
"authors": "nesuprachy",
"roll20userid": "11071738",
"useroptions": [],
Expand Down
Loading