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

!spawn mod --expand could 3rd param handle false/no/0?

I'm trying to use !spawn to add randomness to whether a trap is there or not by using the --expand optional 3rd param that deletes spawned token after animation completes with a roll query that either gives a 1 (that would delete the token) or a 0 (that i thought would just be ignored). I used the roll query to add options of probability to the event, see below for the code: !Spawn {{ --name|trap --expand|30,30, ?{???|yes,1|probably,[[round(1d4/3)]]|maybe,[[1d2-1]]|probably not,[[floor(1d4/4)]]|no,0} }} It isn't working as !spawn just errors if it gets anything but 1/yes/true in that 3rd --expand param. Any chance this is an easy tweak for !spawn or if not does someone have any ideas that can point me towards an easy way to randomise the chances of a macro being called. What i've been trying to do is create a standard thing i can put before a macro that would randomise whether it was called or not i've never quite got it to work so i've ended up just tweaking different custom methods for different situations. Before i thought of this method for the trap i was using the following: !Spawn {{ --name|trap?{???|yes,1|probably,[[round(1d4/3)]]|maybe,[[1d2-1]]|probably not,[[floor(1d4/4)]]|no,0} }} this way i just named the trap item trap1, so if the roll query resulted in 1 it would spawn the trap, if not it would just give an error no token my this name exists etc. it worked but was messy and annoying having to put a number at the end of the item name.
1719025254

Edited 1719025264
timmaugh
Forum Champion
API Scripter
What about: !{&if  ?{???|yes,[[1]]|probably,[[1d4>2]]|maybe,[[1d4>3]]|probably not,[[1d4>4]]|no,[[0]]}.value = 1} Spawn {{   --name|trap   --expand|30,30 }}{&end} That requires the Metascript Toolbox, but it works. Also, I simplified your rolls a bit, but you can go back to what you had, just the same. The important bit is that every value returned from the query is a roll, so that the . value syntax will extract the value.
1719026759
David M.
Pro
API Scripter
Not sure I understand this approach (temporarily spawning a token that shouldn't be there in the first place). Do you have scriptcards installed? With SC and SelectManager, you could use the following to take the binary query result and only fire the Spawn command if the result is a 1. The "--+" lines are optional chat output. If you don't want any chat output, you could add a "--#hidecard|1" line anywhere within the curly braces. !script {{ --=isTrap|?{Is there a trap?|yes,1|probably,[[round(1d4/3)]]|maybe,[[1d2-1]]|probably not,[[floor(1d4/4)]]|no,0} --?[$isTrap] -eq 1|[ --+There's a trap!| --@forselected|Spawn _name|trap --]|[ --+No Trap| --]| }} 
thanks guys those are both great, really appreciate the help and the explanations