Template talk:HadezCharData

From BattleMaster Wiki
Revision as of 03:32, 3 December 2009 by Wraith0x29a (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

So I've been watching the edits for this on the recent change list, figured I'd try it out for you. The main thing I've noticed is that it's unable to pull information if you insert a char_id instead of a char_name. It will fail to display anything if a char_name isn't supplied (supplying both seems to work fine though). I've tested it with my Viscount on Dwilight, my Knight on EI, as well my adventurer on Beluaterra. With the exception of the char_id bug, it works fine assuming you put in all the right information. My test page on this if you're interested. Take note of my fourth and fifth tests, I'm very interested to know how exactly that happened. --Kag 13:27, 29 November 2009 (UTC)

Thanks for checking this out.
I've added a couple of examples to the bottom of your test page with only the world_id and char_id specified and it seems to work fine.
Examples 4 and 5 are downright weird. I'll investigate though it doesn't seem to happen if use parameters as directed.

-- Wraith0x29a 13:47, 29 November 2009 (UTC)

Ok, think I've worked out what went wrong with the forth example.
You used the wrong world_id (4 instead of 8) for Zanaras and no character with that name exists on world 4. The Template should show nothing in this case and skip doing the rest of the work of the template (retrieving and showing data for region, realm and related nobles).
However, you have used multiple instances of the template. I 'guess' that the variables holding your character data persisted from the previous run of the template rather than being overwritten as they would be if correct parameters had been set and the template run fully.
So, the Template did subsequent lookups in the game based on the information given in the parameters mashed together with that from the previous run of the template. As your duke in world 8 was previously set correctly as 'Brynden' and as (by complete coincidence) there is another character named Brynden in world 4 his details were retrieved on the second run.
Shouldn't be a problem unless people use multiple copies of the template on their page 'and' get their parameters wrong in one of them but I'll change the error checking to prevent this.

Incidentally if someone does use both char_id and char_name char_name is given preference as the user is (hopefully) less likely to get that wrong.

-- Wraith0x29a 14:21, 29 November 2009 (UTC)

Rats. It looks like variables are shared between all instances of the same template on the same page. This means handling errors that appear in some of the multiple instances of the same template on a single page is not possible in an elegant way (or at least not in an elegant way I can immediately see).
If I check the validity of the data from a call to the external data API by checking that, say, the character's name is set that will give false positives if a previous call succeeded as {{#external_value:name}} from the previous instance is still set to a valid name.
If I check for the existence of an error message from the API it causes false negatives on subsequent instances as {{#external_value:error}} is still set.

Again, shouldn't be a problem in this case if users always stick to the instructions but I've been a developer too long to hope that will happen :)

I'll revert the error checking to the original test for a valid name from the initial external data look-up as it's less intrusive when combined with the rare edge-cases that will cause problems. I'll edit the docs to highlight this issue.

-- Wraith0x29a 15:20, 29 November 2009 (UTC)

Very Nice Template

I love the template. It's great to see new people using the semantics and the external data. I had a couple comments:

  • I don't know the exact distinction between the different types of non-duke local lords (Baron, Count, Viscount, Marques etc). I thought it was based on region type but have since found rural regions with Viscounts and Counts. If anyone knows let me know and I'll be able to provide more detail than just 'Lord of'.
The new title system allows the ruler to select from various predefined sets of titles. Most of these are pretty self-explanatory. However, the "Complex" system is just that: complex. No one knows the exact method by which the titles are determined, but it is assumed to be base on population, and possibly regional income.
  • Have you encountered any problems with spaces in character names? Specifically, first names? I remember trying to do things like looking up a character's family name, and getting the wrong name due to the first name having a space character in it. (IIRC, I was trying to find the general of Fontan's family name. His first name was (I think) "Jon Paul". When I tried to run that through the external data feed I got back the family details for the character with the first name of "Jon". I think your template may also have that problem if the regional lord's first name contains a space. Or does the "urlencode" fix that issue? If it does, then I maybe able to use that in some other templates I've made, too.
  • One thing we want to avoid is covering the wiki with red links to non-existent pages. Specifically, individual character and family pages that don't already exist, and may never exist. If you automatically link to various family and character pages, then please check to see if the page exists before linking to it. If the page exists, make a link. If not, then just return the unlinked text. I did this as a template to make it easier: Template:FamilyLink. It may not do exactly what you want, but it can give you an idea of how to do it.
  • Do you have any plans to provide an option to box the results? Quite a few people like to box their character and family data.
  • Please add your template to the list of semantic templates: Semantic Wiki/Templates.

Anyway, very nice template. --Indirik (talk), Editor (talk) 15:02, 2 December 2009 (UTC)

Thanks, glad you like it.
Problems with spaces and special characters in names (when calling external data lookups via the HTTP API) are overcome using the urlencode: function.
I was worried about the red links, if there is a way to check if a link exists I will use it.
I do intent to add a customisable formatted box style - as soon as I have learned wiki formatting syntax :)
Once that is done and it's all been tested to destruction I'll add a link to the template list.
-- Wraith0x29a 18:07, 2 December 2009 (UTC)
You can check for the existence of a page using "#ifexist:", like this:
{{#ifexist: {{#external_value:Family}} Family | [[{{#external_value:Family}} Family|{{#external_value:Name}} {{#external_value:Family}}]] | {{#external_value:Name}} {{#external_value:Family}}}}
Another thing to consider is to only link to the family page, and not the individual character pages. There are a lot of people that don't use character subpages.
--Indirik (talk), Editor (talk) 21:03, 2 December 2009 (UTC)
I had a look at the template you linked to and found the #ifexists function. Will just take a while to adapt my template to use it (will likely break-out the family links functionality into a utility template as it will be better as the equivalent of a reusable library function).
I want to keep links to those who do have character sub-pages as they deserve to be rewarded for their effort but that's easy enough using #ifexists.
Thanks for the pointers.
-- Wraith0x29a 01:25, 3 December 2009 (UTC)