Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[API] Setting character Bio

1421032581

Edited 1421033297
What are the api specifics to set the Bio of a character object, I can get the contents with the callback function, but how can I set it.
1421039550
The Aaron
Roll20 Production Team
API Scripter
Getting is handled asynchronously, but setting works as normal using either the function notation or the object notation: // function notation charobj.set('bio', 'bunch of text'); // object notation charobj2.set({ bio: 'bunch of more text' }); Wiki: <a href="https://wiki.roll20.net/API:Objects#Using_the_Note" rel="nofollow">https://wiki.roll20.net/API:Objects#Using_the_Note</a>...
1421054150

Edited 1421054328
Were it only that simple, it seems to like to crash the API when I do that, so I figured there was some secret sauce I'm not aware of. API docs are pretty lacking. I isolated this from my mob-gen script. on("chat:message", function (msg) { var cmdName = "!test_char"; var msgTxt = msg.content; // make the API shut up about avatar images even if none is provided... if (!(msg.selected && msg.selected.length &gt; 0)) { log ("no token selected to given the character some silly image."); return; } var token = getObj('graphic', msg.selected[0]._id); if (msg.type == "api" && msgTxt.indexOf(cmdName) !== -1) { log("check char bio"); var character = createObj("character", { avatar: token.get("imgsrc"), name: "name1", bio: "words1", gmnotes: "", archived: false, inplayerjournals: "", controlledby: "" }); /* character.get('bio',function(bio){ log("bio is " + bio); }); */ log("set bio manually.."); character.set('bio','words2'); }; });
1421073991
The Aaron
Roll20 Production Team
API Scripter
I believe you're having the Firebase.child crash, not a crash related to which field you are setting. Try this version: on("chat:message", function (msg) { 'use strict'; var cmdName = "!test_char", msgTxt = msg.content, fixedCreateObj = (function () { return function () { var obj = createObj.apply(this, arguments); if (obj && !obj.fbpath) { obj.fbpath = obj.changed._fbpath.replace(/([^\/]*\/){4}/, "/"); } return obj; }; }()); // make the API shut up about avatar images even if none is provided... if (!(msg.selected && msg.selected.length &gt; 0)) { log ("no token selected to given the character some silly image."); return; } var token = getObj('graphic', msg.selected[0]._id); if (msg.type === "api" && msgTxt.indexOf(cmdName) !== -1) { log("check char bio"); var character = fixedCreateObj(createObj("character", { avatar: token.get("imgsrc"), name: "name1", bio: "words1", gmnotes: "", archived: false, inplayerjournals: "", controlledby: "" })); /* character.get('bio',function(bio){ log("bio is " + bio); }); */ log("set bio manually.."); character.set('bio','words2'); } }); Reference: Discussion of this bug and it's solution: Community Forums: [API] "Firebase.child failed" Error - Help Please! | Roll20 -- virtual tabletop gaming that tells a story
Well that's an odd bug, I'll have to brush up more on my javascript.
1421162133
The Aaron
Roll20 Production Team
API Scripter
It's not really Jacascript so much as Firebase. It's a known issue which will hopefully get fixed soon.