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 .
×
This post has been closed. You can still view previous posts, but you can't post any new replies.

Update the macro system to allow variables and control statements

(EDIT: on further experimentation, it looks like a little of what I want to do already works! I didn't realize the formula was @{character|attribute}) I would love to have the following commands added to the text chat window (and hence the macro system): /as Aerith This causes me to select the token linked to Aerith on the object layer, and causes all references to @{attribute} to be replaced with @{Aerith|attribute}. For example, @{hitpoints} will be interpreted as @{Aerith|hitpoints}. (Selecting Aerith from the 'As:' dropdown should have the same effect) /as This causes all references to @my:attribute to be replaced with the character associated with the next character-linked token that I click. For example, if I type /as (or run a macro which has /as in it) and click on Aerith, all references to @{hitpoints} will be interpreted as @{Aerith|hitpoints}. If you don't select a character-linked token with your next click, it says "not a character" and cancels back out to the chat window. /target Bob This causes me to select the token linked to Bob on the object layer, and causes all references to @{target|attribute} to be replaced with @{Bob|attribute} within macros. For example, @{target|hitpoints} will be interpreted as @{Bob|hitpoints}. /target This causes all references to @{target|attribute} to be replaced with the character associated with the next character-linked token that I click. For example, if I type /target (or run a macro which has /target in it) and click on Bob, all references to @{target|hitpoints} will be interpreted as @{Bob|hitpoints}. If you don't select a character-linked token with your next click, it says "not a character" and cancels back out to the chat window. /set @{character|attribute} = value The "set" command takes whatever is after the "=" and processes it as if it was typed into chat, but instead of putting the result into the chat window, it puts it into the specified @{character|attribute}. For example, if I type: /set @{Bob|damage_die} = /roll 1d6-1 It will perform /roll 1d6-1, and then put the result of that roll into @{Bob|damage_die}. /if value1 == value2 then command This will check to see if value1 and value2 are string-equivalent. If they are, then it performs command (which could be just text to say, or a #macro, or /em or /if or /set or /roll); otherwise, it does nothing. (We don't really need nesting or do...while control, since we can use #macros as a recursion system) This lets me set up things like "Descent" dice, like so: #attack /set @{damage_die} = /roll 1d6-1 /set @{range_die} = /roll 1d6-1 /set @{damage} = X /if @{damage_die} == 1 then /set @{damage} = ♥♥♥ /if @{damage_die} == 2 then /set @{damage} = ★♥♥ /if @{damage_die} == 3 then /set @{damage} = ♥♥ /if @{damage_die} == 4 then /set @{damage} = ★♥ /if @{damage_die} == 5 then /set @{damage} = ♥ /if @{range_die} == 0 then /set @{damage} = ★@{damage} /set @{range} = /roll 1d0*0 + @{range_die} + @{damage_die} You rolled @{range}@{damage}.
Well what you want is going to be implemented in a different way. Supporters get the preliminary of rollable tables where you can set the table to equal the sides of that damage die. I miss Descent. My brother owned it but then he moved away. I think setting up the macro in chat like that with text is also clunky, a macro is something that is preset. Now if you could set an ATTRIBUTE like that with a macro, that would be useful since you could have a macro that changes a character attribute for something like a shapeshift or ability enhancement spell. And having attributes on a sheet being variables is kind of the point. Oh, I see what you mean now in setting the randomly rolled variable to be calculated, then right? If it can be just part of the equation then there would be no need. Also having if/then statements  with /set attribute statements then you could do something like:  /set @target_AC = 15 /roll 1d20+7 if .>@target_AC == /roll 1d4+4
bingo! (Edited original to be slightly clearer) As long as you have /set and /if, you can pretty much do anything you want with (preset) macros. Having them available both in macros and in the basic chat system allows us to use the macros as a nesting / recursion system. I suppose that if a attribute doesn't exist for a particular character, /set will need to create that attribute, then set it to the value specified.
Ok, re-edited to include almost everything necessary to build a full scripting language (albeit a somewhat clunky one). The only other thing that would be amazing would be to reference a character token's X and Y positions on the grid as if they were attributes.
Brent D. said: Ok, re-edited to include almost everything necessary to build a full scripting language (albeit a somewhat clunky one). While I appreciate the effort and input, you should be aware that we're already working on an API that will let you do what you've outlined. We're not making it part of the macro system for exactly the reason that doing so just ends up with a clunky scripting language bolted on top of a system that's not designed for it.
Rockin'! Do you guys need help coding? I'm an experienced and unemployed game developer and would love to volunteer my time to help, if you're willing. (My usual coding solutions are much more elegant than what you saw up-thread; I was just proposing something that I figured could be implemented really quickly to give people like me a quick solution)
Brent D. said: Rockin'! Do you guys need help coding? I'm an experienced and unemployed game developer and would love to volunteer my time to help, if you're willing. Send me a PM with your info (email, etc.).