Template talk:Cost

From GuildWiki
Jump to: navigation, search

Bug? Feature?[edit source]

code expected output actual output
{{cost | 10 | }} 10 Platinum.png 10 Gold

I see no way of fixing it, though, as tempates and ParserFunctions do not distinguish between the empty string (modulo whitespace) and lack of an argument. 08:12, 28 August 2006 (CDT)

You can distinguish. If the first parameter is undefined, then {{{1|x}}} will not equal {{{1|y}}}. You could say it's a bug in the template's documentation rather than the implementation. --Fyren 08:48, 28 August 2006 (CDT)

rewritten version incoming[edit source]

There is a rewritten version at User:M.mendel/Templates/cost. It has the following advantages:

  1. The cost doesn't wrap, i.e. numbers and symbols always stay on the same line.
  2. The bug mentioned above is fixed.
  3. The new template can actually produce 12 Platinum 0 Gold; this is not possible now.
  4. The old template adds {{cost|12|12345}} to produce 24 Platinum 345 Gold; the new one gives a warning (as the old one should have done per the documentation).
  5. The template code is actually readable and works without complicated expressions.

Since a change of this template affects 500+ pages, I thought I'd ask for criticism and/or suggestions before I implement the change. Any takers? --◄mendel► 18:24, 6 October 2008 (UTC)

Hope you don't mind, I changed your list to an ordered one so I can respond point-by-point.
  1. Whoo!
  2. Whoo!
  3. Is that really necessary? Given a platinum value such as 12 Platinum, most people will understand the implied 0 Gold.
  4. What's your deal with huge, brightly-colored error messages anyway? :P
  5. In defense of the original template, it was created before the StringFunctions extension was installed on GuildWiki, so it had to rely on the mathematical abilities of the ParserFunctions extension.
I don't see any problems with your version, and I can't think of any other possible improvements at this time. —Dr Ishmael Diablo the chicken.gif 19:20, 6 October 2008 (UTC)
3. It's a matter of symmetry (because 0 Platinum some Gold was possible even with the old template), and it might come in handy when there's a list of prices, most of which do have the gold part (especially if it is right-aligned). You can still produce just the platinum if you want by leaving the gold parameter empty.
4. They have to look so ugly as to provide motivation to eliminate them asap. ;-) We ought to do a wiki search for the error phrase as soon as the change is through the job queue.
5. That is no defense for using an arithmetic expression instead of ({{{2}}} < 1000) and no linebreaks.
Thank you.
I'm going to try a DPL query to feed all existing costs into a copy of the new template tomorrow morning, when the server is more responsive - most problems should become obvious (if it works). --◄mendel► 21:30, 6 October 2008 (UTC)

needs more work[edit source]

A quick check with DPL (count=20 was sufficient) made me realize two things:

  1. Because of the above bug, everybody had to add 0g to get just the Platinum to show, so if we use the proposed version, all of these will get converted to show 0g. This means I have to rewrite the template to suppress the 0g, but I could use a gold=yes parameter if I wanted to show 0g.
  2. The {{cost|75000}} results in 000g to be shown; the leading 0s need to go away if it's 050, and the 000g needs to be suppressed completely to look like it does now.

So I can't update until I fix this. --◄mendel► 21:51, 8 October 2008 (UTC)