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

Macro for price of magic item

For my DND campaign I use a similar macro to determine the price of a magic item. Is there a more elegant solution than outputting two results to the chat? Because of the different dice, I can't come up with anything useful. For example, here I use a higher number if the bidding went badly and a lower number if the players tried to get a discount. And if none of this happened, then we look at the first result. We enter the name of the item, select the rarity and roll the dice. If it is a consumable, then we divide the result by 2. &{template:default} {{name=Purchase ?{Enter item name}}} {{ Item Cost [[(?{Select Rarity|Common,(1d6+1)*12|Uncommon,(1d6+1)*120|Rare,(1d6+1)*1200|Very Rare,(1d8+1)*6000|Legendary,(2d6)*30000})/?{Is this a consumable|No,1|Yes,2}]] / [[(?{Select Rarity})/?{Is this a consumable}]] gp}}
1741225118
timmaugh
Forum Champion
API Scripter
Are you open to a metascript solution? It would provide the same default template output, but it could be simplified to only have to present one number, and probably with fewer queries per roll. If that's something you'd be interested in, I can work up a model and share it here.
timmaugh said: Are you open to a metascript solution? It would provide the same default template output, but it could be simplified to only have to present one number, and probably with fewer queries per roll. If that's something you'd be interested in, I can work up a model and share it here. Yes, why not? I would be grateful.
I'm not sure I follow what you're trying to improve here - what do you mean by more elegant solution? What doesn't your macro do that you would like it to do?
1741271205
timmaugh
Forum Champion
API Scripter
OK, here is the metascript mockup. First, install the Metascript Toolbox (if you haven't already). Then create an ability on a character. For my example, the character is named "MuleBoy" and the ability is named "TreasureValue". You can rename those easily enough since they only appear in one place in the command line I'll provide, below. Just update the command line to match whatever names you choose. Make sure that anyone who will need to run this command has controlling rights to the MuleBoy character. In the ability you created, paste this verbiage: Common={\&if globBargain = Favorable}({1d6,1d6}kh1{\&elseif globBargain = Unfavorable}({1d6,1d6}kl1{\&else}(1d6{\&end}+1)*12 Cons.Common={\&if globBargain = Favorable}({1d6,1d6}kh1{\&elseif globBargain = Unfavorable}({1d6,1d6}kl1{\&else}(1d6{\&end}+1)*6 Uncommon={\&if globBargain = Favorable}({1d6,1d6}kh1{\&elseif globBargain = Unfavorable}({1d6,1d6}kl1{\&else}(1d6{\&end}+1)*120 Cons.Uncommon={\&if globBargain = Favorable}({1d6,1d6}kh1{\&elseif globBargain = Unfavorable}({1d6,1d6}kl1{\&else}(1d6{\&end}+1)*60 Rare={\&if globBargain = Favorable}({1d6,1d6}kh1{\&elseif globBargain = Unfavorable}({1d6,1d6}kl1{\&else}(1d6{\&end}+1)*1200 Cons.Rare={\&if globBargain = Favorable}({1d6,1d6}kh1{\&elseif globBargain = Unfavorable}({1d6,1d6}kl1{\&else}(1d6{\&end}+1)*600 VeryRare={\&if globBargain = Favorable}({1d8,1d8}kh1{\&elseif globBargain = Unfavorable}({1d8,1d8}kl1{\&else}(1d8{\&end}+1)*6000 Cons.VeryRare={\&if globBargain = Favorable}({1d8,1d8}kh1{\&elseif globBargain = Unfavorable}({1d8,1d8}kl1{\&else}(1d8{\&end}+1)*3000 Legendary={\&if globBargain = Favorable}({2d6,2d6}kh1{\&elseif globBargain = Unfavorable}({2d6,2d6}kl1{\&else}(2d6{\&end}+1)*30000 Cons.Legendary={\&if globBargain = Favorable}({2d6,2d6}kh1{\&elseif globBargain = Unfavorable}({2d6,2d6}kl1{\&else}(2d6{\&end}+1)*15000 Save that ability (hit the checkmark). The command line you will want to run is: !&{template:default} {{name=Purchase ?{Enter item name}}} {{ Item Cost={\\&r}get.MuleBoy.TreasureValue.?{How common?|Common|Uncommon|Rare|Very Rare,VeryRare|Legendary|Cons. Common,Cons.Common|Cons. Uncommon,Cons.Uncommon|Cons. Rare,Cons.Rare|Cons. Very Rare,Cons.VeryRare|Cons. Legendary,Cons.Legendary}/get{\\&/r}gp}}{&simple}{&global ([globBargain]?{Bargaining result|Favorable|Unfavorable|Neutral}) } That can be entered into chat, assigned to a button, and/or stored in an ability or macro. The command line consolidates the consumability of an item with its rarity (i.e. "Cons. Common" is a category, as is "Common" -- or "non-consumable Common"). Here are some example outputs. First was a "Common Doodad" with favorable bargaining. Then there was the Uncommon Krunk (the best kind of krunk, though it's still just the krunk), with neutral bargaining. Finally, we were unable to look around us to find a way to fashion a rudimentary lathe, so we purchased a Consumable Rare Rudimentary Lathe after unfavorable bargaining.
1741271493
timmaugh
Forum Champion
API Scripter
Tuo, I think the basic efficiency sought after (at least as I understood it) was managing the keep high/low mechanic over different dice types (for the different rarities) so that the result could simply present a single value (single roll).
timmaugh said: Tuo, I think the basic efficiency sought after (at least as I understood it) was managing the keep high/low mechanic over different dice types (for the different rarities) so that the result could simply present a single value (single roll). timmaugh said: OK, here is the metascript mockup. First, install the Metascript Toolbox (if you haven't already). Then create an ability on a character. For my example, the character is named "MuleBoy" and the ability is named "TreasureValue". You can rename those easily enough since they only appear in one place in the command line I'll provide, below. Just update the command line to match whatever names you choose. Make sure that anyone who will need to run this command has controlling rights to the MuleBoy character. In the ability you created, paste this verbiage: Common={\&if globBargain = Favorable}({1d6,1d6}kh1{\&elseif globBargain = Unfavorable}({1d6,1d6}kl1{\&else}(1d6{\&end}+1)*12 Cons.Common={\&if globBargain = Favorable}({1d6,1d6}kh1{\&elseif globBargain = Unfavorable}({1d6,1d6}kl1{\&else}(1d6{\&end}+1)*6 Uncommon={\&if globBargain = Favorable}({1d6,1d6}kh1{\&elseif globBargain = Unfavorable}({1d6,1d6}kl1{\&else}(1d6{\&end}+1)*120 Cons.Uncommon={\&if globBargain = Favorable}({1d6,1d6}kh1{\&elseif globBargain = Unfavorable}({1d6,1d6}kl1{\&else}(1d6{\&end}+1)*60 Rare={\&if globBargain = Favorable}({1d6,1d6}kh1{\&elseif globBargain = Unfavorable}({1d6,1d6}kl1{\&else}(1d6{\&end}+1)*1200 Cons.Rare={\&if globBargain = Favorable}({1d6,1d6}kh1{\&elseif globBargain = Unfavorable}({1d6,1d6}kl1{\&else}(1d6{\&end}+1)*600 VeryRare={\&if globBargain = Favorable}({1d8,1d8}kh1{\&elseif globBargain = Unfavorable}({1d8,1d8}kl1{\&else}(1d8{\&end}+1)*6000 Cons.VeryRare={\&if globBargain = Favorable}({1d8,1d8}kh1{\&elseif globBargain = Unfavorable}({1d8,1d8}kl1{\&else}(1d8{\&end}+1)*3000 Legendary={\&if globBargain = Favorable}({2d6,2d6}kh1{\&elseif globBargain = Unfavorable}({2d6,2d6}kl1{\&else}(2d6{\&end}+1)*30000 Cons.Legendary={\&if globBargain = Favorable}({2d6,2d6}kh1{\&elseif globBargain = Unfavorable}({2d6,2d6}kl1{\&else}(2d6{\&end}+1)*15000 Save that ability (hit the checkmark). The command line you will want to run is: !&{template:default} {{name=Purchase ?{Enter item name}}} {{ Item Cost={\\&r}get.MuleBoy.TreasureValue.?{How common?|Common|Uncommon|Rare|Very Rare,VeryRare|Legendary|Cons. Common,Cons.Common|Cons. Uncommon,Cons.Uncommon|Cons. Rare,Cons.Rare|Cons. Very Rare,Cons.VeryRare|Cons. Legendary,Cons.Legendary}/get{\\&/r}gp}}{&simple}{&global ([globBargain]?{Bargaining result|Favorable|Unfavorable|Neutral}) } That can be entered into chat, assigned to a button, and/or stored in an ability or macro. The command line consolidates the consumability of an item with its rarity (i.e. "Cons. Common" is a category, as is "Common" -- or "non-consumable Common"). Here are some example outputs. First was a "Common Doodad" with favorable bargaining. Then there was the Uncommon Krunk (the best kind of krunk, though it's still just the krunk), with neutral bargaining. Finally, we were unable to look around us to find a way to fashion a rudimentary lathe, so we purchased a Consumable Rare Rudimentary Lathe after unfavorable bargaining. Thank you very much, this is exactly what I needed
I don't see why the metascript here is necessary, when a simple nested query achieves the same results: &{template:default} {{name=Purchase ?{Enter item name} }} {{Item Cost=?{How common?|Common,[[?{Bargaining result|Favorable,(2d6kl1+1)|Neutral,(1d6+1)|Unfavorable,(2d6kh1+1)}*12]]gp |Uncommon,[[?{Bargaining result|Favorable,(2d6kl1+1)|Neutral,(1d6+1)|Unfavorable,(2d6kh1+1)}*120]]gp |Rare,[[?{Bargaining result|Favorable,(2d6kl1+1)|Neutral,(1d6+1)|Unfavorable,(2d6kh1+1)}*1200]]gp |Very Rare,[[?{Bargaining result|Favorable,(2d8kl1+1)|Neutral,(1d8+1)|Unfavorable,(2d8kh1+1)}*6000]]gp |Legendary,[[?{Bargaining result|Favorable,({2d6,2d6}kl1+1)|Neutral,(2d6+1)|Unfavorable,({2d6,2d6}kh1+1)}*30000]]gp |Common (Consumable),[[?{Bargaining result|Favorable,(2d6kl1+1)|Neutral,(1d6+1)|Unfavorable,(2d6kh1+1)}*6]]gp |Uncommon (Consumable),[[?{Bargaining result|Favorable,(2d6kl1+1)|Neutral,(1d6+1)|Unfavorable,(2d6kh1+1)}*60]]gp |Rare (Consumable),[[?{Bargaining result|Favorable,(2d6kl1+1)|Neutral,(1d6+1)|Unfavorable,(2d6kh1+1)}*600]]gp |Very Rare (Consumable),[[?{Bargaining result|Favorable,(2d8kl1+1)|Neutral,(1d8+1)|Unfavorable,(2d8kh1+1)}*3000]]gp |Legendary,[[?{Bargaining result|Favorable,({2d6,2d6}kl1+1)|Neutral,(2d6+1)|Unfavorable,({2d6,2d6}kh1+1)}*15000]]gp}}}
1741285450
Gauss
Forum Champion
Just a note, "simple" and "nested query" for most folks don't belong in the same sentence. :D Even though I do not understand how to write the metascript mockup timmaugh wrote I can look at it and it makes sense to me.  Even though I can write the nested query, looking at it makes less sense to me. So it is just a personal preference thing.  It is kind alike Algebra vs Calculus. They can both do the same calculation solves, but Algebra takes a much longer route and is a lot more involved.  While I always try to provide the non-Pro version of things, if someone does have a Pro account, there is no reason not to leverage the tools available and keep things simpler to use, which in some cases may be an API Script.  Tuo said: I don't see why the metascript here is necessary, when a simple nested query achieves the same results: &{template:default} {{name=Purchase ?{Enter item name} }} {{Item Cost=?{How common?|Common,[[?{Bargaining result|Favorable,(2d6kl1+1)|Neutral,(1d6+1)|Unfavorable,(2d6kh1+1)}*12]]gp |Uncommon,[[?{Bargaining result|Favorable,(2d6kl1+1)|Neutral,(1d6+1)|Unfavorable,(2d6kh1+1)}*120]]gp |Rare,[[?{Bargaining result|Favorable,(2d6kl1+1)|Neutral,(1d6+1)|Unfavorable,(2d6kh1+1)}*1200]]gp |Very Rare,[[?{Bargaining result|Favorable,(2d8kl1+1)|Neutral,(1d8+1)|Unfavorable,(2d8kh1+1)}*6000]]gp |Legendary,[[?{Bargaining result|Favorable,({2d6,2d6}kl1+1)|Neutral,(2d6+1)|Unfavorable,({2d6,2d6}kh1+1)}*30000]]gp |Common (Consumable),[[?{Bargaining result|Favorable,(2d6kl1+1)|Neutral,(1d6+1)|Unfavorable,(2d6kh1+1)}*6]]gp |Uncommon (Consumable),[[?{Bargaining result|Favorable,(2d6kl1+1)|Neutral,(1d6+1)|Unfavorable,(2d6kh1+1)}*60]]gp |Rare (Consumable),[[?{Bargaining result|Favorable,(2d6kl1+1)|Neutral,(1d6+1)|Unfavorable,(2d6kh1+1)}*600]]gp |Very Rare (Consumable),[[?{Bargaining result|Favorable,(2d8kl1+1)|Neutral,(1d8+1)|Unfavorable,(2d8kh1+1)}*3000]]gp |Legendary,[[?{Bargaining result|Favorable,({2d6,2d6}kl1+1)|Neutral,(2d6+1)|Unfavorable,({2d6,2d6}kh1+1)}*15000]]gp}}}
I also shy away from nested queries where possible and in this instance they are avoidable without relying on scripts. Some keep/drop shenanigans are sufficient. Whislt this solution is no longer required- might as well provide it for completeness. &{template:default} {{name=Purchase ?{Enter item name}}} {{Item Cost [[{ {?{Select Rarity| Common,(1d6+1)*12| Uncommon,(1d6+1)*120| Rare,(1d6+1)*1200| Very Rare,(1d8+1)*6000| Legendary,(2d6)*30000} } + {?{Select Rarity} }*[[abs({1,-1}?{Bargaining result| Favorable,k1| Unfavorable,kl1| Neutral,k2})]]}?{Bargaining result}/?{Is this a consumable|No,1|Yes,2}]] gp}} The favourable/unfavourable is just a straight keep high/low on the two roll totals. The neutral however keeps both totals but zeros out the second. The key to that being the abs({1,-1}k??) which is 1 when you keep 1 or 0 when you keep 2 and thus can use the same query for the keep modifier
RainbowEncoder said: I also shy away from nested queries where possible and in this instance they are avoidable without relying on scripts. Some keep/drop shenanigans are sufficient. Whislt this solution is no longer required- might as well provide it for completeness. &{template:default} {{name=Purchase ?{Enter item name}}} {{Item Cost [[{ {?{Select Rarity| Common,(1d6+1)*12| Uncommon,(1d6+1)*120| Rare,(1d6+1)*1200| Very Rare,(1d8+1)*6000| Legendary,(2d6)*30000} } + {?{Select Rarity} }*[[abs({1,-1}?{Bargaining result| Favorable,k1| Unfavorable,kl1| Neutral,k2})]]}?{Bargaining result}/?{Is this a consumable|No,1|Yes,2}]] gp}} The favourable/unfavourable is just a straight keep high/low on the two roll totals. The neutral however keeps both totals but zeros out the second. The key to that being the abs({1,-1}k??) which is 1 when you keep 1 or 0 when you keep 2 and thus can use the same query for the keep modifier Oh, that is very clever, I like that. That keep/drop selection method seems like it would be useful in a bunch of other situations too, I'll have to try to keep it in mind!
1741291874
vÍnce
Pro
Sheet Author
Anytime I see Tuo, Timmaugh and the RainbowEncoder (note: freely substitute any with The Aaron or Doc Brown) in the same thread I assume there is a high probability of a disturbance in the space-time-continuum...
1741320974
timmaugh
Forum Champion
API Scripter
Lol Bringing the party to every thread.