Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

OnMyTurn + TokenMod, not working together?

I can't seem to get this TokenMod command to work The Aaron's OnMyTurn script.  !token-mod --ids @{Bruce Grayson|character_id} --current-page --set statusmarkers|+half-haze The code itself runs fine when isolated and applies the status marker to the token as wanted, but when I use it in an OnMyTurn ability on Bruce Grayson's character sheet, I get the following error report: For reference, the error message generated was:  TypeError: Cannot read properties of undefined (reading 'get') TypeError: Cannot read properties of undefined (reading 'get') at apiscript.js:39022:44 at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:168:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:168:1), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1762:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425) at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:111:461 I have tried using the Meta Script Toolbox's Select Manager to inject/select the appropriate token instead, but it kicks back a similar error. I have even tried swapping the Token Mod command out with a Combat Master status-adding command, but the same result happens.  The character has a Cloak of Displacement, and that effect returns at the beginning of their turn, so I want it to apply the status whenever his turn comes around. Ideally, I would also like to use the Meta Scripts to only apply it if the token does not have two other certain status markers, but that's another can of worms for after this problem is solved. Thanks in advance for any help you can provide!
1720702230
timmaugh
Pro
API Scripter
Two things to look at, here...  First, in TokenMod, there is an option to run the command *as* a player in the event that it is called by another script. A lot of times, SelectManager will take care of this for you, but in certain instances you have to use this bit of syntax from TokenMod: --api-as <player-id> Sub in your player id to have it run as you. If you don't know your player ID and you have the Metascript Toolbox installed, you can get it by speaking as your player name and running this simple command: !Your PlayerID is @(speaker.player_id){&simple} If that doesn't work on its own, then the second thing you can check is the SelectManager configuration. Run: !smconfig ...and check the settings. If either "playerid" or "who" is not enabled, you might want to turn them on, by running: !smconfig +who +playerid Conditional Once you get that to work, the conditional you're looking for (checking for the presence of 2 other status markers) would look something like this (this version checks for the status markers "stopwatch" and "blue", and incorporates the --api-as argument with a made-up player id): !{&if @(Bruce Grayson.is.stopwatch) = yes && @(Bruce Grayson.is.blue) = yes}token-mod --ids @{Bruce Grayson|character_id} --current-page --set statusmarkers|+half-haze --api-as -MYm6xDmt1Ze5LnVz59E{&end}
1720752082

Edited 1720752169
timmaugh said: !smconfig ...and check the settings. If either "playerid" or "who" is not enabled, you might want to turn them on, by running: !smconfig +who +playerid Thank you Timmaugh, this fixed the crash issue with OnMyTurn! Now the other bit that I had mentioned, the conditional, isn't working as expected, but I think that's because I didn't actually explain it well. My goal is to have the "half-haze" condition apply only IF the the token does NOT have the "Restrained-Chained::492975" or "Incapacitated::492782" statuses, or both of them, i.e. the presence of either or both prevents the "half-haze" condition from applying. I understand this to be a logical expression like this (simplified for my own mental processing): {& if restrained = true || incapacitated = true || ( restrained = true && incapacitated = true ) } "command for applying half-haze" {& else} "a dummy 'command' that will NOT apply half-haze" {& end} Now, with this command as written below, I replaced the status you supplied with the ones I would like to use (listed above), and supplied a correct player_id, and got it to function for the logic that is written in it. I was able to come up with the further iteration below.  Conditional Once you get that to work, the conditional you're looking for (checking for the presence of 2 other status markers) would look something like this (this version checks for the status markers "stopwatch" and "blue", and incorporates the --api-as argument with a made-up player id): !{&if @(Bruce Grayson.is.stopwatch) = yes && @(Bruce Grayson.is.blue) = yes}token-mod --ids @{Bruce Grayson|character_id} --current-page --set statusmarkers|+half-haze --api-as -MYm6xDmt1Ze5LnVz59E{&end} My version: !{&if @(Bruce Grayson.is.Incapacitated) = yes || @(Bruce Grayson.is.Restrained-Chained) = yes }token-mod --ids @{Bruce Grayson|character_id} --current-page --set statusmarkers|-half-haze --api-as -MZF6ShaEOUdddrqiipF{& else}token-mod --ids @{Bruce Grayson|character_id} --current-page --set statusmarkers|+half-haze --api-as -MZF6ShaEOUdddrqiipF{&end} This version works well in isolation, i.e. when prompted manually. It applies "half-haze" if "restrained-chained" or "incapacitated" aren't present, and removes it if either or both of them are, which also function as preventing it from applying but was easy to write with a token-mod status marker removal.  However, the above does NOT work within an OnMyTurn call when the token's turn comes around. I get the following crash error, regardless of the True or False states of the logical statement:  For reference, the error message generated was:  TypeError: Cannot read properties of undefined (reading 'get') TypeError: Cannot read properties of undefined (reading 'get') at apiscript.js:39022:44 at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:168:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:168:1), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1762:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425) at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:111:461 Thank you so much for your help so far, it is absolutely a workable thing with some manual input right now. But I want to learn from this too and try to get this to work as intended. Can you think of any reason why the command works when manually called but not by OnMyTurn? Maybe there's a better way of writing it that achieves the same results without the crash?
1720754380
timmaugh
Pro
API Scripter
If you have ScriptInfo installed, can you run this command and share the output? !scriptinfo 39022 If you *don't* have ScriptInfo installed, can you 1) install it, 2) re-generate the above error just to confirm that the line number stays the same, and then 3) run the above command swapping in the line number that reports with the newly generated error? That will help me narrow down which script is having an issue.
1720754601

Edited 1720754634
That line did stay the same, the " apiscript.js:39022:44" bit.
1720756490

Edited 1720756578
I updated my command to a cleaner version with less duplicate text, but it still causes the same crash when used with OnMyTurn.  !token-mod --ids @{Bruce Grayson|character_id} --current-page --set statusmarkers|{&if @(Bruce Grayson.is.Incapacitated) = yes || @(Bruce Grayson.is.Restrained-Chained) = yes }-{& else}+{&end}half-haze --api-as -MZF6ShaEOUdddrqiipF Maybe it'll help knowing that it still happens regardless of the command?
1720788040
timmaugh
Pro
API Scripter
Ok... That's interesting because anything involved in what you're doing should be reporting its offset (OnMyTurn, TokenMod, and the metascripts). What is installed right before Plugger?
1720788186
timmaugh
Pro
API Scripter
Rocklobster said: I updated my command to a cleaner version with less duplicate text, but it still causes the same crash when used with OnMyTurn.  !token-mod --ids @{Bruce Grayson|character_id} --current-page --set statusmarkers|{&if @(Bruce Grayson.is.Incapacitated) = yes || @(Bruce Grayson.is.Restrained-Chained) = yes }-{& else}+{&end}half-haze --api-as -MZF6ShaEOUdddrqiipF Maybe it'll help knowing that it still happens regardless of the command? Good. I was going to make this suggestion before we were through, but I didn't want to confuse things while we were looking at the error. =D
1720805411

Edited 1720805438
timmaugh said: Ok... That's interesting because anything involved in what you're doing should be reporting its offset (OnMyTurn, TokenMod, and the metascripts). What is installed right before Plugger? Here's a screenshot of what's installed. I've never messed with load order. Not sure why that's so blurry, yikes!