Editing Template talk:TrainingTable

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 25: Line 25:
  
 
For a more in depth tutorial or how to use the template, see [[User:DJRedNightGaming#Training_Template_Updates]]
 
For a more in depth tutorial or how to use the template, see [[User:DJRedNightGaming#Training_Template_Updates]]
 
 
===The original TrainingTable template===
 
Hi -- thanks for the interest in fixing up the wiki!  A lot of the templates and SemanticMediaWiki logic can be pretty confusing at first glance.  I've been working on cleaning it up in a few cases, but it's a slow process.
 
Think of it this way -- the current [[Template:TrainingTable]] can be invoked in two ways:
 
<nowiki>{{TrainingTable}}</nowiki>
 
<nowiki>{{TrainingTable|Muffalo}}</nowiki>
 
In fact, try previewing the second version (with the Muffalo param) on any page.
 
 
Using templates and SMW magic it will render the training table for the Muffalo.  Nice!  But where does the data for the Muffalo come from?  Let's look at the exciting part of Template:TrainingTable to see:
 
 
<nowiki>{{#switch: {{#show: {{{1|{{PAGENAME}}}}}|?Can Train Obedience|link=none}} | true=[[File:check.png|24px|link=]] | false=[[File:ex.png|24px|link=]]}}</nowiki>
 
 
Let's add a bit of spacing to make this easier to follow:
 
 
<nowiki>
 
{{#switch:
 
  {{#show: {{{ 1 | {{PAGENAME}} }}}|?Can Train Obedience|link=none}}
 
  | true=[[File:check.png|24px|link=]]
 
  | false=[[File:ex.png|24px|link=]]
 
}}</nowiki>
 
The 2nd line here is where the magic happens.  <code><nowiki>{{{ 1 | {{PAGENAME}} }}}</nowiki></code> will look up the first parameter to the template if it was provided.  If no parameter was provided, it'll use <code><nowiki>{{PAGENAME}}</nowiki></code>.  This means that if you type <code><nowiki>{{TrainingTable}}</nowiki></code> on the Muffalo page it's equivalent to typing <code><nowiki>{{TrainingTable|Muffalo}}</nowiki> </code>
 
 
OK, so that means on the Muffalo page this is equivalent to:
 
<nowiki>
 
{{#switch:
 
  {{#show: Muffalo|?Can Train Obedience|link=none}}
 
  | true=[[File:check.png|24px|link=]]
 
  | false=[[File:ex.png|24px|link=]]
 
}}</nowiki>
 
 
This is an SMW query to look up the "Can Train Obedience" property of Muffalo.  See [https://www.semantic-mediawiki.org/wiki/Help:Inline_queries here] for more details on SMW queries.
 
The "Can Train Obedience" property for Muffalo is set in the monster [[Template:Infobox_main]].  The muffalo page sets <code>trainable = simple</code> as a parameter to Template:Infobox_main, and it sets the appropriate properties in response.
 
 
You can see all the pages which have these properties set at [[Property:Can_Train_Haul]], for example.
 
The TrainingTable for [[elk]] broke when you made [https://rimworldwiki.com/index.php?title=Elk&diff=69553&oldid=64221 this] change.  When you changed the param to "Intermediate" instead of "intermediate" the switch statement in the Template:Infobox_main broke, since it didn't recognize the capitalized version.
 
 
It's a pretty overengineered solution, but it keeps the lights on I suppose :).  Does this make sense?
 
 
[[User:FixSomeBugs|FixSomeBugs]] ([[User talk:FixSomeBugs|talk]]) 05:44, 26 April 2020 (UTC)
 

Please note that all contributions to RimWorld Wiki are considered to be released under the CC BY-SA 3.0 (see RimWorld Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)