PDA

View Full Version : textres ?



Varsuuk
December 4th, 2016, 22:26
I'm sorry if this is a bit premature as I haven't yet started learning much about rulesets and such. I have only just finished a PluralSight Lua "course" on the language and starting the "Standard Library" portion of it.

I decided I wanted to poke at random into some .lua files to see if I "got" any of it yet. I traced something to basically a string.xml file that apparently is used for localization. I used to do this back in Visual C++ 1.52 days in .rc files.

I think I was in 5e or CnC ruleset when noticed it. I tried looking for it there and no references other than .xml. so went a level lower and didn't see in the CoreRPG directory. So, am I looking in the wrong places or is it something that is XMLish somewhere and "automatic"?

Or, is it a defined xml element that the FG application itself where it looks for these tags to display the right language or is this mechanism in some higher level that I missed?

Thanks.

damned
December 4th, 2016, 22:32
textres is used for localisation. instead of hardcoding that Word/Name/Description in the ruleset it is defined in a Strings file which is easier to update for a different language. If you cant find where textres is defined it may be in the back end code.

Moon Wizard
December 4th, 2016, 22:47
As damned mentioned, it's used as an attribute for tags that normally accept text in order to allow them to use string resources instead.

Regards,
JPG

Varsuuk
December 4th, 2016, 23:41
Cool - so just to verify, it is "back end code" - i.e., FG takes care of it as long as I add that element to my XML. I don't have to call anything to "retrieve" the English or other text.

But yeah, I'l wait until I find the right chain of documentation to read because I gripped for strings_cnc.xml and came up wth only one place in the C&C ruleset files, base.xml as an include. Since I am not sure how to include of something already under a <root> element works (I have googling to do... I'm a back end dev with nothing but minor config.xml handling) and it might become apparent then.

Was just wondering how a subruleset indicates to the FG engine that these strings are to be used when encounter a matching textures key.

excerpt from strings_cnc.xml:
<root>
<!-- Common -->
<string name="base">Base</string>
<string name="dash">-</string>
<string name="str">Str</string>
...

Except from one place that refers to it:
<template name="number_charsr">
<number_chartotal>
<modifiersize>mini</modifiersize>
<description textres="spellresistance" />
...

Even presuming that all <string ... /> elements are merged into some table, what happens with clashes... hmm... OK, probably FG builds a table per ruleset or something so it searches up the chain with metatables stuff... as I write this I have an inkling of what might be done if FG looks for <string> elements in rulesets either in general or in db.xml files etc. Yeah... I'll read more first.

Back to my relaxation reading on Birthday where not being asked to do ANY Sunday tasks... life is good :)

damned
December 4th, 2016, 23:45
There are no clashes.... these are kind of like variables - you declare the str=Strength and then later on your declare that str=Stroganoff thats the one it will use :)
You can declare these anywhere in any file that is being loaded/read - including an extension (which is how you would internationalise it).

Varsuuk
December 5th, 2016, 00:01
Yeah, I was typing stream of consciousness. I wondered about classes (and of course, with clashes, the last encountered overwrites the earlier value) and wondered if this wouldn't mess up the other perhaps higher up (ex CoreRPG defines STR as "strength" and someone in DanRPG which is build on CoreRPG, we defined STR as "str" - I was worried that some master "localization file" would not have it's STR entry changed from value "strength" to "str". I didn't mean clash as in name clashes leading to "compile" or in the case of interpreted, "syntax" errors.

I then imagined (with what little I know of Lua so far) that it may use a "Chain of Responsibility" Design Pattern and when inside the "scope" of "classes" (my Lua vocabulary is not yet there) in DanRPG, it resolves to finding "str", when using original CoreRPG lookups, it starts earlier in the chain and only finds "strength".

If that makes any sense to you, what I was thinking?

Trenloe
December 5th, 2016, 05:36
Layered rulesets load in order (for example, Pathfinder ruleset load order is: CoreRPG -> 3.5E -> PFRPG), and anything in the later loaded ruleset overwrites what was loaded earlier.