24,493 ARTICLES
ON THIS WIKI

Template talk:Grid/Crafting Table

< Template talk:Grid

Some recipes call for a varient of ingredient. To show this, a GIF needs to be used, but the current source does not allow for gifs (it will be named [file].gif[XN].png). Can somebody fix the code up to not force a change in the image coding if there's already one there? --Tokoraptor (talk) 06:53, November 23, 2012 (UTC)

Excessive Parser Function use[edit]

In the current state of this template, there's an excessive use of parser functions where the template parameters could simply be used instead. For instance, the current code reads:

{{#if:{{{A1-image|}}}|{{{A1-image}}}|Grid_{{{A1}}}.png}}

(For those unfamiliar, this means "If A1-image has been specified, use A1-image, otherwise use 'Grid_{{{A1}}}.png'")

This uses a parser function unnecessarily, since the same effect is obtained by:

{{{A1-image|Grid_{{{A1}}}.png}}}

("Use A1-image. If A1-image is not specified, use 'Grid_{{{A1}}}.png'")

I'm no expert, but I have to think that calling the parser function is a more expensive operation than using the native template method. I've converted the template to use the latter method at User:timrem/Sandbox, and run a brief side-by-side test of the changes at User:timrem/Test. As expected, they appear to be identical, except in one respect: specifying "|A1-link=" as a blank value, in the current template, does nothing (the same holds for all the other XX-link parameters). In the updated version, specifying a link and providing no target instead removes the link from the image (this difference can be seen by hovering over the output blocks of the two tables on my test page). To be honest, that seems like an improvement, providing a greater range of flexibility (not that I can think of a time when it would be used).

I would appreciate it if someone else could look it over, see if I missed anything, or possibly defend the current version of the template. Thanks! --timrem (talk) 20:15, 15 February 2013 (CET)

Unfortunately I am not the most well-versed with wiki code, but this seems to be a big improvement over the current code. It's much cleaner. So if someone more knowledgable could take a brief look, I'd like to see this implemented! --Artsja (talk) 16:19, 16 February 2013 (CET)

Tooltip Brackets[edit]

Is it possible to get brackets in an item name to show up on a tooltip? For example, on Machine Frame (Thermal Expansion 4) there are crafting recipes for each tier of machine:

{{Grid/Crafting Table|nobreak=1
|A1 = Silver Ingot |B1 = Enderium Gear |C1 = Silver Ingot
|B2 = Machine Frame (Reinforced)
|A3 = Silver Ingot  |C3 = Silver Ingot
|Output = Machine Frame (Resonant)}}

However, the bracketed part of the name is not showing up on tooltips, which may cause user confusion: http://i.imgur.com/V56w2PA.png http://i.imgur.com/pOhoAs5.png (as tested on Chrome Stable 39) -- VanDerProtofsky (talk) 12:56, 27 November 2014 (CET)

The parenthesized suffixes are left out intentionally so that mod name disambiguations like (Thermal Expansion) don't show up in the tooltips. The current algorithm is very simple and just strips everything after an opening parenthesis. Since I recently moved the mod name list to a Lua module, it might be possible to do the suffix stripping in Lua (currently it is implemented in JavaScript, which I know practically nothing about) and check the mod name list to find out if the suffix is a mod name. --dgelessus (talk · contribs) 15:17, 27 November 2014 (CET)
OK, makes sense. Is this something I can attempt to contribute on, or should I wait? (I have prior experience in JS and Lua, but not wiki modules) -- VanDerProtofsky (talk) 18:28, 3 December 2014 (CET)
If you want to give it a try, go for it. In case you don't know, you can create a personal JavaScript page in your userspace at Special:MyPage/common.js, where you can freely test code for yourself without changing it for everyone. Wiki modules are mostly standard Lua, except for the wiki interaction part. For a quick introduction, see Module:Bananas on Wikipedia - if you know MediaWiki and Lua syntax it should be relatively straightforward. Help:Lua also has a number of helpful links to get you started.
Regarding the implementation, I was thinking about adding something like a stripSuffix function to Module:ModNames, which would remove any known mod names and other disambig suffixes (Block, Item) from the name. That could then be called in the grid template to remove the suffix before setting the image alt title (or whatever is used to store the tooltip text). --dgelessus (talk · contribs) 21:30, 3 December 2014 (CET)