Aaron said: So, you want to store the status somewhere and pull it out in scripts? Use the state object. Be sure to namespace your use of the state object. I create an entry with the name of my script, something like this: var AScriptName = AScriptName || (function() {
'use strict';
var version = 0.3,
schemaVersion = 0.1,
HandleInput = function(msg) {
/* api commands */
/////////////////////////////
// after some processing
/////////////////////////////
if(!_.has(state.AScriptName.mookStatus,token_id)) {
state.AScriptName.mookStatus[token_id] = {
SR: 19,
SomethingElse: 'data'
};
} else {
state.AScriptName.mookStatus[token_id].SR=19;
}
},
checkInstall = function() {
if( ! _.has(state,'AScriptName') || state.AScriptName.version !== AScriptName.schemaVersion)
{
/* Default Settings stored in the state. */
state.AScriptName = {
version: AScriptName.schemaVersion,
mookStatus: {}
};
}
},
registerEventHandlers = function() {
on('chat:message', HandleInput);
};
return {
RegisterEventHandlers: registerEventHandlers,
CheckInstall: checkInstall
};
}());
on("ready",function(){
'use strict';
AScriptName.CheckInstall();
AScriptName.RegisterEventHandlers();
});
That could work, but I prefer to work out of the character sheet so that the information is easily accessible. State variables are difficult to check, so it would be difficult to verify whether or not a particular mook has Spell Resistance or a boost to its AC or something like that. For example, if SR was stored as a state variable, if I wanted to remember whether or not a particular mook has SR, I would have to use some kind of API command to get that information. However, if it's just in the character sheet, I can just bring that up and look for myself. Also, wouldn't state variable information be inaccessible from Roll20 macros? Like say I wanted to roll against a character's SR and it was kept as a state variable, wouldn't that be impossible to do from a macro or a chat command?