PDA

View Full Version : Simple question about XML processing in rulesets



swest
October 12th, 2021, 22:22
Greetings,

I hope this is, indeed, a simple question to answer.

base.xml, for CoreRPG, looks like:


<?xml version="1.0" encoding="iso-8859-1"?>

<!--
Please see the license.html file included with this distribution for
attribution and copyright information.
-->

<root version="3.0" release="4.1" logo="logo.png">
<announcement text="Core RPG ruleset (v2021-07-06) for Fantasy Grounds\rCopyright 2021 Smiteworks USA, LLC" font="emotefont" icon="rulesetlogo_CoreRPG" />

<!-- Attributes -->
<description>
<displayname>Core RPG</displayname>
<author>SmiteWorks USA, LLC</author>
<website>https://www.fantasygrounds.com</website>
</description>

<!-- Tabletop settings -->
<includefile source="gameelements.xml" />

<!-- Graphics -->
<includefile source="graphics/graphics_fonts.xml" />
<includefile source="graphics/graphics_frames.xml" />
<includefile source="graphics/graphics_icons.xml" />
<includefile source="graphics/graphics_portraits.xml" />
.
.

up in the 'announcement' stanza, line 9, the specification of 'icon' uses a name, rulesetlogo_CoreRPG, that will not be defined until graphics_icons.xml is read in down at line 24.

How does that work?

Thanks!

- s.west

Zacchaeus
October 12th, 2021, 22:29
I’m guessing here but the xml just defines things and the lua runs it. So that file is just defining the various things that the lua then uses to do whatever it needs to done. Thus it probably doesn’t matter what order stuff appears in the xml file.

Trenloe
October 12th, 2021, 23:00
As Zacchaeus says, <announcement> is just a definition of the announcement. It doesn't "run" the announcement at that line in base.xml - it defines it. Then, when FG fully loads and displays the chat window, the various <announcement> entries defined previously are executed.

https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996645328/announcement

darrenan
October 12th, 2021, 23:01
Or to put it another way, XML is not a procedural language i.e. it does not follow a set of steps in order. It is a declarative language i.e. it declares the ways things are with no implied ordering.

swest
October 12th, 2021, 23:46
Got it.

All three of your responses added something to my repertoire. Thanks!

- s.west

swest
October 13th, 2021, 00:07
Also, while I have your attention here, someone posted (Trenloe, or damned, or Moon Wizard, or?) an answer to the following ruleset development question (and I can't find it again):

Is it better to: 1) Start with a simple base.xml that contains <importruleset source="CoreRPG" /> and then gradually build on top of that?
Or is it better to 2) Copy and rename the CoreRPG ruleset, and gradually change it into what you're developing?

(I hope that question is clear.)

Thanks, gents!

superteddy57
October 13th, 2021, 01:16
It is best to import the CoreRPG as you then start with all of it's resources. You can then declare xml templates and lua scripts that are located there. All of the commercial rulesets use this model and gain the biggest benefit of receiving new core features that are introduced into CoreRPG.

swest
October 13th, 2021, 04:43
Thanks!!