
I would like to share some of the work I have been doing on my sheet. Here is my armor and weapons section of my Pathfinder sheet. It is a slot based system, but I noticed I left out the belt (everyone needs that girdle of strength!) but that is trivial atm. Pic: There are some nice features here. While you can not see it, each of the AC Bonus fields are part of the autocalc for the Total AC on the statistics page of my sheet. The same for the Penalty (for skill checks) and arcane spell Failure. Max Dex and the Magical Properties are just fluff text for your reference. Ok, now for the part that is where I need help. I have some adhoc buttons there for updating my @{"STAT"_misc_mod} to act as dirty sheet JS emulation. The scripts that power (2 for each row) work just fine. My question is just about security. If you notice at the top I have a message saying to only push the update button once. That is because, atm, I have no way of checking if the button has already been pushed and that the stat bonus field as already been added to @{"STAT"_misc_mod}. So right now, every time the update button is pushed, it fires the script and keeps adding the value. So my question is: how do I handle checking if a value has been previously added? Here is the contents of the "Boots" add button. (note: each update button is independent of each and powered by its own script)
on('chat:message', function(msg) {
if (msg.type != 'api') return;
var parts = msg.content.split(' ');
var command = parts.shift().substring(1);
if (command == 'updatesheet')
{
var selectedId = parts[0];
var selectedToken = getObj('graphic', selectedId);
var who = getObj('character', selectedToken.get('represents'));
var bootStat = parseInt(getAttrByName(who.id, "boots_mod"));
var statbonus = parseInt(getAttrByName(who.id, "boots_stat_bonus"));
if(bootStat == "STR")
{
var statMisc = parseInt(getAttrByName(who.id, "STR_mod_temp"));
var search = "STR_mod_temp";
}
if(bootStat == "DEX")
{
var statMisc = parseInt(getAttrByName(who.id, "DEX_mod_temp"));
var search = "DEX_mod_temp";
}
if(bootStat == "CON")
{
var statMisc = parseInt(getAttrByName(who.id, "CON_mod_temp"));
var search = "CON_mod_temp";
}
if(bootStat == "INT")
{
var statMisc = parseInt(getAttrByName(who.id, "INT_mod_temp"));
var search = "INT_mod_temp";
}
if(bootStat == "WIS")
{
var statMisc = parseInt(getAttrByName(who.id, "WIS_mod_temp"));
var search = "WIS_mod_temp";
}
if(bootStat == "CHA")
{
var statMisc = parseInt(getAttrByName(who.id, "CHA_mod_temp"));
var search = "CHA_mod_temp";
}
var statTemp;
var objMSTR = findObjs({_type: "attribute", name: search, _characterid: who.id})
if (objMSTR.length > 0)
{
statTemp = objMSTR[0];
}
statTemp.set("current", STRmisc + statbonus);
}
}); Would the best way be to introduce an embodying if () statement that checks to see if var statbonus > 0. If it is, return, else, continue with script?