
I'm trying to populate repeating sections on the Mork Borg character sheet. I've just inserted the repeating section code, but I'm getting a SyntaxError: Unexpected identifier message when I save it. JSLint does not report this. Suggestions? /**
* Generates Mork Borg Characters
*
* Syntax: !SCVMBuild option
*
*/
let SCVMBuild = SCVMBuild || {
version: "0.0.5",
output: [],
listen: function () {
on('chat:message', function (msg) {
// Exit if not an api command
if (msg.type != "api") {
return;
}
if (isGM(msg.playerid)) {
sendto = "/w gm ";
} else {
sendto = "/direct ";
}
switch (msg.content) {
case '!GenClass':
SCVMBuild.GenClass(msg);
break;
case '!GenWeapon':
SCVMBuild.GenWeapon(msg);
break;
case '!GenArmor':
SCVMBuild.GenArmor(msg);
break;
case '!GenEquipment':
SCVMBuild.GenEquipment(msg);
break;
case '!GenAbilities':
SCVMBuild.GenAbilities(msg);
break;
case '!GenHP':
SCVMBuild.GenHP(msg);
break;
case '!GenPower':
SCVMBuild.GenPower(msg);
break;
case '!GenOmen':
SCVMBuild.GenOmen(msg);
break;
case '!GenTraits':
SCVMBuild.GenTraits(msg);
break;
case '!GenBody':
SCVMBuild.GenBody(msg);
break;
case '!GenHabit':
SCVMBuild.GenHabit(msg);
break;
case '!GenStory':
SCVMBuild.GenStory(msg);
break;
case '!GenName':
SCVMBuild.GenName(msg);
break;
case '!CharView':
SCVMBuild.printSheet(msg);
break;
case '!SaveChar':
SCVMBuild.save(msg);
break;
default:
return;
}
});
},
GenClass: function (msg) {
sendChat("API", "/roll 1t[Class]", function (result) {
let content = JSON.parse(result[0].content);
let values1 = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Class = values1[0];
SCVMBuild.output['Class'] = "<tr><td style='font-weight: bold; padding: 5px;'>Class</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Class + "</td></tr>";
SCVMTextA = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Class'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextA);
});
},
GenWeapon: function (msg) {
generateRowID = function () {
"use strict";
return generateUUID().replace(/_/g, "Z");
};
sendChat("API", "/roll 1t[Weapon]", function (result) {
let content = JSON.parse(result[0].content);
let values2 = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Weapon = values2[0];
SCVMBuild.output['Weapon'] = "<tr><td style='font-weight: bold; padding: 5px;'>Weapon</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Weapon + "</td></tr>";
SCVMTextB = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Weapon'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextB);
repeating_weapons_ROWID_weaponname = SCVMBuild.weaponname;
repeating_weapons_ROWID_attacktype = SCVMBuild.attacktype;
repeating_weapons_ROWID_weapondamage = SCVMBuild.weapondamage;
});
},
GenArmor: function (msg) {
sendChat("API", "/roll 1t[Armor]", function (result) {
let content = JSON.parse(result[0].content);
let values3 = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Armor = values3[0];
SCVMBuild.output['Armor'] = "<tr><td style='font-weight: bold; padding: 5px;'>Armor</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Armor + "</td></tr>";
SCVMTextC = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Armor'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextC);
});
},
GenEquipment: function (msg) {
sendChat("API", "/roll 1t[Equipment1]", function (result) {
let content = JSON.parse(result[0].content);
let values4 = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Equipment1 = values4[0];
SCVMBuild.output['Equipment1'] = "<tr><td style='font-weight: bold; padding: 5px;'>Equipment1</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Equipment1 + "</td></tr>";
SCVMTextD1 = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Equipment1'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextD1);
});
sendChat("API", "/roll 1t[Equipment2]", function (result) {
let content = JSON.parse(result[0].content);
let values5 = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Equipment2 = values5[0];
SCVMBuild.output['Equipment2'] = "<tr><td style='font-weight: bold; padding: 5px;'>Equipment2</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Equipment2 + "</td></tr>";
SCVMTextD2 = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Equipment2'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextD2);
});
sendChat("API", "/roll 1t[Equipment3]", function (result) {
let content = JSON.parse(result[0].content);
let values6 = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Equipment3 = values6[0];
SCVMBuild.output['Equipment3'] = "<tr><td style='font-weight: bold; padding: 5px;'>Equipment3</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Equipment3 + "</td></tr>";
SCVMTextD3 = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Equipment3'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextD3);
});
},
GenAbilities: function (msg) {
SCVMBuild.Agility = randomInteger(7) - 4;
SCVMBuild.output['Agility'] = "<tr><td style='font-weight: bold; padding: 5px;'>Agility</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Agility + "</td></tr>";
SCVMTextE = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Agility'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextE);
SCVMBuild.Presence = randomInteger(7) - 4;
SCVMBuild.output['Presence'] = "<tr><td style='font-weight: bold; padding: 5px;'>Presence</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Presence + "</td></tr>";
SCVMTextF = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Presence'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextF);
SCVMBuild.Strength = randomInteger(7) - 4;
SCVMBuild.output['Strength'] = "<tr><td style='font-weight: bold; padding: 5px;'>Strength</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Strength + "</td></tr>";
SCVMTextG = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Strength'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextG);
SCVMBuild.Toughness = randomInteger(7) - 4;
SCVMBuild.output['Toughness'] = "<tr><td style='font-weight: bold; padding: 5px;'>Toughness</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Toughness + "</td></tr>";
SCVMTextH = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Toughness'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextH);
},
GenHP: function (msg) {
SCVMBuild.HP = SCVMBuild.Toughness + randomInteger(8);
if (SCVMBuild.HP < 1) {
SCVMBuild.HP = "1";
}
SCVMBuild.output['HP'] = "<tr><td style='font-weight: bold; padding: 5px;'>HP</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.HP + "</td></tr>";
SCVMTextI = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['HP'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextI);
},
GenPower: function (msg) {
sendChat("API", "/roll 1t[Power]", function (result) {
let content = JSON.parse(result[0].content);
let valuesB = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Power = valuesB[0];
SCVMBuild.output['Power'] = "<tr><td style='font-weight: bold; padding: 5px;'>Power</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Power + "</td></tr>";
SCVMTextJ = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Power'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextJ);
});
},
GenOmen: function (msg) {
sendChat("API", "/roll 1t[Omens]", function (result) {
let content = JSON.parse(result[0].content);
let valuesC = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Omen = valuesC[0];
SCVMBuild.output['Omen'] = "<tr><td style='font-weight: bold; padding: 5px;'>Omen</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Omen + "</td></tr>";
SCVMTextK = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Omen'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextK);
});
},
GenTraits: function (msg) {
sendChat("API", "/roll 1t[Trait]", function (result) {
let content = JSON.parse(result[0].content);
let valuesC = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Trait1 = valuesC[0];
SCVMBuild.output['Trait1'] = "<tr><td style='font-weight: bold; padding: 5px;'>Trait1</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Trait1 + "</td></tr>";
SCVMTextL1 = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Trait1'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextL1);
});
sendChat("API", "/roll 1t[Trait]", function (result) {
let content = JSON.parse(result[0].content);
let valuesD = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Trait2 = valuesD[0];
SCVMBuild.output['Trait2'] = "<tr><td style='font-weight: bold; padding: 5px;'>Trait2</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Trait2 + "</td></tr>";
SCVMTextL2 = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Trait2'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextL2);
});
},
GenBody: function (msg) {
sendChat("API", "/roll 1t[Body]", function (result) {
let content = JSON.parse(result[0].content);
let valuesE = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Body = valuesE[0];
SCVMBuild.output['Body'] = "<tr><td style='font-weight: bold; padding: 5px;'>Broken Body</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Body + "</td></tr>";
SCVMTextM = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Body'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextM);
});
},
GenHabit: function (msg) {
sendChat("API", "/roll 1t[Habit]", function (result) {
let content = JSON.parse(result[0].content);
let valuesF = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Habit = valuesF[0];
SCVMBuild.output['Habit'] = "<tr><td style='font-weight: bold; padding: 5px;'>Bad Habit</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Habit + "</td></tr>";
SCVMTextN = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Habit'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextN);
});
},
GenStory: function (msg) {
sendChat("API", "/roll 1t[Story]", function (result) {
let content = JSON.parse(result[0].content);
let valuesG = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Story = valuesG[0];
SCVMBuild.output['Story'] = "<tr><td style='font-weight: bold; padding: 5px;'>Troubling Tale</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Story + "</td></tr>";
SCVMTextO = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Story'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextO);
});
},
GenName: function (msg) {
sendChat("API", "/roll 1t[MaleName]", function (result) {
let content = JSON.parse(result[0].content);
let valuesH = content.rolls[0].results[0].tableItem.name.split(':');
SCVMBuild.Name = valuesH[0];
SCVMBuild.output['Name'] = "<tr><td style='font-weight: bold; padding: 5px;'>Name</td></tr><tr><td style='padding: 5px;'>" + SCVMBuild.Name + "</td></tr>";
SCVMTextH = "<table font-size: 10px;'> <tbody>" + SCVMBuild.output['Name'] + "</tbody></table>";
sendChat(msg.who, "/direct " + SCVMTextH);
});
},
printSheet: function (msg) {
let styleLabel = "style='font-weight: bold; padding: 5px;'";
let styleVal = "style='padding: 5px;'";
SCVMBuild.output['Class'] = "<tr><td style='font-weight: bold; padding: 5px;'>Class</td><td style='padding: 5px;'>" + SCVMBuild.Class + "</td></tr>";
SCVMBuild.output['Weapon'] = "<tr><td style='font-weight: bold; padding: 5px;'>Weapon</td><td style='padding: 5px;'>" + SCVMBuild.Weapon + "</td></tr>";
SCVMBuild.output['Armor'] = "<tr><td style='font-weight: bold; padding: 5px;'>Armor</td><td style='padding: 5px;'>" + SCVMBuild.Armor + "</td></tr>";
SCVMBuild.output['Equipment1'] = "<tr><td style='font-weight: bold; padding: 5px;'>Equipment1</td><td style='padding: 5px;'>" + SCVMBuild.Equipment1 + "</td></tr>";
SCVMBuild.output['Equipment2'] = "<tr><td style='font-weight: bold; padding: 5px;'>Equipment2</td><td style='padding: 5px;'>" + SCVMBuild.Equipment2 + "</td></tr>";
SCVMBuild.output['Equipment3'] = "<tr><td style='font-weight: bold; padding: 5px;'>Equipment3</td><td style='padding: 5px;'>" + SCVMBuild.Equipment3 + "</td></tr>";
SCVMBuild.output['Agility'] = "<tr><td style='font-weight: bold; padding: 5px;'>Agility</td><td style='padding: 5px;'>" + SCVMBuild.Agility + "</td></tr>";
SCVMBuild.output['Presence'] = "<tr><td style='font-weight: bold; padding: 5px;'>Presence</td><td style='padding: 5px;'>" + SCVMBuild.Presence + "</td></tr>";
SCVMBuild.output['Strength'] = "<tr><td style='font-weight: bold; padding: 5px;'>Strength</td><td style='padding: 5px;'>" + SCVMBuild.Strength + "</td></tr>";
SCVMBuild.output['Toughness'] = "<tr><td style='font-weight: bold; padding: 5px;'>Toughness</td><td style='padding: 5px;'>" + SCVMBuild.Toughness + "</td></tr>";
SCVMBuild.output['HP'] = "<tr><td style='font-weight: bold; padding: 5px;'>HP</td><td style='padding: 5px;'>" + SCVMBuild.HP + "</td></tr>";
SCVMBuild.output['Power'] = "<tr><td style='font-weight: bold; padding: 5px;'>Power</td><td style='padding: 5px;'>" + SCVMBuild.Power + "</td></tr>";
SCVMBuild.output['Omen'] = "<tr><td style='font-weight: bold; padding: 5px;'>Omen</td><td style='padding: 5px;'>" + SCVMBuild.Omen + "</td></tr>";
SCVMBuild.output['Trait1'] = "<tr><td style='font-weight: bold; padding: 5px;'>Trait1</td><td style='padding: 5px;'>" + SCVMBuild.Trait1 + "</td></tr>";
SCVMBuild.output['Trait2'] = "<tr><td style='font-weight: bold; padding: 5px;'>Trait2</td><td style='padding: 5px;'>" + SCVMBuild.Trait2 + "</td></tr>";
SCVMBuild.output['Body'] = "<tr><td style='font-weight: bold; padding: 5px;'>Broken Body</td><td style='padding: 5px;'>" + SCVMBuild.Body + "</td></tr>";
SCVMBuild.output['Habit'] = "<tr><td style='font-weight: bold; padding: 5px;'>Bad Habit</td><td style='padding: 5px;'>" + SCVMBuild.Habit + "</td></tr>";
SCVMBuild.output['Story'] = "<tr><td style='font-weight: bold; padding: 5px;'>Troubling Tale</td><td style='padding: 5px;'>" + SCVMBuild.Story + "</td></tr>";
SCVMBuild.output['Name'] = "<tr><td style='font-weight: bold; padding: 5px;'>Name</td><td style='padding: 5px;'>" + SCVMBuild.Name + "</td></tr>";
SCVMText1 = "<table font-size: 10px;'> <tbody>" +
SCVMBuild.output['Class`'] +
SCVMBuild.output['Weapon'] +
SCVMBuild.output['Armor'] +
SCVMBuild.output['Equipment1'] +
SCVMBuild.output['Equipment2'] +
SCVMBuild.output['Equipment3'] +
SCVMBuild.output['Strength'] +
SCVMBuild.output['Agility'] +
SCVMBuild.output['Presence'] +
SCVMBuild.output['Toughness'] +
SCVMBuild.output['HP'] +
SCVMBuild.output['Power'] +
SCVMBuild.output['Omen'] +
SCVMBuild.output['Trait1'] +
SCVMBuild.output['Trait2'] +
SCVMBuild.output['Body'] +
SCVMBuild.output['Habit'] +
SCVMBuild.output['Story'] +
SCVMBuild.output['Name'] + "</tbody></table>";
SCVMText = SCVMText1 + "<p><p>";
sendChat(msg.who, "/direct " + SCVMText);
SCVMBuild.Description = SCVMBuild.Trait1 + "\n" + SCVMBuild.Trait2 + "\n" + SCVMBuild.Body + "\n" + SCVMBuild.Habit + "\n" + SCVMBuild.Story;
if (typeof saveCallback === "function") {
saveCallback();
}
},
save: function (msg, saveCallback) {
sendChat(msg.who, "/direct saving character");
let handout = createObj('handout', {
name: SCVMBuild.Name + ' Instructions',
inplayerjournals: "all",
archived: false
});
let character = createObj("character", {
name: SCVMBuild.Name,
archived: false,
inplayerjournals: "all",
controlledby: "all"
});
handout.set('notes', SCVMText);
sendChat('', 'Created instructions for completing <a href="<a href="http://journal.roll20.net/handout/" rel="nofollow">http://journal.roll20.net/handout/</a>' + handout.id + '" style="color:blue;text-decoration:underline;">SCVMBUILDER ' + SCVMBuild.Name + '</a>');
createObj('attribute', {
name: 'class',
current: SCVMBuild.Class,
_characterid: character.id
});
// createObj('attribute', {
// name: 'weapon',
// current: SCVMBuild.Weapon,
// _characterid: character.id
// });
createObj('attribute', {
name: 'armor',
current: SCVMBuild.Armor,
_characterid: character.id
});
createObj('attribute', {
name: 'strength',
current: SCVMBuild.Strength,
_characterid: character.id
});
createObj('attribute', {
name: 'agility',
current: SCVMBuild.Agility,
_characterid: character.id
});
createObj('attribute', {
name: 'presence',
current: SCVMBuild.Presence,
_characterid: character.id
});
createObj('attribute', {
name: 'toughness',
current: SCVMBuild.Toughness,
_characterid: character.id
});
createObj('attribute', {
name: 'hp_curr',
current: SCVMBuild.HP,
_characterid: character.id
});
createObj('attribute', {
name: 'hp',
current: SCVMBuild.HP,
_characterid: character.id
});
createObj('attribute', {
name: 'power',
current: SCVMBuild.Power,
_characterid: character.id
});
createObj('attribute', {
name: 'omen',
current: SCVMBuild.Omen,
_characterid: character.id
});
createObj('attribute', {
name: 'description',
current: SCVMBuild.Description,
_characterid: character.id
});
createObj('attribute', {
name: 'char_name',
current: SCVMBuild.Name,
_characterid: character.id
});
sendChat('', 'Created <a href="<a href="http://journal.roll20.net/character/" rel="nofollow">http://journal.roll20.net/character/</a>' + character.id + '" style="color:blue;text-decoration:underline;">SCVM ' + SCVMBuild.Name + '</a>');
}
};
let generateUUID = (function () {
let a = 0,
b = [];
return function () {
let c = (new Date()).getTime() + 0,
d = c === a;
a = c;
for (let e = new Array(8), f = 7; 0 <= f; f--) {
e[f] = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(c % 64);
c = Math.floor(c / 64);
}
c = e.join("");
if (d) {
for (f = 11; 0 <= f && 63 === b[f]; f--) {
b[f] = 0;
}
b[f]++;
} else {
for (f = 0; 12 > f; f++) {
b[f] = Math.floor(64 * Math.random());
}
}
for (f = 0; 12 > f; f++) {
c += "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(b[f]);
}
log c;
return c;
};
}
),
on("ready", function () {
SCVMBuild.listen();
});