User:Gorgon/Sandbox/Sandbox Alpha: Difference between revisions

From Avlis Wiki
Jump to navigation Jump to search
m (Code here can only be rendered, not added to the spell page. The sec# tags will have to be added to them.)
m (Added my sandbox "message box". Updated with offline edits (still a work in progress, but might as well catch up a bit).)
Line 1: Line 1:
<noinclude>Anything up to/including the '''Template start''' heading will not be included in transclusion of this template (or any part of the trailing documentation section either, though that will eventually be formalized template documentation, possibly with transcluded categories at the end).
<noinclude>{{<!-- sec -->User:Gorgon/Sandbox/Sandbox_Beta | User:Gorgon/Sandbox | 1 }}
 
Anything up to/including the '''Template start''' heading will not be included in transclusion of this template (or any part of the trailing documentation section either, though that will eventually be formalized template documentation, possibly with transcluded categories at the end).


I love to over-comment my code, so why change things here...
I love to over-comment my code, so why change things here...
Line 16: Line 18:
* [http://www.mediawiki.org/wiki/Extension:Labeled_Section_Transclusion Extension:Labeled Section Transclusion] - Allows '''selective''' transclusion of marked-off sections of text.
* [http://www.mediawiki.org/wiki/Extension:Labeled_Section_Transclusion Extension:Labeled Section Transclusion] - Allows '''selective''' transclusion of marked-off sections of text.
** [[Wikipedia:Wikipedia:Transclusion#Without_using_the_labeled_section_method | Wikipedia:Selective transclusion without using the labeled section method]] - This works here with onlyinclude and includeonly, so transcludesection=SECTIONNAME parameters are doable if [http://www.mediawiki.org/wiki/Extension:Labeled_Section_Transclusion Extension:Labeled Section Transclusion] isn't added.
** [[Wikipedia:Wikipedia:Transclusion#Without_using_the_labeled_section_method | Wikipedia:Selective transclusion without using the labeled section method]] - This works here with onlyinclude and includeonly, so transcludesection=SECTIONNAME parameters are doable if [http://www.mediawiki.org/wiki/Extension:Labeled_Section_Transclusion Extension:Labeled Section Transclusion] isn't added.
* [http://www.mediawiki.org/wiki/Extension:DynamicPageList_(third-party) Extension:DynamicPageList (third-party)] - Enhanced version of [http://www.mediawiki.org/wiki/Extension:DynamicPageList_(Wikimedia) Extension:DynamicPageList (Wikimedia)]
* [http://www.mediawiki.org/wiki/Extension:DynamicPageList_(third-party) Extension:DynamicPageList (third-party)] - Enhanced version of [http://www.mediawiki.org/wiki/Extension:DynamicPageList_(Wikimedia) Extension:DynamicPageList (Wikimedia)]
** [http://semeb.com/dpldemo/index.php?title=DPL:Overview DPL:Overview] - Generate dynamic reports based on category members and selective included info from each (Extension:Labeled Section Transclusion above would really help there).
** [http://semeb.com/dpldemo/index.php?title=DPL:Overview DPL:Overview] - Generate dynamic reports based on category members and selective included info from each (Extension:Labeled Section Transclusion above would really help there).
** [http://semeb.com/dpldemo/index.php?title=Template:Catlist DPL:Template:Catlist] - Picture this totally reformatted as filter/sort options up top of the [[Magic:Spell_List | Spell List]] page, as a dynamic table. It starts showing all spells, but sortable with one click by level, school, class, or any other useful [[Template:Spell]] parameter/category used by them. Then add in the ability to filter results to only certain kinds/combinations (e.g, Show only cleric evocation spells, sorted by level, with the option of showing specific domain ones as well).
** [http://semeb.com/dpldemo/index.php?title=Template:Catlist DPL:Template:Catlist] - Picture this totally reformatted as filter/sort options up top of the [[Magic:Spell_List | Spell List]] page, as a dynamic table. It starts showing all spells, but sortable with one click by level, school, class, or any other useful [[Template:Spell]] parameter/category used by them. Then add in the ability to filter results to only certain kinds/combinations (e.g, Show only cleric evocation spells, sorted by level, with the option of showing specific domain ones as well).
** I doubt anyone else besides me would use this (except maybe the occasional dabbler), but it would really be useful for spells, and maybe a few other things eventually. Revamping all spells via this template is a huge undertaking (and my main goal for wiki updating, now that I can verify/test spells again), so adding this extension for that work alone would make a huge difference.
** I doubt anyone else besides me would use this (except maybe the occasional dabbler), but it would really be useful for spells, and maybe a few other things eventually. Revamping all spells via this template is a huge undertaking (and my main goal for wiki updating, now that I can verify/test spells again), so adding this extension for that work alone would make a huge difference.
** After looking into the more recent version of [http://www.mediawiki.org/wiki/Extension:DynamicPageList_(Wikimedia) Extension:DynamicPageList (Wikimedia)] (the one used by most Wikimedia projects, not the "enhanced - 3rd party one"), it may be just as useful (or better), since it allows more sort options. Need to see both in practical use before deciding anything.
** <s>After looking into the more recent version of [http://www.mediawiki.org/wiki/Extension:DynamicPageList_(Wikimedia) Extension:DynamicPageList (Wikimedia)] (the one used by most Wikimedia projects, not the "enhanced - 3rd party one"), it may be just as useful (or better), since it allows more sort options. Need to see both in practical use before deciding anything.</s>
* [http://www.mediawiki.org/wiki/Extension:TemplateData Extension:TemplateData] - See the [[#Non-transcluded_template_documentation_.5Beventually_an_included_doc_subpage_or_.3Ctemplatedata.3E.5D | documentation section]] below.
*** This can't grab sections by template parameter name, but [http://www.mediawiki.org/wiki/Extension:DynamicPageList_(third-party) Extension:DynamicPageList (third-party)] can. See: [http://semeb.com/dpldemo/index.php?title=DPL:Manual_-_DPL_parameters:_Controlling_output_volume#include_contents_related_to_templates include contents related to templates] for how to specify named parameters in a page using a specific template (So grab the name and description in one simple <code>include={Template:Spell}:Name:Description Summary</code> option line, to make a page listing all spells, or filter/sort by whatever criteria, including each Template:Spell parameter)
**** [http://wayback.archive.org/web/20161110223718/http://semeb.com/dpldemo/index.php?title=DPL:Manual_-_DPL_parameters:_Controlling_output_volume#include_contents_related_to_templates Internet Archive link to the same '''include contents related to templates''' link above], since the site is having PhP issues.
** I definitely want this now. The [http://www.mediawiki.org/wiki/Extension:DynamicPageList_(Wikimedia) Extension:DynamicPageList (Wikimedia)] version is '''off my wish list''', since that functionality is pretty much the main reason I want it.
* [http://www.mediawiki.org/wiki/Extension:Arrays Extension:Arrays] - For parsing things like the V, S, M in a single "Descriptors" parameter, without a lot of #explode etc. code (still looking for the best way to do that, and that needs the string parsing extensions enbled).




Line 27: Line 34:


* [[NWN:Template:Spell | Template:Spell on the NWN Wiki]] has some ideas, but not quite what I had in mind either.
* [[NWN:Template:Spell | Template:Spell on the NWN Wiki]] has some ideas, but not quite what I had in mind either.
* I think [[User:Buddha|Buddha]] had the right idea with his discussion on the [[Avlis_Wiki_talk:Categories#Categorizing_Spells | Categories page]] about reformatting how we categorize spells. The current [[Magic:Spell_List | Spell List]] page (and its various subversions) all rely on manual updating when any new changes happen to it, like a new spell being added. Revisions to this template will improve how each spell is displayed, and categorized (even without new extensions), so moving to category listings that update dynamically makes a lot of sense.
* I think [[User:Buddha|Buddha]] had the right idea with his discussion on the [[Avlis_Wiki_talk:Categories#Categorizing_Spells | Categories page]] about reformatting how we categorize spells. The current [[Magic:Spell_List | Spell List]] page (and its various subversions) all rely on manual updating when any new changes happen to it, like a new spell being added. Revisions to this template will improve how each spell is displayed, and categorized (even without new extensions), so moving to category listings that update dynamically makes a lot of sense.
** If the suggested [http://www.mediawiki.org/wiki/Extension:Labeled_Section_Transclusion Labeled Section Transclusion] extension is added, then short spell descriptions and other info can be dynamically added/updated to manually updated lists, like [[Magic:Cleric_Spells:Level-1 | Cleric Spells:Level-1]], even without moving to categories.
** If the suggested [http://www.mediawiki.org/wiki/Extension:Labeled_Section_Transclusion Labeled Section Transclusion] extension is added, then short spell descriptions and other info can be dynamically added/updated to manually updated lists, like [[Magic:Cleric_Spells:Level-1 | Cleric Spells:Level-1]], even without moving to categories.
Line 36: Line 45:




Can the "Name" template parameter be taken from the page name automatically?
Can the '''Name''' template parameter be taken from the page name automatically?
* Maybe as a default if not given as a parameter?
* Maybe as a default if not given as a parameter?
* Might need some page renaming, but should work.
* Might need some page renaming, but should work.
* Keeping the template from categorizing itself as a spell might be annoying, unless namespace checking or other validation is done.
* Keeping the template from categorizing itself as a spell might be annoying, unless namespace checking or other validation is done.
* Taking the '''Name''' template parameter from the <nowiki>{{SUBPAGENAME}}</nowiki> isn't so simple.
** The Magic: (and Epic Spell:) prefix needs to be stripped after checking if it exists, especially for using it as a sort key with categories. Checking for it is easy with something like <code><nowiki>{{#ifeq:{{lc:{{padleft:|6|{{SUBPAGENAME}}}}}}|magic:|}}</nowiki></code>. Removing it is harder. <code><nowiki>{{#explode:{{SUBPAGENAME}}|:|1}}</nowiki></code> could do it, but needs the parser functions for string handling enabled with <code>$wgPFEnableStringFunctions = true;</code> in LocalSettings.php (see the second top note at: [http://www.mediawiki.org/wiki/Extension:StringFunctions Extension:StringFunctions]).
*** All the spell pages should be stripped of these prefixes themselves. Someone was setting it up as if there were actual namespaces for them, but there aren't. Do I really want to get into that mess?
** If the <nowiki>{{SUBPAGENAME}}</nowiki> has more than one word for the spell name, the second and latter words need to be capitalized.
*** Using some sort of <code><nowiki>{{#replace:{{#explode:{{SUBPAGENAME}}| |1}}|{{ucfirst:{{#explode:{{SUBPAGENAME}}</nowiki></code> code, that first counts the words and has enough depth levels for them all would get messy fast (for loop in wiki markup?).
*** Someone must have had a similar problem and found an easier solution, so do some searching.
** We'll have to assume all page names like Bigbys have been changed to use apostrophes too (e.g., Bigby's) - no sane way to check and fix that here (well maybe a switch with the known names already, but new ones would need constant updates... which it what this is supposed to eliminate).
** If it isn't easy, just make it a required parameter with error message, like the rest.




Line 52: Line 71:
* Added <b>Spell Name:</b> at the top.
* Added <b>Spell Name:</b> at the top.
** Having every spell "Name" be the page name "Magic:Name" was inaccurate and confusing.
** Having every spell "Name" be the page name "Magic:Name" was inaccurate and confusing.
** Uses the Name = parameter, or {{SUBPAGENAME}} if not entered (n).
** Uses the Name = parameter, or <nowiki>{{SUBPAGENAME}}</nowiki> if not entered.
* All parameters are now Proper Case.
* All parameters are now Proper Case.
* Lowercase conversion is used for comparison validation of parameter values (when possible).
* Lowercase conversion is used for comparison validation of parameter values (when possible).
Line 63: Line 82:
* Started making missing parameter entries (without forced defaults or warnings) not show in Main, instead of the <nowiki>{{{parameter name}}}</nowiki> (like in the Template namespace).
* Started making missing parameter entries (without forced defaults or warnings) not show in Main, instead of the <nowiki>{{{parameter name}}}</nowiki> (like in the Template namespace).
** Better to add warnings (when defaults aren't possible) for all that should be included. If they see annoying red stuff, they will have to fix it.
** Better to add warnings (when defaults aren't possible) for all that should be included. If they see annoying red stuff, they will have to fix it.
* Split Description Summary and Description Details parameters, so the summary can be trandcluded as a short description elsewhere.
* Split Description Summary and Description Details parameters, so the summary can be transcluded as a short description elsewhere.
** Need to make the Description Details optional (and conditionalon the summary) and add a default "No description" blurb to the summary.
** Need to make the Description Details optional (and conditional on the summary) and add a default "No description" blurb to the summary.
* I don't like all the ifeq: <nowiki>{{NAMESPACE}}</nowiki> | Main checks I added (part of my hiding missing entries above). That can be done a better way.
* I don't like all the ifeq: <nowiki>{{NAMESPACE}}</nowiki> | Main checks I added (part of my hiding missing entries above). That can be done a better way.
* Also need to split up all the level parameters.
* Also need to split up all the level parameters.
Line 76: Line 95:




* Added the test Template:Sec (Section Transclusion) by the author of [http://www.mediawiki.org/wiki/Extension:Labeled_Section_Transclusion Extension:Labeled Section Transclusion] and redid this to be used by it, with other reformatting.
* School, Subschool and Descriptor links aren't being transcluded, just the names.
** Only the name and description use it so far, but easier than redoing it all while testing (something always needs tweaking).
** I haven't added the Descriptor links to the template yet...
** Fixed: This wasn't passing my test for being a sandbox spell, so it was using the template page display...
 
 
* Don't really like having 3 separate parameters for Descriptors, and later the same deal for Components. Figure out a way to use an array from one parameter (cold, acid, ...).
 
 
----
 
 
:'''Whatever is done here is only RENDERED in the page. To have the spell code changed, the sec# tags must be added to each spell.'''
 
:* Even [http://www.mediawiki.org/wiki/Extension:Labeled_Section_Transclusion#Limitations Extension:Labeled Section Transclusion - Limitations] can't do that.
:* [http://www.mediawiki.org/wiki/Extension:DynamicPageList_(third-party)#Which_steps_are_necessary.3F Extension:DynamicPageList (third-party) - Define contents you want to show section] can (not the [http://www.mediawiki.org/wiki/Extension:DynamicPageList_(Wikimedia) Extension:DynamicPageList (Wikimedia)] version).'''
:** See: [http://semeb.com/dpldemo/index.php?title=DPL:Manual_-_DPL_parameters:_Controlling_output_volume#include_contents_related_to_templates include contents related to templates] for how to specify named parameters in a page using a specific template (So grab the name and description in one simple <code>include={Template:Spell}:Name:Description Summary</code> option line, to make a page listing all spells, or filter/sort by whatever criteria, including each Template:Spell parameter)
:** [http://wayback.archive.org/web/20161110223718/http://semeb.com/dpldemo/index.php?title=DPL:Manual_-_DPL_parameters:_Controlling_output_volume#include_contents_related_to_templates Internet Archive link to the same '''include contents related to templates''' link above], since the site is having PhP issues.
:* I definitely want this now. The [http://www.mediawiki.org/wiki/Extension:DynamicPageList_(Wikimedia) Extension:DynamicPageList (Wikimedia)] version is '''off my wish list''', since that functionality is pretty much the main reason I want it.
:* Updated the top list with this info.


* Need the sec# tags on the spell pages themselves, so trying some tricks for that.
** <code><nowiki>&lt;includeonly>&amp;lt;onlyinclude>{{{sec1 |&lt;/includeonly></nowiki></code> and <code><nowiki>&lt;includeonly>}}}&amp;lt;/onlyinclude>&lt;/includeonly></nowiki></code> should be easier than the 3 templates below (might be able to do only 1 with a parameter for sec# too). Trying to avoid more templates that I don't know are even needed, or if they will work right (deletion requests here don't get resolved).
*** If this does work as I hope, and all parameters get separate tags included this way, adding a template makes sense (shouldn't need all 3 below then).
** [https://stackoverflow.com/questions/8947654/is-there-a-way-to-get-onlyinclude-included-onto-a-mediawiki-page-via-a-templa Hack for including onlyinclude tags] - uses safesubst and 3 simple templates.


* Parameters that are named with empty values are defined when checked. E.g., If <code>Parameter Name =</code> is in the spell code with no value, <code><nowiki>{{#if: {{{Parameter Name|}}} | yes | no }}</nowiki></code> is yes. Redo all of my checks (only 3 of them).


* <code><nowiki>&lt;includeonly>&amp;lt;onlyinclude>{{{sec1 |&lt;/includeonly></nowiki></code> and <code><nowiki>&lt;includeonly>}}}&amp;lt;/onlyinclude>&lt;/includeonly></nowiki></code> just added them as text to the spell, so template safesubst might be needed after all. <code><nowiki>&lt;includeonly>&lt;onlyinclude>{{{sec1 |&lt;/includeonly></nowiki></code> and <code><nowiki>&lt;includeonly>}}}&lt;/onlyinclude>&lt;/includeonly></nowiki></code> might work.
** Nope, they get parsed in the template first, so only those sections get transcluded. Try the safesubst method next.


* Too many extra spaces are being added to things, like the end of the '''Name''' parameter. I may have to get rid of readable code format in many places, to get the correct output (commenting out space is even worse in many cases... maybe OK for newlines).
** [[Special:ExpandTemplates]] works well for this, and can cut down on template edits, if what is causing a problem is obvious enough to fix in np++, instead of extra trial and error saves (Offline/preview editing is great for most pages, but not templates used by other pages, so anything that can reduce the page save spam is good).
*** Use any name of a spell for '''Context title''' (E.g., Magic:Aid or User:Gorgon/Sandbox/Sandbox_Alpha/SbA01). This is used while expanding info used as <nowiki>{{FULLPAGENAME}}</nowiki> or whatever by the template, so using Template:Test will act as if in the template namespace (including a full preview as if in that namespace, with the provided page name and working category links. Handy!).
*** Paste the full spell (template call and parameters) into the '''Input text:''' box, and it shows all the hidden stuff used to render the page, including white-spaces (if a space is at the end of a line, it still shows the cursor being one space right... or just copy and paste all into np++ and show white-spaces there).
*** '''Show XML parse tree''' and '''Show raw HTML''' give even more useful info for this (in separate views), so use them all the time when checking. Toggling '''Remove comments''' is useful for seeing commented out categories in test spells (and being sure they don't get included.)
** The current version needs a lot of fixes after seeing it that way (ugh).
** Might also look at adding [[Wikipedia:Template:Trim|Template:Trim]] here, to clean up all parameters added on the spell pages, if they start adding more spaces (whitespace characters are stripped from the beginnings and ends of named parameter names and values, so this could only happen with ones in quotes).


* School, Subschool and Descriptor links aren't being transcluded, just the names.
** I haven't added the Descriptor links to the template yet...
** This wasn't pasing my test for being a sandbox spell, so it was using the template page display...


* The error results for bad/missing parameter values (in red) should be links to the spell format documentation, which should be in this template's documentation. Basically this template makes the spells link back here on errors.


* Don't really like having 3 separate parameters for Descriptors, and later the same deal for Components. Figure out a way to use an array from one parameter (cold, acid, ...).


* Trying to grab the spell '''Name''' from <nowiki>{{SUBPAGENAME}}</nowiki> isn't working (see the extra info on that I added to my orignal notes above). Making it a required parameter with an error message, like the rest.


----


* Every spell in spelld.2da has a school (which is any spell like effect from anything pretty much), and there is no universal in NWN, only a general constant (SPELL_SCHOOL_GENERAL) for any spell in the 2da that doesn't have a school letter aassigned (e.g., ****). This shouldn't allow a blank school, but should allow <code>general</code> as a parameter (or <code>universal</code>???). See if that universal school term is used anywhere else outside of [[Magic:Spell_Format]] before using <code>general</code>.


* Trying new safesubst: test templates in [[User:Gorgon/Sandbox/Sandbox Beta/SbB01 | Sandbox Beta/SbB01]] (Template:Startincludesec) and [[User:Gorgon/Sandbox/Sandbox Beta/SbB02 | Sandbox Beta/SbB02]] (Template:Endincludesec).
** Forgot spaces are preserved with unnamed template parameters. Section numbers can't have spaces between them and the preceding | in the substitution calls, unless I name it.
** safesubst method failed because it was designed to be added to the end page (spell). I'm trying to pass the code on to the spell unparsed with the other transcluded stuff. Time to try different things.


* Testing for defined/empty parameters:
: ''"The value of a parameter can be the empty string (pipe or equals sign followed immediately by the next pipe or the closing braces). This is different from omitting the parameter altogether, which leaves it undefined, although templates are often coded so as to behave the same in both cases."''


'''This won't work! Whatever is done here is only RENDERED in the page. To have the spell code changed, the sec# tags must be added to each spell.'''
:* Add [[Template:Ifparadef]] usage for parameters that need it.




* Parameters that are named with empty values are defined when checked. E.g., If <code>Parameter Name =</code> is in the spell code with no value, <code><nowiki>{{#if: {{{Parameter Name | }}} | yes | no }}</nowiki></code> is yes. Redo all of my checks (only 3 of them).
* I forgot the '''"Main"''' namespace returns blank when checking <nowiki>{{NAMESPACE}}</nowiki>. I could use a blank, but better to show it by number, so all <code>Main</code> instances have been replaced with <code><nowiki>{{ns:0}}</nowiki></code>.
 
 
----
 
 
* Revamp for '''<nowiki>{{ns detect}}</nowiki>''' (Namespace detect) template usage, instead of complicated namespace checks.
** Transclusion of this template should only work in the main namespace.
** In the template or user namespace, is shows the parameters. The user namespace is intentional (and permanent) for testing template edits.
** For testing transclusion in a user namespace (i.e., a sandbox spell), use the <code>| demospace = main</code> optional parameter value.
** In any other namespace, this doesn't render anything, unless the <code>| demospace = main</code> or <code>| demospace = template</code> optional parameter values are used (<code>| page = Pagename</code> or <code>| page = Template:Pagename</code> give the same results).




Line 121: Line 166:




</noinclude><div class="notice metadata" id="spell updates" style="background-color: #FFFFE0; margin: 1em; padding: 10px; border: 1px solid #CDCDB4;">
</noinclude>{{ns detect | talk = | avlis wiki = | file = | mediawiki = | help = | category =
| other =
<div class="notice metadata" id="spell updates" style="background-color: #FFFFE0; margin: 1em; padding: 10px; border: 1px solid #CDCDB4;">


''<font style="font-size: 16px;">Spell articles are presently undergoing an overhaul to improve ease of updating. Please excuse any mess that this may cause for the duration.</font>
<font style="font-size: 16px; font-style: italic;">Spell articles are presently undergoing an overhaul to improve ease of updating. Please excuse any mess that this may cause for the duration.</font>
</div>
</div>
<b>Spell Name:</b> <!-- {{#ifeq: {{NAMESPACE}} | Main |{{{Name |{{SUBPAGENAME}} }}} |{{{Name}}} }} -->{{#ifeq: {{#titleparts: {{FULLPAGENAME}} | -1 }} | User:Gorgon/Sandbox/Sandbox Alpha |{{{Name |{{SUBPAGENAME}}}}} |{{{Name}}} }} <br />
 
<b>[[Magic:School | School]]:</b>&nbsp;<!-- {{#ifeq: {{NAMESPACE}} | Main -->{{#ifeq: {{#titleparts: {{FULLPAGENAME}} | -1 }} | User:Gorgon/Sandbox/Sandbox Alpha
<b>Spell Name:</b> {{ns detect | main = {{{Name | <span style="color:red">Missing "Name" parameter value!</span> }}} | other = {{{Name}}} | demospace = {{{demospace|}}} | page = {{{page|}}} }}<br />
{{#switch: {{lc: {{{School | }}} }}
<b>[[Magic:School | School:]]</b> {{ns detect | main =
         |              = <span style="color:red">Empty "School" parameter!</span>
    {{#switch: {{lc: {{{School|}}} }}
         | abjuration    = [[Magic:Abjuration | Abjuration]]
         |              = <span style="color:red">Missing "School" parameter value!</span>
         | conjuration  = [[Magic:Conjuration | Conjuration]]
         | abjuration    = [[Magic:Abjuration   | Abjuration]]
        | conjuration   = [[Magic:Conjuration | Conjuration]]
         | conjuration  = [[Magic:Conjuration  | Conjuration]]
         | divination    = [[Magic:Divination | Divination]]
         | divination    = [[Magic:Divination   | Divination]]
         | enchantment  = [[Magic:Enchantment | Enchantment]]
         | enchantment  = [[Magic:Enchantment   | Enchantment]]
         | evocation    = [[Magic:Evocation | Evocation]]
         | evocation    = [[Magic:Evocation     | Evocation]]
         | illusion      = [[Magic:Illusion | Illusion]]
         | illusion      = [[Magic:Illusion     | Illusion]]
         | necromancy    = [[Magic:Necromancy | Necromancy]]
         | necromancy    = [[Magic:Necromancy   | Necromancy]]
         | transmutation = [[Magic:Transmutation | Transmutation]]
         | transmutation = [[Magic:Transmutation | Transmutation]]
         | universal    = Universal
         | general      = [[Magic:General      | General]]
         | #default      = <span style="color:red">Invalid "School" parameter!</span>
         | #default      = <span style="color:red">Invalid "School" parameter value!</span>
     }}
     }}
     {{#switch: {{lc: {{{Subschool | }}} }}
     {{#if: {{{Subschool|}}} |<!-- Is &nbsp; needed here, or will the next space be preserved? --> ( <b>[[Magic:Spell_Format:Subschool | Subschool:]] </b>
        |           = <!-- This blank case and result is needed to not trigger the default Invalid "Subschool" error -->
         {{#switch: {{lc: {{{Subschool|}}} }}
         | calling    = {{#ifeq: {{lc: {{{School | }}} }} | conjuration | &nbsp;( <b>[[Magic:Spell_Format:Subschool | Subschool]]:</b> [[Magic:Conjuration#Calling | Calling]] ) | ( <span style="color:red"><nowiki>"Subschool = Calling" requires "School = Conjuration"!</nowiki></span> ) }}
            | calling    = {{#ifeq: {{lc: {{{School|}}} }} | conjuration | [[Magic:Conjuration#Calling | Calling]] ) | <span style="color:red">"Subschool = Calling" requires "School = Conjuration"!</span> ) }}
        | creation  = {{#ifeq: {{lc: {{{School | }}} }} | conjuration | &nbsp;( <b>[[Magic:Spell_Format:Subschool | Subschool]]:</b> [[Magic:Conjuration#Creation | Creation]] ) | ( <span style="color:red"><nowiki>"Subschool = Creation" requires "School = Conjuration"!</nowiki></span> ) }}
            | creation  = {{#ifeq: {{lc: {{{School|}}} }} | conjuration | [[Magic:Conjuration#Creation | Creation]] ) | <span style="color:red">"Subschool = Creation" requires "School = Conjuration"!</span> ) }}
        | healing    = {{#ifeq: {{lc: {{{School | }}} }} | conjuration | &nbsp;( <b>[[Magic:Spell_Format:Subschool | Subschool]]:</b> [[Magic:Conjuration#Healing | Healing]] ) | ( <span style="color:red"><nowiki>"Subschool = Healing" requires "School = Conjuration"!</nowiki></span> ) }}
            | healing    = {{#ifeq: {{lc: {{{School|}}} }} | conjuration | [[Magic:Conjuration#Healing | Healing]] ) | <span style="color:red">"Subschool = Healing" requires "School = Conjuration"!</span> ) }}
        | summoning  = {{#ifeq: {{lc: {{{School | }}} }} | conjuration | &nbsp;( <b>[[Magic:Spell_Format:Subschool | Subschool]]:</b> [[Magic:Conjuration#Summoning | Summoning]] ) | ( <span style="color:red"><nowiki>"Subschool = Summoning" requires "School = Conjuration"!</nowiki></span> ) }}
            | summoning  = {{#ifeq: {{lc: {{{School|}}} }} | conjuration | [[Magic:Conjuration#Summoning | Summoning]] ) | <span style="color:red">"Subschool = Summoning" requires "School = Conjuration"!</span> ) }}
        | charm      = {{#ifeq: {{lc: {{{School | }}} }} | enchantment | &nbsp;( <b>[[Magic:Spell_Format:Subschool | Subschool]]:</b> [[Magic:Enchantment#Charm | Charm]] ) | ( <span style="color:red"><nowiki>"Subschool = Charm" requires "School = Enchantment"!</nowiki></span> ) }}
            | charm      = {{#ifeq: {{lc: {{{School|}}} }} | enchantment | [[Magic:Enchantment#Charm | Charm]] ) | <span style="color:red">"Subschool = Charm" requires "School = Enchantment"!</span> ) }}
        | compulsion = {{#ifeq: {{lc: {{{School | }}} }} | enchantment | &nbsp;( <b>[[Magic:Spell_Format:Subschool | Subschool]]:</b> [[Magic:Enchantment#Compulsion | Compulsion]] ) | ( <span style="color:red"><nowiki>"Subschool = Compulsion" requires "School = Enchantment"!</nowiki></span> ) }}
            | compulsion = {{#ifeq: {{lc: {{{School|}}} }} | enchantment | [[Magic:Enchantment#Compulsion | Compulsion]] ) | <span style="color:red">"Subschool = Compulsion" requires "School = Enchantment"!</span> ) }}
        | figment    = {{#ifeq: {{lc: {{{School | }}} }} | Illusion | &nbsp;( <b>[[Magic:Spell_Format:Subschool | Subschool]]:</b> [[Magic:Illusion#Figment | Figment]] ) | ( <span style="color:red"><nowiki>"Subschool = Figment" requires "School = Illusion"!</nowiki></span> ) }}
            | figment    = {{#ifeq: {{lc: {{{School|}}} }} | Illusion | [[Magic:Illusion#Figment | Figment]] ) | <span style="color:red">"Subschool = Figment" requires "School = Illusion"!</span> ) }}
        | glamer    = {{#ifeq: {{lc: {{{School | }}} }} | Illusion | &nbsp;( <b>[[Magic:Spell_Format:Subschool | Subschool]]:</b> [[Magic:Illusion#Glamer | Glamer]] ) | ( <span style="color:red"><nowiki>"Subschool = Glamer" requires "School = Illusion"!</nowiki></span> ) }}
            | glamer    = {{#ifeq: {{lc: {{{School|}}} }} | Illusion | [[Magic:Illusion#Glamer | Glamer]] ) | <span style="color:red">"Subschool = Glamer" requires "School = Illusion"!</span> ) }}
        | pattern    = {{#ifeq: {{lc: {{{School | }}} }} | Illusion | &nbsp;( <b>[[Magic:Spell_Format:Subschool | Subschool]]:</b> [[Magic:Illusion#Pattern | Pattern]] ) | ( <span style="color:red"><nowiki>"Subschool = Pattern" requires "School = Illusion"!</nowiki></span> ) }}
            | pattern    = {{#ifeq: {{lc: {{{School|}}} }} | Illusion | [[Magic:Illusion#Pattern | Pattern]] ) | <span style="color:red">"Subschool = Pattern" requires "School = Illusion"!</span> ) }}
        | phantasm  = {{#ifeq: {{lc: {{{School | }}} }} | Illusion | &nbsp;( <b>[[Magic:Spell_Format:Subschool | Subschool]]:</b> [[Magic:Illusion#Phantasm | Phantasm]] ) | ( <span style="color:red"><nowiki>"Subschool = Phantasm" requires "School = Illusion"!</nowiki></span> ) }}
            | phantasm  = {{#ifeq: {{lc: {{{School|}}} }} | Illusion | [[Magic:Illusion#Phantasm | Phantasm]] ) | <span style="color:red">"Subschool = Phantasm" requires "School = Illusion"!</span> ) }}
        | shadow    = {{#ifeq: {{lc: {{{School | }}} }} | Illusion | &nbsp;( <b>[[Magic:Spell_Format:Subschool | Subschool]]:</b> [[Magic:Illusion#Shadow | Shadow]] ) | ( <span style="color:red"><nowiki>"Subschool = Shadow" requires "School = Illusion"!</nowiki></span> ) }}
            | shadow    = {{#ifeq: {{lc: {{{School|}}} }} | Illusion | [[Magic:Illusion#Shadow | Shadow]] ) | <span style="color:red">"Subschool = Shadow" requires "School = Illusion"!</span> ) }}
        | #default  = &nbsp;( <span style="color:red">Invalid "Subschool" parameter!</span> )
            | #default  = <span style="color:red">Invalid "Subschool" parameter value!</span> )
        }}
     }}
     }}
     {{#switch: {{lc: {{{Descriptor | }}} }}
     {{#if: {{{Descriptors|}}} |<!-- Is &nbsp; needed here, or will the next space be preserved? --> ( <b>[[Magic:Descriptors | Descriptors:]] </b><!-- Redo with #explode and comma separated Descriptors. Just test the first letter of each (so v, verbal... or vine all return "V") -->
        | = <!-- This blank case and result is needed to not trigger the default Invalid "Descriptor" error -->
        {{#switch: {{lc: {{{Descriptors|}}} }}
        | acid | chaotic | cold | darkness | death | disease | divine | electricity | evil
            | = <!-- This blank case and result is needed to not trigger the default Invalid "Descriptor" error -->
        | fear | fire | force | good | language-dependent | lawful | light | mind-affecting
            | acid | chaotic | cold | darkness | death | disease | divine | electricity | evil
        | negative | nature | paralyze | poison | positive | sonic | teleportation
            | fear | fire | force | good | language-dependent | lawful | light | mind-affecting
        | weapon enchantment = &nbsp;[ <b>[[Magic:Descriptors | Descriptors]]:</b> {{{Descriptor}}}
            | negative | nature | paralyze | poison | positive | sonic | teleportation
            {{#if: {{{Descriptor 2 | }}}
            | weapon enchantment = &nbsp;[ <b>[[Magic:Descriptors | Descriptors]]:</b> {{{Descriptor}}}
            |  {{#switch: {{lc: {{{Descriptor 2}}} }}
                {{#if: {{{Descriptor 2|}}}
                    | {{lc: {{{Descriptor}}} }} = <span style="color:red">, Duplicate "Descriptor 2" parameter!</span>
                |  {{#switch: {{lc: {{{Descriptor 2}}} }}
                    | acid | chaotic | cold | darkness | death | disease | divine | electricity | evil
                        | {{lc: {{{Descriptor}}} }} = <span style="color:red">, Duplicate "Descriptor 2" parameter value!</span>
                    | fear | fire | force | good | language-dependent | lawful | light | mind-affecting
                    | negative | nature | paralyze | poison | positive | sonic | teleportation
                    | weapon enchantment = , {{{Descriptor 2}}}
                    | #default          = <span style="color:red">, Invalid "Descriptor 2" parameter!</span>
                }}
                {{#if: {{{Descriptor 3 | }}}
                |  {{#switch: {{lc: {{{Descriptor 3}}} }}
                        | {{lc: {{{Descriptor}}} }} | {{lc: {{{Descriptor 2}}} }} = <span style="color:red">, Duplicate "Descriptor 3" parameter!</span>
                         | acid | chaotic | cold | darkness | death | disease | divine | electricity | evil
                         | acid | chaotic | cold | darkness | death | disease | divine | electricity | evil
                         | fear | fire | force | good | language-dependent | lawful | light | mind-affecting
                         | fear | fire | force | good | language-dependent | lawful | light | mind-affecting
                         | negative | nature | paralyze | poison | positive | sonic | teleportation
                         | negative | nature | paralyze | poison | positive | sonic | teleportation
                         | weapon enchantment = , {{{Descriptor 3}}}
                         | weapon enchantment = , {{{Descriptor 2}}}
                        | #default          = <span style="color:red">, Invalid "Descriptor 3" parameter!</span>
                        | #default          = <span style="color:red">, Invalid "Descriptor 2" parameter value!</span>
                    }}
                    {{#if: {{{Descriptor 3|}}}
                    |  {{#switch: {{lc: {{{Descriptor 3}}} }}
                            | {{lc: {{{Descriptor}}} }} | {{lc: {{{Descriptor 2}}} }} = <span style="color:red">, Duplicate "Descriptor 3" parameter value!</span>
                            | acid | chaotic | cold | darkness | death | disease | divine | electricity | evil
                            | fear | fire | force | good | language-dependent | lawful | light | mind-affecting
                            | negative | nature | paralyze | poison | positive | sonic | teleportation
                            | weapon enchantment = , {{{Descriptor 3}}}
                            | #default          = <span style="color:red">, Invalid "Descriptor 3" parameter value!</span>
                        }}
                     }}
                     }}
                 }}
                 }} ]
             }} ]
             | #default = &nbsp;[ <b>[[Magic:Descriptors | Descriptors]]:</b> <span style="color:red">Invalid "Descriptor" parameter value!</span> ]
        | #default = &nbsp;[ <b>[[Magic:Descriptors | Descriptors]]:</b> <span style="color:red">Invalid "Descriptor" parameter!</span> ]
        }}
     }}
     }}
|   {{{School}}} ( <b>[[Magic:Spell_Format:Subschool | Subschool]]:</b> {{{Subschool}}} ) [ <b>[[Magic:Descriptors | Descriptors]]:</b> {{{Descriptor}}}, {{{Descriptor 2}}}, {{{Descriptor 3}}} ] }} <br />
| other = {{{School}}} ( <b>[[Magic:Spell_Format:Subschool | Subschool]]:</b> {{{Subschool}}} ) [ <b>[[Magic:Descriptors | Descriptors]]:</b> {{{Descriptors}}} ]
<b>[[Magic:Level | Level(s)]]:</b> {{#ifeq: {{NAMESPACE}} | Main | {{{Level | }}} | {{{Level}}} }} <br />
| demospace = {{{demospace|}}}
<b>[[Magic:Innate_Level | Innate Level]]:</b> {{#ifeq: {{NAMESPACE}} | Main | {{{Innate Level | }}} | {{{Innate Level}}} }} <br />
| page = {{{page|}}}
<b>[[Magic:Components | Component(s)]]:</b> {{#ifeq: {{NAMESPACE}} | Main | {{{Components | }}} | {{{Components}}} }} <br />
}} <br />
<b>[[Magic:Casting_Time | Casting Time]]:</b> {{#ifeq: {{NAMESPACE}} | Main | {{{Casting Time | }}} | {{{Casting Time}}} }} <br />
<b>[[Magic:Level | Level(s)]]:</b> {{#ifeq: {{NAMESPACE}} | {{ns:0}} | {{{Level|}}} | {{{Level}}} }} <br />
<b>[[Magic:Range | Range]]:</b> {{#ifeq: {{NAMESPACE}} | Main | {{{Range | }}} | {{{Range}}} }} <br />
<b>[[Magic:Innate_Level | Innate Level]]:</b> {{#ifeq: {{NAMESPACE}} | {{ns:0}} | {{{Innate Level|}}} | {{{Innate Level}}} }} <br />
<b>[[Magic:Target | Target]]:</b> {{#ifeq: {{NAMESPACE}} | Main | {{{Target | }}} | {{{Target}}} }} <br />
<b>[[Magic:Components | Component(s)]]:</b> {{#ifeq: {{NAMESPACE}} | {{ns:0}} | {{{Components|}}} | {{{Components}}} }} <br />
<b>[[Magic:Duration | Duration]]:</b> {{#ifeq: {{NAMESPACE}} | Main | {{{Duration | }}} | {{{Duration}}} }} <br />
<b>[[Magic:Casting_Time | Casting Time]]:</b> {{#ifeq: {{NAMESPACE}} | {{ns:0}} | {{{Casting Time|}}} | {{{Casting Time}}} }} <br />
<b>[[Magic:Counter | Counter(s)]]:</b> {{#ifeq: {{NAMESPACE}} | Main | {{{Counters | }}} | {{{Counters}}} }} <br />
<b>[[Magic:Range | Range]]:</b> {{#ifeq: {{NAMESPACE}} | {{ns:0}} | {{{Range|}}} | {{{Range}}} }} <br />
<b>[[Magic:Saving_Throw | Saving Throw]]:</b> {{#ifeq: {{NAMESPACE}} | Main | {{{Saving Throw | }}} | {{{Saving Throw}}} }} <br />
<b>[[Magic:Target | Target]]:</b> {{#ifeq: {{NAMESPACE}} | {{ns:0}} | {{{Target|}}} | {{{Target}}} }} <br />
<b>[[Magic:Spell_Resistance | Spell Resistance]]:</b> {{#ifeq: {{NAMESPACE}} | Main | {{{Spell Resistance | }}} | {{{Spell Resistance}}} }} <br />
<b>[[Magic:Duration | Duration]]:</b> {{#ifeq: {{NAMESPACE}} | {{ns:0}} | {{{Duration|}}} | {{{Duration}}} }} <br />
<b>[[Magic:Metamagic | Metamagic]]:</b> {{#ifeq: {{NAMESPACE}} | Main | {{{Metamagic | }}} | {{{Metamagic}}} }} <br />
<b>[[Magic:Counter | Counter(s)]]:</b> {{#ifeq: {{NAMESPACE}} | {{ns:0}} | {{{Counters|}}} | {{{Counters}}} }} <br />
<b>[[Magic:Energy_Substitution | Energy Substitution]]:</b> {{#ifeq: {{NAMESPACE}} | Main | {{{Energy Substitution | }}} | {{{Energy Substitution}}} }} <br />
<b>[[Magic:Saving_Throw | Saving Throw]]:</b> {{#ifeq: {{NAMESPACE}} | {{ns:0}} | {{{Saving Throw|}}} | {{{Saving Throw}}} }} <br />
{{#ifeq: {{NAMESPACE}} | Main |{{{Description Summary | }}} |{{{Description Summary}}} }}
<b>[[Magic:Spell_Resistance | Spell Resistance]]:</b> {{#ifeq: {{NAMESPACE}} | {{ns:0}} | {{{Spell Resistance|}}} | {{{Spell Resistance}}} }} <br />
{{#if: {{{Description Details | }}} | <br /><br /> | <!-- {{#ifeq: {{NAMESPACE}} | Template | <br /><br /> }} -->{{#ifeq: {{FULLPAGENAME}} | User:Gorgon/Sandbox/Sandbox Alpha | <br /><br /> }} }}
<b>[[Magic:Metamagic | Metamagic]]:</b> {{#ifeq: {{NAMESPACE}} | {{ns:0}} | {{{Metamagic|}}} | {{{Metamagic}}} }} <br />
{{#ifeq: {{NAMESPACE}} | Main |{{{Description Details | }}} |{{{Description Details}}} }}
<b>[[Magic:Energy_Substitution | Energy Substitution]]:</b> {{#ifeq: {{NAMESPACE}} | {{ns:0}} | {{{Energy Substitution|}}} | {{{Energy Substitution}}} }} <br />
<includeonly>{{#ifeq: {{NAMESPACE}} | Main |
<!-- Redo the rest of these (above) to check if set, then give the "required" warnings. -->{{{Description Summary|{{ns detect | main = <span style="color:red">Missing "Description Summary" parameter value!</span> | other = {{{Description Summary}}} }} }}}
[[Category:Magic |{{{name | {{PAGENAME}} }}}]]
{{ifparadef | {{{Description Details|¬}}} | <br /><br />{{{Description Details}}} | {{ns detect | other = <br /><br />{{{Description Details}}} }} | {{ns detect | other = <br /><br />{{{Description Details}}} }} }}
[[Category:{{{School}}}_Spells |{{{name | {{PAGENAME}} }}}]] }}</includeonly>
{{ns detect | main =
{{#ifeq: {{NAMESPACE}} | Template |
[[Category:Magic |{{{Name |{{PAGENAME}} }}}]]
[[Category:Templates |{{PAGENAME}}]] }}<noinclude>
[[Category:{{{School}}}_Spells |{{{Name |{{PAGENAME}} }}}]] }}
| demospace = {{{demospace|}}}
| page = {{{page|}}}
}}<noinclude>
 
<!-- Add template documentation here, or include a doc subpage (see: http://wikipedia.org/wiki/Wikipedia:Template_documentation#How_to_create_a_documentation_subpage). -->
== Non-transcluded template documentation [or an included doc subpage] ==


<!-- Add template documentation here, or include a doc subpage (see: http://wikipedia.org/wiki/Wikipedia:Template_documentation#How_to_create_a_documentation_subpage). The <templatedata></templatedata> tags would be simpler. -->
Add template documentation here, or include a doc subpage (see: [[Wikipedia:Wikipedia:Template_documentation#How_to_create_a_documentation_subpage | How to create a documentation subpage]]).
== Non-transcluded template documentation [eventually an included doc subpage or <templatedata>] ==


* A <nowiki>{{</nowiki>[[Wikipedia:Template:Documentation |Documentation]]<nowiki>}}</nowiki> sub-template would be useful for all templates on this wiki, since they need usage documentation (stripped down version, without the dozens of other templates).


[[Magic:Spell_Format]] should be here as documentation, instead of that hard to find page.


Add template documentation here, or include a doc subpage (see: [[Wikipedia:Wikipedia:Template_documentation#How_to_create_a_documentation_subpage | How to create a documentation subpage]]).
* [[Magic:Spell_Format]] should be here as documentation, instead of that hard to find page.
* A <nowiki>{{</nowiki>[[Wikipedia:Template:Documentation |Documentation]]<nowiki>}}</nowiki> sub-template would be useful for all templates on this wiki, since they need usage documentation (stripped down version, without the dozens of other templates).
* [http://www.mediawiki.org/wiki/Extension:TemplateData Extension:TemplateData] would work better on its own, keeping things simple.
** It should install a "Manage TemplateData" button for the edit gui, but I am not sure what else that needs (probably [http://www.mediawiki.org/wiki/VisualEditor VisualEditor], which is a slow pig, so pass on that). See: [http://www.mediawiki.org/wiki/Help:TemplateData#TemplateData_editor TemplateData editor].
** Below is what might be the beginning of the spell template documentation as an example (using <nowiki><templatedata></templatedata></nowiki> tags), if it is done manually. ''I have the "Name" as'' '''"required": false''' ''because I may try grabbing it from the page title, if it isn't given.''


<pre style="white-space: pre-wrap">


== Usage ==
* Include instructions for using this in namespaces outside of main, with a simple <code>| demospace = main</code> parameter example above the name parameter.


<templatedata>
{
    "description": "Spells Template",
    "params": {
        "Name": {
            "label": "Spell Name",
            "description": "Name of the Spell (Uses the page title if not defined)",
            "required": false,
            "suggested": true,
            "default": {{SUBPAGENAME}},
            "type": "string",
            "example": "Name = Freedom of Movement"
        },
        "School": {
            "label": "Spell School",
            "description": "School of magic the spell belongs to. Must be one of: Abjuration, Conjuration, Divination, Enchantment, Evocation, Illusion, Necromancy, Transmutation or Universal.",
            "required": true,
            "type": "string",
            "example": "School = Abjuration"
        },
        "Subschool": {
            "label": "Spell Subschool",
            "description": "Subschool of the spell.",
            "required": false,
            "type": "string",
            "example": "Subschool = "
        },
        "Descriptors": {
            "label": "Spell Descriptors",
            "description": "Descriptors of the spell.",
            "required": false,
            "type": "string",
            "example": "Descriptors = "
        },
        "Bard Level": {
            "label": "Bard Level",
            "description": "Level of spell for Bards (if it is a Bard spell).",
            "required": false,
            "type": "number",
            "example": "Bard Level = "
        },
        "Cleric Level": {
            "label": "Cleric Level",
            "description": "Level of spell for Clerics (if it is a Cleric spell).",
            "example": "Cleric Level = 4",
            "inherits": "Bard Level"
        },
        "Druid Level": {
            "label": "Druid Level",
            "description": "Level of spell for Druids (if it is a Druid spell).",
            "example": "Druid Level = 4",
            "inherits": "Bard Level"
        },
        "Paladin Level": {
            "label": "Paladin Level",
            "description": "Level of spell for Paladins (if it is a Paladin spell).",
            "example": "Paladin Level = 4",
            "inherits": "Bard Level"
        },
        "Ranger Level": {
            "label": "Ranger Level",
            "description": "Level of spell for Rangers (if it is a Ranger spell).",
            "example": "Ranger Level = 4",
            "inherits": "Bard Level"
        },
        "Arcane Level": {
            "label": "Sorcerer/Wizard Level",
            "description": "Level of spell for Sorcerers/Wizards (if it is an Arcane spell).",
            "example": "Arcane Level = 4",
            "inherits": "Bard Level"
        },
        "Domain": {
            "label": "Domain (1) Name",
            "description": "1st Domain name of spell for Clerics (if it is a Domain spell).",
            "required": false,
            "type": "string",
            "example": "Domain = Travel"
        },
        "Domain Level": {
            "label": "Domain (1) Level",
            "description": "1st Domain Level of spell for Clerics (if it is a Domain spell).",
            "required": false,
            "type": "number",
            "example": "Domain Level = 3"
        },
        "Domain 2": {
            "label": "Domain (2) Name",
            "description": "2nd Domain name of spell for Clerics (if it is a Domain spell).",
            "example": "Domain 2 = ",
            "inherits": "Domain"
        },
        "Domain 2 Level": {
            "label": "Domain (2) Level",
            "description": "2nd Domain Level of spell for Clerics (if it is a Domain spell).",
            "example": "Domain 2 Level = ",
            "inherits": "Domain Level"
        }
    },
    "paramOrder": [
        "Name",
        "School",
        "Subschool",
        "Descriptors",
        "Bard Level",
        "Cleric Level",
        "Druid Level",
        "Paladin Level",
        "Ranger Level",
        "Arcane Level",
        "Domain",
        "Domain Level",
        "Domain 2",
        "Domain 2 Level"
    ]
}
</templatedata>
</pre>


Obviously I've added more parameters for class and domain spells, similar to the NWN Wiki version of [[NWN:Template:Spell | Template:Spell]]. Their full parameter list is below (they don't use Subschool, and I used proper case with spaces for all parameters):
* Obviously I've added more parameters for class and domain spells, similar to the NWN Wiki version of [[NWN:Template:Spell | Template:Spell]]. Their full parameter list is below (they don't use Subschool, and I used proper case with spaces for all parameters):




Line 385: Line 318:




<!-- End of documentation. --></noinclude>
<!-- End of documentation. -->
{{ns detect | template = [[Category:Templates |{{PAGENAME}}]] }}</noinclude>

Revision as of 17:39, 3 February 2017

This is a user sandbox of Gorgon. A user sandbox is a subpage of the user's user page. It serves as a testing spot and page development space for the user, and is not an Avlis wiki article.

Anything up to/including the Template start heading will not be included in transclusion of this template (or any part of the trailing documentation section either, though that will eventually be formalized template documentation, possibly with transcluded categories at the end).

I love to over-comment my code, so why change things here...




Test version of Template:Spell

Extensions that would make this work better [My wish list]


  • Extension:DynamicPageList (third-party) - Enhanced version of Extension:DynamicPageList (Wikimedia)
    • DPL:Overview - Generate dynamic reports based on category members and selective included info from each (Extension:Labeled Section Transclusion above would really help there).
    • DPL:Template:Catlist - Picture this totally reformatted as filter/sort options up top of the Spell List page, as a dynamic table. It starts showing all spells, but sortable with one click by level, school, class, or any other useful Template:Spell parameter/category used by them. Then add in the ability to filter results to only certain kinds/combinations (e.g, Show only cleric evocation spells, sorted by level, with the option of showing specific domain ones as well).
    • I doubt anyone else besides me would use this (except maybe the occasional dabbler), but it would really be useful for spells, and maybe a few other things eventually. Revamping all spells via this template is a huge undertaking (and my main goal for wiki updating, now that I can verify/test spells again), so adding this extension for that work alone would make a huge difference.
    • After looking into the more recent version of Extension:DynamicPageList (Wikimedia) (the one used by most Wikimedia projects, not the "enhanced - 3rd party one"), it may be just as useful (or better), since it allows more sort options. Need to see both in practical use before deciding anything.
    • I definitely want this now. The Extension:DynamicPageList (Wikimedia) version is off my wish list, since that functionality is pretty much the main reason I want it.
  • Extension:Arrays - For parsing things like the V, S, M in a single "Descriptors" parameter, without a lot of #explode etc. code (still looking for the best way to do that, and that needs the string parsing extensions enbled).


Revision notes


  • I think Buddha had the right idea with his discussion on the Categories page about reformatting how we categorize spells. The current Spell List page (and its various subversions) all rely on manual updating when any new changes happen to it, like a new spell being added. Revisions to this template will improve how each spell is displayed, and categorized (even without new extensions), so moving to category listings that update dynamically makes a lot of sense.




Can the Name template parameter be taken from the page name automatically?

  • Maybe as a default if not given as a parameter?
  • Might need some page renaming, but should work.
  • Keeping the template from categorizing itself as a spell might be annoying, unless namespace checking or other validation is done.


  • Taking the Name template parameter from the {{SUBPAGENAME}} isn't so simple.
    • The Magic: (and Epic Spell:) prefix needs to be stripped after checking if it exists, especially for using it as a sort key with categories. Checking for it is easy with something like {{#ifeq:{{lc:{{padleft:|6|{{SUBPAGENAME}}}}}}|magic:|}}. Removing it is harder. {{#explode:{{SUBPAGENAME}}|:|1}} could do it, but needs the parser functions for string handling enabled with $wgPFEnableStringFunctions = true; in LocalSettings.php (see the second top note at: Extension:StringFunctions).
      • All the spell pages should be stripped of these prefixes themselves. Someone was setting it up as if there were actual namespaces for them, but there aren't. Do I really want to get into that mess?
    • If the {{SUBPAGENAME}} has more than one word for the spell name, the second and latter words need to be capitalized.
      • Using some sort of {{#replace:{{#explode:{{SUBPAGENAME}}| |1}}|{{ucfirst:{{#explode:{{SUBPAGENAME}} code, that first counts the words and has enough depth levels for them all would get messy fast (for loop in wiki markup?).
      • Someone must have had a similar problem and found an easier solution, so do some searching.
    • We'll have to assume all page names like Bigbys have been changed to use apostrophes too (e.g., Bigby's) - no sane way to check and fix that here (well maybe a switch with the known names already, but new ones would need constant updates... which it what this is supposed to eliminate).
    • If it isn't easy, just make it a required parameter with error message, like the rest.




  • Redone using onlyinclude sections with transcludesection tags (See above).
    • Not as simple as Labeled Section Transclusion, and can't do some things with it, but good enough for now.
  • Major School/Subschool/Descriptors redo.
    • Added the Subschool: and Descriptors: prefixes, but they may make the School line too long.
    • Added a bunch of validation checks in switches.
  • Added Spell Name: at the top.
    • Having every spell "Name" be the page name "Magic:Name" was inaccurate and confusing.
    • Uses the Name = parameter, or {{SUBPAGENAME}} if not entered.
  • All parameters are now Proper Case.
  • Lowercase conversion is used for comparison validation of parameter values (when possible).
    • ifeq: and case entries in a switch are case sensitive, so this is necessary.
  • Proper Case conversion is used (when possible) in output results.
    • If people don't use the right case, this should fix at least some of the issues.
  • Added a bunch of namespace checks as part of the validation,
    • All spells should be in the Main namespace, so anything outside that is a template (or test page in a userspace).
    • Added a hak to make my sandbox spell pages work as if in Main (remember to change it back when publishing this).
  • Started making missing parameter entries (without forced defaults or warnings) not show in Main, instead of the {{{parameter name}}} (like in the Template namespace).
    • Better to add warnings (when defaults aren't possible) for all that should be included. If they see annoying red stuff, they will have to fix it.
  • Split Description Summary and Description Details parameters, so the summary can be transcluded as a short description elsewhere.
    • Need to make the Description Details optional (and conditional on the summary) and add a default "No description" blurb to the summary.
  • I don't like all the ifeq: {{NAMESPACE}} | Main checks I added (part of my hiding missing entries above). That can be done a better way.
  • Also need to split up all the level parameters.
  • Just getting started. Too many other things to do, so not gonna try listing them all (lots of trial and error with ideas anyway).


I'm an idiot. I'm trying to use transcludesection directly from the template, instead of passing it on to each spell. Taking a break and I'll come at it fresh later.




  • School, Subschool and Descriptor links aren't being transcluded, just the names.
    • I haven't added the Descriptor links to the template yet...
    • Fixed: This wasn't passing my test for being a sandbox spell, so it was using the template page display...


  • Don't really like having 3 separate parameters for Descriptors, and later the same deal for Components. Figure out a way to use an array from one parameter (cold, acid, ...).




Whatever is done here is only RENDERED in the page. To have the spell code changed, the sec# tags must be added to each spell.


  • Parameters that are named with empty values are defined when checked. E.g., If Parameter Name = is in the spell code with no value, {{#if: {{{Parameter Name|}}} | yes | no }} is yes. Redo all of my checks (only 3 of them).


  • Too many extra spaces are being added to things, like the end of the Name parameter. I may have to get rid of readable code format in many places, to get the correct output (commenting out space is even worse in many cases... maybe OK for newlines).
    • Special:ExpandTemplates works well for this, and can cut down on template edits, if what is causing a problem is obvious enough to fix in np++, instead of extra trial and error saves (Offline/preview editing is great for most pages, but not templates used by other pages, so anything that can reduce the page save spam is good).
      • Use any name of a spell for Context title (E.g., Magic:Aid or User:Gorgon/Sandbox/Sandbox_Alpha/SbA01). This is used while expanding info used as {{FULLPAGENAME}} or whatever by the template, so using Template:Test will act as if in the template namespace (including a full preview as if in that namespace, with the provided page name and working category links. Handy!).
      • Paste the full spell (template call and parameters) into the Input text: box, and it shows all the hidden stuff used to render the page, including white-spaces (if a space is at the end of a line, it still shows the cursor being one space right... or just copy and paste all into np++ and show white-spaces there).
      • Show XML parse tree and Show raw HTML give even more useful info for this (in separate views), so use them all the time when checking. Toggling Remove comments is useful for seeing commented out categories in test spells (and being sure they don't get included.)
    • The current version needs a lot of fixes after seeing it that way (ugh).
    • Might also look at adding Template:Trim here, to clean up all parameters added on the spell pages, if they start adding more spaces (whitespace characters are stripped from the beginnings and ends of named parameter names and values, so this could only happen with ones in quotes).


  • The error results for bad/missing parameter values (in red) should be links to the spell format documentation, which should be in this template's documentation. Basically this template makes the spells link back here on errors.


  • Trying to grab the spell Name from {{SUBPAGENAME}} isn't working (see the extra info on that I added to my orignal notes above). Making it a required parameter with an error message, like the rest.


  • Every spell in spelld.2da has a school (which is any spell like effect from anything pretty much), and there is no universal in NWN, only a general constant (SPELL_SCHOOL_GENERAL) for any spell in the 2da that doesn't have a school letter aassigned (e.g., ****). This shouldn't allow a blank school, but should allow general as a parameter (or universal???). See if that universal school term is used anywhere else outside of Magic:Spell_Format before using general.


  • Testing for defined/empty parameters:
"The value of a parameter can be the empty string (pipe or equals sign followed immediately by the next pipe or the closing braces). This is different from omitting the parameter altogether, which leaves it undefined, although templates are often coded so as to behave the same in both cases."


  • I forgot the "Main" namespace returns blank when checking {{NAMESPACE}}. I could use a blank, but better to show it by number, so all Main instances have been replaced with {{ns:0}}.




  • Revamp for {{ns detect}} (Namespace detect) template usage, instead of complicated namespace checks.
    • Transclusion of this template should only work in the main namespace.
    • In the template or user namespace, is shows the parameters. The user namespace is intentional (and permanent) for testing template edits.
    • For testing transclusion in a user namespace (i.e., a sandbox spell), use the | demospace = main optional parameter value.
    • In any other namespace, this doesn't render anything, unless the | demospace = main or | demospace = template optional parameter values are used (| page = Pagename or | page = Template:Pagename give the same results).




More to come...


Template start

Spell Name: {{{Name}}}
School: {{{School}}} ( Subschool: {{{Subschool}}} ) [ Descriptors: {{{Descriptors}}} ]
Level(s): {{{Level}}}
Innate Level: {{{Innate Level}}}
Component(s): {{{Components}}}
Casting Time: {{{Casting Time}}}
Range: {{{Range}}}
Target: {{{Target}}}
Duration: {{{Duration}}}
Counter(s): {{{Counters}}}
Saving Throw: {{{Saving Throw}}}
Spell Resistance: {{{Spell Resistance}}}
Metamagic: {{{Metamagic}}}
Energy Substitution: {{{Energy Substitution}}}
{{{Description Summary}}}

{{{Description Details}}}

Non-transcluded template documentation [or an included doc subpage]

Add template documentation here, or include a doc subpage (see: How to create a documentation subpage).

  • A {{Documentation}} sub-template would be useful for all templates on this wiki, since they need usage documentation (stripped down version, without the dozens of other templates).



  • Include instructions for using this in namespaces outside of main, with a simple | demospace = main parameter example above the name parameter.


  • Obviously I've added more parameters for class and domain spells, similar to the NWN Wiki version of Template:Spell. Their full parameter list is below (they don't use Subschool, and I used proper case with spaces for all parameters):


Spell levels:
  • bardlevel — The level of this spell when cast by a bard. Optional
  • clericlevel — The level of this spell when cast by a cleric. Optional
  • druidlevel — The level of this spell when cast by a druid. Optional
  • paladinlevel — The level of this spell when cast by a paladin. Optional
  • rangerlevel — The level of this spell when cast by a ranger. Optional
  • magelevel — The level of this spell when cast by a sorcerer or wizard. Optional
  • domain — The clerical domain that grants access to this spell. Optional
  • domainlevel — The level of this spell when granted by this domain. Required if domain is specified
  • domain2 — A second clerical domain that grants access to this spell. Optional
  • domain2level — The level of this spell when granted by the second domain. Required if domain2 is specified
  • domain3 — A third clerical domain that grants access to this spell. Optional
  • domain3level — The level of this spell when granted by the third domain. Required if domain3 is specified
  • domain4 — A fourth clerical domain that grants access to this spell. Optional
  • domain4level — The level of this spell when granted by the fourth domain. Required if domain4 is specified
  • innatelevel — The innate level of this spell.


Lines of spells:
  • line — a name for the spell line this spell belongs to. Optional, but if not set then line0 through line9 are ignored
  • line0 through line9 — names of spells (not linked) that are considered in the same "line" of spells as the current spell. Use the parameter corresponding to the spell's innate level. Include the current spell. Optional, but some should be used if "line" is set
  • linebreach — set this (to "yes") to get a table for the breach line of spells. (This is a hack to accommodate disjunction having two spell lines.) Optional


Other:
  • area — The area affected by this spell. The values "small", "medium", "large", "huge", "gargantuan", "colossal", and "spellcone" should be used when appropriate.
    • areanote — Additional information about the area of effect (e.g. a limit on the number of targets in a colossal area). Optional
    • conesize — This can override the default length of "10" for spell cones.
  • components — "V", "S", or "VS" indicating the components this spell utilizes. Optional
  • counters — Additional counterspells, preferably linked. Optional
  • duration — The duration of the spell.
  • immunity — The descriptor (immunity type) of this spell. Optional
  • range — "p", "t", "s", "m", or "l" indicating the range of the spell.
  • save — The save allowed for this spell, preferably linked. Optional
  • school — The spell school of this spell, preferably linked.
  • spellcraft — The spellcraft requirement (for epic spells). Optional, epic only
  • spellresistance — Should be "yes" if spell resistance can bock this spell. Should be "yes*" if the BioWare description says spell resistance can block this spell, but it does not actually do so. Optional
  • desc — The spell's in-game description.
  • icon — The name of the image (icon) for this spell. Optional