
I am confused on what is exactly needed for chat command handling. My goal is to make a run-once API that will load all of my rollable tables. I just made a single one that would make the 10 GP gems from the DMG to try this out, but it's not parsing my !loot-table command to start itself (as evidenced by the lack of sendChat on the listener.
Am I missing another chunk that activates the chat listener?
Am I missing another chunk that activates the chat listener?
var chatName="Loot-Table-API", tableName, tableFind, error=0; createTable = function(newName){ var newTable; tableFind=findObjs({type: "rollabletable", name: newName}); if(tableFind.length){ sendChat("LootTable-API", "/w GM "+newName+" already exists as a rollable table."); return ""; } else { newTable=createObj("rollabletable",{name: newName}); return newTable; } }, createItem = function(tableFind,itemName,itemWeight){ createObj("tableitem",{ _rollabletableid: tableFind.id, name: itemName, weight: itemWeight }); }, doItAll = function(){ var gems10 = createTable("Gems10"); if(gems10 != ""){ createItem(gems10,"Azurite (plaque mottled deep blue)",1); /* Things I'm taking out of the forum post because I don't want to violate copyright just now / / / */ createItem(gems10,"Turquoise (opaque light blue green)",1); sendChat(chatName, "/w GM "+gems10.name+" was created."); } } registerEventHandlers = function(){ on("chat:message", function (msg) { // Exit if not an api command if (msg.type !== "api") { return; } var tokenized = msg.content.split(" "), command = tokenized[0]; switch(command) { case "!loot-table": sendChat(chatName,"LootTable API called") if(playerIsGM(msg.playerid)) { doItAll(); } break; } }); };