|
|
(3 intermediate revisions by the same user not shown) |
Line 29: |
Line 29: |
|
| |
|
| <div class="ext_background1" style="display:block;color:#fff;text-shadow: 0 0 2px black;padding:8px;width:679px;height:279px;box-sizing: border-box;font-size: 16px;text-align:justify;overflow-y:auto;border:solid black 4px;">{{Lorem}}{{Lorem}}</div> | | <div class="ext_background1" style="display:block;color:#fff;text-shadow: 0 0 2px black;padding:8px;width:679px;height:279px;box-sizing: border-box;font-size: 16px;text-align:justify;overflow-y:auto;border:solid black 4px;">{{Lorem}}{{Lorem}}</div> |
|
| |
| == ==
| |
| Objective: Write a string function that can compare the number from a category title with the level range in a template. eg. Level 5 monsters category added to Level 1-5 monsters and Level 5-10 monsters category. Should also work for crafting sheets and equipment. Should also account for level range like "51+" so all pages with a level 51 or higher are added to that group category. Template should include something like an if/then list that looks for keywords in the category title (eg. "Level 5 monsters" returns "monsters", iterate range check using the monster level group categories).
| |
| <pre>{{#ifexpr:1 <= 6 and 6 <= 5 |yes |no}}</pre>
| |
| {{#ifexpr:1 <= 6 and 6 <= 5 |yes |no}}
| |
|
| |
| <pre>{{#ifexpr:5 >= 1 and 5 <= 5|yes|no}}</pre>
| |
| {{#ifexpr:5 >= 1 and 5 <= 5|yes|no}}
| |
|
| |
| <pre>{{#invoke:String2 |split |Level 5 monster|" "|2|true}}</pre>
| |
| {{#invoke:String2 |split |Level 5 monster|" "|2|true}}
| |
|
| |
| <pre>{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}</pre>
| |
| {{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}
| |
|
| |
| <pre>{{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|1|true}}</pre>
| |
| {{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|1|true}}
| |
|
| |
| <pre>{{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|2|true}}</pre>
| |
| {{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|2|true}}
| |
|
| |
| <pre>{{#ifexpr:{{#invoke:String2 |split |Level 5 monster|" "|2|true}}>={{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|1|true}} and {{#invoke:String2 |split |Level 5 monster|" "|2|true}}<={{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|2|true}}|yes|no}}</pre>
| |
| {{#ifexpr:{{#invoke:String2 |split |Level 5 monster|" "|2|true}}>={{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|1|true}} and {{#invoke:String2 |split |Level 5 monster|" "|2|true}}<={{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|2|true}}|yes|no}}
| |
|
| |
| Final test:
| |
| <pre>{{#ifexpr:{{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|1|true}} <= {{#invoke:String2 |split |Level 10 monster|" "|2|true}} and {{#invoke:String2 |split |Level 10 monster|" "|2|true}} <= {{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|2|true}} |Add to Level 1-5 monsters category|Do nothing}}, {{#ifexpr:{{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|1|true}} <= {{#invoke:String2 |split |Level 5 monster|" "|2|true}} and {{#invoke:String2 |split |Level 5 monster|" "|2|true}} <= {{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|2|true}} |Add to Level 1-5 monsters category|Do nothing}}</pre>
| |
| ''Compare to "Level 1-5 monsters" category:''
| |
| ; Level 10 monster : {{#ifexpr:{{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|1|true}} <= {{#invoke:String2 |split |Level 10 monster|" "|2|true}} and {{#invoke:String2 |split |Level 10 monster|" "|2|true}} <= {{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|2|true}} |Add to Level 1-5 monsters category|Do nothing}}
| |
| ; Level 5 monster : {{#ifexpr:{{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|1|true}} <= {{#invoke:String2 |split |Level 5 monster|" "|2|true}} and {{#invoke:String2 |split |Level 5 monster|" "|2|true}} <= {{#invoke:String2 |split |{{#invoke:String2 |split |Level 1-5 monsters|" "|2|true}}|-|2|true}} |Add to Level 1-5 monsters category|Do nothing}}
| |
|
| |
| Use this to build a template to add to category pages:
| |
| <pre>{{#ifexpr:{{String split|{{#invoke:String2 |trim |{{#invoke:String |replace |{{String split|CATEGORYGROUPHERE|" "|2}}|+| }}}}|-|1}} <= {{String split|{{#titleparts:{{PAGENAME}}}}|" "|2}} and {{String split|{{#titleparts:{{PAGENAME}}}}|" "|2}} <= {{String split|{{#invoke:String2 |trim |{{#invoke:String |replace |{{String split|CATEGORYGROUPHERE|" "|2}}|+| }}}}|-|-1}}|Add category|Do nothing}}
| |
| </pre>
| |
| Output: {{#invoke:String2 |split |{{#invoke:String2 |trim |{{#invoke:String |replace |{{#invoke:String2 |split |Level 51+ monsters|" "|2|true}}|+| }}}}|-|1|true}} <= {{#invoke:String2 |split |Level 5 monsters|" "|2|true}} and {{#invoke:String2 |split |Level 5 monsters|" "|2|true}} <= {{#invoke:String2 |split |{{#invoke:String2 |trim |{{#invoke:String |replace |{{#invoke:String2 |split |Level 51+ monsters|" "|2|true}}|+| }}}}|-|-1|true}}
| |
|
| |
| TEST 51+: {{#invoke:String2 |split |{{#invoke:String2 |trim |{{#invoke:String |replace |{{#invoke:String2 |split |Level 51+ monsters|" "|2|true}}|+| }}}}|-|1|true}} and {{#invoke:String2 |split |{{#invoke:String2 |trim |{{#invoke:String |replace |{{#invoke:String2 |split |Level 51+ monsters|" "|2|true}}|+| }}}}|-|-1|true}}
| |
|
| |
| {{#invoke:String2 |split |{{#invoke:String2 |trim |{{#invoke:String |replace |{{#invoke:String2 |split |Level 51+ monsters|" "|2|true}}|+| }}}}|-|1|true}}
| |
|
| |
| {{#invoke:String2 |trim |{{#invoke:String |replace |{{#invoke:String2 |split |Level 51+ monsters|" "|2|true}}|+|-}}}}
| |
|
| |
| {{String split |This is a piece of text to be split |" "| 4}}
| |
|
| |
|
| <!--{{#mapsdoc:leaflet|parameters=all}}--> | | <!--{{#mapsdoc:leaflet|parameters=all}}--> |