User:Gorgon/Sandbox/Sandbox Alpha

From Avlis Wiki
Revision as of 17:39, 3 February 2017 by Gorgon (talk | contribs) (Added my sandbox "message box". Updated with offline edits (still a work in progress, but might as well catch up a bit).)
Jump to navigation Jump to search
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