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

automated looping macros for all attributes in a repeating section

1461616127
Phoxounet
Sheet Author
Translator
Hi there ! I recently tried to make a macro with attributes coming from a repeating section. If you definitively know what will be the number of the row, it is pretty easy by referring to rows with $0, $1, $n. Anyway, the way I see repeating section is the possibility to have multiple rows without knowing their numbers at the beginning. Moreover, if repeating sections is used for evolving sections (like it looks like to be designed for) like stuff, skills, etc., you can't simply use a global macro for your sheet without knowing n, number of rows.  My suggestion is to have a value for $ (let's say n) that will make the macro to loop for every values, and return all results as a different result of the macro. For example, it can really usefull with a query. Here is a piece of code regarding advanced skills using repeating fields. <div > <fieldset class="repeating_skill"> <input type="text" name="attr_skill_name"style="margin-left:5px;width:145px;"/> <input type="text" name="attr_skillcarac"style="width:30px;margin-left:1px;font-weight:lighter;"/> <input type="radio" name="attr_skill" value="1" style="margin-left:15px;" checked/> <!--1/2--> <input type="radio" name="attr_skill" value="2"/> <!-- taken--> <input type="radio" name="attr_skill" value="3" style="margin-left:20px;"/> <!-- +10%--> <input type="radio" name="attr_skill" value="4"style="margin-left:23px;"/> <!-- +20% --> <input type="text" value="0" name="attr_totalskill" style="width:40px;height:18px;background:black;margin-left:25px;"/> <divstyle="width:10px;margin-left:1px;" >%</div> </fieldset> </div> here is the macro I made : !power {{ --corners|10 --charid|@{character_id} ?{Skill ? ?| @{repeating_skill_$0_skillname} (@{repeating_skill_$0_totalskill} %), --name|@{repeating_skill_$0_skillname} --emote|**@{character_name}** rolls for **@{repeating_skill_$0_0_skillname}** ! --rightsub|Advanced Skill --Skill:|**@{repeating_skill_$0_totalskill} %** --Degree of Success:|[[ [$Roll] floor((@{repeating_skill_$0_totalskill}+?{Bonus|0}-1D100cs<@{repeating_skill_$0_totalskill}cf>@{repeating_skill_$0_totalskill})/10)]] --?? $Roll >= 0 ?? Success| ! --?? $Roll< 0 ?? Fail| ! | @{repeating_skill_$1_skillname} (@{repeating_skill_$1_totalskill} %), --name|@{repeating_skill_$1_skillname} --emote|**@{character_name}** rolls for **@{repeating_skill_$1_skillname}** ! --rightsub|Advanced Skill --Skill:|**@{repeating_skill_$1_totalskill} %** --Degree of Success:|[[ [$Roll] floor((@{repeating_skill_$1_totalskill}+?{Bonus|0}-1D100cs<@{repeating_skill_$1_totalskill}cf>@{repeating_skill_$1_totalskill})/10)]] --?? $Roll>= 0 ?? Success| ! --?? $Roll< 0 ?? Fail| ! } }} Problem is that players won't have the same number of advanced skills and not all players would be able to understand it or correctly modify it. Here is an example of what could be done : !power {{ --corners|10 --charid|@{character_id} ?{Skill ? ?| @{repeating_skill_$n_skillname} (@{repeating_skill_$n_totalskill} %), --name|@{repeating_skill_$n_skillname} --emote|**@{character_name}** rolls for **@{repeating_skill_$n_skillname}** ! --rightsub|Advanced Skill --Skill:|**@{repeating_skill_$n_totalskill} %** --Degree of Success:|[[ [$Roll] floor((@{repeating_skill_$n_totalskill}+?{Bonus|0}-1D100cs<@{repeating_skill_$n_totalskill}cf>@{repeating_skill_$n_totalskill})/10)]] --?? $Roll >= 0 ?? Success| ! --?? $Roll< 0 ?? Fail| ! | In my proposal, checking $n would start to recover the n values of the repeating section and then pass all values in a loop : $0, $1, $2 to $n. It would then propose a drop down query based on the dynamic range of row permitted by repeating sections. Any macro embedded within a query would achieve far simplier results than having to manually check each time how many rows are present in a repeating section. Regards :)
1461616829
Silvyre
Forum Champion
Support!
1492685925
Loki
Sheet Author
I definitely support this too. For me it's an actual problem, that I have to know, how many rows a player in the given repeating section has and I can therefore only make character-tailored macros that must be updated when the repeating sections row count changes.
1492691204
Phoxounet
Sheet Author
Translator
Hi ! I made an example coming from the use of Powercards (pro users) but it also should be possible to create a floating query using $n. However, that means that it would behave like arrays e.g. : ?{weapon query ?|@{repeating_weapons_$n_weaponName}, @{selected|token_name} uses his/her @{repeating_weapons_$n_weaponName} to attack his/her targetand get [[1D20+@{repeating_weapons_$n_totalBonus}]] and deals [[@repeating_weapons_$n_totalDamage]]} As you can see here, the app would pass each n value to the repeating section meaning it will get 0, 1, 2 until it reach the end of the section. Each time n takes a value, it would replace all n values in the step of the loop meaning the first pass would give the first weapon name in the query, then the output would deliver the attack and damages rolls for this weapon. $n would allow the query to loop and transform the designed query into the necessary one e.g. having the number of necessary lines depending on n value. For example, let's say you have 3 weapons in our example. Here is how the app should have the query interpreted like below, behind the scene. ?{weapon query ?|@{repeating_weapons_$0_weaponName}, @{selected|token_name} uses his/her @{repeating_weapons_$0_weaponName} to attack his/her targetand get [[1D20+@{repeating_weapons_$0_totalBonus}]] and deals [[@repeating_weapons_$0_totalDamage]]| @{repeating_weapons_$1_weaponName}, @{selected|token_name} uses his/her @{repeating_weapons_$1_weaponName} to attack his/her targetand get [[1D20+@{repeating_weapons_$1_totalBonus}]] and deals [[@repeating_weapons_$1_totalDamage]]| @{repeating_weapons_$2_weaponName}, @{selected|token_name} uses his/her @{repeating_weapons_$2_weaponName} to attack his/her targetand get [[1D20+@{repeating_weapons_$2_totalBonus}]] and deals [[@repeating_weapons_$2_totalDamage]]} So far, for this kind of query, the app would have to : 1) read the number of rows in the repeating section. 2) create loops incremeting n at each step. 3) add a | at the end of each line 4) close the query when n reaches the last value (meaning it replace the | by a } Regards :)
Thanks for the suggestion! After 30 days, Suggestions and Ideas with fewer than 10 votes are closed and the votes are refunded to promote freshness. Your suggestion didn't build the right momentum this time, but feel free to submit it again! We find that the best suggestions describe the problem you are having, and the solution you want. You can learn more about the process of making suggestions on the Roll20 Wiki! More details can be found here .