PDA

View Full Version : A Question of Templates



Pages : [1] 2

S Ferguson
December 20th, 2012, 18:28
I posted this in the Savage Worlds forum, but the topic also has bearing on my 3.5 campaigns.

I was wondering if there was a way to "drag and drop" a "template" onto a character or NPC. This would alter both Attributes and Skills/Feats, as well as add Hindrances or Benefits, Alignment Changes, etc. on a character. An example would be, say, becoming a Vampire, in which your core stats are altered (increased STR, DEX, etc), various Vampiric abilities, and weaknesses.

The concept is drawn from the aptly named Book of Templates put out by Goodman games. There, they describe how to adjust a creature or character block in this manner. It was also used in DragonMech. Does anyone know if this feature is available in FG?

Trenloe
December 20th, 2012, 18:38
I've thought about doing this before. But, from what is actually required to implement the template rebuild rules there would have to be a lot of work to do this properly - especially for more advanced templates.

It could be done though - an extension would need to be written that would allow templates to be entered (and stored for future use) and then apply the changes in the template to an NPC when the template was added.

The big work would be templates that do a lot of changes that need comparisons of what is there now and what they change to. Take the young template as an example: https://paizo.com/pathfinderRPG/prd/monsters/monsterAdvancement.html

The creature's size reduces by 1 step. This affects a lot of things - to hit rolls, AC, weapon damage dice, etc.. This would all have to be programmed into the template extension for all sizes of creatures.

At first I thought it would be a fairly straightforward extension, but on further investigation realised it would be more work that just adding a few modifiers and abilities to an NPC statblock.

S Ferguson
December 20th, 2012, 18:53
True, however a fair amount of the recalculations are either provided for by FG or could be worked out once (however laborious this may be) and then applied to a PC/NPC/Creature. The Book of Templates uses tables to provide the answers for most of the very material and complications you describe.

I just wanted to know if it *could* be done within FG. (or with a "template extension").

Trenloe
December 20th, 2012, 18:57
True, however a fair amount of the recalculations are either provided for by FG or could be worked out once (however laborious this may be) and then applied to a PC/NPC/Creature. The Book of Templates uses tables to provide the answers for most of the very material and complications you describe.

I just wanted to know if it *could* be done within FG. (or with a "template extension").
Yes, it can be done with an extension (as there will need to be a lot of coding and additions to the ruleset to do this). Are you the man for the job? :)

S Ferguson
December 20th, 2012, 19:24
Oh good god no. I could design the algorithms and functionality but my XML and Lua skills are sadly lacking. :(

If someone were to help I could give it a shot. Or at least point me in the right direction to Extension building resources, Lua shouldn't be hard to pick up for me but XML.. there's my problem. Know of any good references? ;)

Trenloe
December 20th, 2012, 20:01
I was just thinking this would be quite a good FG extension learning project. Start off small and then expand on it if wanted.

Perhaps try just adding the advanced simple template to an NPC. The rebuild rules for this are: Rebuild Rules: AC increase natural armor by +2; Ability Scores +4 to all ability scores (except Int scores of 2 or less).

Suggested steps would be:

Add an "Apply Tempate" button to the NPC window. Modify npc_top.xml in \campaign or the underlying npc_main.xml file. These contain the structure definition of the NPC window.
Attach some code to this button (in a new LUA script) that applies the modifiers to relevant areas.

This would give an introduction to FG XML (it's really not that bad), how to call some LUA code from the XML when the button is pressed, and how to access the DB information of the NPC and modify it based on the template being applied. This will also require a bit of string searching and manipulation to find the various bonuses (to hit, damage, skills, AC, etc.) and add the +2 for the improved abilities.

A few steps to do before getting started:
Get the 3.5E.pak file from the Fantasy Grounds installation directory (usually Program Files\Fantasy Grounds II). Rename to .zip and extract to the <FG App Data Directory>\rulesets directory - but give it a new directory such as 3.5E_DEV. This will allow you to create a new campaign, with the ruleset name 3.5E_DEV and so you can modify the files in this ruleset and test, without impacting the normal 3.5E rules. We can work on migrating any changes you make into an extension later.
Download Notepad++ (free) and add the XML plugin: https://notepad-plus-plus.org/ You can use this for modifying both XML and LUA files - and check the XML syntax with the XML plugin. Also, "Find in Files" is your friend for working out where things are in the ruleset.
Have a look at the Ruleset Modification Guide - available under the "Library" link at the top of this page.
Check some of the XML resources mentioned in the FG library: https://www.fantasygrounds.com/modguide/introduction.xcp
Check the LUA resources too: https://www.fantasygrounds.com/modguide/scripting.xcp


Then, you should be ready to give it a go...

First step would be to add a button to the NPC sheet. The buttoncontrol is detailed in the Ruleset Reference in the Library: https://www.fantasygrounds.com/refdoc/buttoncontrol.xcp There are also a number of button templates defined in the \common\template_buttons.xml file. To see an example in action - look in \charsheet\charsheet_toplevel.xml for the <button_charmini> section - this gives the location of the button "button_charmini" that is defined in charsheet\template_charsheet_general.xml.

Decide where you'd like to add the "Apply Template" button to the NPC sheet and add the button to npc_top.xml in \campaign or the underlying npc_main.xml file. Check the XML syntax in Notepad++ and save the file. Create a new campaign using your 3.5E_DEV ruleset (where you have just made the change to). Load the campaign, create a new NPC and you should see your new button...

Next step is to add code behind the button...

Hopefully the above is not too confusing - please ask questions on anything. :)

JohnD
December 20th, 2012, 20:34
Would this not be possible also through effects (possibly multiple would be needed)?

S Ferguson
December 20th, 2012, 20:36
O.K. I'm willing to give it a go. But I was thinking of having (possibly) a button associated with a "library" of templates that could be "dropped" on the "Base" PC/NPC/Creature. Each would be handled differently, of course.

Would this change the coding style any? :).

Luckily, I don't have to worry about Notepad++, I have a more powerful editor.:D

Trenloe
December 20th, 2012, 20:56
Would this not be possible also through effects (possibly multiple would be needed)?
Basic templates could be applied through effects. e.g. Advanced would be: STR:4;DEX:4;CON:4;INT:4;WIS:4;CHA:4 which works for most things, but some aren't updated (HP based on the CON increase for example).

Also, effects can only be applied to creatures in the Combat Tracker (CT), so you can't prepare in advance an "Advanced Kobold" or whatever - you'd have to remember to apply the effect to the entries in the CT when you initiate the encounter.

Phystus
December 20th, 2012, 20:56
Would this not be possible also through effects (possibly multiple would be needed)?

Some of it definitely would, but perhaps not all. For example, you can't, as far as I know, change space or reach with an effect, which would be needed for Trenloe's example of the Young template. You also couldn't change hit dice (like changing humanoid d8's to undead d12's), much less re-roll them.

It's a shame you can't change size with an effect though, it would make dealing with the Enlarge Person spell a lot easier. But dealing with weapon damage changes could be a real headache.

~P

Trenloe
December 20th, 2012, 20:58
O.K. I'm willing to give it a go. But I was thinking of having (possibly) a button associated with a "library" of templates that could be "dropped" on the "Base" PC/NPC/Creature. Each would be handled differently, of course.

Would this change the coding style any? :)
Yep, I understand where you want to get to - I'm just trying to make it possible for you to learn about FG while applying a single template, so that you're not getting in too deep to start off with.

Once you get the advanced template working, you can then change the code to have the button bring up a list of templates and select which one/s you want to apply. The base work I'm suggesting would not be wasted, you'd be building on that.

Don't try to sprint before you can walk! :)

Trenloe
December 20th, 2012, 21:03
Some of it definitely would, but perhaps not all. For example, you can't, as far as I know, change space or reach with an effect, which would be needed for Trenloe's example of the Young template. You also couldn't change hit dice (like changing humanoid d8's to undead d12's), much less re-roll them.

It's a shame you can't change size with an effect though, it would make dealing with the Enlarge Person spell a lot easier. But dealing with weapon damage changes could be a real headache.

~P
I hadn't even thought about space/reach and HD...

Yep, this is definitely something that seems relatively straightforward at first, but the more you delve into it you soon realise there are a lot of areas where changes could be required when applying a template.

Phystus
December 20th, 2012, 21:11
I hadn't even thought about space/reach and HD...

Yep, this is definitely something that seems relatively straightforward at first, but the more you delve into it you soon realise there are a lot of areas where changes could be required when applying a template.

Yeah, it can get messy pretty quickly.

I think it's time I resurrect my project to add a utility to import NPC's from PCGen. PCGen already can add templates, so you could build the character there and import it to FG.

~p

S Ferguson
December 20th, 2012, 21:34
Don't try to sprint before you can walk! :)

Nope. I'd fall flat on my face. ;) What's been mentioned so far, including adjustments to reach, etc., are all tabulated in The Book of Templates. Pretty much *everything* about adding templates to anything (like changing a humanoid to a plant that ambles) is included. Shame you can't post the book. It's available at DriveThruRPG.com if anyone is interested.

I'll try changing the tables into psuedocode and work from there. I'll take one template and attempt to modify an NPC. That will be my first step.

Thanks for the references though. I'm perusing as I type (which would explain the rambling).

Trenloe
December 20th, 2012, 22:10
I think it's time I resurrect my project to add a utility to import NPC's from PCGen. PCGen already can add templates, so you could build the character there and import it to FG.
The Creature Parser can do this with a slight editing of the statblock output: https://www.fantasygrounds.com/forums/showthread.php?t=15475

In the new 6.0 PCGen, create your NPC and export using the csheet_fantasy_Statblock5.htm option. Open the exported HTML file in a web browser, copy the text and past into a text editor, then do the following:

Add an XP line between the Name/CR line and the Type line.
Remove any blank lines.
Change the "Possessions" heading to "gear".
Use the parser...


If you're interested in a project, how about modifying the PCGen output to more adhere to the Paizo statblock standard which will then allow the creature parser to bring the NPC into FG for you without having to make the above modifications?? :)

S Ferguson
December 21st, 2012, 01:24
Wouldn't it be a mite more simple to work it *into* FG than rely on a certain external program? As far as I know PCGen doesn't import FG Characters so if one were to aquire a template in game, you wouldn't have resort to fudging with another tool. PCGen is good for characters starting off with templates, but if you're playing in say, an off-the-cuff Ravenloft game as a human, there is a strong possibility you might become a vampire.

I just can't see the benefits of running different programs if one will do.

Trenloe
December 21st, 2012, 01:47
Wouldn't it be a mite more simple to work it *into* FG than rely on a certain external program? As far as I know PCGen doesn't import FG Characters so if one were to aquire a template in game, you wouldn't have resort to fudging with another tool. PCGen is good for characters starting off with templates, but if you're playing in say, an off-the-cuff Ravenloft game as a human, there is a strong possibility you might become a vampire.

I just can't see the benefits of running different programs if one will do.
If there was that functionality within FG then great. But, at the moment there isn't.

We were more talking about importing into FG in general from PCGen, and I was commenting that there are solutions for that now with the creature parser for NPCs. And, there is also the Smiteworks provided character converter for PCs.

Sorry for hijacking your thread on applying templates *within* Fantasy Grounds. :)

S Ferguson
December 21st, 2012, 02:07
If there was that functionality within FG then great. But, at the moment there isn't.

We were more talking about importing into FG in general from PCGen, and I was commenting that there are solutions for that now with the creature parser for NPCs. And, there is also the Smiteworks provided character converter for PCs.

Sorry for hijacking your thread on applying templates *within* Fantasy Grounds. :)

Hey hijack it anytime ;), this has been the most informative thread I've started. I was actually wondering if the main database, where all that character information is stored, could be parsed and/or altered to this effect.

Thanks in advanced.

Trenloe
December 21st, 2012, 02:17
I was actually wondering if the main database, where all that character information is stored, could be parsed and/or altered to this effect.
Absolutely - using the DB package to get to the database nodes: https://www.fantasygrounds.com/refdoc/DB.xcp

S Ferguson
December 21st, 2012, 02:44
So (forgive my naivete) in *theory* a ruleset could be written within FG that acts on the value nodes as long as it knows where to look in each instance, by say adding new nodes, deleting old nodes and altering existing ones.

Then *if* the template gets removed. The changes could be altered by "negating" the template which would "un-parse" the added, subtracted or adjusted nodes.

Is this a feasible option? It's digging deep but should work depending on where the "character sheet" resides in the database.

Once again, thanks.

Trenloe
December 21st, 2012, 03:01
So (forgive my naivete) in *theory* a ruleset could be written within FG that acts on the value nodes as long as it knows where to look in each instance, by say adding new nodes, deleting old nodes and altering existing ones.

Then *if* the template gets removed. The changes could be altered by "negating" the template which would "un-parse" the added, subtracted or adjusted nodes.

Is this a feasible option? It's digging deep but should work depending on where the "character sheet" resides in the database.
Yep - both PC and NPC data is stored in the FG campaign database. To see this, create a campaign and then create a PC and NPC (or drag an NPC from the bestiary into the NPC list so it is copied to the campaign database). Exit the campaign and then look in the campaign directory: <FG App Data Directory>\campaigns\<name of your campaign> there will be a db.xml file there - open this in Notepad++. Within the "root" XML tag there are a number of sections - "charsheet" holds the PCs and "npc" the NPCs. Each entry will have a tag (section) name of id-XXXXX - where XXXXX is the number of the entry, counting up from 1 for the first one created. thus <id-00001> is the first PC in the <charsheet> section.

Use the DB package in LUA scripts to search and modify these values.

So, yes, you can apply a template and then remove it later.

Doing this was what I thought would be the next step in the "learning" exercise I suggested - basically putting code under the button that would get the "ID" of the NPC (or PC) that the "Apply Template" button was pressed for and then going into the campaign database and applying the relevant template changes.

Once you're familiar with doing this for a basic template (perhaps the "advanced" one as an example), you an then do additional XML and LUA code to populate a template list and use that to select which template to apply to the NPC/PC campaign database data.

S Ferguson
December 21st, 2012, 03:43
Thanks for the help!

I'll see what I can do with the singleton "advanced" template over the next few weeks. If I have any trouble I'll no doubt pester the forum :D.

S Ferguson
December 22nd, 2012, 01:59
Actually after thinking this over, would it be safe to override the FX Button, call it Templates, and add the specific code there?

It would seem, at least, that Templates are a logical extension of effects and the drag and drop is already there, as well as the button. The template would follow a Mini-sheet format and the effects would be applied directly to a PC or NPC or even a Vehicle or Location.

My question is, is it safe to modify this, and where would the script for the application of FX be? I found it right away in the SW ruleset but it seems to be obscured in the 3.5 system.

Any help would be appreciated.

Trenloe
December 22nd, 2012, 11:19
Actually after thinking this over, would it be safe to override the FX Button, call it Templates, and add the specific code there?

It would seem, at least, that Templates are a logical extension of effects and the drag and drop is already there, as well as the button. The template would follow a Mini-sheet format and the effects would be applied directly to a PC or NPC or even a Vehicle or Location.

My question is, is it safe to modify this, and where would the script for the application of FX be? I found it right away in the SW ruleset but it seems to be obscured in the 3.5 system.

Any help would be appreciated.
Effects are really meant to be temporary changes to a PC/NPC. In 3.5E they can only be applied to a PC or NPC once they are in the Combat Tracker. So, effects in 3.5E really aren't such a great place to do templates.

Plus, the effects subsystem is part of ongoing development in the ruleset so making an extension that utilises effects subsystem will constantly require updating when new FG releases are brought out, and runs the risk of either breaking effects or being broken itself.

As templates are usually permanent (or long term) changes I think it is best to actually modify the base stats.

S Ferguson
December 22nd, 2012, 16:29
Mmmm. I noticed that after the fact. Thanks for pointing that out :o.

I was thinking of putting a button in that area of the screen (mabye a wide one, as I like the current "balance") I think there is a way of anchoring it to the bottom (though I'm not quite so sure - never give someone who's A.I, trained a graphic interface :o),

Luckily though, if I can get it so I can input a singleton template; parsing it, and applying the results should be relatively easy. That's playing to my strengths.:)

Is there a more clear reference doc on how to make buttons and lists, the XML and the help docs sometimes seem straightforward, but are mostly obfuscated (at least to me :o) on doing this sort of thing. Not that I expect *everything* to be spelled out for me. just a few walkthrough tutorials and *why* I'm writing it this way.

Thanks in advance
SF

S Ferguson
December 22nd, 2012, 16:42
Oh, and one other thing which I'm also fuzzy about :o. Is this a ruleset change, a module, a library or an extension? It's ruleset dependent, but so are some of the extensions I've seen. There seems to be a fine line on how you approach the different aspects.

Once again, Thanks for any help.

Trenloe
December 22nd, 2012, 21:47
Is there a more clear reference doc on how to make buttons and lists, the XML and the help docs sometimes seem straightforward, but are mostly obfuscated (at least to me :o) on doing this sort of thing. Not that I expect *everything* to be spelled out for me. just a few walkthrough tutorials and *why* I'm writing it this way.
There's no real step-by-step guides for this, unfortunately. There's a bit of info in the windows and control section of the ruleset modification guide: https://www.fantasygrounds.com/modguide/windowing.xcp

I tend to look at actual examples in the ruleset I'm interested in myself. It takes a little while to get used to the structure of a specific ruleset and so finding things can seem daunting at first (that "find in files" functionality is your best friend here). Find an example of what you like in the FG FUI and then look at how it is coded in the ruleset XML itself.

I've done a little example for you - just a very simple button at the end of the body of the 3.5E NPC details (scroll right down to the bottom of the first tab). Look for the commented "Example Button" section in this file:
3501

There is also a basic example <script> section that just writes "Button Pressed" - this is just an example of a hook to launch your code.

Simply overwrite the npc_mail.xml file in your DEV ruleset to give this a go.

FYI - if you're coding and modifying files and need to see if they have worked, you need to restart Fantasy Grounds or type /reload in the chat window to reload the ruleset without exiting.

Trenloe
December 22nd, 2012, 21:53
Oh, and one other thing which I'm also fuzzy about :o. Is this a ruleset change, a module, a library or an extension? It's ruleset dependent, but so are some of the extensions I've seen. There seems to be a fine line on how you approach the different aspects.
The initial way I'm suggesting to do this is to modify a copy of the ruleset - as this is the easiest way to start. Once you're happy with the changes you've made, the best way to "package" it is an extension - which contains all of the new files and modified base ruleset files, and is loaded after the ruleset overwriting the base ruleset files. This allows you to distribute it and also to turn it on/off at the campaign level.

It's not a module or library module as these are reference/data files that essentially contain FG database entries that can be used within a campaign if desired.

S Ferguson
December 22nd, 2012, 23:00
Okay, thanks. :)

S Ferguson
December 29th, 2012, 22:29
O.K. I feel like I'm a little over my head here. :confused:

I need a *very* small example of a function outside of of npc_main that accesses the currently selected "npc's/player's" nodes in the database and alters it *after* checking it's current value: "type" would be a good beginner example.

I've fooled around a bit with the example I have and can now manipulate buttons and their anchoring positions and don't feel so bad about XML anymore.

I'm just looking for an example that say scans through the type_value and if something isn't present, say "amorphous," then add it. if it's already there ignore it.

The manual is rather skittish when it comes to interfacing directly with database entries. (mabye there should be a total beginners guide to making extensions - FG II for Dummies or something...).

Thanks in advance, for any help.

Trenloe
December 30th, 2012, 23:47
O.K. I feel like I'm a little over my head here. :confused:
Well, you're into full on ruleset modification now. :) It does take a well to get used to it...

I need a *very* small example of a function outside of of npc_main that accesses the currently selected "npc's/player's" nodes in the database and alters it *after* checking it's current value: "type" would be a good beginner example.

...

I'm just looking for an example that say scans through the type_value and if something isn't present, say "amorphous," then add it. if it's already there ignore it.
See the modified XML attached:
3527

You can't put comments in LUA embedded in an XML file, so here is the code with comments attached:

function onButtonPress()
-- Example function to get the "type" child databasenode of the databasenode where the button was pressed
-- Writes data to the chat window for debugging purposes

-- Get the databasenode tied to the window where the button was pressed
local nodeNPC = window.getDatabaseNode();

-- Get the name of the DB node where the button was pressed - for NPCs within a campaign this will usually be "id-XXXXX"
local nodeName = nodeNPC.getName();
local msg = {text = "NPC node name = " .. nodeName};
Comm.addChatMessage(msg);

-- Get the child dbnode "type"
local nodeType = nodeNPC.getChild("type");
-- Get the value of the node
local NPCType = nodeType.getValue();
-- Write debug to the chat window
local msg = {text = "NPC type = " .. NPCType};
Comm.addChatMessage(msg);

-- Check to see if amorphous is in the type string - do this in lowercase to catch all occurences
if string.find(string.lower(NPCType), "amorphous") == nil then
local msg = {text = "NPC type does not contain amorphous - adding..."};
Comm.addChatMessage(msg);

-- If amorphous is not in the type string, add it to the end of the string.
nodeType.setValue(NPCType .. " amorphous");
end

end
In the long run, it is better to move code such as this to it's own .LUA file - you can add comments, use version control better, etc.. But for the moment it is OK doing the code in the XML file.

A common comment is that there is not a lot of documentation about modifying rulesets. To be honest, it would be a huge undertaking to cover off most of what people want to do - each developer will probably be starting out with different goals in mind, and each ruleset can be different in how it handles things.

The best approach is:

Don't try to run before you can walk - I know I've said this before, but it is very true. You're learning how to do full blown development - you don't do this in a couple of hours.
There is a wealth of example code in the ruleset you are interested in modifying. Do a "find in files" in the ruleset for example code and you will see examples of how coding has been done. I can't over state the value of this approach - take your time and understand what the code is doing...
Refer to the code in the ruleset and check the library references for info on the FG specific code.
When all else fails, ask on the forums (as you have been).

S Ferguson
December 31st, 2012, 00:17
I know. My first project and it happens to be a doozy.:D Thanks for the advice (and code). I will use it well.

SF

S Ferguson
December 31st, 2012, 19:47
In fact I used it so well I can now create Vampiric Donkeys galore. I can adjust all of the child nodes in the NPC Block from an external file.

Trenloe
December 31st, 2012, 19:58
In fact I used it so well I can now create Vampiric Donkeys galore. I can adjust all of the child nodes in the NPC Block from an external file.
Nice one. You can never have too many vampiric donkeys! :)

S Ferguson
December 31st, 2012, 20:02
Not as half as bad as my vampiric elephants. :) Now to change it to a drag and drop, I have to have a window in which I can create these templates. Any reading assignments?;)

Trenloe
December 31st, 2012, 20:22
Not as half as bad as my vampiric elephants. :)
Nasty! :-o


Now to change it to a drag and drop, I have to have a window in which I can create these templates. Any reading assignments?;)
There is some code for drag/drop in the items list window - in the 3.5E ruleset, campaign\campaign_items.xml and campaign\scripts\campaign_itemdrop.lua where the onDrop event is coded.

Trenloe
December 31st, 2012, 20:24
onDrop info for the windowclass control here: https://www.fantasygrounds.com/refdoc/windowcontrol.xcp#onDrop

S Ferguson
January 1st, 2013, 16:56
OK. I don't want to sprint now. I just want an icon on the main screen, that when I press on it, it prompts me to enter a new template. I know what the template's template looks like, and am pretty sure I could put the required fields in a window;)
but I'll work on that after I've got the "window list of templates." as it will be a "new" button I'll be attaching my code to.

I think the main problem from learning from the code that has already been written in the 3.5/Pathfinder set is that 1) it was written by people who knew the structure of the code and FG2 itself (and there is one thing lacking in the ruleset - comments) and 2) *didn't* program in LISP and Prolog for 20 yrs.:)

I'm picking up Lua quite nicely (it's a lot like Scheme) and (with the help of Liquid Studios' XML 2011 catching my mistakes) even XML. I just can't for the life of me figure out how the 3.5e ruleset is organized so I can get the info I need. After all you can't search if you don't know what you're looking for (or rather what you *think* you're looking for).

Any help (Tremoe :)) would be much appreciated.
SF

S Ferguson
January 1st, 2013, 16:57
OK. I don't want to sprint now. I just want an icon on the main screen, that when I press on it, it prompts me to enter a new template. I know what the template's template looks like, and am pretty sure I could put the required fields in a window;)
but I'll work on that after I've got the "window list of templates." as it will be a "new" button I'll be attaching my code to.

I think the main problem from learning from the code that has already been written in the 3.5/Pathfinder set is that 1) it was written by people who knew the structure of the code and FG2 itself (and there is one thing lacking in the ruleset - comments) and 2) *didn't* program in LISP and Prolog for 20 yrs.:)

I'm picking up Lua quite nicely (it's a lot like Scheme) and (with the help of Liquid Studios' XML 2011 catching my mistakes) even XML. I just can't for the life of me figure out how the 3.5e ruleset is organized so I can get the info I need. After all you can't search if you don't know what you're looking for (or rather what you *think* you're looking for).

Any help (Trenloe :)) would be much appreciated.
SF

S Ferguson
January 1st, 2013, 17:03
Sorry for the duplication of posts, I *had* to correct your name.:D

Trenloe
January 2nd, 2013, 18:06
OK. I don't want to sprint now. I just want an icon on the main screen, that when I press on it, it prompts me to enter a new template. I know what the template's template looks like, and am pretty sure I could put the required fields in a window;)
but I'll work on that after I've got the "window list of templates." as it will be a "new" button I'll be attaching my code to.

I think the main problem from learning from the code that has already been written in the 3.5/Pathfinder set is that 1) it was written by people who knew the structure of the code and FG2 itself (and there is one thing lacking in the ruleset - comments) and 2) *didn't* program in LISP and Prolog for 20 yrs.:)

I'm picking up Lua quite nicely (it's a lot like Scheme) and (with the help of Liquid Studios' XML 2011 catching my mistakes) even XML. I just can't for the life of me figure out how the 3.5e ruleset is organized so I can get the info I need. After all you can't search if you don't know what you're looking for (or rather what you *think* you're looking for).

Any help (Trenloe :)) would be much appreciated.
SF
Don't get me started on the lack of comments in the code... :mad:

A few pointers where "stuff" is in the 3.5E ruleset. This is the high level directories - most contain XML files (usually GUI objects and their layout) and associated LUA scripts in the underlying \scripts directory :

calendar - XML and LUA to do with the calendar.
campaign - XML and LUA to do with the campaign side of things, i.e. Story, Maps & Images, NPCs, Encounters, Items, etc.. Basically, the main icons along the right side of the FG desktop.
charsheet - err, the Character Sheet, I think... ;)
common - commonly used template and scripts. Buttons, lists, toolbars, etc..
ct - the Combat Tracker.
desktop - stuff that is on the desktop: chat window, dice tower, modifier stack, etc.
graphics - all of the graphics used within the ruleset.
ps - the Party Sheet.
ref - XML and LUA to do with the library reference (displaying library modules) and the different windows that can be displayed for library reference entries.
scripts - data_common.lua (contains a lot of 3.5E and Pathfinder relevant data - like skills, effects, abilities, conditions, energy types, immune types, damage types, bonus types, etc., etc.. Also has "manager" scripts - the main code that handles specific functionality within FG - like damage, attacks, initiative, exporting, spells, targeting, etc., etc..
utility - basically the "stuff" hanging off the icons in the top right of the FG desktop - character list, effects list, tokens, modifiers, options, tables.


So, if you want to make a list, where you can create template details; you're probably looking at something like the campaign entries - NPC or Items being examples of a list that opens a form with various fields you can fill out. Have a look at campaign\campaign_items.xml (the "itemsmall" class is the list container and "itemlist" is the list of items), item_main.xml & item_top.xml and the associated campaign\scripts\campaign_itemXXXX.lua scripts.

S Ferguson
January 2nd, 2013, 18:31
Thanks... And I know: Lack of comments just :mad:....

S Ferguson
January 2nd, 2013, 19:00
This question I'm embarrassed to ask. :( Since the "Monster Manual" isn't consistent in the way it formats it's output, how would you, in Lua, say:

1) If the field is empty then write "Blah" if it's not write "blah blah."
2) If the field doesn't exist (like alignment for animals) ignore (1).

Once again, Thanks in advance.

Trenloe
January 2nd, 2013, 19:22
What do you mean by field? The whole entry within a control in the FG interface, or some piece of data within that?

For example, the "Type" DB Node of an NPC entry:

3553

Are you meaning the whole node is a field? Or, something within the node - e.g. this node contains alignment, size and Type; so is alignment, size and type all "fields" you're looking for?

S Ferguson
January 2nd, 2013, 19:30
Sorry, I meant "Values." As in the Value of the Alignment "field" is "(any) Evil." I know fields are different entities in the context of FG (and the LUA online reference manual assumes you're playing with the whole extension defined in 5.1), but like I said, I'm used to LISP and Prolog, so a "field" to me is anything that can hold a value within the context of the NPC Sheet. I apologize for the misunderstanding. :o

Trenloe
January 2nd, 2013, 20:05
Sorry, I meant "Values." As in the Value of the Alignment "field" is "(any) Evil." I know fields are different entities in the context of FG (and the LUA online reference manual assumes you're playing with the whole extension defined in 5.1), but like I said, I'm used to LISP and Prolog, so a "field" to me is anything that can hold a value within the context of the NPC Sheet. I apologize for the misunderstanding. :o
OK, I'm still not sure what you're actually referring to when you say "alignment field" - the confusion may be because there is an "alignment" database node within the Bestiary modules. For example:

<name type="string">Aboleth</name>
<type type="string">LE Huge aberration (aquatic)</type>
...
<alignment type="string">LE</alignment>

But when you create a new NPC within a campaign itself there is no "alignment" db node created. Alignment is part of the "type" node which can contain race, class, level, alignment, size and type. So, using purely the alignment db node won't work as this won't always be populated.

So, I'm guessing you're actually referring to being able to identify alignment within the "type" db node, which might be:

<type type="string">Female human cleric of Norgorber 1 NE Medium humanoid (human)</type>
So, you need to be able to parse through the value of this db node to determine what the alignment is - if you're looking for any evil alignment, then look for LE, NE or CE within the string.

There are a few examples within the FG code regarding parsing - basically splitting up a long string into separate words (in a table) and stepping through those words and checking each one - see parseEffect in manager_effect.lua. But, this is perhaps a bit over the top - using standard LUA to check for "LE ", "NE " or "CE " in the string should be fine - so this is just like the example I gave you earlier looking for "amorphous" in a string.

I hope that's what you were actually asking... ;)

S Ferguson
January 2nd, 2013, 20:18
Yes I wanted to know how to check to see if there is an alignment type under a given NPC (always) or creature. I know that some creatures have no alignment (mostly animals, but by 3.5e rules all creatures are supposed to share a common block that includes alignment (True Neutral for animals).

Checking for LE CE and NE I don't think will help as some are "(any) evil." or "Always Lawful Evil." Unless you're suggesting I look for those particular letters.

Does this clear up what I'm asking? ;)

S Ferguson
January 2nd, 2013, 20:27
The tokenizing of a string shouldn't be too much of a problem (even if it's over the top).:) *That* I can do. It's just frustrating trying to find out how the particular ruleset was put together :( in order to parse the string (if it even exists). I've tried checking for the value when it *is* present and it's alright, but like you said, if it doesn't exist, how do you check for it?

Dakadin
January 2nd, 2013, 20:32
You can check if it exists using it in an IF statement without the getValue(). Here is a small sample:



if node.getChild("alignment") then
if node.getChild("alignment").getValue() == "LE" then
.... Do Something .....
end
end

S Ferguson
January 2nd, 2013, 20:34
OK. Thanks! :)

Trenloe
January 2nd, 2013, 21:28
I've found out what the "alignment" database node is used for... It is actually a field that is just used by the 3.5E portion of the 3.5E ruleset - it is hidden when PFRPG is selected as the ruleset mode in the campaign.

So, if you're using 3.5E only, you can access the alignment database node and just work it out from there.

Either way, the issue you're always going to get with parsing this type of data is that you need to code for all eventualities of data - or, as many as possible, based around the official statblock format.

I'm having lots of "fun" trying to parse all formats of spell list blocks for the next version of my PF Creature parser... :p

S Ferguson
January 2nd, 2013, 21:32
Oh, a little parsing never hurt anyone... seriously:o.

Dakadin
January 2nd, 2013, 21:34
LOL. Maybe not long term, but it can definitely be painful in the short term. ;)

S Ferguson
January 2nd, 2013, 21:48
Actually, I've been using the 3.5e side, not the Pathfinder side. I thought the same thing too, that alignment was part of the creature block but apparently it isn't. Animals aren't given one for some reason (a "none" would have sufficed.

(Besides, it would take a long time to work my Neo-Exodus campaign in).;)

Trenloe
January 2nd, 2013, 22:00
(Besides, it would take a long time to work my Neo-Exodus campaign in).;)
Nice to hear you're using NeoExodus. :) The design director for NeoExodus, JP Chapleau, is a good friend of mine and we've been playing a few NeoExodus games recently (mostly play testing for future products). We don't play on Fantasy Grounds as he's just an hour down the road...

S Ferguson
January 2nd, 2013, 22:04
Let him know that he created a great product!:) I'm still waiting for these new products, though (crack of the whip... :D).

S Ferguson
January 3rd, 2013, 05:07
Well I found out why alignment acts a little "wonky," It would seem that even though the 3.5e rules (presumably) are there but all the monster blocks are in Pathfinder format and even this isn't really consistent (animals in Pathfinder are assumed to be N as they are in 3.5e I believe). :cry: However it *might* explain the lack of comments in the code.:)

So now the question becomes how to determine whether or not a Type is present (the code snippet kept coughing up errors no matter how I altered it logically). So if anyone has an alternate suggestion it would be much appreciated. :)

Thanks in advance.

S Ferguson
January 3rd, 2013, 05:16
Yep. The Pathfinder side works as advertised. The 3.5e monster block is faulty.:(

Trenloe
January 3rd, 2013, 05:27
Yep. The Pathfinder side works as advertised. The 3.5e monster block is faulty.:(
How is it faulty, I'm not understanding where the actual problem is here? Are you actually opening the 3.5E creature module - "3.5E Monsters"?

As an example from this module:

<name type="string">Aboleth</name>
<type type="string">Huge Aberration (Aquatic)</type>
...
<alignment type="string">Usually lawful evil</alignment>
This has the alignment and type separate - which is as designed for the 3.5E ruleset where the "alignment" control and db node is used.

EDIT: Basically if you want all the statistics to be populated 100% as per the relevant statblock standard, you can't use Pathfinder creature modules if you're using the 3.5E mode of the ruleset, and vice versa. This is because, as you're finding out, some values aren't the same and are stored/handled differently. You can use the creatures in different ruleset modes - FG makes some changes as required, but it doesn't convert the whole of the creature from one statblock standard to another.

To clarify - the 3.5E Creature module is in the 3.5E statblock format where alignment is a separate field to type. The Pathfinder creature module is in the Pathfinder statblock format where there is not a separate alignment field, but it is included in the type field.

S Ferguson
January 3rd, 2013, 17:16
How is it faulty, I'm not understanding where the actual problem is here? Are you actually opening the 3.5E creature module - "3.5E Monsters"?


It has to do with the 3.5e monster statblock. If you open up a 3.5e "Camel" you won't find an Alignment stat anywhere. in 3.5e the block *should* be filled with "Neutral" because it's an animal with Int under 3 (and not generally vampiric ;)).

The block for *all* creatures should read: Name. HD, Init, Speed, AC, Attacks, Damage, Face/Reach, SA, SQ, Saves, Abilities, Skills, Feats, Climate/Terrain, Organization, CR, Treasure, Alignment, and Advancement according to the 3.5 Rules Compendium.

There are also some "Pathfinder-isms" that have crept in (likely because they share similar creatures), such as "ooze" instead of "amorphous" among other differences in terminology, and the separation into Attack and Defense subsections.

I'm assuming this was done unintentionally (they just weren't waiting around for me to show up to have a laugh :)) and probably as a means of simplification for coping with both rulesets even though there are now more differences between the two systems.

I hope this clears up what I was trying to say.;)

Trenloe
January 3rd, 2013, 18:54
This all relies on how the module was put together, which is very often by community members and usually by an auto populate from the d20 SRD.

For animals, the d20 SRD (which is what has to be used in order to distribute these modules) does not specifically have alignment in it's stat block: https://www.wizards.com/d20/files/v35/MonstersAnimals.rtf That is, there is no "alignment" field in the document for each animal.

Although, as you say, it does mention that alignment is "always neutral" in the animal traits section at the top of the document.

I'm sure there also are some simplifications between 3.5 and PF within the same ruleset.

I get what you're on about now! :)

S Ferguson
January 3rd, 2013, 19:03
I'm sure there also are some simplifications between 3.5 and PF within the same ruleset.

More than likely. The Paizo block makes a little more sense.



I get what you're on about now! :)

And that's when it gets scary. :D

So now (back to the original post) what can be done about this? is it even possible to give a Type like "Alignment" to NPC/Creatures? That would seem the next logical course. If the round peg doesn't fit the square hole take a sledgehammer and...

Trenloe
January 3rd, 2013, 19:11
So now (back to the original post) what can be done about this? is it even possible to give a Type like "Alignment" to NPC/Creatures? That would seem the next logical course. If the round peg doesn't fit the square hole take a sledgehammer and...
For the d20 portion of the 3.5E ruleset the "alignment" DB node is valid and is in fact displayed in the NPC window - it is hidden only if the PFRPG game mode is selected in the campaign "Options" (as alignment in the Pathfinder statblock definition is included in the "type" entry).

In the 3.5E Creature FG module, is it only animals that don't have an "alignment" DB node (or a blank node) or are there others? If it is just animals, then you could take the step that if it is blank or not present it is "always Neutral" and add that in to the creature DB entry as necessary?

S Ferguson
January 3rd, 2013, 19:39
Actually, all animals (as far as I know) are "alignmentless." The trouble is when it comes to Vermin. Some have it, and some don't. The SRD says, back to the basics, that anything with Int under 3 has Neutral alignment. Mabye that could be used to sort them out, and type Animal to add the alignment node to it? :confused: Is this done using createChild()? Now I've slipped and I'm treading water....:o

Trenloe
January 3rd, 2013, 19:51
Is this done using createChild()? Now I've slipped and I'm treading water....:o
You could use dbnode.createChild on the top level dbnode of the creature.

I also came across this code last night (in manager_spells.lua):

-- Convert the description field from module data
local nodeDesc = nodeNewSpell.getChild("description");
if nodeDesc then
local sDescType = nodeDesc.getType();
if sDescType == "formattedtext" then
local sDesc = nodeDesc.getText();
local sValue = nodeDesc.getValue();

nodeDesc.delete();
DB.setValue(nodeNewSpell, "description", "string", sDesc);
This code deletes a child "description" field from a database node (the "spell" node) if it is of the type "formattedtext" and then recreates it as type="string" using the DB.setValue command.

This is just a small example of accessing, deleting and creating database entries and I think it is quite useful as it covers a few DB node functions.

You could use nodeNewSpell.createChild as well...

S Ferguson
January 3rd, 2013, 19:58
You could use nodeNewSpell.createChild as well...

Yes, It could come in handy (and it didn't come under the tree this year:)). I'll tinker with this a bit.

S Ferguson
January 3rd, 2013, 20:15
Actually I updated the DB creature list unintentionally, the button on the NPC Sheet, which I'm still using for testing purposes also shows up in the Sheets in the main DB. I've permanently changed the Solar Angel into a bloodsucking fiend! :)

This definitely *isn't* a side effect I want. I guess placing restrictions on the drag-and-drop will be necessary, if I ever get to that part.

Trenloe
January 3rd, 2013, 21:00
Actually I updated the DB creature list unintentionally, the button on the NPC Sheet, which I'm still using for testing purposes also shows up in the Sheets in the main DB. I've permanently changed the Solar Angel into a bloodsucking fiend! :)

This definitely *isn't* a side effect I want. I guess placing restrictions on the drag-and-drop will be necessary, if I ever get to that part.
Don't worry - modules are read-only and you can't change them through normal FG use, only by manually modifying the XML within the module itself and saving that module.

But, you can appear to make changes to a module within a campaign, and these changes are stored specific to that campaign. If you opened the module in a difference campaign you wouldn't see the "changes" as they are at the campaign level only. The campaign stores these changes in the moduledb directory of the campaign - with a XML file for each module that has been changed. Delete the XML file for the creature module and reload the campaign - it will be back to it's pristine condition.

S Ferguson
January 3rd, 2013, 21:05
Phew, was worried there. I still wouldn't want that effect mid campaign either. Imagine a divine healer reduced to naught more than a ghoul because his guardian angel went permanently savage on them? Not cool. :(

Trenloe
January 3rd, 2013, 21:23
Phew, was worried there. I still wouldn't want that effect mid campaign either. Imagine a divine healer reduced to naught more than a ghoul because his guardian angel went permanently savage on them? Not cool. :(
I think the best way to apply templates etc. is top copy the NPC from the library modules (click-and-drag from the module to the NPC list) and then apply templates against the NPC in the NPC list. This means the changes are just made to the "copy" of the the specific NPC data in the campaign NPC entry itself - you can make multiple copies of the same NPC and apply different templates.

S Ferguson
January 3rd, 2013, 21:25
Great minds think alike. :)

S Ferguson
January 4th, 2013, 00:20
I've always wanted a herd of unique llamas. to set loose in the against the Cult of the Emissary.;)

S Ferguson
January 4th, 2013, 00:41
Seriously, though how much of the programs code is object-oriented? Are the only functions available the ones documented in the API? The functions to my eyes look fairly specific and I do so hate rewriting code with a simple variable change.:o

If I could get a hold of "high-level constructs" to build others it would be a *huge* boon. Just Ambrosia.

S Ferguson
January 4th, 2013, 03:07
Actually, while I was thinking about NPC/Creature blocks it came to me that there is a getChildren() function that returns a table of all the child modes of the parent. Perhaps it would be easier to modify it the "block" was tokenized in this manner and checks could be applied across the table.

Is this feasible?

Thanks in advance

Trenloe
January 4th, 2013, 03:18
Actually, while I was thinking about NPC/Creature blocks it came to me that there is a getChildren() function that returns a table of all the child modes of the parent. Perhaps it would be easier to modify it the "block" was tokenized in this manner and checks could be applied across the table.

Is this feasible?

Thanks in advance
If you need to check a number of different child db nodes then this may be a good way of doing it. But, you're still going to have to check/specify the name of the node you want to read/change. I suppose it all depends how you are detailing the template - if you're detailing "look for field AAAAA, with value BBBBB and change XXXXXX to YYYYYY" then coding to step through all entries in a table until you find AAAAA and BBBBB could be quite an elegant way of doing this without having to hard code AAAAA and BBBBB in the LUA script.

S Ferguson
January 4th, 2013, 03:29
If you need to check a number of different child db nodes then this may be a good way of doing it. But, you're still going to have to check/specify the name of the node you want to read/change. I suppose it all depends how you are detailing the template - if you're detailing "look for field AAAAA, with value BBBBB and change XXXXXX to YYYYYY" then coding to step through all entries in a table until you find AAAAA and BBBBB could be quite an elegant way of doing this without having to hard code AAAAA and BBBBB in the LUA script.

That's what I'm thinking as all I'm doing is adjusting attributes or changing or adding new values. They appear to be keyed by name in the table so it would be easy to abstract a lot of unnecessary code and keep it tightly contained. :) That's a Good Thing (tm). I think this would also simplify the LUA Script as frequently used functions could be declared elsewhere leading to easier to read code. Have I got this right from a theoretical point of view?;)

Trenloe
January 4th, 2013, 04:04
Modifying rulesets (via extensions) really should be a case of minimising the changes to the existing code - but adding in additional code in separate LUA files. So, you're on the right track with what you're saying... The XML changing side of things is harder - but you can define templates in separate files too - so it is possible with a bit of good design to restrict base ruleset changes to only a few lines and keep your custom code in new files. This is really handy when it comes to upgrading your extension to work with future versions of Fantasy Grounds.

S Ferguson
January 4th, 2013, 04:11
Although I'm not really sure how the function is used. It accepts a node and returns a keyed table of which I have no idea how to store. Another look through the files, I guess.:(

Trenloe
January 4th, 2013, 17:56
Although I'm not really sure how the function is used. It accepts a node and returns a keyed table of which I have no idea how to store. Another look through the files, I guess.:(
Plenty, plenty of examples in the ruleset itself - do a "find in files" for getchildren and you'll find them easily.

S Ferguson
January 4th, 2013, 18:06
Yes but do you understand how they work? I'm confused. It seems they go through lists (like the CT or Effects List, or Spell Targeting and are usually *always* written in the same way, just the variable names change - or whether it's "in pairs" or not). but I can't seem to get it grabbing a NPC ID node children. :(

ANY help would be appreciated now. Once I get the children of that node, I've already got a fair amount of the non-graphic LUA script written.

Thanks in advance.

Trenloe
January 4th, 2013, 18:51
Yes but do you understand how they work? I'm confused. It seems they go through lists (like the CT or Effects List, or Spell Targeting and are usually *always* written in the same way, just the variable names change - or whether it's "in pairs" or not). but I can't seem to get it grabbing a NPC ID node children. :(
Using hasFeat from manager_char.lua as an example:


function hasFeat(nodeChar, sFeat)
if not sFeat then
return false;
end
local sLowerFeat = string.lower(sFeat);

for _,vNode in pairs(DB.getChildren(nodeChar, "featlist")) do
if string.lower(DB.getValue(vNode, "value", "")) == sLowerFeat then
return true;
end
end
return false;
end

Here is an example of "featlist" character XML:

<featlist>
<id-00001>
<shortcut type="windowreference">
<class>referencefeat</class>
<recordname>reference.feats.eschewmaterials@PFRPG Basic Rules</recordname>
</shortcut>
<value type="string">Eschew Materials</value>
</id-00001>
<id-00002>
<shortcut type="windowreference">
<class>referencefeat</class>
<recordname>reference.feats.spellfocus@PFRPG Basic Rules</recordname>
</shortcut>
<value type="string">Spell Focus (Evocation)</value>
</id-00002>
</featlist>


"DB.getChildren(nodeChar, "featlist")" returns a table of the child db nodes from the "featlist" db node in the character node currently being worked on
"for _,vNode in pairs ... do" loops through each of the table entries in turn - storing the db node of the current child being looked at in the "vNode" variable. For the first loop, this would be the "id-00001" db node, for the 2nd loop this would be the "id-00002" db node.
Then DB.getValue(vNode, "value", "") is used to return the contents of the "value" XML element - which will be "Eschew Materials" for the first loop and "Spell Focus (Evocation)".
The code will keep executing through each of the child DB nodes (stored in vNode for each loop) until it gets a match with the feat name ("value" XML element) or it reaches the end of all of the child db nodes.

It's a pretty powerful way of returning a long list of data in the table and stepping through each object (in this case a database node help in vNode) and doing various operations against each vNode in turn - you'll have full access to the DB package and databasenode object within the Fantasy Grounds API so can read/modify the child dbnode entries as required.

To look further at this example of getChildren, the FG reference doc: https://www.fantasygrounds.com/refdoc/databasenode.xcp#getChildren

The return value is: (table) The child nodes are returned as databasenode objects in a table with keys corresponding to the names of the child nodes.

So, the table returned is made up of 2 columns ("pairs") - the first being the key, which is the name of the child nodes - id-00001, etc.. and the second column being the databasenode object for that specific child node. This is what the "in pairs" code is referring to.

As we're only interested in the databasenode object (not the child node key value) the LUA code only looks at the 2nd column and ignore the first - hence the "for _,vNode in pairs" code that ignores the first column "_" and stores the second column in the vNode variable.

S Ferguson
January 4th, 2013, 21:01
Thamk you. I had read the reference but wasn't sure how to manipulate it. Learning LUA on the fly is awkward. I need a hardcopy reference. Online docs just bother me. ;)

Trenloe
January 4th, 2013, 21:05
Thamk you. I had read the reference but wasn't sure how to manipulate it. Learning LUA on the fly is awkward. I need a hardcopy reference. Online docs just bother me. ;)
https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=lua

S Ferguson
January 4th, 2013, 22:03
LOL. Thanks! :D

S Ferguson
January 6th, 2013, 21:23
Alright, I cannot seem to get this to go through the NPC_Main node and find the appropriate nodes I'm looking (or not) looking for :confused:

Perhaps a concrete example of how you would check to see *if*, say, Alignment is part of the the list print it else if it's not part then add it and make it neutral.

This is really all the power I need to go through the PC or NPC Encounter structure; it's just using it practically.

And since Amazon takes a while to deliver (I'm still waiting on a parcel from the last week of December), I'm relying on others' code and using the online LUA guide to "hack" things together nicely, until a hardcopy comes in. :)

S Ferguson
January 8th, 2013, 02:49
Using the example code I seem to always get a global node with a nil value. Any ideas on how to correct this?

Thanks in Advance

Trenloe
January 8th, 2013, 02:57
Using the example code I seem to always get a global node with a nil value. Any ideas on how to correct this?
Please provide the code you are using?

How are you getting the initial DB node object? In the featlist example above this was passed into the function as "nodeChar" - what are you using to reference the parent level in the db?

If you're unsure of the underlying XML structure, you can get it from the campaign db.xml - within Fantasy Grounds create a simple PC or NPC within the campaign and then save the campaign (type /save in the chat window, or exit the campaign) and look at the db.xml file from the campaign directory - this will show you how the data is stored within the FG database XML structure.

You'll also find it useful to write debug message either to the chat window or to the FG console as you step through the various levels of the XML - this very often helps to see what the code has returned and what it has access to .

S Ferguson
January 8th, 2013, 03:13
The code is virtually identical to the hasFeat function, save that instead of letting it roll through alll the nodes, I'm giving it the current ID-XXXXX node to search through and using the npc_main as it's target. Instead of looking for "feats," it looks for "alignment" and if it finds it, it types that string value out to the console. At least thats what it's supposed to do. it's kept as a function and callled when the button is pressed, after the current ID has been obtained. I'd list the code itself but it's a mess of comments, commented out code, and other functions that have no bearing on hte issue at hand. Sorry in advance.:o

Trenloe
January 8th, 2013, 03:43
If you have nodeNPC, like in the example code in post #31, try this:


for vKey,vNode in pairs(nodeNPC.getChildren()) do
if vNode.getValue() ~= nil then
local msg = {text = "Key value = " .. vKey .. ". node value " .. vNode.getValue()};
Comm.addChatMessage(msg);
if vKey == "alignment" then
if vNode.getValue() == "" then
vNode.setValue("Neutral");
end
alignment = vNode.getValue();
break;
end
end
end

if alignment == "" then
local nodeAlignmnent = nodeNPC.createChild("alignment", "string");
nodeAlignment.setValue("Neutral");
end
It writes each child node it comes across to the chat window, just so you can see all of the names and values it is returning.

S Ferguson
January 8th, 2013, 03:44
Thanks a lot.

SF

S Ferguson
January 8th, 2013, 03:56
OK. I'm still getting a "trying to reference a Global value nodeNPC is nil" error. I've tried declaring the variable but to no avail. :confused:

Trenloe
January 8th, 2013, 04:07
Where are you getting nodeNPC from?

Are you using the code in post #31 to get the nodeNPC from the NPC window where the button is pressed?

S Ferguson
January 8th, 2013, 04:08
Yes. That's exactly how I'm defining it.

Trenloe
January 8th, 2013, 04:15
You're going to have to show me your code.

S Ferguson
January 8th, 2013, 04:20
local nodeValue = window.getDatabaseNode();
local nodeNPC = nodeValue.getName();
local msg = {text = "Data Node of NPC is: " .. nodeNPC};
chatOut(msg);

for vKey,vNode in pairs(nodeNPC.getChildren()) do
if vNode.getValue() ~= nil then
local msg = {text = "Key value = " .. vKey .. ". node value " .. vNode.getValue()};
chatOut(msg);
if vKey == "alignment" then
if vNode.getValue() == "" then
vNode.setValue("Neutral");
end
alignment = vNode.getValue();
break;
end
end
end
if alignment == "" then
local nodeAlignmnent = nodeNPC.createChild("alignment", "string");
nodeAlignment.setValue("Neutral");
end

Hope this helps. chatOUt is just an alias for the longer Comm... statement.

Trenloe
January 8th, 2013, 04:24
local nodeValue = window.getDatabaseNode();
local nodeNPC = nodeValue.getName();
I think you must have been staring at this code and gone cross-eyed! ;) Don't worry, it happens to us all... :)

Change the above 2 lines to just:

local nodeNPC = window.getDatabaseNode();

See where the problem was?

Trenloe
January 8th, 2013, 04:28
Oh, I forgot, for my example code that sets the alignment, you'll need to define the alignment variable before calling the for loop:

local alignment = ""
This is used to flag if after going through all of the child dbnodes the "alignment" XML element wasn't found and so if it is still equal to "" then the a dbnode called "alignment" is created.

S Ferguson
January 8th, 2013, 04:35
Yep, saw the code cross-eyed :confused:. It's what you get for trying to code in an imperative syntax language, when all day you work with functional and logical languages.:) I've at least got the nodes printing out now. Thanks for bearing with my ignorance; and for taking the time to help. Hope you're around when I port this to Savage Worlds (which is originally what I needed the template for).:D

Trenloe
January 8th, 2013, 04:43
Yep, saw the code cross-eyed :confused:. It's what you get for trying to code in an imperative syntax language, when all day you work with functional and logical languages.:) I've at least got the nodes printing out now. Thanks for bearing with my ignorance; and for taking the time to help. Hope you're around when I port this to Savage Worlds (which is originally what I needed the template for).:D
No worries - glad it worked in the end.

Of course, what we've just done is an example of returning all child nodes of a parent DB node and working through them to find (and change) "stuff". If you already know the name/s of the child nodes you can jump straight to them:

local alignmentNode = nodeNPC.getChild("alignment");
if alignmentNode ~= nil then
local msg = {text = "Alignment node value = " .. alignmentNode.getValue()};
Comm.addChatMessage(msg);
end
It all depends on how freeform the template definition is as to whether this is how you are coding: with specific, predefined NPC dbnodes the template will look for; or if you have a freeform template definition that requires searching for dbnodes...

S Ferguson
January 8th, 2013, 04:55
The template will be static in design. following the standard description block for creatures. Some will be populated and some won't. I'm not quite sure how I'm going to code this yet, aside from the fact I want a simple drag-n-drop interface. A valid template would be operable only on certain base creatures.

I am attempting to write this functionally (which is probably the reason for my specs;)) so I can import it later into another piece of code. to get maximum bang for my buck.

S Ferguson
January 8th, 2013, 05:47
If I was to turn the snippet into a function (it is rather handy) would I write:

function(type, notHereThenAdd)

...insert code here with type taking the place of "alignment" and notHereThenAdd in the place of "Neutral"...

end

S Ferguson
January 8th, 2013, 05:50
If I was to turn the snippet into a function (it is rather handy) would I write:

function(type, notHereThenAdd)

...insert code here with type taking the place of "alignment" and notHereThenAdd in the place of "Neutral"...

end

with two string arguments?

S Ferguson
January 8th, 2013, 17:22
There is one thing I've noticed. The right-hand icons (the ones we all love and adore ;)) don't give much room to put anything else in there while the window is minimized; when it's maximized it almost looks vacant. Drawing new icons isn't really a problem, save that it interferes with more data from the ruleset than I'm willing to make. Is there an option for scaling the size of icons (I assume the code for placement is somewhere in the campaign section), or will I just have to do it manually?

S Ferguson
January 9th, 2013, 17:05
Alright I've got an alterState function, that whips through an NPC's children. unfortunately I can't get it to recognize lists, ir to insert items, within them. the code is:

function alterType(type, notHereAdd)

-- alters type searched for in an NPC. If the type isn't present, add it
-- Set nodeNPC to the top of the NPC database & set intial type to the empty == -- -- string.
l
ocal nodeNPC = window.getDatabaseNode();
local nType = "";


-- cycle through nodeNPC looking for type

for vKey,vNode in pairs(nodeNPC.getChildren()) do

if vNode.getValue() ~= nil then
-- Start Looping through the children of the current NPC
local msg = {text = "Key value = " .. vKey .. ". node value " .. vNode.getValue()};
console(msg);

-- Scored a hit on type looked for so get value. Otherwise fall through to catch-all.

if vKey == type then
if vNode.getValue() == "" or " " then
vNode.setValue(notHereAdd);
end
nType = vNode.getValue();
break;
end
end
end

-- Catch-all. Haven't run into type so add it.

if type == "" then
local nodeAlignmnent = nodeNPC.createChild(type, notHereAdd);
nodeAlignment.setValue(notHereAdd);
end
end


Is there any way of altering this so instead of turning the type into a value, (it currently if encountering "Large Animal" will override it with "Undead" as it's coded to do) find a way of adding the result to a list (say, "Large Undead Animal"). I also need a way of changing stat values by means of modifiers (+1, -1, etc.) Am I asking too much of this function or can it be tweaked some more to give me the functionality I need.

S Ferguson
January 9th, 2013, 17:07
Alright I've got an alterState function, that whips through an NPC's children. unfortunately I can't get it to recognize lists, ir to insert items, within them. the code is:

function alterType(type, notHereAdd)

-- alters type searched for in an NPC. If the type isn't present, add it
-- Set nodeNPC to the top of the NPC database & set intial type to the empty == -- -- string.

local nodeNPC = window.getDatabaseNode();
local nType = "";


-- cycle through nodeNPC looking for type

for vKey,vNode in pairs(nodeNPC.getChildren()) do

if vNode.getValue() ~= nil then
-- Start Looping through the children of the current NPC
local msg = {text = "Key value = " .. vKey .. ". node value " .. vNode.getValue()};
console(msg);

-- Scored a hit on type looked for so get value. Otherwise fall through to catch-all.

if vKey == type then
if vNode.getValue() == "" or " " then
vNode.setValue(notHereAdd);
end
nType = vNode.getValue();
break;
end
end
end

-- Catch-all. Haven't run into type so add it.

if type == "" then
local nodeAlignmnent = nodeNPC.createChild(type, notHereAdd);
nodeAlignment.setValue(notHereAdd);
end
end


Is there any way of altering this so instead of turning the type into a value, (it currently if encountering "Large Animal" will override it with "Undead" as it's coded to do) find a way of adding the result to a list (say, "Large Undead Animal"). I also need a way of changing stat values by means of modifiers (+1, -1, etc.) Am I asking too much of this function or can it be tweaked some more to give me the functionality I need.

S Ferguson
January 9th, 2013, 17:08
Sorry for the repeat. Glitch on user's end ;).

Trenloe
January 9th, 2013, 18:06
You're going to have to use LUA string handling techniques to do this.

See the final section of the example code I gave in post #31 - this uses "string.find" to see if "amorphous" is in the string of the DB node and then concatenates (using "..") amorphous to the end of the string if it is not found.

There are lots of different ways to split up string, replace, concatenate, etc. - check the LUA documentation for string handling techniques.

S Ferguson
January 9th, 2013, 18:14
O.K. Should it be in it's own function or not?

S Ferguson
January 9th, 2013, 18:19
Also, when it adds a value that isn't there such as the Always Neutral case, you have to close the window and open it again to see the added alignment. Whereas in non-functionally it updates the display. Any help on why?

Trenloe
January 9th, 2013, 18:23
O.K. Should it be in it's own function or not?
Doesn't matter - it depends how you want to design it; if the code will be used by other functions and if you don't need access to local variables in the function you call it from.

Trenloe
January 9th, 2013, 18:26
Also, when it adds a value that isn't there such as the Always Neutral case, you have to close the window and open it again to see the added alignment. Whereas in non-functionally it updates the display. Any help on why?
You'll have to initiate a refresh or update of the window. I'm not on a PC where I can check - do a search of the ruleset files for "refresh" or "update" to see if there are other examples.

S Ferguson
January 9th, 2013, 19:51
Can't find either (well I can but none of them seem to do the trick). Mabye I'll just have to reopen the window.

S Ferguson
January 9th, 2013, 22:15
I'm at the point where if I see "/reload ruleset" one more time.... It worked when it wasn't a function, but just the routine. I've got no clue. Everything I try gives errors. And this was supposed to be a stress free vacation....:(

Trenloe
January 10th, 2013, 22:25
I think moving your code from the npc_main.xml to a LUA function you introduced a number of errors in the code.

Plus, moving to a function you need to make sure you pass over the local variables from the onButtonPress script in npc_main.xml - this includes the "window" class as this is local to onButtonPress as it is the window where the button was pressed.

Also the variables you were using (nType) to identify if the db child node had been matched was not being checked at the end (you were checking for type).

Additionally - to update a window use the window.update() method.

I've fixed your code and moved it all into an extension - see the attached.

3596

Extract this zip file into <FG App Dat Directory>\extensions so that the files are under a directory called "NPC Template Test" within the "extensions" directory.

Then load up a normal 3.5E campaign (not using your 3.5E dev ruleset, just the normal 3.5E ruleset) and this extension will overwrite the files as specified in the "NPC Template Test" extension directory - namely campaign\npc_main.xml and then adds a new script \campaign\scripts\NPCTemplates.lua which has your alterType function coded - with the various fixes I mentioned above.

Give this extension a go - then make any changes to the code in NPCTemplates.lua - adding other functions as required or changing alterType().

After saving changes to these extension files, you'll need to type your favourite /reload command! ;)

Hope this helps you move forwards.

S Ferguson
January 10th, 2013, 22:42
Thanks. It's much appreciated.

S Ferguson
January 10th, 2013, 23:29
OK. One short question. How do you access these functions now that they're in their exalted positions now, through the internal npc_main only?

OK. mabye two short questions. I posted this earlier but forgot in my fuming. How do you resize those lovely banner icons to insert your own? (I would like to work on an actual form so I can work on some of the parsing issues that might come up :) Gosh, I love to parse.)

OK Three: Just fooling;) there is no three.

Trenloe
January 10th, 2013, 23:51
OK. One short question. How do you access these functions now that they're in their exalted positions now, through the internal npc_main only?
Do you see how the function is called in npc_main.xml?

NPCTemplates.alterType(window, "alignment", "Neutral");
"NPCTemplates" refers to a script file reference. This is in extension.xml:

<script name="NPCTemplates" file="campaign/scripts/NPCTemplates.lua"/>
So, whenever FG sees NPCTemplates.XXXXX it will look in campaign/scripts/NPCTemplates.lua for the XXXXX function.

This was probably one of the places that was causing issues with your initial attempt to move to a function?


OK. mabye two short questions. I posted this earlier but forgot in my fuming. How do you resize those lovely banner icons to insert your own? (I would like to work on an actual form so I can work on some of the parsing issues that might come up :) Gosh, I love to parse.)
The graphics are in the ruleset: graphics\sidebar directory. I don't know if reducing the size of these would result in more real estate available in the sidebar when FG is at it's smallest. There may be some specification for the size of the area, but I can't find it in the ruleset files.

S Ferguson
January 11th, 2013, 00:00
Oh I did find out you can place script comments in the XML code directly using a
<!-- Comment -->. It comes in handy.

S Ferguson
January 11th, 2013, 00:15
I found scaleGUI but that works on a global level, and you lose the ability to read the fine print. There must be a way, though, as the icons are resized in the Savage Worlds 3.3.1 Ruleset.

S Ferguson
January 11th, 2013, 16:13
Just curious, Comm.addChatMessage takes a table argument. If I have a group of words, determined one at a time, how do I add them to a table to output to "chat"? These are randomly determined for a random alignment (:confused:), but a general case will do.:) and can I store these words in another type of structure? (a string wold be handy).

Thanks in advance

Trenloe
January 11th, 2013, 17:52
Just curious, Comm.addChatMessage takes a table argument. If I have a group of words, determined one at a time, how do I add them to a table to output to "chat"? These are randomly determined for a random alignment (:confused:), but a general case will do.:) and can I store these words in another type of structure? (a string wold be handy).

Thanks in advance
The table for addChatMessage is defined in the Comm reference: https://www.fantasygrounds.com/refdoc/Comm.xcp

The table has different parameters that allow changing of the display of the Chat message - not a table of words to display. The text of the chat is stored in the "text" entry of the msg table - which is a string.

I'm not exactly sure what you're asking above, but as the "text" parameter of the table is a string you can manipulate that string however you want with standard LUA string handling - add words/string, etc.

S Ferguson
January 11th, 2013, 20:49
You got what I was asking, thanks.

S Ferguson
January 12th, 2013, 01:25
Speaking of strings, StringManager seems to be a useful Library but I have no idea what the documentation for it is. Any clues?

Trenloe
January 12th, 2013, 01:43
Speaking of strings, StringManager seems to be a useful Library but I have no idea what the documentation for it is. Any clues?
Look in scripts\manager_string.lua - this is where the functions are coded. Some of them, but not all, even have comments! ;)

S Ferguson
January 12th, 2013, 01:44
ooooohhh, coments.....:)

S Ferguson
January 12th, 2013, 02:07
Actually, with a few minor tweaks this is some pretty powerful parsing material. The "split" function is great, one that makes tokenizing a lot easier.

And you were right about having to use my favorite /reload command :cry: infinitely more often.

S Ferguson
January 12th, 2013, 18:54
B.T.W., How generic is the removed alterType. Could I use it in the Pathfinder side of the block if I pay strict attention to the DB XML code and it's datanodes?

And Trenloe, are you ever going to set up a NeoExodus campaign on FG? Please? No spoilers though. ;)

S Ferguson
January 12th, 2013, 21:20
Okay, don;t answer the last question (except about the NeoExodus stuff;)), I know the answer. I'm now comfortable programming in LUA (although I dislike it as much as Scheme:mad:), and was now wondering about filling out the template form itself (it follows the 3.5e statblock), examples or preferably toward pointers to code to these small questions, would be much appreciated:

1. Where would a new icon for templates logically go? And how do I get it there? Don't foget these can apply to characters as well as encounter/NPCS so I was thinking the top level. But do to lack of real estate... comments?

2. The form follows the statblock. All of the changes are optional (the empty case). How would I compact this into its smallest subset (i.e. don't write the empty blocks in the template itself, nor have them appear in the finished window).

3. Applying the effects of this isn't going to be difficult :rolleyes: (just tedious for Size changes), I'm thinking of using the smallest changes, keyed by statblock name, to make it easier to map changes. How would this type of keyed data fit into the overall scheme of things. I mean where do you store user created data?

S Ferguson
January 13th, 2013, 01:24
Also in the original d20 ruleset there was a file desktopmanager.lua in it, that had icon resizing routines in it. Does anyone know why this functionality was dropped and how to bring it back into the fold?

Additionally, pardon the occasionally mispunctuated sentences.:o

S Ferguson
January 13th, 2013, 02:09
The manager_desktop file in Scripts in 3.5e has (as far as I can tell) identical code. Which leaves me wondering why the Icon resizing features there don't work.:confused:

Trenloe
January 13th, 2013, 03:20
The manager_desktop file in Scripts in 3.5e has (as far as I can tell) identical code. Which leaves me wondering why the Icon resizing features there don't work.:confused:
Are you sure it isn't working?

From what I'm seeing, it doesn't make the icons bigger if you make the FG window bigger (so you see space between library and tokens), but it does resize them down if you make the FG screen smaller down to the minimum allowed. Thus if extra buttons were added then they would be resized.

Trenloe
January 13th, 2013, 03:28
1. Where would a new icon for templates logically go? And how do I get it there? Don't foget these can apply to characters as well as encounter/NPCS so I was thinking the top level. But do to lack of real estate... comments?
Add it as a button in the top right - like tables, modifiers, effects, etc. See desktop\scripts\desktop.lua for examples of the "DesktopManager.registerStackShortcut" command that is used to add buttons.


2. The form follows the statblock. All of the changes are optional (the empty case). How would I compact this into its smallest subset (i.e. don't write the empty blocks in the template itself, nor have them appear in the finished window).
Don't write blank entries into the database (i.e. don't create the DB nodes). If you want to hide controls use the "setVisible(false)" command - see campaign\scripts\campaign_npc_main.lua lines 65 - 74, which is used to hide the alignment entry and label if the ruleset is in Pathfinder mode - as there is no individual "alignment" field in the Pathfinder statblock.


3. Applying the effects of this isn't going to be difficult :rolleyes: (just tedious for Size changes), I'm thinking of using the smallest changes, keyed by statblock name, to make it easier to map changes. How would this type of keyed data fit into the overall scheme of things. I mean where do you store user created data?
Create new database nodes that are stored in the campaign db.xml schema - of course, use a top level node name that isn't used by other FG functionality. You should also then be able to create library modules of the data.

S Ferguson
January 13th, 2013, 03:46
I got the real estate by editing manager_desktop with new sizes of icon (75, 65) as opposed to (100, 93) (a little large for my tastes). and the new ones with a bit of color touch up, are as good, and as readable, as the old ones. Can you put graphics in an extension? I know my manager_desktop will override the old one, but what about graphics?

S Ferguson
January 13th, 2013, 04:42
Don't write blank entries into the database (i.e. don't create the DB nodes). If you want to hide controls use the "setVisible(false)" command - see campaign\scripts\campaign_npc_main.lua lines 65 - 74, which is used to hide the alignment entry and label if the ruleset is in Pathfinder mode - as there is no individual "alignment" field in the Pathfinder statblock.

Yes, but if a character was , say affected by Vampirism, the changes are extensive literally populating the NPC block including a change in alignment. Even the description block is added to ("The Base Creature looks like a paler version of its base race.").

But if one becomes "energy-infused," say, all that is needed is a few changes to Creature type, SQ, SA, and Immunity to the form of energy it is infused with. along with an alignment shift towards neutral, and a succinct description modifier.


Create new database nodes that are stored in the campaign db.xml schema - of course, use a top level node name that isn't used by other FG functionality. You should also then be able to create library modules of the data.

I can't possibly cover *that* much ground ;). What if I created an "overhead copy" of a generic creature template and only saved the nodes I needed to be changed to populate my list of templates. The Templates if looked at will only show the attributes that will be changed. That way when it comes down to drag-and-drop time, only the "activated" nodes of the template, will be applied to the Base Creature. Is this a feasible trade? How does one fill in forms that are mutable?

S Ferguson
January 13th, 2013, 04:50
If you have the 3.3.1 Savage Worlds Deluxe Ruleset, you'll notice that the icons are smaller in the windowed mode and when maximized assume there natural size. Phantomwhale said he got the code from original D20 set and it is true. Unfortunately, I have no idea how this works under manager_desktop, because it's almost identical to the old D20 code. His response is under "Size Matters?" in the Savage Worlds forum.

Trenloe
January 13th, 2013, 05:22
If you have the 3.3.1 Savage Worlds Deluxe Ruleset, you'll notice that the icons are smaller in the windowed mode and when maximized assume there natural size. Phantomwhale said he got the code from original D20 set and it is true. Unfortunately, I have no idea how this works under manager_desktop, because it's almost identical to the old D20 code. His response is under "Size Matters?" in the Savage Worlds forum.
Yes, I've seen that in the Savage Worlds ruleset.

I've also seen the same behaviour in the 3.5E ruleset when additional buttons are added to the area in the top right corner - as I mentioned in an earlier post.

Add a button with "DesktopManager.registerStackShortcut" in desktop\scripts\desktop.lua and see what happens.

Trenloe
January 13th, 2013, 05:30
I got the real estate by editing manager_desktop with new sizes of icon (75, 65) as opposed to (100, 93) (a little large for my tastes). and the new ones with a bit of color touch up, are as good, and as readable, as the old ones. Can you put graphics in an extension? I know my manager_desktop will override the old one, but what about graphics?
Everything in a ruleset can be replaced through an extension. There are a number of theme extensions in the <FG App Data Directory>\extensions directory - have a look at "Dungeon Theme.ext" for examples.

Trenloe
January 13th, 2013, 05:34
I can't possibly cover *that* much ground ;). What if I created an "overhead copy" of a generic creature template and only saved the nodes I needed to be changed to populate my list of templates. The Templates if looked at will only show the attributes that will be changed. That way when it comes down to drag-and-drop time, only the "activated" nodes of the template, will be applied to the Base Creature. Is this a feasible trade? How does one fill in forms that are mutable?
You're going to have to store the template data somewhere, and the main way of doing this is through database nodes within the campaign db.xml or within a module. It sounds like you're essentially saying this with your "overhead copy".

You'll want to go the module route in the long run, as this will allow you to use the templates in different campaigns and not have to enter them manually into each campaign. The module would simply be a copy of the XML from the campaign db.xml

S Ferguson
January 13th, 2013, 05:56
Thanks. The Template system I envisioned would be different from campaign to campaign. I pictured more of a format in which you can make templates like NPC's. Templates specifically created for a particular adventure e.g. a mad sorcerer is delving in the dire arts of combining races, Bingo. A template for Half-Breeds can be created.
Am I still looking at a module? Or can I keep this as an extension?

S Ferguson
January 13th, 2013, 16:28
[quote=Trenloe]You're going to have to store the template data somewhere, and the main way of doing this is through database nodes within the campaign db.xml or within a module. It sounds like you're essentially saying this with your "overhead copy". /quote]

No, no. I wasn't refering to having a physically written database copy but extra "overhead" in memory for a transitory state between making and saving the data into the campaign DB. Usually "overhead" in programs is frowned upon as it devours precious clock cycles and cause plagues, outbreaks of demonic possession etc.;)

No like I referred to in one of the posts below. I just want a desktop button like NPC or STORY because the list would change from campaign to campaign.

My apologies for the misunderstandings.

S Ferguson
January 13th, 2013, 16:31
Remind me not to post before my second coffee in the morning. Sorry about the bad formatting below.

S Ferguson
January 13th, 2013, 16:31
[quote=Trenloe]You're going to have to store the template data somewhere, and the main way of doing this is through database nodes within the campaign db.xml or within a module. It sounds like you're essentially saying this with your "overhead copy".[ /quote]

No, no. I wasn't refering to having a physically written database copy but extra "overhead" in memory for a transitory state between making and saving the data into the campaign DB. Usually "overhead" in programs is frowned upon as it devours precious clock cycles and cause plagues, outbreaks of demonic possession etc.;)

No like I referred to in one of the posts below. I just want a desktop button like NPC or STORY because the list would change from campaign to campaign.

My apologies for the misunderstandings.

Trenloe
January 13th, 2013, 19:00
No, no. I wasn't refering to having a physically written database copy but extra "overhead" in memory for a transitory state between making and saving the data into the campaign DB. Usually "overhead" in programs is frowned upon as it devours precious clock cycles and cause plagues, outbreaks of demonic possession etc.;)

No like I referred to in one of the posts below. I just want a desktop button like NPC or STORY because the list would change from campaign to campaign.

My apologies for the misunderstandings.
Now I'm completely confused...

Are you basically saying that the template information will be manually added by the GM each time it is applied? Or, are you planning on storing the template data so that it can be applied whenever needed?

If you are storing the template data, then that will more than likely need to be in the campaign database (saved in db.xml by Fantasy Grounds). If it is stored in the campaign database, then it can also be made into a module - which can be distributed to others, used in another campaign, etc..

If you're not thinking of doing this, I would strongly recommend it.

A good example of this in Fantasy Grounds is the NPC data:

NPC records can be stored directly in the FG database (under the <npc> XML element) by manually adding a new NPC and entering the data in the NPC window.
NPCs can also be stored in library modules - see the 3.5E-monsters.mod. This is a library module that allows the monster entries to be dragged from the library to the NPC list - creating local copies of the monster in the campaign database. If you open the module you'll see a big long list of monster entries that are in exactly the same format of the NPC entries in the campaign DB.
NPC data from the campaign DB.xml can be exported into a module - to be used in another campaign, distributed to other people, etc..


You mention that you want to have your template data stored under a button similar to NPC. Use "DesktopManager.registerStackShortcut" to create either a small button (similar to effects, tables, etc.) or if you want a large icon and then have the underlying list entries directly linked to a section of the Fantasy Grounds DB (you will need to decide what to call this section, just don't pick a name that is already used). Quite frankly, I honestly can't think of any other way to do this - unless you enter manually the template data every time you want to apply a template, even if you applied the same template only 5 minutes ago.

S Ferguson
January 13th, 2013, 20:26
Now I'm completely confused...

Are you basically saying that the template information will be manually added by the GM each time it is applied? Or, are you planning on storing the template data so that it can be applied whenever needed?

If you are storing the template data, then that will more than likely need to be in the campaign database (saved in db.xml by Fantasy Grounds). If it is stored in the campaign database, then it can also be made into a module - which can be distributed to others, used in another campaign, etc..

If you're not thinking of doing this, I would strongly recommend it.

A good example of this in Fantasy Grounds is the NPC data:
NPC records can be stored directly in the FG database (under the <npc> XML element) by manually adding a new NPC and entering the data in the NPC window.
NPCs can also be stored in library modules - see the 3.5E-monsters.mod. This is a library module that allows the monster entries to be dragged from the library to the NPC list - creating local copies of the monster in the campaign database. If you open the module you'll see a big long list of monster entries that are in exactly the same format of the NPC entries in the campaign DB.
NPC data from the campaign DB.xml can be exported into a module - to be used in another campaign, distributed to other people, etc..You mention that you want to have your template data stored under a button similar to NPC. Use "DesktopManager.registerStackShortcut" to create either a small button (similar to effects, tables, etc.) or if you want a large icon and then have the underlying list entries directly linked to a section of the Fantasy Grounds DB (you will need to decide what to call this section, just don't pick a name that is already used). Quite frankly, I honestly can't think of any other way to do this - unless you enter manually the template data every time you want to apply a template, even if you applied the same template only 5 minutes ago.
Okay. In order: Yes I'm planning on storing the template list so it can be applied whenever needed. Yes, I was planning on using a template in this list to apply whenever needed. I am planning on making the lists of templates campiaign specific, and portable from 3e to Pathfinder and other systems (there'll be no check for alignment in that one;)).

All I want is the functionality of being able to create a list of "templates;" a "template being defined as a discreet set of changes to one or more attributes of a character, NPC or creature, in a single campaign environment.

Yes that mignt be a large list but it's not feasibly possible to cover, say, all of the "horror" templates of a "Wraith Recon" game and plant it into a "Underdark" campaign so it wouldn't make a particularly good library, because it's campaign specific.

"The large icon on the table"(tm) was to intuitively let people know this is a list that is populated by the GM. No other reason.

I can't really comment on a module implemtation, I'm still fairly new to FG. The only thing I know is that the calendar module seems awkward, as it can't cover campaign specific information so the programmer has to take a guess on what's going to be the "next big thing"(tm), i.e. plan for all the possibilities.

It might be simpler to rewrite the original D20 rules into some new ruleset that is similar, but conforms to my needs....:)

Trenloe
January 13th, 2013, 20:44
It might be simpler to rewrite the original D20 rules into some new ruleset that is similar, but conforms to my needs....:)
The original d20 ruleset is very old now (even the d20_JPG ruleset is dated), the 3.5E ruleset has much more functionality.

Why do you feel you need to rewrite the original D20 rules and not base your template code on the 3.5E ruleset?

S Ferguson
January 13th, 2013, 21:04
The original d20 ruleset is very old now (even the d20_JPG ruleset is dated), the 3.5E ruleset has much more functionality.

Why do you feel you need to rewrite the original D20 rules and not base your template code on the 3.5E ruleset?

No, I wouldn't actually rewrite the original D20_JPG code. :p (but it is more linear in structure and easier to follow than the mire of file-finding in the 3.5e edition). I *want* the functionality of the new ruleset. As I said I would like to port to other systems like SW, BRP, and the Pathfinder portion.

I think it would be a good tool to make as you don't have to customize something, say, by dragging and dropping eight-million items over multiple creatures or characters and manually type in numbers, when a template system will do the job automagically.;)

Trenloe
January 13th, 2013, 21:18
May I make a suggestion for the next things for you to try? Please actually try these and see how they work for you... I think this is exactly what you are looking for (at least the next steps towards getting there)...

- Copy/Paste the following into \desktop\scripts\desktop.lua in the onInit() function - in the "if User.isHost() then" section (which will only add a button for the GM, not a player. Copy/paste after the "button_effects" line. Don't make any changes, just copy/paste.

"DesktopManager.registerStackShortcut("button_modules", "button_modules_down", "NPC Templates", "npclist", "npctemplate");"
Save the ruleset and load your campaign - you will see a new button now with a book icon (the "modules" icon that was used before module activation was moved in the library window). Notice how all the other buttons (small and large) resize to accommodate this new button.

When the button is clicked the "npclist" window class appears. *But* because the last argument "npctemplate" is different from the usual "npc" entry, this window is tied to a new section in the campaign DB.XML file - one that is named "npctemplate". Any NPC entry you create in this window will not appear in the NPC window, and vice versa.

Create an NPC entry in the NPC Template window. Close the NPC window and type /save in the chat window. Open up the db.xml file from the campaign directory and search for "npctemplate" and you will see that FG has created a new XML section to store all of the data entered in this new "npctemplate" list window.

What we have here is the beginning of your new NPC Template list/window.
The next steps will be to take the NPC list XML structure and copy this to new files to be modified so that it just displays the fields you need for entering templates.

But, that's enough for this post - what I wanted to do was make it clear that what you want to do can be done in the 3.5E ruleset. You are more than likely thinking the old d20 ruleset "simpler" purely because there is a lot less code in it. The 3.5E ruleset really isn't that bad, and it is logically laid out - remember the sections I detailed in post #41 of this thread? (https://www.fantasygrounds.com/forums/showpost.php?p=140183&postcount=41) I'm not sure which text editor you are using, but if you're not using Notepad++ I'd suggest checking it out - when you do a "find in files" the results are shown in a new section at the bottom of the Notepad++ window and you can move between the files by just double-clicking on the search results - it really is pretty easy.

S Ferguson
January 13th, 2013, 21:44
Cute. I agree that it's time to close the topic so I can reflect on the wherefores and whatnots of how I want to proceed. I try and have a version before March. And thanks a lot. You've really helped me, like a gazillion times and I appreciate each and every answer. You definitely rock!

Thanks
SF

-- end of transmission

S Ferguson
January 14th, 2013, 00:26
Oh, and to answer your question, I use UltraEdit Pro, LuaEdit and Liquid Studios XML Editor Pro in no particular order (except when searching through files, in which case I'll use UltraEdit Pro, or if comparing two files Ultracompare Pro).

Salut et finis

S Ferguson
January 16th, 2013, 00:31
Hey. I found alignment as a separate node in the Pathfinder db output. Almost the very first in the list. Makes me feel a little better about how far I've come.

I have been giving it a lot of thought, templates will work like a bundle of effects without the need for combat and of infinite duration, mind you this will be done at the db level with direct substtution, addition and subtraction. They will used to alter PC's/NPC's/Creatures, Vehicles, or Items. I was thinking of making this a "docking" icon, along the side with the different alterations a different tab. Rather like an effects (say a disease or condition) notebook.

My question is where exactly does this XML code fit in for the framework, and how do you put an icon on the side in 3.5e/Pathfinder.

Trenloe
January 16th, 2013, 00:47
Hey. I found alignment as a separate node in the Pathfinder db output. Almost the very first in the list. Makes me feel a little better about how far I've come.
In the Pathfinder mode of the 3.5E ruleset the alignment field is hidden in the NPC form. The field may be there in some of the creature modules, but if anyone manually creates a NPC in the FG interface then alignment will not be populated at all in the NPC DB entry.


... and how do you put an icon on the side in 3.5e/Pathfinder.
Hasn't this been covered a number of times in this thread and in the one in Savage Worlds?

S Ferguson
January 16th, 2013, 00:59
In the Pathfinder mode of the 3.5E ruleset the alignment field is hidden in the NPC form. The field may be there in some of the creature modules, but if anyone manually creates a NPC in the FG interface then alignment will not be populated at all in the NPC DB entry.

Actually, I think the string is usually concatenated with the creature's type. Am I reading the XML entry wrong? The alignment Almost always shows up as part of the creatures type like "N Small Vermin." I actually find this makes more sense.

Hasn't this been covered a number of times in this thread and in the one in Savage Worlds?

Yes.:confused: Unfortunately in Savage Worlds I've almost got all of the components coded, except the exact tabs on the "Mini-sheet" used. I just need to know where you would put the registration icon in 3.5e/Pathfinder ruleset so I can get up to the same position.

I really don't know how you keep these different versions of the code and the position of things in your head.

And I do apologize for restarting this thread.

Trenloe
January 16th, 2013, 01:33
I really don't know how you keep these different versions of the code and the position of things in your head.
I don't, I use "find in files" a lot. :)

See desktop\scripts\desktop.lua for examples of the "DesktopManager.registerDockShortcut", grap one of the first arguments (the reference to the graphics file as mentioned in the Savage Worlds thread) and do a "find in files" for that reference, which will point you to one of the graphics_XXX.xml files which will then reference the actual graphic .png file used for the icon.

S Ferguson
January 22nd, 2013, 18:17
How does one go about "shadowing" a copy of an already existing XML structure? By this I mean having a separate copy of say, a creature structure, that exists outside the creature node (i.e it's a separate database entry). Copy and paste doesn't work. Basically I want three copies of a character structure in the database in three different spots. My XML is really bad:(. I can get the gist of what the code is trying to do, but don't know enough to accomplish what I'm trying to do and reading through Mastering XML isn't helping, just like programming in LUA isn't *really* a proper map onto the "LUA stripped down language used in FG.

Any help would be greatly appreciated, and thanks in advance.

S Ferguson
January 22nd, 2013, 23:57
Trenloe? I *really* need help now. Once I'm through this hurdle I'm home free.

Trenloe
January 23rd, 2013, 02:48
I'm intrigued as to why you'd need to have 3 separate copies of something, but hey...

Have you looked at the DB.copyNode function? Do a search for this in the 3.5E ruleset and you'll see a handful of examples where this is used.

S Ferguson
January 23rd, 2013, 03:08
One holds the PC/NPC, Another, on a separate tab holds the "template," modifiers to whatever added to a block, and one for holding the "normal" stats for the character *if* he roleplays and "buys off" his template. As an example take disease. it has debilitating effects on the character. Store the NPC/vehicle/PC, apply the template. If something is permanent, say scarrring from smallpox, add this to the stored "thing." the disease will keep wasting away at the charaacter until he/she/it gets vaccinated or wards it off with a spell of cure disease.

My problem is that currently I'm linked to the primary NPC_main XML structure. Which means everything that is done in one window is done permanantly as you're referencing the same object. I just don't have an XML store or a XML template to link to. ANy suggestions or ideas on how this would be handled?

Trenloe
January 23rd, 2013, 03:37
My problem is that currently I'm linked to the primary NPC_main XML structure. Which means everything that is done in one window is done permanantly as you're referencing the same object. I just don't have an XML store or a XML template to link to. Any suggestions or ideas on how this would be handled?
Change each tab to be anchored on a different database node - be it either a separate DB node for each tab or a child DB node for each item (template and modifiers being children of the NPC DB entry). Using children is probably a better idea as they are then directly linked to the NPC entry.

Use the <datasource> tag to anchor a windowclass control to a specific database node: https://www.fantasygrounds.com/refdoc/windowclass.xcp

S Ferguson
January 23rd, 2013, 03:39
OK. Thanks.

S Ferguson
January 23rd, 2013, 16:41
OK. Obviously I didn't have a sound sleep last night because I just looked at the answer, checked the documentation and went Huh? I also didn't add information in my post that might have come in handy - like the fact this is all being done in an extension.

I've currently got a button that I want to open up as a list of templates with side tabs for PC's, NPC's, and "Vehicles" (read "mounts"). I want to shadow the item (or person) in question in a healthy "pre-templated" state (hence the want for a backup - which I agree should be kept with the "base item" if that's what you meant). I also want a "cypher," for lack of a better word, that acts as the template itself. This would mirror the base item, but be empty, save for the slots that contain changes (ie +4 Strength, Feat: improved dual-wield, etc).

Now this is where I have to be handheld (i.e have the answer phrased in the simplest possible terms - preferably with code snippets). Do I need 6 different XML thingies to accomplish this? And how does one exactly place the thingies into XML code? Since one case is attached and the other on the level of the DB, does this alter things?

Sorry about all the questions. I've never worked IT and markup languages scare the bejebees outta me. Never been good at them.

Trenloe
January 23rd, 2013, 17:58
I also didn't add information in my post that might have come in handy - like the fact this is all being done in an extension.
Using an extension really shouldn't make a difference. Remember, an extension overwrites the underlying ruleset - it is just like a modified ruleset except it only contains modified or new files, the unmodified files are taken from the ruleset itself. So, coding in an extension is essentially exactly the same as directly modifying a ruleset. These are the only 2 options you have for coding in FG - directly modify the ruleset, or "layer" your modifications on top by use of an extension.


Now this is where I have to be handheld (i.e have the answer phrased in the simplest possible terms - preferably with code snippets). Do I need 6 different XML thingies to accomplish this? And how does one exactly place the thingies into XML code? Since one case is attached and the other on the level of the DB, does this alter things?
I think you need to spend some time reading the "Ruleset modification guide" especially the "Windows and controls" and "The Data Base" sections - specifically looking at control data sources and how to access underlying data base content.

Also, have a search for "datasource" in the ruleset files and see how that tag is used to tie control to an underlying portion of the FG database. "charsheet_abilities.xml" has a few examples where different portions of the PC abilities tab are tied to different underlying sections of the FG charsheet database.

An example is the featlist control where the datasource is ".featlist" (see what this means under "Node identifiers" in the Ruleset Modification Guide - The Data Base section);

<list_charabilities name="featlist">
<anchored>
<to>featframe</to>
<position>over</position>
<offset>-15,-15</offset>
<top>
<offset>30</offset>
</top>
</anchored>
<datasource>.featlist</datasource>
<class>charsheet_abilityitem</class>
</list_charabilities>
This is just one example of how the datasource tag is used to tie a control (or section of controls) to a specific area of the FG database.

S Ferguson
January 24th, 2013, 19:04
Well I understand the DB and how it keeps nodes just fine. It makes a lot of sense. Unfortunately the XML code I'm still *not* getting. All of the items I want to affect are different and insofar as the documentation goes, the examples are more pronounced in the Lua script wrinting, and somewhat assume that one is familiar with markup languages.

Speaking of which can you copy and paste the XML entries, give them a new name, and use them at the windowclass level (for the templates - the best example I've found is the racial modifier "packages" in Pathfinder - of which I finally got my own rulebooks and my Pathfinder Society ID :)) as a top-level node and then another that "shadows" characters (at the same level for now to keep it simple)?

Otherwise how do I approach this?

Trenloe
January 24th, 2013, 23:20
EDITED due to pressing reply to early...


Speaking of which can you copy and paste the XML entries, give them a new name, and use them at the windowclass level
Assuming you're talking about the windowclass XML and not DB xml: Yes you can, but you will have to be careful if the FG XML entry uses an XML template defined elsewhere as this will inherit all of the settings in that template.

For example, the following control for listing feats in a PC is based off the "list_charabilities" XML template - use "find in files" to see where this is defined. This example doesn't have much in the template (other than a link to LUA code so you'd have to check what the LUA code was doing) but some other XML templates do have a lot of settings.


<list_charabilities name="featlist">
<anchored>
<to>featframe</to>
<position>over</position>
<offset>-15,-15</offset>
<top>
<offset>30</offset>
</top>
</anchored>
<datasource>.featlist</datasource>
<class>charsheet_abilityitem</class>
</list_charabilities>



(for the templates - the best example I've found is the racial modifier "packages" in Pathfinder

OK, I know where you're coming from talking about racial modifiers being a package, but Pathfinder does have "templates" too, specifically for modifying NPCs and PCs as needed: https://paizo.com/pathfinderRPG/prd/monsters/monsterAdvancement.html which is what you're trying to do, right? I suppose racial modifiers are templates too... :)



as a top-level node and then another that "shadows" characters (at the same level for now to keep it simple)?

Otherwise how do I approach this?
Again, check out the "Windows and Controls" section in the documentation about how controls are setup and tied to the underlying database.

Decide on how your underlying database structure is going to be set out and then design the FG GUI XML to setup the controls that you require and tie them to an underlying datasource as mentioned 2 posts above.

S Ferguson
January 25th, 2013, 01:29
Yes, Paizo's definition of a template is *exactly* what I'm trying to accomplish.

But I'm a player. I'm not supposed to be privy to that information. I'm not even supposed to own the beastiary. Shhhhhh.... I want to play a few PFS games. The concept is just neat.:)

And I suppose racial packages are a template if you were, say, turned from a Human into a Cavian, or something like that. Funny thing, Pathfinder is. Very well thought thought out and lavish with the little details... like templates. ;)

And I take it from the lack of responses to my post in the pathfinder forum, that there aren't enough NeoExodus players out there.:cry:

S Ferguson
January 25th, 2013, 02:06
Since I'm temporarily only concerned with "top values" (i.e. surface stats and current abilities which are "frozen" the moment the template is applied, could I get away with, say for NPCs a "shallow" copy of stats, without pulling in any Lua scripting that is currently present? I'm just not sure what you mean by inheritance in Windowclass XML. I would have thought, from the docs, that differently named structures would create their own nodes, and not inherit from other members of the DB.

Nevertheless, as I've said I'm more interested in a "photocopy" of the character sheet, or NPC block, without worrying about the underlying rules, that adjust stats, etc. That *should* be easy to code right? :)

S Ferguson
January 26th, 2013, 22:27
And I'm assuming, warily, that these won't interact with anything else.

S Ferguson
January 27th, 2013, 17:00
Is this the right way to go about it? I figure that the extra database node could also be used for other purposes as well. As for Drawing the window and its tabs, it's back to the reference manuals...:(

Trenloe
January 28th, 2013, 18:05
Is this the right way to go about it?
I think you're way over complicating things - I really don't think you need to store original stats, or the details of the actual template applied. Just apply the template and note which templates have been applied.

My thinking around this is that how many times are you actually going to apply a template at some point and then remove it later:

For an NPC templates are usually applied during design time, there are very few NPC templates that would be applied and then removed at some point - I can only really think of the age based templates (young, for example). How often would an NPC in a campaign mature and need the young template removing? If you were keeping track of a long term NPC such as this, you'd probably be developing them more like a PC and would be tracking them elsewhere and so their stats might well have changed from the original stats by they time the "young" template no longer applied so rolling back to the original stats would not be appropriate.
For PCs, how often would templates be applied and removed before the PC went up a level and their base stats change? Or, you apply another template at some point and then remove the first template - your PC stats would all be screwed up as you'd roll back to the original stats and would have to re-apply any other templates added after the first.

I think the number of times you would actually use the base stats to roll back a template would be very, very rare and so spending lots of development time (and taking up FG DB space) may not be a good use of your time or the FG database. If you're coding to parse and apply the template in the first place, just do some coding to parse and remove the template later. This is, in the end, much more flexible and caters for PCs going up levels, permanent damage to statistics, multiple templates being applied, etc..

S Ferguson
January 28th, 2013, 21:43
I think you're way over complicating things - I really don't think you need to store original stats, or the details of the actual template applied. Just apply the template and note which templates have been applied....

My thinking around this is that how many times are you actually going to apply a template at some point and then remove it later...

I think the number of times you would actually use the base stats to roll back a template would be very, very rare and so spending lots of development time (and taking up FG DB space) may not be a good use of your time or the FG database. If you're coding to parse and apply the template in the first place, just do some coding to parse and remove the template later. This is, in the end, much more flexible and caters for PCs going up levels, permanent damage to statistics, multiple templates being applied, etc..

You're absolutely correct on the over-complication issues. It was taught and ingrained in me. Think of the worst case scenario then build the foundation upon which you can handle a "general case." I hope I can be forgiven for that...;)

When you come to think of it a template is a fairly general factory. I had a long diatribe on the benefits of templates, but you're also correct about PC's and NPC's: Although I believe that, with proper use, templates could be applied more often (representing alignment change with *direct* effect on the PC or NPC, as in Pathfinder's example of clerics forced to commit acts against their alignment), monsterous companions with some "flair"; effects of oft carried magic items; with more myriad effects occurring in higher level campaigns (remember that 12 foot goblin we summoned to beat up on the bandits and followed us around for three weeks?). Again apologies....

After much tinkering, the rollback turns out to be a nightmare to implement, let alone maintain, so as you implied that's something I have pitched; but that leaves the question of how to store and name what could be an arbitrary template, and how to apply it. If it's a simple matter of making a "note," the rollback on the template would be easy to accomplish, provided one had the means to generate them.

So it's the course of implementation right now that is the problem (I can even make the pathfinder alignment changes now! :)) My only wish list is it be quick and simple to apply (which I have almost figured out), uniform design (which I think is causing a lot of the problems), and the templates named and kept in a database such that they can be reused by others, i.e. they can export there own mods. That and a license to convert the book of monsterous templates....:)

Thoughts?

Trenloe
January 28th, 2013, 22:18
So it's the course of implementation right now that is the problem (I can even make the pathfinder alignment changes now! :)) My only wish list is it be quick and simple to apply (which I have almost figured out), uniform design (which I think is causing a lot of the problems), and the templates named and kept in a database such that they can be reused by others, i.e. they can export there own mods. That and a license to convert the book of monsterous templates....:)

Thoughts?
The first step I'd recommend is to do a review of a lot of templates to see how the data is presented and what areas each template changes. In the end, it is probably all areas of an NPC statblock that can be changed by a template. As you say, you'll need a way to store that data in a uniform manner. The problem will be wanting to apply that template to either an NPC or a PC - where the data is stored slightly differently. But, you could probably get away with the template data being stored in something like the NPC data structure. Remember post #147? https://www.fantasygrounds.com/forums/showpost.php?p=140909&postcount=147

You can specify the "class" that a NPC list will be tied to. The class is the underlying database node - so, in post #147 I give an example of how to open a NPC Template list, where you can create new "NPC" entries that are tied not to the usual "npc" database structure, but to a "npctemplate" database structure. Create a new NPC window from this list and fill out template specific entries - e.g. Dex +4, etc. and name the npctemplate entry (the NPC name).

Now you have a database structure that holds modification information for each of the NPC fields. What you'll have to do is come up with a uniform method for specifying any modifications in those fields.

Then, when you drag/drop a template from the "npctemplate" list to an NPC entry you can step through each field of the npctemplate and apply the relevant modification to the NPC entry. This is what I was trying to suggest a while back, but I think there was too much confusion going on all over the place back there...

S Ferguson
January 28th, 2013, 23:27
The first step I'd recommend is to do a review of a lot of templates to see how the data is presented and what areas each template changes. In the end, it is probably all areas of an NPC statblock that can be changed by a template. As you say, you'll need a way to store that data in a uniform manner. The problem will be wanting to apply that template to either an NPC or a PC - where the data is stored slightly differently. But, you could probably get away with the template data being stored in something like the NPC data structure. Remember post #147?
It's the base of all my code. How could I forget it?



You can specify the "class" that a NPC list will be tied to. The class is the underlying database node - so, in post #147 I give an example of how to open a NPC Template list, where you can create new "NPC" entries that are tied not to the usual "npc" database structure, but to a "npctemplate" database structure. Create a new NPC window from this list and fill out template specific entries - e.g. Dex +4, etc. and name the npctemplate entry (the NPC name).
Did I go cross-eyed, because the actions were triggered off a button press and the button appeared in *both* the NPC main database node as well as the NPCTemplate node so the effects were global with every button press. Or perhaps there was a misunderstanding.



Now you have a database structure that holds modification information for each of the NPC fields. What you'll have to do is come up with a uniform method for specifying any modifications in those fields.

Then, when you drag/drop a template from the "npctemplate" list to an NPC entry you can step through each field of the npctemplate and apply the relevant modification to the NPC entry. This is what I was trying to suggest a while back, but I think there was too much confusion going on all over the place back there...
That's what I'm aiming for. The Lua code I have pretty much down pat now (I have to manually open the console window now :)). It's the XML that I can't seem to comprehend....

Trenloe
January 28th, 2013, 23:46
Did I go cross-eyed, because the actions were triggered off a button press and the button appeared in *both* the NPC main database node as well as the NPCTemplate node so the effects were global with every button press. Or perhaps there was a misunderstanding.
The custom button will appear in both because they are using the same XML template ("npclist" and everything underneath that). The difference is that the class changes - so anything you enter in a new NPC window created from the NPCTemplates list will be stored in the npctemplates database node, not the npc DB node - because the button used to launch the list specifies the DB node used; the 5th argument to registerStackShortcut.

Give it a go (this is 1 line of code), create the new Stack Shortcut button as mentioned in post #147, then in FG add a new "NPC" (this would actually be template data, not NPC stats) and save the campaign (type /save in the chat window). Open the db.xml for the campaign and you'll see your NPC template information in a new database node "npctemplate". This is where you'll store the template data.

Now, you have a list control where you can add as many different templates as you need.

To use the templates, drag-drop one or more templates onto normal NPC records. It is here (the onDrop event: https://www.fantasygrounds.com/refdoc/windowcontrol.xcp#onDrop) that you will need to code the parsing logic that will:

Get the dragdata object containing the npctemplate reference/information.
Step through the npctemplate DB record, I'd suggest using a table that contains all the name, value data of the NPC template. The "name" will be the DB fieldname of the npc template, that ties in exactly with the fieldname of an NPC record, the value will be the modification required to apply the template.
Apply the relevant modification from the "npctemplate" DB field to the appropriate field in the "npc" record (the NPC record can be returned from the window where the npc template was dropped on).

S Ferguson
January 29th, 2013, 00:10
I was thinking of a simpler structure - the "shallow copy" I mentioned, that only holds the Basic stat block. No frills, and the only Lua code will be to compensate for Pathfinder's Alignment (which I've already written). I really don't think the rest of the overhead is necessary. But, I suppose I need the window...;)

S Ferguson
January 29th, 2013, 17:27
Yes, definitely a simpler structure.

The trouble is in the NPC windowclass it's based on. I need help here, because I understand the Lua half and (just barely holding my head above water) the XML. I need to eliminate the "drag-n-drop" of NPC's to this window, so that, like "notes" you can only create new items. I've streamlined the code, and the simplest solution was to rename the files so now I have two "shadows" of the windowclass, called template_class and it's corresponding Lua code, ready to alter.

Unfortunately, though, I don't know what I'm looking for. I don't want to break anything that deals with the NPC windowclass (and shouldn't now that I've "shadowed" it) but I have to get rid of that behavior, eliminate the icons on the sidebar and change "NPC" to say something different (like "Templates" ?;)) on the main window. I just need to know where to look and what to look for.

Any help or pointers in the right direction would be greatly appreciated. And Trenloe, you were right about this being a "learning experience" but I think it's turning into a semester-long one.

Trenloe
January 29th, 2013, 19:19
Make copies of everything that has "npc" in it under \campaign (including \campaign\scripts) - replace the npc section with npc_template (or whatever you want to use to label the template files).

You will now have to step through from the top level (the "npclist" windowclass in campaign_npcs.xml (now campaign_npc_templates.xml ??) as specified in the DesktopManager.registerStackShortcut command, and see how all of the templates come together beneath "<windowclass name="npclist">" and if you wish to change them you will need to change the names and the calling reference.

To remove the drag/drop functionality the <acceptdrop> tags will need to be removed from the <windowclass name="npclist"> section of campaign_npc_templates.xml and the references to encounters (battles) should be removed too.

campaign_npc_templates.xml should also be referenced in base.xml (extension.xml if you are using an extension) - as this will initialise it and make the templates available.

S Ferguson
January 29th, 2013, 19:21
Okay. I'm on it.

S Ferguson
January 29th, 2013, 21:13
O.K. everything went according to plan save for 1 problem and one issue.

Problem: when the "template" button is pressed initially, an error comes up in buttongroups_tabs.lua which I'm pretty sure is because I removed the banner button on the sheet. I can look further into this one.

Issue: You can't put things into the "box" but you can certainly drag "templates" into the Combat Tracker. Not good. Unless it was a weather template I guess.... regardless, this is behavior I would like to avoid.

Any more suggestions? I don't want to mess with the CT. The code itself is menacing.

S Ferguson
January 29th, 2013, 22:53
Make that two issues. I can't seem to eliminate the side tabs (so the left side of the window is free of tabs) without disabling the Create New button.

Suggestions?

Trenloe
January 29th, 2013, 23:59
Try this extension (NPC Template Test) in a new 3.5E campaign with no other extensions: 3687

This screenshot shows some numbered steps:
3688

Click the new "NPC Templates" shortcut icon, this opens a "Templates" list.
Click the "New" button and enter a simple template. The screenshot shows the PF Advanced Creature.
Open an NPC and drag the template you created in step 2 onto the Main page of the NPC.
This will trigger the onDrop event in scripts\campaign\campaign_npctemplate_actions.lua that identifies the source (template) and target (NPC) database nodes and so you can do all of your parsing of the template info from the source DB node and apply the template details to the target DB nodes.

I've left a lot of code commented out in campaign_npctemplate_actions.lua (from the item drop scripts) so you can see some DB manipulation examples.

Also, as part of this extension, the templates are stored in the campaign db.xml in a new <npctemplate> XML section.

S Ferguson
January 30th, 2013, 01:30
I feel absolutely horrible. I should have uploaded my extension. It is almost identical to yours, save the Lua code battle battle exemption and a few exceptions. I'll incorporate both code sets (I even made my own icon too...) and continue to make it 3.5/Pathfinder compatible. This thread should die down now that I have a solid foundation in Lua now and am *beginning* to understand the markup language.

Thanks alot, You Rock.

S Ferguson
January 30th, 2013, 16:59
BTW nice pictorial. How did you capture the screen?

Trenloe
January 30th, 2013, 17:31
BTW nice pictorial. How did you capture the screen?
I use Snagit, quite an old version now as the current one is getting quite expensive.

S Ferguson
January 30th, 2013, 17:45
O.K one final question. The alterType code needs a window passed to it. What window am I passing, considering the drag-n-drop (slick coding, by the way)? I hope that part of the code is still effective.

S Ferguson
January 30th, 2013, 17:46
Well that might not be the final one, but I go back to work tomorrow so I'll be tinkering with it for a while.

Trenloe
January 30th, 2013, 17:58
O.K one final question. The alterType code needs a window passed to it. What window am I passing, considering the drag-n-drop (slick coding, by the way)? I hope that part of the code is still effective.
The reference to "window" being passed to the alterType function was purely there to allow the window.getDatabaseNode() command to return the nodeNPC database node.

This (nodeNPC) is already available in the onDrop function in campaign_npctemplate_actions.lua as nodeTarget (the target DB node of the drop function, which is the NPC db node).

-- NPC Templates extension.
function onDrop(x, y, draginfo)
...

local nodeSource = draginfo.getDatabaseNode();
local nodeTarget = window.getDatabaseNode();

local sSourceType = DB.getValue(nodeSource, "type", "");
local sTargetType = DB.getValue(nodeTarget, "type", "");

So, change alterType to be:

function alterType(nodeNPC, dbChildNodeName, notHereAdd)

-- alters dbChildNodeName searched for in an NPC. If the dbChildNodeName isn't present, add it
-- Set intial dbChildNodeName value to an empty string.

local nType = "";

-- cycle through nodeNPC looking for type
for vKey,vNode in pairs(nodeNPC.getChildren()) do
And call it from the onDrop function with:

alterType(nodeTarget, "type", "whatever to add")

S Ferguson
January 30th, 2013, 18:26
Still getting the error: Error line 17 trying to access a global variable nodeNPC.

S Ferguson
January 30th, 2013, 18:28
Oops. Forgot, it says it's a nil value.

Trenloe
January 30th, 2013, 18:33
Oops. Forgot, it says it's a nil value.
So, you've fixed the error?

S Ferguson
January 30th, 2013, 18:39
No :(. It seems to have altered the input method. You get the node error everytime you call


NPCTemateManager.alterType(nodeTarget, "type", "newType")

Trenloe
January 30th, 2013, 18:40
And you actually have a nodeTarget value using "local nodeTarget = window.getDatabaseNode();" before you call alterType?

S Ferguson
January 30th, 2013, 19:03
I'm not sure I follow.

Trenloe
January 30th, 2013, 19:10
I'm not sure I follow.
If you're calling "NPCTemateManager.alterType(nodeTarget, "type", "newType")" somewhere and you get a nil error for nodeTarget, then it means that nodeTarget hasn't been defined or doesn't contain data at that point.

In the onDrop function you will need (in the following order):


local nodeTarget = window.getDatabaseNode();

NPCTemateManager.alterType(nodeTarget, "type", "newType")

If you try to call the alterType function with nodeTarget as an argument before nodeTarget actually exists as a DB node then you will get an error.

S Ferguson
January 30th, 2013, 19:29
Calling the functionsin that order gives the error that alterType is nil. I don't think I can use it if the function isn't recognised. :)

Trenloe
January 30th, 2013, 19:42
Please provide the code for both the alterType function and the function you are calling it from. Also, please tell me the exact error and highlight which line the error refers to. Thanks.

S Ferguson
January 30th, 2013, 19:54
Here it is.

Trenloe
January 30th, 2013, 19:56
Here it is.
Don't see anything. But, it is more than likely that your call to NPCTemateManager.alterType is incorrect.

Do you have NPCTemateManager properly defined in extension.xml? Pointing to the script file where the alterType function is?

S Ferguson
January 30th, 2013, 20:00
Yes, everything is in order on the extension.xml side.

S Ferguson
January 30th, 2013, 20:02
And the call to NPCTemplateManager.alterType(nodeTarget, "alignment", "Neutral");
was written exactly like the function was supposed to work.

Trenloe
January 30th, 2013, 20:26
Still don't see any code or description of the exact error - there was no code in your post above.

S Ferguson
January 30th, 2013, 20:36
NPCTemplateManager.alterType(nodeTarget, "type", "Monsterous Ichor");

was the code posted. it got blurred in the message. Mabye there has to be something else I need in the dragdata item? It's supposed to be able to handle this type of input.

S Ferguson
January 30th, 2013, 20:40
Sorry, I'll try again.

Trenloe
January 30th, 2013, 20:41
Your "Here it is" post has nothing in it, so I'm completely lost as to what the error is, where it is occurring, etc.

If this is an extension, just post the extension so I have the whole code. Thanks.

Trenloe
January 30th, 2013, 20:48
function alterType(nodeReference, dbChildNodeName, notHereAdd)

-- alters dbChildNodeName searched for in an NPC. If the dbChildNodeName isn't present, add it
-- Set nodeNPC to the top of the NPC database & set intial dbChildNodeName value to an empty string.

local nType = "";

-- cycle through nodeNPC looking for type
for vKey,vNode in pairs(nodeNPC.getChildren()) do

The DB node variable in your function definition is nodeReference, but then the function looks for nodeNPC which doesn't exist. As shown in post #185 you should have nodeNPC in the definition.

S Ferguson
January 30th, 2013, 20:49
Here's the whole extension: The error when you drag the icon over the template is "attempt to access alterType a nil value.

Trenloe
January 30th, 2013, 20:58
Yes, everything is in order on the extension.xml side.
Hhhmmm... Sorry, but it's not in order.

In campaign_npctemplate_actions.lua the onDrop event code calls:

NPCTemplateManager.alterType(nodeTarget, "type", "Monstrous Ichor");
So, FG is looking for alterType in NPCTemplateManager. The file for this is defined in extension.xml:

<script name="NPCTemplateManager" file="scripts/manager_NPCTemplates.lua"/>
So, FG will be looking for the alterType function in scripts/manager_NPCTemplates.lua. alterType is not in this file it is in campaign\scripts\NPCTemplates.lua, which is defined in extension.xml as NPCTemplates:

<script name="NPCTemplates" file="campaign/scripts/NPCTemplates.lua"/>
So, change the calling of NPCTemplateManager.alterType to NPCTemplates.alterType

Also, fix the definition of alterType as mentioned in my previous post.

S Ferguson
January 30th, 2013, 21:39
OK. Now It works (i.e. the code alters what it's supposed to) but it tosses up a error on line 29 of NPCTemplates where it calls window.update the first time. Are you getting these errors at your end?

Trenloe
January 30th, 2013, 21:41
OK. Now It works (i.e. the code alters what it's supposed to) but it tosses up a error on line 29 of NPCTemplates where it calls window.update the first time. Are you getting these errors at your end?
Yes, just remove it and move the windows.update to the onDrop event - after you have done all of the changes you need.

S Ferguson
January 30th, 2013, 21:55
Silly solution. The window is automatically updated after an onDrop. I'm kicking myself for not realizing it sooner.

S Ferguson
January 30th, 2013, 22:16
There's another problem if you're trying to apply more than one "effect." the node for the window updates itself after the drop, and moves on to the next "entry" in the database. How would I rollback this effect?

Trenloe
January 30th, 2013, 22:31
There's another problem if you're trying to apply more than one "effect." the node for the window updates itself after the drop, and moves on to the next "entry" in the database. How would I rollback this effect?
I don't understand what you mean by moving onto the next entry in the database?

As part of the onDrop event you have access to the whole DB node of the template you are dropping (nodeSource) and the whole DB node of the NPC the template was dropped on (nodeTarget). You can freeform search either of these DB nodes for specific values (.getValue), or you step through the whole set of children in the database node one at a time as the result of the .getChildren command.

Do all of your template effect application as part of the onDrop event code - parse through each of the nodeSource children and then apply the results as necessary to the relevant fields of the nodeTarget database node.

S Ferguson
January 30th, 2013, 22:48
When we originally wrote the NPCTemplates code it was to go through each of the getChildren for a particular creature, say <id-00001> until something was found and then it moved to the next IDNode, say <id-00002>, after performing the actions to <id-00001>. I'll probably have to change that part of the code so it pulls the values out all at once. That way it will be easier to parse the 3.5e/Pathfinder alignment change (contained as part of the "type" string), and functions to add and subtract values in the list boxes (i.e. type -4 dex in template, subtract 4 from NPC dex), the reach factor for large creatures, additional abilities....

Try writing another alterType line underneath the "Monstrous Ichor" line, or with a get new "nodeTarget" line above it, you'll see what I mean.

Trenloe
January 30th, 2013, 23:04
When we originally wrote the NPCTemplates code it was to go through each of the getChildren for a particular creature, say <id-00001> until something was found and then it moved to the next IDNode, say <id-00002>, after performing the actions to <id-00001>.
Sorry, but it doesn't do this. The nodeTarget database node refers to just the single NPC node <id-00001> or whatever the number is. Using nodeTarget.getChildren and then parsing through all of the children does not step onto the next NPC database node.


Try writing another alterType line underneath the "Monstrous Ichor" line
I have and it works fine. I just call it again and it will get a new table with all of the children of the target DB node and step through them all again - using the same top level NPC database node (nodeTarget) which hasn't incremented to the "next" NPC.


or with a get new "nodeTarget" line above it, you'll see what I mean.
Why would we get a new nodeTarget - we already have it, we don't need to get it again.

S Ferguson
January 30th, 2013, 23:17
I get a


script error campaign/scripts/npctemplates:17 attempt to index local nodeNPC a nil value.
Any idea why it's throwing this at me? Try loading your extension up. and I'll run some file compares to see if everything is kosher.

Trenloe
January 30th, 2013, 23:24
I get a

Any idea why it's throwing this at me? Try loading your extension up. and I'll run some file compares to see if everything is kosher.
Getting a "nil" value means that nodeNPC doesn't exist. How are you calling the function?

This is how I call my 2 alterType commands within the onDrop function:

NPCTemplates.alterType(nodeTarget, "type", "Monstrous Ichor");

NPCTemplates.alterType(nodeTarget, "specialqualities", "SQ Test");

S Ferguson
January 30th, 2013, 23:34
I'm actually writing them exactly like that. The node seems to disappear after the first run though.

Trenloe
January 30th, 2013, 23:36
What are you doing in the alterType code - you're not clearing the db node in there are you? Please post the whole function code.

S Ferguson
January 31st, 2013, 00:17
Fixed 'er. Getting the node no problem now.

S Ferguson
January 31st, 2013, 00:22
In fact I just created an Eco-Enviromentalist template with alignment "Green", Special qualities "Green Thumb" and Special Attacks "Protesting."

Thanks a lot for your patience in going over this with me (and for all the times to come...;)). You are a good mentor.

Trenloe
January 31st, 2013, 02:51
In fact I just created an Eco-Enviromentalist template with alignment "Green", Special qualities "Green Thumb" and Special Attacks "Protesting."

Thanks a lot for your patience in going over this with me (and for all the times to come...;)). You are a good mentor.
Nice one! :)

No worries, glad you're learning a lot and making progress... I'm learning a bit too! :D

Dakadin
January 31st, 2013, 03:08
No worries, glad you're learning a lot and making progress... I'm learning a bit too! :D

I've been learning a bit also just following this thread. ;)

S Ferguson
January 31st, 2013, 03:35
No worries, we're going to annotate it and publish it as a learning documentary. :D

S Ferguson
January 31st, 2013, 15:50
Just a brief pointer needed here. The "Descriptors" (natural weapons, armor, SQ, SA, etc.) are going to have to be prepended or appended to the existing descriptors, depending on the descriptor and whether it's nil or not. I think can do this, but I'm befuddled on how to take the Stats and adding/subtracting them from the respective target values. how would you approach the unary modifiers, and apply them as a respective addition or subtraction op?

Also how to you get rid of that silly chat bubble in the upper right hand corner? I don't think it's appropriate for my templates to have a voice in anything.

I think I've had too much coffee.

Trenloe
January 31st, 2013, 18:04
but I'm befuddled on how to take the Stats and adding/subtracting them from the respective target values. how would you approach the unary modifiers, and apply them as a respective addition or subtraction op?
Get the value in the template and the NPC with .getValue, add them together and then set the new value in the NPC with .setValue.

For example, for strength, you can run this in the onDrop event:


nodeTarget.getChild("strength").setValue(nodeTarget.getChild("strength").getValue() + nodeSource.getChild("strength").getValue())


Also how to you get rid of that silly chat bubble in the upper right hand corner?
Remove the "<button_activateid>" control from the npctemplate_top.xml file.

S Ferguson
January 31st, 2013, 18:40
Thanks, as always.

S Ferguson
January 31st, 2013, 22:04
Is there a book for the Pathdinder system dealing with templates. I've seen the Paizo line in the earlier post, but want some concrete ones to set up as a beginner's module, so yuo can see how they're made, etc. I just don't want to violate any copyright restrictions.

Trenloe
January 31st, 2013, 22:21
Is there a book for the Pathdinder system dealing with templates. I've seen the Paizo line in the earlier post, but want some concrete ones to set up as a beginner's module, so yuo can see how they're made, etc. I just don't want to violate any copyright restrictions.
https://paizo.com/search?q=templates+pfrpg&x.x=0&x.y=0&includeUnrated=true&includeUnavailable=true&what=products

Each book may have a different copyright condition. It depends if they're released as part of the OGL or not.

Also, there are many templates within the Paizo PRD:
https://paizo.com/pathfinderRPG/prd/monsters/monsterAdvancement.html

Plus, templates in creatures, here are a few examples (see the "creating a XXX" section):
https://paizo.com/pathfinderRPG/prd/monsters/skeleton.html#_skeleton
https://paizo.com/pathfinderRPG/prd/monsters/zombie.html#_zombie
https://paizo.com/pathfinderRPG/prd/monsters/skeletalChampion.html#_skeletal-champion

Trenloe
January 31st, 2013, 22:43
Also, plenty of templates available here: https://www.d20pfsrd.com/bestiary/monster-listings/templates

S Ferguson
January 31st, 2013, 23:22
That's great! This wouldn't have spawned out of the skeleton thread in the Pathfinder Forum, would it?;)

S Ferguson
February 1st, 2013, 01:32
What is the correct way of distinguishing between the two rulesets (Pathfinder & 3.5e) code-wise. I've seen an example in the standard files but am reluctant to follow its path because I'm not quite sure how it's implemented.

I need to be able to handle alignment change (the first element in the "type" string in Pathfinder), and the BAB/CM (CMB,CMD) vs. the BAB/grp. There's also the calculations to perform Space/reach modifiers (if required), and Aura and Senses which have no counterpart in 3.5e.

I know that the "template pulled up is game specific, but I want to make the code as portable as possible. Preferably in one extension. You're definitely getting your name in this one. :)

S Ferguson
February 1st, 2013, 01:55
Oh and there's also changes due to HD (goody! math class;)). Which is pretty much similar between the two systems, but Pathfinder features it more prominently.

S Ferguson
February 1st, 2013, 01:57
And please forgive my grammar. I've been up since 0530 and have had way to much coffee to think straight.

Trenloe
February 1st, 2013, 17:12
What is the correct way of distinguishing between the two rulesets (Pathfinder & 3.5e) code-wise. I've seen an example in the standard files but am reluctant to follow its path because I'm not quite sure how it's implemented.
local bPFMode = OptionsManager.isOption("SYSTEM", "pf");

See onSystemChanged() in charsheet_tabcombat.lua for an example of it being used. Or, do a find-in-files for pfMode to see lots of examples. The actual definition for the System button in the "Options" screen is "systemselection" in utilty_misc.xml, which shows the 2 options for PFRPG or 3.5E and what values are set in the OptionsManager.

S Ferguson
February 1st, 2013, 18:25
What program are you using for "Find in Files"?

Trenloe
February 1st, 2013, 18:36
What program are you using for "Find in Files"?
Notepad++ https://notepad-plus-plus.org/

It's very good a lot of people on the forums use it, it has built in XML and LUA code colour highlighting. Also, the XML plugin is very handy for checking the syntax of XML files.

S Ferguson
February 2nd, 2013, 03:02
Funny. I own the program but only use is for text files. Mabye I should look more into it's features. UltraEdit will load in files and perform a global search, but if I can get it out of Notepad+....

S Ferguson
February 3rd, 2013, 20:35
Anyone know if template additions "stack" their values or are effects only applied once. For example, an Aboleth skeleton happens to bump into a necromancer who's slain a T-Rex. Realizing he has a bit of flesh lying around decides to resurrect it as a lich. (seeing it was magic using in ihe Aboleth's lifetime). Do we remove the template,or stack the values?

Apologies for the outlandish scenario. The writer's will be dealt with accordingly.

S Ferguson
February 3rd, 2013, 20:55
Also, there is a problem with inserting negative CR values.

Trenloe
February 4th, 2013, 16:37
Anyone know if template additions "stack" their values or are effects only applied once. For example, an Aboleth skeleton happens to bump into a necromancer who's slain a T-Rex. Realizing he has a bit of flesh lying around decides to resurrect it as a lich. (seeing it was magic using in ihe Aboleth's lifetime). Do we remove the template,or stack the values?

Apologies for the outlandish scenario. The writer's will be dealt with accordingly.
Simple answer - they usually stack. Some advanced templates may not and have to be taken on a template by template basis. But, the general rule is that templates stack.

S Ferguson
February 4th, 2013, 16:41
Two other small questions: one deals with negative values in the cr fieldbox and the second is the removal of the "token" spot if possible.

Trenloe
February 4th, 2013, 16:44
Also, there is a problem with inserting negative CR values.
What kind of problem?

Trenloe
February 4th, 2013, 16:47
and the second is the removal of the "token" spot if possible.
Have you looked for the control in the NPC XML specification? Similar to the activateid control that was removed.

S Ferguson
February 4th, 2013, 17:00
Got it. About the negative CR's?

Trenloe
February 4th, 2013, 17:05
Got it. About the negative CR's?
What about them? Please let me know what the *exact* issue is.

S Ferguson
February 4th, 2013, 17:15
Currently, you are unable to type a negative value into the CR box. Some templates require a negative CR (a weaker member of the base type). If I'm to accommodate the adjustments stemming from CR change, I need to know whether the CR is positive or negative.

Trenloe
February 4th, 2013, 17:33
Currently, you are unable to type a negative value into the CR box.
Works fine for me:
3742

S Ferguson
February 4th, 2013, 17:37
Weird. Wasn't working yesterday. Mind you I also get a "not responding" notification in the FG window before it switches to the main screen.

S Ferguson
February 4th, 2013, 17:59
Actually I do have a logic problem I need help on as well, if you don't mind the time. If you look on the paizo.com template site the table for CR changes are a little daunting. somehow I have to know the original CR value (which I know), the new CR value (which I know), and then all heck breaks loose.

Somehow I need to keep a "track system" of how far down or up the CR table the value has moved, and apply "strangely placed" modifiers to various stats and values in steps.

For example a CR 4 monster has a -3 CR template placed upon him. for each drop in CR, in this case 3, it loses 15 Hp for the 4 to 3 drop, then 5 HP for the remaining two for 10 in total. For AC it's dropped by 2 for the CR 4 to CR 3 drop, 1 for the CR 3 to CR 2 drop then 2 for the final drop to CR 1. The mess propagates.

Any thoughts on an approach to this "track system"?

Trenloe
February 4th, 2013, 18:06
For example a CR 4 monster has a -3 CR template placed upon him. for each drop in CR, in this case 3, it loses 15 Hp for the 4 to 3 drop, then 5 HP for the remaining two for 10 in total. For AC it's dropped by 2 for the CR 4 to CR 3 drop, 1 for the CR 3 to CR 2 drop then 2 for the final drop to CR 1. The mess propagates.
That's not how applying templates and CR changes works at all.

The CR change listed in the template is the CR changed based on the template - all of the changes that modify the CR are included in the template, you don't apply anything else.

I assume you're referring the "Table: Monster Advancement" table? This table is for adding racial hit dice to a creature, it is completely separate from applying Templates.

S Ferguson
February 4th, 2013, 18:43
Oh, boy 0 for 2 today - shouldn't have got out of bed this morning:o. How about one more to even the score. I know how to search and replace in a string using .find and .gsub, but for some items, like alignment or size and type, I have to be able to do a little bit more. mainly to alter the "type" property to read properly (as no-one can know in advance what will become undead, etc., and some (esp. magical beasts) retain their base type). That little string is a problem. Especially when you get it on the Pathfinder side. Insertion isn't a string option, and pulling out the base type is non-trivial (I think...).

This recurs in the SA and SQ strings (and Aura and Senses in Pf) , and also in the feats, etc. So I would like a functional way of dealing with these string problems (same problem - one solution).

Thoughts? Criticisms? (I can take it, I'm still half asleep).

S Ferguson
February 4th, 2013, 19:18
And a second request for aide that hopefully negates the other blunder. In the skeleton template, for example, It states Dex +2,Wis and Con 0 and everything else 10. how do I determine whether or not I have a unary minus or plus in a slot as opposed to a raw value score.

Thanks in advance.