Richard @ Damery said: Is there any problem with running TokenMod through sendChat() from an API? I'm sure this has been working absolutely fine until the last month or so. In August, I could send the following via sendChat() and it would work absolutely fine, changing the image of a token. !token-mod --ignore-selected --ids -Ngyyexy8HRksV92_vGY --set imgsrc|<a href="https://s3.amazonaws.com/files.d20.io/images/2839308/_RR8niUb3sTQgLSoxDhM4g/thumb.png?1390447785" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/2839308/_RR8niUb3sTQgLSoxDhM4g/thumb.png?1390447785</a> width|70 height|70 Today, it is totally ignored and does nothing when sent via a correctly formatted sendChat() call - I know the sendChat() is correctly formatted as calls to my RPGMaster APIs (such as !magic --pickorput @{selected|token_id}|@{Rm23-Coffer|searcher}|@{Rm23-Coffer|searcher|max}|long) work absolutely fine. If I send the same command from chat, or from an API Button, it works fine. This would be very difficult for me if this fails to work - RoundMaster effects that use TokenMod will not work, and my drag & drop locks and traps will fail. Perhaps there is something that I am doing wrong, or some change notification I've missed? OK, I've been playing around with this issue, and I've reduced the problem down to two issues. I've set up a testbed campaign here and loaded in TokenMod, ChatSetAttr, and a simple API I've created that just takes a command string and sends it to chat, replacing its API command with !token-mod: !tmtest --set bar1_value|8 becomes !token-mod --set bar1_value|8 which is then sent to chat using sendChat('player|'+gm, msg, null, {noarchive:true, use3d:false}); where gm is replaced with the gm's ID, and msg is the translated command. (It's a little more complicated than that, but not much). The text of the translated command is sent to both the chat window and to the Mod console so you can check what was actually sent. Problem 1: !token-mod --set bar1_value|8 does not work via sendChat() If I type directly into the chat window !token-mod --set bar1_value|8 with a token selected, all works fine and Bar1 value is set to 8 However, with the token selected if I use !tmtest --set bar1_value|8 which then replaces !tmtest with !token-mod and sends it via sendChat(), nothing happens. I.e. the same command via typing into the chat window, and sending via sendChat() behaves differently. If I send !tmtest --ids - Nh6mIbDpr2SFNncW6BG --set bar1_value|8, all works fine. Problem 2: API commands in quick succession work intermittently My !tmtest API will take multiple commands on the same line: it splits them on the !, then sends each (with the ! replaced of course) to chat via sendChat(). So if I send the command line !tmtest --ids - Nh6mIbDpr2SFNncW6BG --set bar1_value|7 !setattr --charname TestChar --hp|12 This will send two separate commands to chat by two calls to sendChat() , the first being the !token-mod call and the second the !setattr . The !setattr always works, but the !token-mod is intermittent. I can't see any pattern to why TokenMod sometimes does not fire. Why do I need this? In addition to the over 6,000 pre-programmed database items (magic items, Drag & Drop creatures & containers, class & race definitions, weapons, armour, attack specifications, wizard & priest spells...), my APIs allow GMs to create their own spells, powers, spell effects on tokens & character sheets, Drag & Drop locked & trapped containers, etc. Obviously, I can give them help (see the large number of Help Handouts my APIs generate), but I can't control everything they do, so I try to make it as simple as possible for GMs. This requires them to create Roll20 macros in ability fields on character sheets. These include data tags that my API replaces on the fly, such as the name of the shape of an area of effect, or the name of the damage macro to run on a successful hit with a weapon, etc. Many of the macros, especially in the RoundMaster Effects-DB, use TokenMod and ChatSetAttr to alter the tokens and character sheets to reflect the effects the GM wants to occur. The GM can't access my API or write javaScript, so the approach must be to use API calls in this way, and I want those to work easily, and consistently. I've been developing these APIs over 3 years now, and all of this used to work absolutely fine. I went away for a while, and now I'm helping a GM set up his campaign I find certain things aren't working the same way as they used to - this being one. Do have a look at the RPGMaster suite (on One-Click with that name, which will install everything), and then e.g. use the command !magic --extract-db Locks-Traps-DB
and
!rounds --extract-db Effects-DB and look at the ability fields on the character sheets "Locks-Traps-DB" and "Effects-DB" that are created to see examples of the macros that GM's can write (and that's just one DB of many). As you might realise, this is a bit of a labour of love! I am sure there must be some things I can do better, or differently, to help sort this - as it is I've recently modded all calls to !token-mod to use --api-as <player_id>, though that does not always seem to help. Thoughts very welcome...