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 .
×

[Script/Help] Alter Bar on Token (Rage BAR)

1622460993

Edited 1622463197
Start: Hi! i have absolutely little to no idea how scripting works in Roll20. I got some basic experience with Scripting (Mostly Powershell) so i thought i had at least a little insight into this but tbh im a bit Overwhelmed. So lets just go straight to what i wanted Topic: Im Playing a Barbarian with lots of Homebrew abilities. I won't bother you with details but his feature is having multiple stages of Rage kind of like exhaustion just that he gets really pissed, stronger and more dangerous (in the later even to his party). He advances through these stages with Wis-Saves. (DC12* for now) What i wanted to do is: Throwing Wisdom Saves and if it is below VALUE=12 ... add +1 to Bar 3 just to keep track The Costume Wis-Save works (Mostly because I just copied it from the normal wis save) But how to add a (IF Function) or how to make the ! token - mod or !alter-token Stuff work in combination (or even on its own) is beyond me. Or at least currently. Could anyone give me some help? Thanks a ton in advance ! Current code (its really just the wis save with a diffrent name) @{wtype}&{template:simple} {{rname=Controll inner Rage}} {{mod=@{wisdom_save_bonus}}} {{r1=[[@{d20}+@{wisdom_save_bonus}@{pbd_safe}]]}} @{advantagetoggle}+@{wisdom_save_bonus}@{pbd_safe}]]}} {{global=@{global_save_mod}}} @{charname_output} Codeblocks i tryed !alter @{target||token_id} +1 {Add to Bar|+1} !token-mod{{   --set     bar3_current|bar3_value|+1     bar3_max|5 }} So far i found None for the if Functions
1622464716
timmaugh
Roll20 Production Team
API Scripter
Those commands (token-mod and alterbars) are utilizing scripts people wrote... So TokenMod and AlterBars are what we would call the script. Doing what you're doing (using them in a game) requires a Pro subscription to Roll20, or at least that you're playing in a game created by someone with a Pro sub. Once you're that far, either of those commands should work (or you can tweak them to get them right). That's when you run into the fact that there isn't a native IF logical construct to the chat interface. You can get one by utilizing my APILogic meta script (part of the meta Toolbox), to branch your commands. I'll try to post links and examples when I'm back at my PC.
1622465609

Edited 1622465652
I am indeed playing in a Premium Game (at least for the spoken of character). However i do not have GM Access. Could it be something about Permisions too ? something my GM has to enable? APILogic and Meta Scripts also throw big ? for me for now. If you could Provide links to these that would be awesome. Otherwhise ill just google it. Anyways Ty a bunch for the help so far! timmaugh said: Those commands (token-mod and alterbars) are utilizing scripts people wrote... So TokenMod and AlterBars are what we would call the script. Doing what you're doing (using them in a game) requires a Pro subscription to Roll20, or at least that you're playing in a game created by someone with a Pro sub. Once you're that far, either of those commands should work (or you can tweak them to get them right). That's when you run into the fact that there isn't a native IF logical construct to the chat interface. You can get one by utilizing my APILogic meta script (part of the meta Toolbox), to branch your commands. I'll try to post links and examples when I'm back at my PC.
1622477329
timmaugh
Roll20 Production Team
API Scripter
Sopinien said: I am indeed playing in a Premium Game (at least for the spoken of character). However i do not have GM Access. Could it be something about Permisions too ? something my GM has to enable? APILogic and Meta Scripts also throw big ? for me for now. If you could Provide links to these that would be awesome. Otherwhise ill just google it. There are particular scripts that would require GM rights (like Bump), and there are configurations that a script might offer the GM to apply which would give the players more access to functionalities of the script (like TokenMod opening up the "players can use ids" setting). However, I don't think these are your issue. First, you have to make sure that the scripts are installed in the game. Since you don't have GM rights, you have to ask a GM to install them. On the game page for a GM, there will be a "Settings" drop down where they can get to API Scripts, and from there they can copy/paste in script code or install them from the one-click. In your case, you're looking to have either/or of TokenMod and AlterBars installed. Once they are installed, the sandbox can still break and/or go stale, and can require rebooting. This is also a function of the GM, so if at some time you realize that you're getting no output for the script command you are sending through the chat, you will have to reach out to have the sandbox rebooted. I am pretty sure you're running into one of those two cases being true. Once you've installed the scripts and/or rebooted your sandbox (and your sandbox reboots every time you install a script), you should see responses from chat commands that should drive API function. (Also, you could ask your GM to check out the APIHeartbeat script, which gives a visual indication in your game that the sandbox is up and functional.) As for Meta-Scripts... those are scripts (written like other scripts) which interact with the message before normal scripts get the message, adding capability or function to the command line. They don't exist as an end to themselves, but as a way to give other scripts more ability. They use the fact that the message object generated from a single chat entry is handed off one API script to the next ( diagramed and discussed here ). Most "normal" scripts that are an end to themselves have to check whether they should take action on a message; meta-scripts do not. They figure if you are using their recognized syntax structures (like {& if ...} for APILogic, or @(selected...) for Fetch, etc.), then you intend for them to do what they do. I released a handful of meta-scripts and a controlling framework ( ZeroFrame ) as the Meta Toolbox . What you are looking to do would be an APILogic construction. I will probably not get the math of the inline roll right (to match your homebrew), but as an example: !{& if [[1d20+@{Berserker|wisdom_save_bonus}]].value >= 12}token-mod --set bar3_current|+1{& else}Barely... controlled... rage... {&simple}{& end} Note that this is built to be run from anywhere - not just from your character sheet - because I included a name for the character (here, Berserker). Replace that with your character's name to get it to work. If the condition in the IF token passes, then the token-mod command is included. If it fails, the ELSE case is included, which includes a SIMPLE token to turn it into a simple chat message (no longer an API message). That's a really basic example using a single simplified "what-if" from your homebrew. It sounds like your full homebrew would have more cases and more interactions of rolls and saves and levels. With that complexity, other meta-scripts might be helpful (something like Muler or Fetch). If you have any question about going that route, post back with more details about your setup. POST SCRIPT: I should probably mention that Kurt's ScriptCards is another script that could help you. ScriptCards isn't a meta-script (it is an end to itself), but it acts like a command line interface to let you build complex custom procedures for your macro (including ifs and cases). Meta-scripts still work with SC, and they are quite often used, but SC would be responsible for calling tokenmod and/or alterbars.
Thanks! Ive yet to talk about the Scripts with my DM but did i understand correctly that the script bellow works ANYWHERE? No API required? I tryed it and it sadly Just said it "no character 'Ahrokarn' found" Might i need some id or Something? The token as well as the connected sheet are both named Ahrokarn. So i might be doing Something wrong? Also for some reason it didnt post the last two times ive replyed. So i hope i havent sent you this already xD Thanks again btw timmaugh said: Sopinien said: I am indeed playing in a Premium Game (at least for the spoken of character). However i do not have GM Access. Could it be something about Permisions too ? something my GM has to enable? APILogic and Meta Scripts also throw big ? for me for now. If you could Provide links to these that would be awesome. Otherwhise ill just google it. There are particular scripts that would require GM rights (like Bump), and there are configurations that a script might offer the GM to apply which would give the players more access to functionalities of the script (like TokenMod opening up the "players can use ids" setting). However, I don't think these are your issue. First, you have to make sure that the scripts are installed in the game. Since you don't have GM rights, you have to ask a GM to install them. On the game page for a GM, there will be a "Settings" drop down where they can get to API Scripts, and from there they can copy/paste in script code or install them from the one-click. In your case, you're looking to have either/or of TokenMod and AlterBars installed. Once they are installed, the sandbox can still break and/or go stale, and can require rebooting. This is also a function of the GM, so if at some time you realize that you're getting no output for the script command you are sending through the chat, you will have to reach out to have the sandbox rebooted. I am pretty sure you're running into one of those two cases being true. Once you've installed the scripts and/or rebooted your sandbox (and your sandbox reboots every time you install a script), you should see responses from chat commands that should drive API function. (Also, you could ask your GM to check out the APIHeartbeat script, which gives a visual indication in your game that the sandbox is up and functional.) As for Meta-Scripts... those are scripts (written like other scripts) which interact with the message before normal scripts get the message, adding capability or function to the command line. They don't exist as an end to themselves, but as a way to give other scripts more ability. They use the fact that the message object generated from a single chat entry is handed off one API script to the next ( diagramed and discussed here ). Most "normal" scripts that are an end to themselves have to check whether they should take action on a message; meta-scripts do not. They figure if you are using their recognized syntax structures (like {& if ...} for APILogic, or @(selected...) for Fetch, etc.), then you intend for them to do what they do. I released a handful of meta-scripts and a controlling framework ( ZeroFrame ) as the Meta Toolbox . What you are looking to do would be an APILogic construction. I will probably not get the math of the inline roll right (to match your homebrew), but as an example: !{& if [[1d20+@{Berserker|wisdom_save_bonus}]].value >= 12}token-mod --set bar3_current|+1{& else}Barely... controlled... rage... {&simple}{& end} Note that this is built to be run from anywhere - not just from your character sheet - because I included a name for the character (here, Berserker). Replace that with your character's name to get it to work. If the condition in the IF token passes, then the token-mod command is included. If it fails, the ELSE case is included, which includes a SIMPLE token to turn it into a simple chat message (no longer an API message). That's a really basic example using a single simplified "what-if" from your homebrew. It sounds like your full homebrew would have more cases and more interactions of rolls and saves and levels. With that complexity, other meta-scripts might be helpful (something like Muler or Fetch). If you have any question about going that route, post back with more details about your setup. POST SCRIPT: I should probably mention that Kurt's ScriptCards is another script that could help you. ScriptCards isn't a meta-script (it is an end to itself), but it acts like a command line interface to let you build complex custom procedures for your macro (including ifs and cases). Meta-scripts still work with SC, and they are quite often used, but SC would be responsible for calling tokenmod and/or alterbars.
1622642167
timmaugh
Roll20 Production Team
API Scripter
Ahh... let me be clear. First, any statement that begins with an exclamation point is going to be an API message. Those don't get sent directly to chat. Any output that makes it to the chat after an API command line is sent is coming from some API script which picked up the message and sent some output to the chat. If you don't have API access those messages just seem to go nowhere. In fact, you can still have messages that seem to go nowhere, because typically a script is looking to see whether it needs to take action on the message (that is, did you intend to send that message to this script). They do that (again, typically) by looking at the first few characters of the command line. TokenMod is looking for !token-mod , InsertArg is looking for !ia , etc. If you send a command line through that no script picks up, that message will go nowhere: !sassypants --dial|sassy|+100 If you don't have a SassyPants script (or, more specifically, a script that looks for the !sassypants handle), then this message will just pass harmlessly through. By contrast, meta-scripts aren't looking for the message to begin with any particular handle. They're looking for actionable items anywhere in the text. They just get to the message before other scripts (including any that would eventually recognize the command line's handle), look for what they need to do, and get out of the way. Whether or not they do anything, the idea is that the message continues to the script that is eventually going to "pick up". Harry Potter: "Where does the message go?" That means that the command line I posted (with the APILogic constructions) will only work if you have the APILogic script installed and a functional sandbox. Second, what I meant when I said that command would work "anywhere" is the difference between including the character name or not. From a character sheet you don't have to include the character name to reference some data from that character's sheet: @{JazzHands} From the sheet, the above will get the JazzHands attribute from that character. However, that won't work entered directly into chat. You have to include the character's name: @{Englebert Slaptiback|JazzHands} By including the character's name, my command line should work from a character or from chat. So for your game to tell you that there isn't a character by that name... is there a character by that name? That you have control over? Even without API access, you should be able to put a call like the above (including the character name) into chat and get the appropriate return of information.
Ahh ok got it. So to edit the Bars i need API's or it wont work! ... (or well ... without the API's ...it dosnt understand the commands im giving it...or the message is not being Processed. As far as ive understood so far). About the Character tho. Yes there should be a token, char and sheet named that way. HP etc also is linked between them so id assume the Token should have the same name as the Sheet then? Here is what ive got:  And Here is the Error Message that is displayed in Chat uppon use:  No character was found for 'Ahrokarn' I then played around myself a little bit and used Selected instead of the Characters name. That one probably worked? At least i didnt get an error message that time... but it didnt increase the Bar_3 either. Tho once again... as far as ive understood we still need the API for that. Right? After all it DOSE seem to understand that (what i want from it) it is a script... or at least it recognises syntax. Otherwhise it wouldt tell me that it couldnt find the character (if we'd assume the message is sent into the void). So...the command is Processed! Or is just Part of it Processed? I assume the part in the IF {brackets} is understood by Roll20 even without the use of Extra API's ? And the Token-Mod stuff still requires me to install stuff. Correct? Because in that case it is to be assumed that it SHOULD work with selected. (Once API's etc are installed). Why it dosnt work with the name tho... i dont know. Maybe i have to use 'NAME' "NAME" %NAME% for the variable or something? 
Picture had to be Really super duper Tiny because im on the Free-Membership and i assume upload limits also affect forum posts. Oop x_x
1622680383
timmaugh
Roll20 Production Team
API Scripter
There is no way to modify the bars via chat EXCEPT with a script. You can return the value of a bar, but not change it. For a selected token you can do: @{selected|bar1} For a named token (or using the token ID) you can return it with the Fetch formation (only in an API call): @(Ahrokarn.bar1) But when you use the standard Roll20 formation (curly braces) with a character's name, it will be looking for an ATTRIBUTE... not a TOKEN PROPERTY (like bar1, bar2, etc.). The fact that it's telling you it can't find a character named that tells me that you don't have a character sheet attached to that token... you just have a token of that name. In order to pull an attribute off the character sheet, you have to have a sheet backing up that token. This wiki article has good info on linking a token to the character sheet. Start there and make sure you have the character by the name you want to use.