All of the @{} references and [[ ]] calls are resolved before any of the API calls occur. The /w GM will happen before the API call, as it gets dispatched earlier, conceptually:: /w gm ... ::= Client -> Chat Server -> Client
!api ... ::= Client -> Cht Server -> API Server -> Client The only way to get things lined up is to have the fetching of the information occur on the API server, which means having a script that is doing it.... Like this! on('ready',() => {
on('chat:message',(msg) => {
if('api'===msg.type && /^!token-summary/i.test(msg.content) && playerIsGM(msg.playerid)){
_.chain(msg.selected)
.map((o)=>getObj('graphic',o._id))
.reject(_.isUndefined)
.each((t)=>{
sendChat('',`/w gm &{template:default}`+
`{{name=${t.get('name')}}}`+
`{{Hit Points=${t.get('bar1_value')}}}`+
`{{Armor Class=${t.get('bar2_value')}}}`+
`{{Passive Perception=${t.get('bar3_value')}}}`
);
});
}
});
});
Then you can use !token-summary to get that output. BTW, you can keep chaining things to set with --set, and you can set the same property more than once and it will go in order, so I'd rewrite that as: !token-mod {{
--set
bar1_link| bar2_link| bar3_link| bar1| bar2| bar3|
bar1|[[ {[[@{selected|npc_hpformula}]],[[@{selected|npc_hpformula}]]}kh1 ]]
bar2_value|@{selected|npcd_ac}
bar3_value|[[10 + [[@{selected|npc_perception}]]]]
--on showname
}}
!token-summary It will be more efficient as it only needs to look up the token once, rather than twice