PDA

View Full Version : Help with offline character creation



GoOrange
September 18th, 2007, 02:36
I found a bug in my Star Wars Saga Edition ruleset. For those who have been following previously, the skill section gave me a bit of trouble and was discussed quite a bit here: https://www.fantasygrounds.com/forums/showthread.php?t=7062

When I tried to create a character offline (using the leftmost tab on the intro screen), I rolled up abilities, started entering in stuff, then got an error as soon as I went to the skills tab. It told me that skillistitem:halflevel was attempting to index a nil value.

The odd part is that this behavior does not happen when I create characters from a GM hosting session, only when I create characters offline using the ruleset (as a potential player would do before logging into the game if he had my ruleset).

Any ideas as to why I would get an error in offline mode but not in hosting mode? Are there different sections of the ruleset for the different modes that I don't know about, or do they write to the database in different ways so that my lookup calls are failing?

Any ideas or help would be most welcome.

Thanks,
Jeff

Griogre
September 18th, 2007, 05:42
I believe local charcters do not have access to the server database and thus your database calls fail. Someone who knows should come along and help soon, hopefully.

GoOrange
September 19th, 2007, 02:22
I believe local charcters do not have access to the server database and thus your database calls fail. Someone who knows should come along and help soon, hopefully.

What I'm doing shouldn't be accessing any data on the server, just a node created on page one of the character sheet. The skills page function that I think is crashing is trying to lookup a value with a few getparent, getchild and getvalue funtions.

It's odd that it only happens in the create and view local characters page and not in the server or client mode.

Unless, what you're telling me is that these getparent and getchild functions only work when you're connected to the server...hmm. That would explain things, but would be odd.

Oberoten
September 19th, 2007, 08:02
What I'm doing shouldn't be accessing any data on the server, just a node created on page one of the character sheet. The skills page function that I think is crashing is trying to lookup a value with a few getparent, getchild and getvalue funtions.

It's odd that it only happens in the create and view local characters page and not in the server or client mode.

Unless, what you're telling me is that these getparent and getchild functions only work when you're connected to the server...hmm. That would explain things, but would be odd.

Well, basically the characters are stored as server characters on the host machine. The local characters on the other hand are saved as separate files. I expect this has much to do with it. I do not know if the files are identical as it is. There has been some problems coding rulesets that work fine in Local-Mode as well before.

GoOrange
September 19th, 2007, 17:23
OK, I figured out the source of the problem. The database trees are set up differently in local mode than in server mode.

In server mode, when I print the current database node name at the problem point, it comes up:
charsheet.id-00003.skilllist.id-00002

In local mode, the print comes up:
skilllist.id-00002

OK, so now I have two problems.

First, I can't figure out how to get this line to work in local mode (it works in server mode)

lvlsource = window.getDatabaseNode().getParent().getParent().g etChild("classes.totallevel.level");
Since there are fewer levels to the DB tree, I tried dropping off a getParent or two, but the getParent function returns a nil value when it goes to the root directory and doesn't want to look up the getChild at that point.

So how do I re-write the function to work in local mode?

Second question - How do I set up an if then else statement to test if I am in server mode or character mode?

Thanks,
Jeff

Foen
September 19th, 2007, 22:39
Okies, it has been a little time since I dabbled with this, but here goes...

With the database, you use getParent() to navigate one up, and getChild() to look downwards. I seem to recall that you can do similar navigation using windowclasses: 'window' returns the parent window of the current control, and 'windowlist' returns the containing list if the current windowclass is part of a list.

Assuming you start from a nested control within charsheet.id-00003.skilllist.id-00002, then window gets you to id-00002, windowlist gets you to skilllist, and window moves you to the sheet which contains skillist. Then getDatabaseNode() should return you the charsheet level node (containing the skill list) and hence you might try the following:

window.windowlist.window.getDatabaseNode().getChil d("classes.totallevel.level")

For your second point, try User.isHost() and User.isLocal(), both of which are documented here (https://www.fantasygrounds.com/refdoc/User.xcp).

Cheers

Stuart

GoOrange
September 20th, 2007, 14:36
Stuart, you're a genius.

Using window.windowlist.window worked much better than the getParent() functions in this case. This method worked perfectly for both host and client modes and so I didn't need to set up the if then else (although I did read through the section of the library in case I need it for future use).

Things are looking good at this point, thank you very much for your help.

Cheers,
Jeff

Foen
September 20th, 2007, 20:14
Umm, I don't think so.

There are a few reasons you might take one path over another though.

Using window.windowlist etc

The target is not bound to the database (this method gives you access to unbound controls)
You want to be independent of the database structure (such as offline vs online character creation)


Using getParent().getChild() etc

You want to be independent from how you layout the character sheet (changing the cosmetic stuff leaves your code in tact)
This is the best default approach (not sure how it compares on speed)


Unfortunately, I don't think the window.windowlist method is well documented. For example with subwindows, the documentation says you can access the individual sub-windows using the subwindow property. In fact you often need to access the containing window (such as getting hold of the top level charsheet from a sub-sheet such as charsheet_skills) and there is little/no help.

Just my two pen'th

Stuart

Bidmaron
October 11th, 2008, 14:03
This discussion involves generating characters in local mode. I just want to make sure I understand the limitation of that. Is the following true:
<<In order to generate a character in local mode, you either need to be using the default d20 ruleset, or you must own and have installed the ruleset for which you are trying to generate the character. Also, you must choose that ruleset when starting up Fantasy Grounds.>>
Is that statement accurate and complete?

Oberoten
October 11th, 2008, 14:07
That... And you need a full version unless you are savy enough to make a pak file and reg-keys to point to it.

Bidmaron
October 11th, 2008, 14:45
OK, Obi-Wan, you had to know this was coming:

1) How do you make a pak file?
2) How do you do the reg-keys?

The padwanh (sp?) learner requests to know.

Oberoten
October 11th, 2008, 14:57
On Master Yoda's lap this I learned...

First Zip utility you will need. Ruleset zip you shall, making sure in the base of archive they end up. No subdirectories do you want in this.

File to PAK rename you shall.

Next to the Regedit side of the force reach out. Search yourself and the force for : HKEY_CURRENT_USER\Software\FantasyGrounds\Rulesets

Under this a new key create you shall. And the name of your ruleset it should bear.

Under key two values you will add : Name which is the name of created ruleset that you have, and Package which the name of file contain must.

Many advantages to this there will be, offline creation for characters but one is... License and thumbnail showing up on selection the others are.

Meditate on this now you shall, hmmmm?


** Edit **
Pak files are located in the PROGRAM folder, not the application data folder. Might be good to know too.

Oberoten
October 11th, 2008, 14:59
And yes, with one of my players always making lewd Yoda jokes, you DID walk straight into this one. Just be glad I spared you all the worst of his jokes... Like Yoda hitting on Luke.

- Obe

Bidmaron
October 11th, 2008, 15:02
The force is indeed strong.

Foen
October 11th, 2008, 15:55
To be clear, a PAK file is required or the session needs to be running on a full licence with a copy of the target ruleset installed locally.

d20 is nothing more special than a PAK file in this regard.

Stuart

Oberoten
October 11th, 2008, 20:19
Clouded the future of this is.

Griogre
October 11th, 2008, 20:28
PAKs are the way of the future, IMO. You either need an installer to handle the registry settings since you really don't want users forced to muck around in the registry or FG needs to set registry settings itself when if first uses a PAK ruleset or on load of the PAK ruleset (the better solution) so it can dump them on close so the registry doesn't get full of obsolete settings..

Foen
October 11th, 2008, 20:54
The problem with PAK files is that it means the licensed content is installed on every machine, not just the host.

For commercial rulesets this is a potential killer: would folks want to pay ten bucks (say) once for the GM; or ten bucks for the GM and eight bucks (say) for every player? And all you get extra is offline character generation.

As soon as you find a licensor who is happy to distribute product to players free of charge, you will find commercial rulesets using PAK files, or so it seems to me.

Foen

Oberoten
October 11th, 2008, 22:41
The best solution we could be given here is that if there IS a pak file present in a proper directory it shouldn't need the registry key...

... that way if you have a home-spun ruleset you could distribute it to the players beforehand and it'd all just work.

- Obe

Griogre
October 11th, 2008, 23:22
The problem with PAK files is that it means the licensed content is installed on every machine, not just the host.

For commercial rulesets this is a potential killer: would folks want to pay ten bucks (say) once for the GM; or ten bucks for the GM and eight bucks (say) for every player? And all you get extra is offline character generation.

As soon as you find a licensor who is happy to distribute product to players free of charge, you will find commercial rulesets using PAK files, or so it seems to me.

Foen
I agree with you to a certain extent. However, most game character sheets would be fine in a PAK - you don't really have to put anything else in them for the clients and most companies give their character sheets away. Most people just want to fill in a character sheet locally and transfer it to the server when they connect. Am I wrong in thinking you could just make the character sheet only for clients? If they want referance they can use their own referance of connect to the server.

Foen
October 11th, 2008, 23:26
Sorry if I seem to have a downer on PAK files ;)

They are ideal for non-commercial use and I'll be wrapping my RuneQuest(tm) OGL up as a PAK file when I get round to finishing it. It just isn't good news for offline character creation for commercial rulesets, such as Savage Worlds or Call of Cthulhu.

Shame, really.

Stuart