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

Dropdown Queries with Calculations?

I have a question about dropdown queries that include calculations. I've been googling this, reading the forums and cannot seem to find what I'm looking for. A bit of background on what I'm attempting to do here: Shadowrun 3rd Edition. To throw a Grenade requires a target number based on the range. This range is based on the character's strength. Essentially I have a macro that calls up a generic character sheet with the Attribute of "Range Grenade." This "Range Grenade" attribute is the dropdown query: 0 to @{Selected|Strength}, 4|@{Selected|Strength}+1 to @{Selected|Strength}*5, 5|@{Selected|Strength}*5+1 to @{Selected|Strength}*10, 8|@{Selected|Strength}*10+1 to @{Selected|Strength}*30, 9 The intent is based on the distance between the player and that target, there is a modifier to the target number. Obviously the further away from the player, the harder it is to hit the target.  Basically it is grabbing the player's strength attribute and plugging it into the @{Selected|Strength}. This is working perfectly in the dropdown. What is not working perfectly is the math parts. Let's say the player's Strength is 8. My dropdown looks like this: 0-8 8+1 to 8*5 8*5+1 to 8*10 8*10+1 to 8*30 The resulting output works if you mentally do the math and selected the correct distance, but. I don't want the players to have to do the math. I'm all about streamlining and I want it calculated in the dropdown. Any ideas on how to edit: 0 to @{Selected|Strength}, 4|@{Selected|Strength}+1 to @{Selected|Strength}*5, 5|@{Selected|Strength}*5+1 to @{Selected|Strength}*10, 8|@{Selected|Strength}*10+1 to @{Selected|Strength}*30, 9 to get this to calculate in the dropdown window? I appreciate you folks looking at this. 
Try bracketing [] the calculations to make them resolve to a single number: 0 to @{Selected|Strength}, 4|[[@{Selected|Strength}+1]] to [[@{Selected|Strength}*5]], 5|[[@{Selected|Strength}*5+1]] to [[@{Selected|Strength}*10]], 8|[[@{Selected|Strength}*10+1]] to [[@{Selected|Strength}*30]], 9
Rabulias said: Try bracketing [] the calculations to make them resolve to a single number: 0 to @{Selected|Strength}, 4|[[@{Selected|Strength}+1]] to [[@{Selected|Strength}*5]], 5|[[@{Selected|Strength}*5+1]] to [[@{Selected|Strength}*10]], 8|[[@{Selected|Strength}*10+1]] to [[@{Selected|Strength}*30]], 9 Tried that already, lol. Looks like this in the dropdown: 0-8 [[8+1]] to [[8*5]] [[8*5+1]] to [[8*10]] [[8*10+1]] to [[8*30]]
Yeah, you'd need to use a sheetworker script and other stuff, to have calculations done for an attribute, that could then be referenced as your drop down option labels.  It is something that goes beyond my knowledge. Why not just have your drop down be the options "close, short, medium, and long", and have the macro include a whisper to the targeted token's owner that tells them what each range category is distance wise?
1528710119
GiGs
Pro
Sheet Author
API Scripter
Instead of a RangeGrenade attribute, you probably need to create a different attribute for each range (GrenadeShort, GrenadeMedium, etc), and have them calculate the ranges. If you're using your own character sheet, you can use a sheetworker or autocalc field to calculate this. Alternatively, you could use an API script to calculate these ranges and present a dropdown menu with the entries filled in. 
Aranador said: Yeah, you'd need to use a sheetworker script and other stuff, to have calculations done for an attribute, that could then be referenced as your drop down option labels.  It is something that goes beyond my knowledge. Why not just have your drop down be the options "close, short, medium, and long", and have the macro include a whisper to the targeted token's owner that tells them what each range category is distance wise? Yeah, I am not too knowledgeable on sheetworker. I thought about doing the close, short, medium, long. Can you actually have a dropdown whisper to the token owner? I have not seen that trick. Do you have an example of what that would look like?
G G said: Instead of a RangeGrenade attribute, you probably need to create a different attribute for each range (GrenadeShort, GrenadeMedium, etc), and have them calculate the ranges. If you're using your own character sheet, you can use a sheetworker or autocalc field to calculate this. Alternatively, you could use an API script to calculate these ranges and present a dropdown menu with the entries filled in.  I did try creating one for each type of range. I ended up getting the same output: 0-8 8+1 to 8*5 8*5+1 to 8*10 8*10+1 to 8*30 or 0-8 [[8+1]] to [[8*5]] [[8*5+1]] to [[8*10]] [[8*10+1]] to [[8*30]] I am using a self created character sheet. When I say that I mean it is 100% text. The Attributes are all the things that my macros use... probably have 100s. The macro for the sheet is one, per the token user called "Menu" which brings up a tailor made list of things that specific player can do. My goal would be to further expand my knowledge of java script. Unfortunately this stupid thing called a job gets in the way of gaming.
what about using command buttons per character sheet they could be whispered.... /w joe [medium](~selected|medium} - [long](~selected|long) then next macro named "medium"...ect...ect... [[(@{Strength}*5)+1]] to [[@{Strength}*10]] ect....ect...
David said: Aranador said: Yeah, you'd need to use a sheetworker script and other stuff, to have calculations done for an attribute, that could then be referenced as your drop down option labels.  It is something that goes beyond my knowledge. Why not just have your drop down be the options "close, short, medium, and long", and have the macro include a whisper to the targeted token's owner that tells them what each range category is distance wise? Yeah, I am not too knowledgeable on sheetworker. I thought about doing the close, short, medium, long. Can you actually have a dropdown whisper to the token owner? I have not seen that trick. Do you have an example of what that would look like? You don't have the drop down to the whisper, you have the macro that the drop down is in do a whisper as well as the drop down.  Basically, a macro can have multiple commands in it.  Every line of the macro gets executed.  So you would have one line be a whisper that tells you what the distances of each range are, and another line that is your query of if you want to do close, short, medium, long.  When you call the macro, it does both of those things.  Then add a third line that is an animated gif of an explosion, because why not. A different approach might be to use a 'chat menu' rather than a drop down query.  It requires you to have several 'sub-macros' but this approach is often simpler than using a query.