PDA

View Full Version : I need some FG2 specifici xml/lua guidance



DrClarke
June 27th, 2007, 22:06
Okay, be patient with me here. :) As kalmarjan pointed out in another post, I'm not grasping this like I thought I would.

I'm no pro coder/scripter, but I can get by well enough for my own personal projects. I do just fine with things like .php, mysql, or even perl, but I'm feel I'm missing something fundamental here in FG2.

I've never tinkered with .xml, but I assumed it was, for better use of a term, simply a flat file db? I've never touched lua, even though I played WoW for the better part of two years, I just never got around to modding an interface project.

Enter FG2. I'll post my 'example' here and then try to ask my questions so that one of the pros can point me in the right direction.


<?xml version="1.0" encoding="ISO-8859-1"?>
<root version="2.0">
<library>
<d20Armor static="true">
<name type="string">d20Armor</name>
<categoryname type="string">d20Armor</categoryname>
<entries>
<armor2>
<librarylink type="windowreference">
<class>referencetextwide</class>
<recordname>..</recordname>
</librarylink>
<name type="string">Armor 2</name>
<text type="formattedtext">
<table width="100%" border="0">
<tr decoration="underline"><td colspan="2"><b>Armor</b></td><td><b>Cost</b></td><td><b>Armor/Shield Bonus</b></td><td><b>Maximum Dex Bonus</b></td><td><b>Armor Check Penalty</b></td><td><b>Arcane Spell Failure Chance</b></td><td><b>Speed (30 ft.)</b></td><td><b>Speed (20 ft.)</b></td><td><b>Weight</b></td></tr>
<tr><td colspan="10">Light armor</td></tr>
<tr><td colspan="2">&#160;&#160;&#160;&#160;Padded</td><td>5 gp</td><td>+1</td><td>+8</td><td>0</td><td>5%</td><td>30 ft.</td><td>20 ft.</td><td>10 lb.</td></tr>
<tr><td colspan="2">&#160;&#160;&#160;&#160;Leather</td><td>10 gp</td><td>+2</td><td>+6</td><td>0</td><td>10%</td><td>30 ft.</td><td>20 ft.</td><td>15 lb.</td></tr>
<tr><td colspan="2">&#160;&#160;&#160;&#160;Studded Leather</td><td>25 gp</td><td>+3</td><td>+5</td><td>-1</td><td>15%</td><td>30 ft.</td><td>20 ft.</td><td>20 lb.</td></tr>
<tr><td colspan="2">&#160;&#160;&#160;&#160;Chain Shirt</td><td>100 gp</td><td>+4</td><td>+4</td><td>-2</td><td>20%</td><td>30 ft.</td><td>20 ft.</td><td>25 lb.</td></tr>
</table>
</text>
</armor2>
</entries>
</d20Armor>
</library>
</root>

Okay, for the most part, I was thinking that .xml simply stored our data and the <tags></tags> we utilize/created were of our own design, but to be called upon from elsewhere within another script/application.

So, for my first question, how is it that FG2 knows to actually bold something in this .xml that utilizes the <b></b>? It's as if it's treating it like an html or xhtml command.

Is it because of the afore mentioned portion:


<text type="formattedtext">

I've literally loaded up all the .xml and .lua items I could find in FG2 into Notepad++ and did a search on all files for snippets to locate my Ah-ha! moment. Like an example I would do is a complete search on text or formattedtext thinking that since this was data stored in xml, the actual 'structure' had been formed somewhere else.

I KNOW I'm missing something easy here. I'm simply trying to learn what/where/how the data stored in this .xml files is being called from.

bonzai95
June 27th, 2007, 22:48
Let me preface this by, all of the following is strictly my assumption on how FG works.


Actually you have it all right.

XML (eXtensible Markup Language) is used to describe data. It is a markup language like HTML, but designed for a different purpose. It's made up of tags, anything between <> and attributes, which are properties of the tag.

For example you might have a date tag, with a format attribute you want to go along with it.

<date format="mm/dd/yyyy"> </date>

Something to remember about xml is that in itself, it doesn't *do* anything. It's just a way of structuring data.


In your example you are creating library entries (like in the modules section). I believe Library is a 'hardcoded' tag in FG that lets the program know how to treat this data (ie to send it to the clients, make available to players, etc).

You created a Category of the library called "d20Armor". That category can have many entries, though your example has just one, called "armor2".

The next part descibes how to render that library entry when it is clicked on. In this case you are creating a window of class "referencetextwide".

If you look through the xml files there is one called something like "basicclasses.xml" (I don't have FG installed here) and in it is a description, template, of that window class. Part of that description will include the size of the window (width and height) and what other data elements it takes.

In the case of referencetetwide, it takes a TEXT node, which is good since you've created a text node in your example.

<text type="formattedtext"> .....</text>

Everything between the text tags will get sent into the text area of the referencetextwide window.

For the formatting FG allows some basic HTML style formatting. It won't render everything you can do with HTML, but it does the basics.

<b>bold</b> <i>italics</i> etc...

The rest of your example there creates a table that spans the entire window, with the width="100%" attribute, and it has 6 rows with the first one being an underlined header row.

Hope this helps

bonzai

kalmarjan
June 28th, 2007, 03:46
Something to remember is that really, people have had it wrong the whole time.

We are not really talking about XML, or XHTML documents. What we have are snippets of XHTML that is called up to display when FG needs them. (Hence the markup)

So it is kind of like PHP or another web programming language like that.

So the tag <text type="formattedtext"> .....</text> is really telling FG that the information between the tag is a presentational XHMTL snippet.

So what does that mean? Anything that is between a tag such as <name type="string"> is really database information string that holds the name of the record, where when you see <text type="formattedtext"> is talking about what is displayed.

So, where is all this information held? That depends on what is being called. In db.xml, it could be a record for a NPC, an item etc. If it is from a module like d20 spells, then the record would be called from there.

I hope that i have not confused it too much. LOL

Sandeman

DrClarke
June 28th, 2007, 20:30
Okay, I'm getting closer now. You guys are helping out a bit, that and just continual digging.

So, kalmarjan, in my example above (It's really just a hacked up d20basicrules.mod) the data between the <text type="formattedtext"> .....</text>, i.e.: things like <table><td><tr><b>, work as html/xhtml because they reside within the <text type="formattedtext"> .....</text>. In this case they're treated like markup language and not traditional xml tags to store your data.

If this is the case, then how come not all html/xhtml tags work within the <text type="formattedtext"> .....</text>? Such as something like <sub></sub> or <sup></sup>?

My next thought was based off of what bonzai95 posted. So, again utilizing my example above, I opened up the reference_basicclasses.xml and for example, found the referencetextwide class and I found some neat stuff like: <normal>chatfont</normal>, <bold>narratorfont</bold>, <italic>chatitalicfont</italic>, etc. and found these in the fonts folder. So, it appeared to be another way of getting bold, normal, and italic properties to display, by just actually hard coding that desired effect in there.

Sadly, it didn't answer my <b></b> issue.

More delving... I'm getting closer.

joeru
June 28th, 2007, 20:53
Okay, I'm getting closer now. You guys are helping out a bit, that and just continual digging.

So, kalmarjan, in my example above (It's really just a hacked up d20basicrules.mod) the data between the <text type="formattedtext"> .....</text>, i.e.: things like <table><td><tr><b>, work as html/xhtml because they reside within the <text type="formattedtext"> .....</text>. In this case they're treated like markup language and not traditional xml tags to store your data.

If this is the case, then how come not all html/xhtml tags work within the <text type="formattedtext"> .....</text>? Such as something like <sub></sub> or <sup></sup>?

<< snip >>

Sadly, it didn't answer my <b></b> issue.

More delving... I'm getting closer.

Not all html tags work, because SmiteWorks didn't input them into FG's parser, only what they deemed necessary. (And the parser is in the executable, so you can't find the definitions for basic html tags by browsing the xml files.)

DrClarke
June 28th, 2007, 21:00
Ahhh and a secret puzzle piece now falls into place :)

If Smiteworks people are reading this:

1. Any chance you can list out the valid/working html/xhtml tags?
2. Will you ever be open to future requests for non existent html/xhtml tags?

bonzai95
June 28th, 2007, 22:14
Not all html tags work, because SmiteWorks didn't input them into FG's parser, only what they deemed necessary. (And the parser is in the executable, so you can't find the definitions for basic html tags by browsing the xml files.)

That's what I meant above when I said "For the formatting FG allows some basic HTML style formatting. It won't render everything you can do with HTML, but it does the basics."

Sooner or later I'll learn to be more legible. =-)

bonzai