Template talk:HadezCharData

From BattleMaster Wiki
Revision as of 17:41, 29 November 2009 by Wraith0x29a (talk | contribs) (More bug detail.)
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 it. I'll edit the docs to highlight this issue.

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