Skip to content

Commit f309dd2

Browse files
authored
CharDupToken Update 1.031 (Roll20#983)
1 parent dfa6e71 commit f309dd2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

DupCharToken/1.03/DupCharToken.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
// Version 1.01 Nov 2019 Chris D. After all characters have been created, do loops to read attributes and abilities once and create for each new character.
5151
// Version 1.02 Jan 2020 Chris D. Fixed bug where script would crash API if clean was run with no tokens selected.
5252
// Version 1.03 Mar 2020 Chris D. Tokens dragged from the journal would not be correctly linked. Moved setDefaultTokenForCharacter to occur after attributes are copied.
53+
// Update 1.031 May 2020 Chris D. Minor bugfix with copying bio and gmnotes.
5354
//
5455
//
5556
// Commands:
@@ -173,7 +174,7 @@ on('ready',()=>{
173174
sChat( "Token is not correctly linked to a good character." );
174175
else { // Everything is good. We are duplicating.
175176
let oldCid = charObj.id;
176-
let tmpC = JSON.stringify( charObj ),
177+
let tmpC = JSON.stringify( charObj ).replace ( /\,"bio"\:.*?\,/gi, ',"bio":"",').replace ( /\,"gmnotes"\:.*?\,/gi, ',"gmnotes":"",'),
177178
tmpT = JSON.stringify( tokenObj );
178179

179180
for( let i = startnum; i < (startnum + num); ++i) { // We are going to want to duplicate both the character and token this many times.
@@ -232,12 +233,12 @@ on('ready',()=>{
232233
}
233234
charObj.get("bio", function(bio) {
234235
_.each( charArray, c => {
235-
if( !_.isNull( bio ) && !_.isUndefined( bio) && bio != "null" && bio != "undefined" && !(typeof bio === 'string' && bio.trim() !== "") )
236+
if( !_.isNull( bio ) && !_.isUndefined( bio) && bio != "null" && bio != "undefined" && (typeof bio === 'string' && bio.trim() !== "") )
236237
c.set( 'bio', bio );
237238
}); });
238239
charObj.get("gmnotes", function(gmnotes) {
239240
_.each( charArray, c => {
240-
if( !_.isNull( gmnotes ) && !_.isUndefined( gmnotes) && gmnotes != "null" && gmnotes != "undefined" && !(typeof gmnotes === 'string' && gmnotes.trim() !== "") )
241+
if( !_.isNull( gmnotes ) && !_.isUndefined( gmnotes) && gmnotes != "null" && gmnotes != "undefined" && (typeof gmnotes === 'string' && gmnotes.trim() !== "") )
241242
c.set( 'gmnotes', gmnotes );
242243
}); });
243244
sChat( "Duplicated: " + charObj.get( "name" ) + " " + num + " times." );

0 commit comments

Comments
 (0)