I'm still relatively new to this API and JavaScript. But I had this functionality working up until earlier today. Now, I can't get properties from objects. I removed all my scripts, and started fresh. on("chat:message", function(msg) { if (msg.type == "api" && msg.content.indexOf("!InfoDump") !== -1 && msg.who.indexOf("(GM)") !== -1) { log("InfoDump: " + msg);
_.each(msg.selected, function(obj) { log(obj); }); } });
Selecting some objects in the UI and running the script, I get these expected results. Restarting sandbox due to script changes... Spinning up new sandbox... "InfoDump: [object Object]" {"_id":"-J8_2kYzjoXSHg6cp_ja","_type":"graphic"} {"_id":"-J8_2nj1UGOVgqANMPDz","_type":"graphic"} {"_id":"-J8_2o2kIcsMMJpP_X5k","_type":"graphic"} {"_id":"-J8_2ojNFSM0aipVy0jB","_type":"graphic"} {"_id":"-J8_2pDo0i3oZoE3IZs4","_type":"graphic"} However, if I modify the script by adding a single line. on("chat:message", function(msg) { if (msg.type == "api" && msg.content.indexOf("!InfoDump") !== -1 && msg.who.indexOf("(GM)") !== -1) { log("InfoDump: " + msg); _.each(msg.selected, function(obj) { log(obj); var selObjType = obj.get("_type"); }); } }); I get the following. I did not change which objects were selected. Restarting sandbox due to script changes...
Spinning up new sandbox...
TypeError: Object [object Object] has no method 'get'
at evalmachine.<anonymous>:137:34
at Array.forEach (native)
at Function._.each._.forEach (/home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:78:11)
at Sandbox.<anonymous> (evalmachine.<anonymous>:134:11)
at eval (