5E Product Walkthrough Playlist
  1. #1

    Need an assist with my first extension (3.5/PFRPG)

    I'm new to LUA and FG, but I've been programming for a long time and I am ready to jump in.

    Per my original question in the 3.5/PFRPG forum, I want to add a check box to the character sheet titled

    "Receives XP"

    And then I want to override the awardXP method of manager_ps2.lua to check the state of that box when determining the members of the party for xp calculation and awarding.

    so, I know I need to modify the record_char_main.xml to add the new title and check box.
    I presume I also need to somehow persist the state of this check box to the database.

    Then over in the lua script for the manager, when I override the awardXP function, I need to modify the conditional:

    local nodePC = DB.findNode(sRecord);
    if nodePC then
    local sName = DB.getValue(v, "name", "");
    table.insert(aParty, { name = sName, node = nodePC } );
    end

    with something like

    local nodePC = DB.findNode(sRecord);
    local nodeXP = <whtever it takes to lookup the check box I created>
    if nodePC and nodeXP then
    local sName = DB.getValue(v, "name", "");
    table.insert(aParty, { name = sName, node = nodePC } );
    end


    This should really do exactly what I want in the least invasive way possible.

    I'm struggling with the learning curve, however.

    I'm taking it in small chunks, and the first thing I'm struggling with is adding the label and checkbox.
    Can I get some advise on where to find the right documentation, and maybe an example?
    I've been picking apart existing extensions but haven't quite nailed it down yet.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,413
    This thread gives some good background (and further links): https://www.fantasygrounds.com/forum...-PFRPG-ruleset

    Have a look at the "Windows and Controls" page of the Ruleset modification guide (linked in post #1 of the above referenced thread). Control positioning covers the basics of how to position controls within the FG XML. Most standard rulesets will use a lot of "relative" anchoring, so you'll need to understand this.

    If you want to put it on the "Main" tab, then you're looking in the right file (campaign\record_char_main.xml in the 3.5e ruleset). I'm not sure where you're going to put it, there isn't much usable space on the main tab. Perhaps try to squeeze it into the level/XP frame (starting at <frame_char name="levelframe">), but you'll need to rearrange/resize the current controls there.

    For the checkbox, have a search through the 3.5E ruleset (use "find in files" in your text editor) for button_checkbox and see how it's been used within the ruleset itself (there's a couple of examples in record_char_skills.xml). button_checkbox is defined in the CoreRPG ruleset (remember that 3.5E is built on top of CoreRPG, so you sometimes have to search on CoreRPG for templates/definitions used in 3.5E) and is built on the buttonfield control, which is the database sourced version of buttoncontrol: https://www.fantasygrounds.com/refdoc/buttoncontrol.xcp So, we know that button_checkbox is sourced on a database field, which will use the same name set for the control in the FG XML. For example: <button_checkbox name="receivesxp"> would store the state of the button in a database field in the character DB entry called "receivesxp".

    Hope this gets you started...
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    Perfect!

    I've gotten the label on there and I see what you mean re: the relative positioning and the lack of real estate.
    I was just digging in to resizing those controls when you posted, so the recommendation is super timely.

    I am thinking I might try to squeeze the button in to the left of the word "Experience" (below "Total Level") without a label, but give it a tooltip description.
    This probably won't look too forced, and will keep me from spending a lot of time making minute movements of relative positions.

    Thanks!

  4. #4
    So I think I have an idea that will work, but I've been fiddling for over an hour without any luck. I want to modify the label for the experience field that appears on the character main tab to contain the checkbox, with a tooltip explaining what it does.
    For this, I want to replace just the label field. However, since it's declared as a label_fieldtop control relative to the number_dropadd control named "exp" I think I need to redefine the "exp" control and the label attached to it, inserting the button.

    I'm trying to grok the object hierarchies, and making some headway but I'm missing some things.
    First, is it even possible to put a checkmark inside a label?
    Second, if so, how do I override the number_dropadd control named "exp" with my new label containing the check box?

    I thought it had something to do with the windowclass property merge="join", perhaps there's a different value that allows me to overwrite an existing named control?
    I looked at the definition for windowclass and the page for windowinstance, but I couldn't find info on that property and was having trouble determining if there is a parent class that might define it.

  5. #5
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,413
    Quote Originally Posted by nickabbey View Post
    First, is it even possible to put a checkmark inside a label?
    In general you can't put a base control inside another base control. You will need to add the checkbox as a new control.

    Try the attached extension, this adds a button_checkbox control into the existing "charsheet_main" windowclass. It's position is anchored to the "levelframe" control.

    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  6. #6
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    As a general comment Id do it the other way - you check the box not to receive XP for this character so that you dont omit awarding XP to a new Character because you forgot to check the box.

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,413
    Quote Originally Posted by damned View Post
    As a general comment Id do it the other way - you check the box not to receive XP for this character so that you dont omit awarding XP to a new Character because you forgot to check the box.
    Or, you could set the code to automatically default to checking the box when a new character is created.

    Oh look, I did!

    Code:
    		<windowclass name="charsheet_main" merge="join">
    			<sheetdata>
    				<!--New-->
    				<button_checkbox name="receivesxp">
    					<anchored to="levelframe" position="insidetopleft" offset="20,35" width="10" height="10"/>
    					<default>1</default>
    				</button_checkbox>
    				<!--End New-->		
    			</sheetdata>
    		</windowclass>
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  8. #8
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    Quote Originally Posted by Trenloe View Post
    Or, you could set the code to automatically default to checking the box when a new character is created.

    Oh look, I did!

    Code:
    		<windowclass name="charsheet_main" merge="join">
    			<sheetdata>
    				<!--New-->
    				<button_checkbox name="receivesxp">
    					<anchored to="levelframe" position="insidetopleft" offset="20,35" width="10" height="10"/>
    					<default>1</default>
    				</button_checkbox>
    				<!--End New-->		
    			</sheetdata>
    		</windowclass>

    Of course you did! Thanks Trenloe

  9. #9
    What did that take you, like 5 minutes?

    Facepalm... I've been messing with this for hours, and I've come SO close.

    With your guidance though, I was able to see that I was VERY close.
    Thanks for taking the time to show me the ropes on this!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
STAR TREK 2d20

Log in

Log in