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

Using generic macro modifiers with attributes on an Ability

Hi, I'd love to get some advice here because I've been knocking my head against this issue and I can't find a satisfying solution. Here's the template for a custom Attack formula I'm using for an RP of mine: &{template:default} {{name=@{character_name} attacked @{target|character_name} with its claws!}} {{damage (Phys)=[[ceil((3d10+@{Level}+@{St}*3)*(#damagereduction ))]]}} As it is now it works, but I want to make it look even prettier by having the damage formula be a generic macro so I can reuse the modifier for other stuff, like so:  &{template:default} {{name=@{character_name} attacked @{target|character_name} with its claws!}} {{damage (Phys)=[[ceil((#normalAttackModifier )*(#damagereduction ))]]}} But sadly this gives me the error "error: TypeError: Cannot read property 'substring' of undefined", which means that the macro isn't recognizing the attributes even though I am calling it directly from the character sheet, despite recognizing it when I use the 'target' tag and not asking for two prompts. People have asked a similar question before, but the only answer they gave was to use the 'selected' tag which is pretty dissatisfying to me as it doesn't let me roll to test directly from the sheet, and feels like it could screw up the code later. Is there any solution to this or am I stuck pasting complicated chains of numbers in every formula? I'd like a definitive answer, because I currently have a lot of formulas to burn through.
As you may have guessed, all Attribute calls used outside of the Character Sheet tab or an Ability require a keyword to function. In your case, I would use Attributes instead of Macros to contain your damage formula. It is common practice within Character Sheets, for example, to nest Attributes within other Attributes.
Silvyre said: As you may have guessed, all Attribute calls used outside of the Character Sheet tab or an Ability require a keyword to function. In your case, I would use Attributes instead of Macros to contain your damage formula. It is common practice within Character Sheets, for example, to nest Attributes within other Attributes. Oh man, and just when I'd thrown the towel. That idea is brilliant man! One more question, could I use the ChatSetAtt script to manually set up those formulas for all characters or would I have to do it the hard way?
You could definitely use ChatSetAttr. You'd want to use the --replace functionality, though.
1490656589

Edited 1490656761
Silvyre said: You could definitely use ChatSetAttr. You'd want to use the --replace functionality, though. Uuuhhh... I tried it out, but no dice. The command:  !setattr --sel --replace --DmgMult|(1+0.1*@{TarukajaMod})*(1-(0.1*(floor(@{target|Vi}/10)))-(0.1*@{target|RakukajaMod})) returns the same error as before: TypeError: Cannot read property 'substring' of undefined. For the record, it works when I remove the @s. EDIT: Ok, tried again with the '--'s placed correctly, but it's still not working.
You need to replace the @'s with `
1490657060

Edited 1490657703
Silvyre said: You need to replace the @'s with ` Sweeeeeeeeeeeeeeeeeeet. Thanks, really. Now I'll have to sort it all over again but maybe I can avoid my players bugging the heck out when they try to use macros without selecitng a token. These scripts really do come in handy. EDIT: Oh I ran into another problem (really sorry, guess I'm just pushing these tools as far as I can hahahah). Is there any way to replace the '|' characters? Readme doesn't say, and they're messing up the value setting due to that cursed 'target' tag. EDIT2: Found it!  If you want to use '|' or '#' inside an attribute value, escape it with a preceding backslash: '\|'. Guess that's all, no more questions after that. EDIT3: Oh actually the backslash only works the first time the '|' appears for some strange reason. Guess I'll go ask the script devs what's up with that.
Cool, good luck and happy rolling!