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

Apparent Bug in Power Card

Using the following macro !power {{&nbsp; &nbsp;--ordinal|@{Global|Date}&nbsp; --year|[[floor(@{Global|Date}/365)]] --day-of-year| [[@{Global|Date} - floor(@{Global|Date}/365)*365]]&nbsp; --??&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &gt; 0&nbsp; AND&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &lt; 31 ?? Month|January&nbsp; --??&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &gt; 30&nbsp; AND&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &lt; 58 ?? Month|February &nbsp; results in the following output ordinal &nbsp;678910 year &nbsp;<span class="userscript-inlinerollresult userscript-showtip userscript-tipsy" original-title="Roll: floor(678910 / 365) Results: floor(678910/365) = 1860" style="box-sizing: content-box; min-width: 1.75em; text-align: center; display: inline-block; font-weight: bold; height: 1em; margin-top: -1px; margin-bottom: 1px; padding: 0px 2px; border: 1px solid rgb(135, 133, 10); border-radius: 3px; background-color: rgb(255, 254, 162);">1860 day-of-year &nbsp;<span class="userscript-inlinerollresult userscript-showtip userscript-tipsy" original-title="Roll: 678910 - floor(678910 / 365) 365 Results: 678910 - floor(678910 / 365) 365 = 10" style="box-sizing: content-box; min-width: 1.75em; text-align: center; display: inline-block; font-weight: bold; height: 1em; margin-top: -1px; margin-bottom: 1px; padding: 0px 2px; border: 1px solid rgb(135, 133, 10); border-radius: 3px; background-color: rgb(255, 254, 162);">10 Month &nbsp;February Month &nbsp;February
1589984122
Ziechael
Forum Champion
Sheet Author
API Scripter
Powercards doesn't work with labels that are the same: Try this: !power {{&nbsp; &nbsp;--ordinal|@{Global|Date}&nbsp; --year|[[floor(@{Global|Date}/365)]] --day-of-year| [[@{Global|Date} - floor(@{Global|Date}/365)*365]]&nbsp; --??&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &gt; 0&nbsp; AND&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &lt; 31 ?? !Month1|**Month:** January&nbsp; --??&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &gt; 30&nbsp; AND&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &lt; 58 ?? !Month2|**Month:**&nbsp;February }}
Ziechael said: Powercards doesn't work with labels that are the same: Try this: !power {{&nbsp; &nbsp;--ordinal|@{Global|Date}&nbsp; --year|[[floor(@{Global|Date}/365)]] --day-of-year| [[@{Global|Date} - floor(@{Global|Date}/365)*365]]&nbsp; --??&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &gt; 0&nbsp; AND&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &lt; 31 ?? !Month1|**Month:** January&nbsp; --??&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &gt; 30&nbsp; AND&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &lt; 58 ?? !Month2|**Month:**&nbsp;February }} Now the output is ordinal &nbsp;678910 year &nbsp;<span title="Roll: floor(678910 / 365) Results: floor(678910/365) = 1860" class="userscript-inlinerollresult userscript-showtip userscript-tipsy" style="box-sizing: content-box; min-width: 1.75em; text-align: center; display: inline-block; font-weight: bold; height: 1em; margin-top: -1px; margin-bottom: 1px; padding: 0px 2px; border: 1px solid rgb(135, 133, 10); border-radius: 3px; background-color: rgb(255, 254, 162);">1860 day-of-year &nbsp;<span title="Roll: 678910 - floor(678910 / 365) 365 Results: 678910 - floor(678910 / 365) 365 = 10" class="userscript-inlinerollresult userscript-showtip userscript-tipsy" style="box-sizing: content-box; min-width: 1.75em; text-align: center; display: inline-block; font-weight: bold; height: 1em; margin-top: -1px; margin-bottom: 1px; padding: 0px 2px; border: 1px solid rgb(135, 133, 10); border-radius: 3px; background-color: rgb(255, 254, 162);">10 Month: &nbsp;January Month: &nbsp;February still not right :(
1589988458

Edited 1589988655
Ziechael
Forum Champion
Sheet Author
API Scripter
Is the end result of your equation 30 or 31? &gt; and &lt; are the same as &gt;= and &lt;= in Roll20 Also, not sure if it makes a difference but you have some double spacing in your conditional sections?
In pseudocode, it looks something like this day-of-year = 10 if (day-of-year &gt; 0 OR day-of-year &lt; 31) then&nbsp; !Month1|**Month:** January endif if (day-of-year &gt; 30 OR day-of-year &lt; 58) then&nbsp; &nbsp;!Month2|**Month:**&nbsp;February &nbsp; endif as such, it should not be printing out both&nbsp; Month: &nbsp;January Month: &nbsp;February
1589997633

Edited 1589997698
GiGs
Pro
Sheet Author
API Scripter
In roll20, the &gt; symbol means &gt;=, and the &lt; symbol means &lt;=, so the month listings should be --??&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &gt; 1&nbsp; AND&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &lt; 31 ?? !Month1|**Month:** January&nbsp; --??&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &gt; 32&nbsp; AND&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &lt; 59 ?? !Month2|**Month:**&nbsp;February That doesnt seem like it explains your issue though if the day of the year is 10 - its comfortably inside those edges.
1589999553

Edited 1590000372
GiGs said: In roll20, the &gt; symbol means &gt;=, and the &lt; symbol means &lt;=, so the month listings should be --??&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &gt; 1&nbsp; AND&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &lt; 31 ?? !Month1|**Month:** January&nbsp; --??&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &gt; 32&nbsp; AND&nbsp; [[@{Global|Date} - floor(@{Global|Date}/365)*365]] &lt; 59 ?? !Month2|**Month:**&nbsp;February That doesnt seem like it explains your issue though if the day of the year is 10 - its comfortably inside those edges. No, because the day-of-year starts at zero.&nbsp; I know it sounds weird, but it is a consequence of how year is determined (ie by taking the number of days since day zero and dividing it by 365).
For your pseudocode, shouldn't those two IF statements be in one IF statement? A day-of-year value of 10 makes both of those statements True, so both months print. It's entirely possible I am missing something here...
Rabulias said: For your pseudocode, shouldn't those two IF statements be in one IF statement? A day-of-year value of 10 makes both of those statements True, so both months print. It's entirely possible I am missing something here... I'm sorry.&nbsp; I'm not following you.&nbsp; Please, clarify for me.
1590012336

Edited 1590012393
if (day-of-year &gt; 0 OR day-of-year &lt; 31) then&nbsp; !Month1|**Month:** January endif 10 &gt; 0 and 10 &lt; 31 so this statement evaluates to True. if (day-of-year &gt; 30 OR day-of-year &lt; 58) then&nbsp; &nbsp;!Month2|**Month:**&nbsp;February &nbsp; endif 10 !&gt; 30 but 10 &lt; 58, so this statement also evaluates to True. If you only want January OR February (not both), then you need to structure it more like: if (day-of-year &gt; 0 OR day-of-year &lt; 31) then&nbsp; !Month1|**Month:** January else if (day-of-year &gt; 30 OR day-of-year &lt; 58) then&nbsp; &nbsp;!Month2|**Month:**&nbsp;February endif so only one choice prints out . Assuming you are doing the whole year, a Switch might be a better option than an If loop. Or maybe use ANDs in your statements instead of ORs? I may be misinterpreting your goal, and I hope I am not cluttering things here.
Rabulias said: if (day-of-year &gt; 30 OR day-of-year &lt; 58) then&nbsp; &nbsp;!Month2|**Month:**&nbsp;February &nbsp; endif 10 !&gt; 30 but 10 &lt; 58, so this statement also evaluates to True. Except the logic condition on that second if doesn't say OR, it says AND
Brian N. said: Rabulias said: if (day-of-year &gt; 30 OR day-of-year &lt; 58) then&nbsp; &nbsp;!Month2|**Month:**&nbsp;February &nbsp; endif 10 !&gt; 30 but 10 &lt; 58, so this statement also evaluates to True. Except the logic condition on that second if doesn't say OR, it says AND Rabulias &nbsp;said: &nbsp;a Switch might be a better option than an If loop. Is Switch available in PowerCard?
Brian N. said: Except the logic condition on that second if doesn't say OR, it says AND It clearly says OR in your pseudocode post above, but I think I understand you are saying that in your actually code it is an AND.
Rabulias said: Brian N. said: Except the logic condition on that second if doesn't say OR, it says AND It clearly says OR in your pseudocode post above, but I think I understand you are saying that in your actually code it is an AND. Looks like I had a brainfart when I wrote the pseudocode.