I've added API to create the effect. The same effect can be achieved by adding abilities manually. Once your open the character sheet to re-order them, this causes them to re order correctly which tells me it's something to do with initial ordering while adding. That's because when you shift them in the sheet, the update causes them to order properly. function doThings(token) {
var funcFixNewObject = function(obj) {
var p = obj.changed._fbpath;
var new_p = p.replace(/([^\/]*\/){4}/, "/");
obj.fbpath = new_p;
return obj;
};
var charSheet = null, charId = null;
var items = ["1","2","3","4","5","6","7","8","9","10","11"];
var name = "Some-name";
charSheet = createObj("character", {
avatar: token.get("imgsrc"),
name: name,
gmnotes: "",
archived: false,
inplayerjournals: "",
controlledby: ""
});
charSheet = funcFixNewObject(charSheet);
if (!charSheet) {
log("ERROR: could not create character sheet");
return;
}
charId = charSheet.get('_id');
token.set("represents",charId);
for (var item in items) {
createObj("ability", {
name: items[item],
description: '',
action: "! \nMarco text for " + items[item] + "!",
istokenaction: true,
characterid: charId
});
}
sendChat('API',"done, check token actions for " + name);
}
on("chat:message", function (msg) {
var cmdName = "!ability_bug";
var msgTxt = msg.content;
// make the API shut up about avatar images even if none is provided...
if (msg.type == "api") {
if (msg.content.indexOf(cmdName) != -1) {
if (!(msg.selected && msg.selected.length > 0)) {
sendChat('API',"no token selected for demonstration");
return;
}
var token = getObj('graphic', msg.selected[0]._id);
doThings(token);
}
}
});