View Full Version : Character sheet, Char Gen "do once" questions
Spooks_Ghoul
May 23rd, 2014, 16:32
Let me preface by saying, I have absolutely no lua experience. I did a little python in college, but so far it's been just enough to get me in trouble. That being said - Has anybody successfully coded a chargen "doonce" chunk when a new character sheet is initialized. Is there any current commercial or custom ruleset that has such functionality?
Are there any resources or guides especially suited to how Fantasy Grounds employs lua?
Thanks in advance.
Spooks, steam client purchaser.
Trenloe
May 23rd, 2014, 16:48
Let me preface by saying, I have absolutely no lua experience. I did a little python in college, but so far it's been just enough to get me in trouble. That being said - Has anybody successfully coded a chargen "doonce" chunk when a new character sheet is initialized. Is there any current commercial or custom ruleset that has such functionality?
I'm not sure what you mean by "do once"?
Also, which ruleset are you referring to?
If you want to have a set of basic abilities, skills, whatever setup then you can use the character export/import functionality (see "export a character" and "import a character" in the "GM Actions" section here: https://www.fantasygrounds.com/wiki/index.php/Character_Management). This allows you to export a specific character you have created to an XML file and then load it back in - creating a new PC of the same name, rename the new PC and off you go.
Are there any resources or guides especially suited to how Fantasy Grounds employs lua?
There are a few developer guides available in the Wiki: https://www.fantasygrounds.com/wiki/index.php/Developer_Guides
The "Ruleset Modification Guide" has a section on Lua: https://www.fantasygrounds.com/modguide/scripting.xcp
Spooks_Ghoul
May 23rd, 2014, 19:06
[I'm not sure what you mean by "do once"?]
A "do once" is a code chunk that begins by checking a variable (local or global) for a true/false Boolean return before executing any additional functions or checks. It ends by changing the checked variable to one (either true or false according to preference) so that the code will not execute, even if its start condition is something like "on init" (which would run every time the element is initiated).
As a code independent logic example
#charsheet
var1 = _doonce
On initiation
> if _doonce = 0;
>> then do character generation (spend points as per game rules) chunk;
>>set _doonce = 1;
>else display character sheet with values stored in database
End
[Also, which ruleset are you referring to?]
I'm not referring to a ruleset, I'm talking about coding one (thinking nWoD, perhaps Codex rule system like buffy or serenity.)
Trenloe
May 23rd, 2014, 20:20
Ah right, OK.
Some rulesets do something like this - usually in the onInit() event when the character sheet is opened: https://www.fantasygrounds.com/refdoc/windowinstance.xcp#onInit
Within the related event handler there is usually code that checks the database entry that the character sheet is anchored on. Sometimes just checking that basic data exists in the FG campaign database is enough to know if there needs to be "do once" code running, or if necessary set a flag in the <charsheet> entry in the database, as this is the main area that is persistent between sessions.
Willot
May 23rd, 2014, 23:51
[I'm not sure what you mean by "do once"?]
A "do once" is a code chunk that begins by checking a variable (local or global) for a true/false Boolean return before executing any additional functions or checks. It ends by changing the checked variable to one (either true or false according to preference) so that the code will not execute, even if its start condition is something like "on init" (which would run every time the element is initiated).
As a code independent logic example
#charsheet
var1 = _doonce
On initiation
> if _doonce = 0;
>> then do character generation (spend points as per game rules) chunk;
>>set _doonce = 1;
>else display character sheet with values stored in database
End
[Also, which ruleset are you referring to?]
I'm not referring to a ruleset, I'm talking about coding one (thinking nWoD, perhaps Codex rule system like buffy or serenity.)
I wasnt even aware that method had a name. 8)
damned
May 24th, 2014, 00:34
I wasnt even aware that method had a name. 8)
It does now.
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.