I have been banging my head against the well trying to get this to work. This is the beginning of a script which will handle auto calculation for things that can't be calculated with normal equations. // Ensure fatigue_skillgrade exists
on("add:character", function(obj) {
createObj('attribute', {
name: 'fatigue_skillgrade',
characterid: obj.id,
current: 'Standard'
});
});
// Actually change values (will be dependent on fatigue value once I get past this problem)
on("add:attribute", function(obj) {
var attributeName = obj.get("name");
if (attributeName == "fatigue") {
var fatigueSkillGrade = findObjs({_type: 'attribute', _characterid: obj.get('_characterid'), name: 'fatigue_skillgrade'})[0];
log(fatigueSkillGrade);
fatigueSkillGrade.set({current: 'Hard'});
//fatigueSkillGrade.set('current', 'Hard'); // Same problem
log(fatigueSkillGrade);
}
});
Everything seems to work okay if the line setting current for fatigueSkillGrade is commented out. You can see in the first two lines of output that the value actually does change but it throws an error anyway. If anyone sees a problem in the code please let me know. This is the output I get: {"name":"fatigue_skillgrade","current":"Standard","max":"","_id":"-JeRvnLoYq5emnTZHNsJ","_type":"attribute","_characterid":"-JeRvJJD3aVtI_fY_VbC"}
{"name":"fatigue_skillgrade","current":"Hard","max":"","_id":"-JeRvnLoYq5emnTZHNsJ","_type":"attribute","_characterid":"-JeRvJJD3aVtI_fY_VbC"}
/home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1
orts, require, module, __filename, __dirname) { function f(a){throw a;}var j=v
^
Error: Firebase.child failed: First argument must be a non-empty string and can't contain ".", "#", "$", "[", or "]".
at Error (<anonymous>)
at Ha (/home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:12:204)
at G.W.H (/home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:126:213)
at TrackedObj._doSave (