Will this work? Syntax !charsheet //previous behavior. Creates character named "PlayerName #1", etc !charsheet --charName //creates character sheet named charName (if spaces in name, use quotes, i.e. --"Bob the Great") Modified script: /**
* Generates a blank character sheet for any player in the campaign.
*
* Syntax: !charsheet
*/
var Charsheet = Charsheet || {};
on("chat:message", function(msg) {
// Exit if not an api command
if (msg.type != "api") {
return;
}
if (msg.content.indexOf('!charsheet') != -1) {
let charName = msg.who;
let args = msg.content.split(/\s+--/);
if (args.length > 1) {
charName = args[1].trim();
}
Charsheet.Generate(msg, charName);
}
});
Charsheet.Generate = function(msg, charName) {
var generatorversion = "1.2.1";
var playerid = msg.playerid;
var player = msg.who;
let numString = '';
if (charName === msg.who) {
numString = "#" + (findObjs({_type: "character", controlledby: playerid}).length + 1);
}
/**
* Templates
*/
var template = {
gmnotes: "Player: " + player +"<br>Generated By: CharacterSheet " + generatorversion,
charactername: charName + numString
}
template.channelalert = "created a character named \"" + template.charactername + "\"!";
/**
* Permissions
*
* Valid values are "all" or comma-delimited list of player IDs.
*/
/* Who can view the sheet */
var viewableBy = "all";
/* Who can edit the sheet */
var controlledby = playerid;
/**
* Character generation
*/
/* Create the base character object */
var character = createObj("character", {
name: template.charactername,
archived: false,
inplayerjournals: viewableBy,
controlledby: controlledby
});
/* Set GM Notes */
character.set("gmnotes", template.gmnotes);
/* Set Player's name */
createObj("attribute", {
name: "player_name",
current: player,
_characterid: character.id
});
/* Set Character's name */
createObj("attribute", {
name: "name",
current: template.charactername,
_characterid: character.id
});
/* Set script version, used for debugging */
createObj("attribute", {
name: "sheet_generator",
current: "CharacterSheet v" + generatorversion,
_characterid: character.id
});
sendChat(player, "/me " + template.channelalert);
};