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

Is there a way to expand macros for charactersheets for automatically calculated fields?

1431551248

Edited 1431551490
I would like to have a input field with name="attr_spell_name" and then have some textfield/textarea where i can fetch the description of said spell_name from a database like structure like here <a href="https://app.roll20.net/forum/post/1949684/database" rel="nofollow">https://app.roll20.net/forum/post/1949684/database</a>... with %{Spell-@{spell_name{|Description{ Sadly, it looks like macros are not expanded for value fields. Is there a way to get the current players name per macro such that I can write a macro to /w @{myself{ %{Spell-@{spell_name{|Description{ ? I know that talktomyself doesn't work for that (from the wiki:) Note: API commands (a Mentor subscription feature) will not be executed when /talktomyself is on.
1431586325
Kryx
Pro
Sheet Author
API Scripter
You can't have a variable be composed of other variables. It doesn't work in programming in general.
Mark said: You can't have a variable be composed of other variables. It doesn't work in programming in general. Not true... in javascript and especially in the powercards api, I have variables calling other variables such as Rolls[RollID][Type]. Regarding Kevin's question, there is currently no way to get the player name / display name that is in the SpeakingAs box below the chat window... without using the API.
1431589626
Kryx
Pro
Sheet Author
API Scripter
HoneyBadger said: Not true... in javascript and especially in the powercards api, I have variables calling other variables such as Rolls[RollID][Type] Not sure if you used the bracket syntax purposefully, but brackets are either an object or an array in javascript which is totally possible to look at an item in an object/array based on another variable. What you can't have is a variable named "foo" and then another variable named "boo_foo" and expect the boo variable to be "boo_XXXXX" where XXXXX is the contents of foo. The op is asking for that.
1431592757

Edited 1431592862
Of course this does work, I use this for the macros of my spell rolltemplate. The problem is it does not work in general. You can use this for a roll because roll20 will expand those terms until no terms are found. I haven't tried it, but i assuem there is a built in maximum and you can't create an endless loop, at least i hope so ;) Also i think there is a differentiation between calling a macro which will be expanded meanwhile calling it. I use the exact code above for my shadowrun 5 charactersheet successfully to make first get @{spell_name{ to "Fireball" and then expand the term by calling the macro %{Spell-Fireball|Description{ Roll20 seem to first expand variables with @{name{ and then call the macros. What shall i say, it works on my sheet and I use it for spells, skills and all other lookups such that i can avoid to have hardcoded all information into the sheet. The problem is i need a database of characters for that, but i have opened another question how to avoid this ;) The problem is, roll20 does not expand this everywhere and obviously you can't do this without thinking because you could very easily generate endless loops. I just hoped there was a way to expand it for value attributes of autocalculated input type="text" fields.
1431593285
Kryx
Pro
Sheet Author
API Scripter
Kevin said: Roll20 seem to first expand variables with @{name{ and then call the macros. Ah, roll20 uses some parsing to parse names before anything else. Makes sense. But I don't really understand your syntax. /w @{myself{ %{Spell-@{spell_name{|Description{ ? @{myself is referencing a variable on your journal, but you don't have the "|" character? Same with spell_name. And no closing brackets, but I assume you just left those off.
1431593574

Edited 1431593646
I left the closing brackets off because I am not able to type them here in this chat editor - Altough this is really annoying. I see now how using another opening bracket was a stupid example. I will use a &gt; instead of a closing curly bracket ok? /w @{myself&gt; %{Spell-@{spell_name&gt;|Description&gt; Where there exists a character name e.g. Spell-Fireball which has a macro named Description which contains text like "You shoot fire from your hands". Why do I want this? This would allow me to let players lookup rule texts for complicated stuff like spells by making such queries without spamming the gm (which would be the fallback alternative) or spamming the chat for all others. Especially since it can be expected that this query would contain a lot of text. This macro would be called on a button inside of a fieldset for repeating areas like spells.
1431593695
Kryx
Pro
Sheet Author
API Scripter
Ok, now that makes a LOT more sense. You should be able to use closing brackets though. /w @{myself} %{Spell-@{spell_name}|Description} That would indeed work because roll20 parses the names before anything else.
1431593838

Edited 1431593935
} I can copy paste them - but if it type them they immediatly get removed ... straaaange.... Ok i can use alt+125 but typing it directly on the keyboard removes them from the chat. It gets stranger and stranger. The problem is @{myself} does not exist as predefined macro or constant. I just thought i could use a input field "Playername" and refer to that for the charactersheets, but this would be limited to characters sheets and I am not sure what would happen if the macro would be called from outside, likely it would fail.