Awesome!
!token-mod --set defaulttokenYou can of course chain this with other set commands:
!token-mod {{ --set represents|@{bob|character_id} bar1_link|hp bar2_link|speed bar3_link|ac controlledby|tom|sally|nancy statusmarkers|blue:3|red:[[1d6]] defaulttoken }}Be sure to set the default token after all the settings you want preserved. For example, if you set bar3_link after, it won't be set when you drag the token out later. (Thanks Jakob!)
Just reread what you said. With linking, you're at the mercy of what the attribute has in it. You could set the value with an inline roll:The Aaron said:
For the 30, you could put it in an inline roll.
!token-mod --set bar3_value|[[@{selected|npcd_speed]]
!token-mod --help
!token-mod --set statusmarkers|!archery-target --ids @{target|token_id}To toggle it on and off.
!token-mod {{ --ignore-selectedThis is the macro I want... but maybe this is already possible. But when I try it I just get an error saying "No character was found for 'Character Name 1'". All player tokens are controlled by the same Player account (since it is face to face) and the "Represents" setting is correctly set.
--ids
-KekZFFMOlXE_D4E68VF
--set
light_radius|60
}}
!token-mod {{
--ignore-selected
--ids
-KekZFFMOlXE_D4E68VF
-KekmGhKlBiwbqJoJoZ5
--set
light_multiplier|2
}}
!token-mod {{ --ignore-selectedAm I just doing this wrong? Or does such functionality need to be added? I know you already have a way to pull token_ids via character names... Just can't figure out how to do this here. Since I'd rather not manually change the token_ids all the time, if I have to use targeting then I will... but I'd rather be able to do it by name.
--ids
@{"Character Name 1"|token_id}
--set
light_radius|60
}}
!token-mod {{
--ignore-selected
--ids
@{"Character Name 1"|token_id}
@{"Character Name 2"|token_id}
--set
light_multiplier|2
}}
if(ids.length){ _.chain(ids) .uniq() .map(function(t){ return { id: t, token: getObj('graphic',t), character: getObj('character',t) }; }) .reduce(function(m,o){ if(o.token){ m.push(o.token.id); } else if(o.character){ m=_.union(m,findObjs({type:'graphic',represents:o.character.id})); } return m; },[]) .reject(_.isUndefined) .each(function(t) { applyModListToToken(modlist,t); }); }Then you should be able to do:
!token-mod {{ --ignore-selected --ids @{Character Name 1|character_id} --set light_radius|60 }} !token-mod {{ --ignore-selected --ids @{Character Name 1|character_id} @{Character Name 2|character_id} --set light_multiplier|2 }}and it will find all tokens representing the specified character_id and adjust them on every map in one go.
ReferenceError: t is not defined ReferenceError: t is not defined at apiscript.js:1633:36 at iterator (/home/node/d20-api-server/node_modules/underscore/underscore.js:184:16) at Function.<anonymous> (/home/node/d20-api-server/node_modules/underscore/underscore.js:199:14) at _.(anonymous function) [as reduce] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34) at handleInput (apiscript.js:1631:22) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:34), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:34), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1510: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)
The Aaron said:
Whoops! Fixed. Changed:m.push(t);tom.push(o.token.id);
m.push(o.token);Got a really odd error when I used !token-mod --flip light_hassight
TypeError: token.get is not a function TypeError: token.get is not a function at applyModListToToken (apiscript.js:1277:36) at apiscript.js:1641:8 at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9) at _.(anonymous function) [as each] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34) at handleInput (apiscript.js:1640:8) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:34), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:34), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1510: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)But changing it to what I mentioned above fixes the problem
!token-mod {{
--on showname
light_hassight
showplayers_name
showplayers_bar1
showplayers_bar2
showplayers_bar3
showplayers_aura1
showplayers_aura2
--set represents|?{Character Name}
bar2_link|ac
bar1_link|hp
bar3_link|spell_save_dc
light_radius|5
light_dimradius|=-5
defaulttoken
}}
on("change:token", function (obj) { if (obj.get("subtype") != "token" || obj.get("isdrawing") == "true") return; if (parseInt(obj.get("bar1_value")) < 0 && parseInt(obj.get("bar1_max")) > 0) obj.set("bar1_value", 0); if (parseInt(obj.get("bar1_value")) > parseInt(obj.get("bar1_max"))) obj.set("bar1_value", parseInt(obj.get("bar1_max"))); });
SkyCaptainXIII said:
Really small api script to keep Bar1 at or above zero, but no higher than the max.
on('ready',function(){ "use strict"; var constrainBar1ToMax = function (obj) { if (obj.get("subtype") != "token" || obj.get("isdrawing") == "true") return; if (parseInt(obj.get("bar1_value")) < 0 && parseInt(obj.get("bar1_max")) > 0) obj.set("bar1_value", 0); if (parseInt(obj.get("bar1_value")) > parseInt(obj.get("bar1_max"))) obj.set("bar1_value", parseInt(obj.get("bar1_max"))); }; on("change:token", constrainBar1ToMax); if('undefined' !== typeof TokenMod && TokenMod.ObserveTokenChange){ TokenMod.ObserveTokenChange(constrainBar1ToMax); } });
The Aaron said:
You could actually modify HB's code to get a notification from TokenMod and enforce that constraint:
The Aaron said:
It depends on what character sheet you're using. If you find the number on a character sheet and right click, inspect it (in chrome), you can look for a name like 'attr_passive_perception' or the like. It's that, without the 'attr_'.
@{target|choose a target|bar1|max}You can replace "choose a target" with whatever you like, that's the label, what gets shown on the query. Any where you use the same label it will only prompt you once, so you could do:
@{target|choose a target|character_name} has @{target|choose a target|bar1}/@{target|choose a target|bar1|max} hp.and it would only ask you which token once.
The Aaron said:
This is a quirk of the way character sheet attributes work. Anywhere you see an attribute ending in "_max" on a character sheet, you translate that to "|max" for an attribute reference in chat. Further, with @{target}, you must specify a label to make it work, so your final reference will be:@{target|choose a target|bar1|max}You can replace "choose a target" with whatever you like, that's the label, what gets shown on the query. Any where you use the same label it will only prompt you once, so you could do:@{target|choose a target|character_name} has @{target|choose a target|bar1}/@{target|choose a target|bar1|max} hp.and it would only ask you which token once.
!token-mod --set height|*2 width|*2To double the size of your token, or this:
!token-mod --set height|/2 width|/2To shrink it back down again.
!token-mod --helpgives me:
For reference, the error message generated was: ReferenceError: msg is not defined ReferenceError: msg is not defined at showHelp (apiscript.js:5721:28) at handleInput (apiscript.js:7016:8) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1510: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 Zd.Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425)
!token-mod --set aura1_radius|
TypeError: Cannot read property 'match' of undefined
TypeError: Cannot read property 'match' of undefined
at parseArguments (apiscript.js:1020:35)
at Function._.map._.collect (/home/node/d20-api-server/node_modules/underscore/underscore.js:172:24)
at _.(anonymous function) [as map] (/home/node/d20-api-server/node_modules/underscore/underscore.js:1496:34)
at parseSetArguments (apiscript.js:1212:5)
at handleInput (apiscript.js:1599:20)
at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:65:16)
at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:70:8)
at /home/node/d20-api-server/api.js:1510: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)
!token-mod --set aura1_radius|0