
Hello all, I'm not a very experienced scripter, but am trying to write a function that is called when a new token ("obj") that represents a character is created. The idea is that the function will look at the represented character's attributes and will make an array of all the attributes named "spawn_with". These attributes have a character id as current value and a comma separated list of xOffset, yOffset, xSize and ySize as the max value. The function should go through the array of attributes and use !forceselected (from SelectManager) and Spawn to spawn that token in a position relative to the original token. The command that is sent to sendChat is logged, so that I can see what actually is sent. It seems like the sendChat command does not work (nothing appears in chat). However, when I copy the logged command and paste it into chat, it does work. Is this something that can be fixed, or is it impossible to call Spawn Default Token from a script in this way? Thanks, Thomas spawnNearSpawn = function (obj) { var character=findObjs({type:"character", _id: obj.get("represents")})[0]; var spawnList= findObjs({ type: 'attribute', _characterid: character.get("_id"), name: "spawn_with"}); var newCharacter, xOffset, xSize, yOffset, ySize, name; var chatCommand; _.each(spawnList, function(attribute){ newCharacter=getObj("character",attribute.get("current")); xOffset=attribute.get("max").split(",")[0]; yOffset=attribute.get("max").split(",")[1]; xSize=attribute.get("max").split(",")[2]; ySize=attribute.get("max").split(",")[3]; name=newCharacter.get("name"); chatCommand="!forselected Spawn --name| "+name+" --offset| "+xOffset+","+yOffset+" --size| "+xSize+","+ySize+" {& select "+obj.get("_id")+"}"; sendChat("GM",chatCommand); log(chatCommand); }); };