GI JOE RPG Launch
Page 2 of 2 First 12
  1. #11

    Join Date
    Sep 2020
    Location
    Ballston Lake, NY
    Posts
    853
    Many extensions are not vaulted, so you can unzip them and look at them. You can learn much doing that. My extensions are not vaulted, and I put notes in them. I also name things to make it obvious what they do. There's also a development wiki page and forum posts.
    Add feature suggestions for Savage Worlds to Fantasy Grounds Feature Request.

  2. #12

    Join Date
    Mar 2020
    Location
    Sammamish, WA, USA
    Posts
    47
    OK, I beat my head against this for a day and a half and I think I've forced FGU into submission. Here's what I've done:

    I added a new field to battles for keeping track of emotion (or whatever other per encounter number you need).
    I made it editable in the Encounter dialog.
    I added a button on the encounter to copy the encounter's Emotion to the GM's Emotion (GM.Emotion).
    I added a control down by GM Bennies to show the GM.Emotion value, which is editable.
    I gave it right click menus for +1, -1, set to 0, and "roll 2d4 and use that" which is the Ghost Mountain random haunt emotion value.

    Things I'm doing that I'm not sure are kosher, that I'd love someone more knowledgeable to check:
    data_library_sw.lua has overrides for the battle already. I had to copy these into mine, because if I just did my override it seemed to remove the SW ones. So I've got:

    aRecordOverrides = {
    ["battle"] = {
    aDataMap = { "combat", "reference.battles" },
    aCustom = { ["npclist"] = "actorlist", ["acceptdrop"] = { "npc", "vehicle" } },
    emotionCount = 2,
    }
    }

    function onInit()
    RecordDataManager.overrideRecordData(aRecordOverri des);
    end

    And that seems to work. But this seems like a problem if any *other* extension also needs to do this, so I'm wondering what the right way is?

    I had to replace the "battle_header" class from record_battle.xml to add my new control. I couldn't figure out a way to merge in another control without the Encounter Title field overwriting it, since it's anchored to the right edge.


    menu.png Encounter.png GMEmotion.png

  3. #13
    https://www.fantasygrounds.com/forum...ial&highlight=

    This is how to make a Derived Stat on the character sheets - you can have them appear on NPCs ONLY if you look at it.

    Look for Ikael's misc tutorials on the forums, lots of nuggets there.

    https://www.fantasygrounds.com/forum...ous-extensions
    Last edited by Jiminimonka; February 9th, 2025 at 10:15.
    Savage Rifts© on Fantasy Grounds Store
    Ultimate Edition Fantasy Grounds - ONLY ON Linux
    Twitch Channel

  4. #14
    Quote Originally Posted by RickSaada View Post
    OK, I beat my head against this for a day and a half and I think I've forced FGU into submission. Here's what I've done:

    I added a new field to battles for keeping track of emotion (or whatever other per encounter number you need).
    I made it editable in the Encounter dialog.
    I added a button on the encounter to copy the encounter's Emotion to the GM's Emotion (GM.Emotion).
    I added a control down by GM Bennies to show the GM.Emotion value, which is editable.
    I gave it right click menus for +1, -1, set to 0, and "roll 2d4 and use that" which is the Ghost Mountain random haunt emotion value.

    Things I'm doing that I'm not sure are kosher, that I'd love someone more knowledgeable to check:
    data_library_sw.lua has overrides for the battle already. I had to copy these into mine, because if I just did my override it seemed to remove the SW ones. So I've got:

    aRecordOverrides = {
    ["battle"] = {
    aDataMap = { "combat", "reference.battles" },
    aCustom = { ["npclist"] = "actorlist", ["acceptdrop"] = { "npc", "vehicle" } },
    emotionCount = 2,
    }
    }

    function onInit()
    RecordDataManager.overrideRecordData(aRecordOverri des);
    end

    And that seems to work. But this seems like a problem if any *other* extension also needs to do this, so I'm wondering what the right way is?

    I had to replace the "battle_header" class from record_battle.xml to add my new control. I couldn't figure out a way to merge in another control without the Encounter Title field overwriting it, since it's anchored to the right edge.


    menu.png Encounter.png GMEmotion.png
    Make an extension and share this please (not vaulted on the Forge)
    Savage Rifts© on Fantasy Grounds Store
    Ultimate Edition Fantasy Grounds - ONLY ON Linux
    Twitch Channel

  5. #15

    Join Date
    Sep 2020
    Location
    Ballston Lake, NY
    Posts
    853
    You're close. You earned a benny!

    You're correct in that your approach will trip up other extensions. Or another extension could overwrite yours. It's also overriding things CoreRPG does with battles.

    Adding to the Library
    First, you want to put this in onTabletopInit rather than onInit. onTabletopInit is evoked at a better time in the sequence of events for what you're doing.
    You add to an array / table using table.insert. Here's the code:

    Code:
    function onTabletopInit()
    	local aRecordOverride = RecordDataManager.getRecordTypeData("battle")
    	table.insert(aRecordOverride, "emotionCount")
    	aRecordOverride.emotionCount = 2
    end
    Important Notes
    Always declare variables as local unless they're going to be used everywhere. Avoid duplicating names of global (not local) variables because one will overwrite the other, and you can't control which one wins. Notice my local variables is names aRecordOverride (no s on the end).

    Avoid overwriting and replacing. If you're doing that, you're probably using the wrong approach. (It raised a red flag for you, so another benny!)

    NEVER directly change anything in CoreRPG! Code in RPG should never be touched directly!

    Altering Windows
    Windows are designed to be very adjustable.
    They work by creating a clone file then declaring the alterations in that file.
    Rather than write all this out, get my NPC Region extension. That adds a widget to the NPC window. It's pretty straight forward and easier to figure out than the library.

    Debug
    In case you missed it, Debug is your friend.
    You can check your work using code similar to this:

    Code:
    local aRecordOverride = RecordDataManager.getRecordTypeData("battle")
    Debug.chat("battle", aRecordOverride)
    Put that somewhere you know it will run, like a button click or window onInit.


    I'll answer any questions you have (within reason).
    If you zip up your code and post it, I'll look it over.

    For daring to plunge into the world of FG code, you get to select any single card from the adventure deck.
    Last edited by Mike Serfass; February 9th, 2025 at 17:01.
    Add feature suggestions for Savage Worlds to Fantasy Grounds Feature Request.

  6. #16

    Join Date
    Mar 2020
    Location
    Sammamish, WA, USA
    Posts
    47
    Jiminimonka - Yeah, I'll update my extension later today, I wanted to make sure I wasn't breaking anything before I released it into the wild.

    Mike Serfass - It looks like I may have stomped the SW aRecordOverrides with mine when I declared it with only my addition, and that's why it broke things. I'll fix that up. I've been programming since the 80's, so it didn't really pass my sniff test. Honestly, I've never done web dev, though, so fighting the XML layout was the worst part. This would all have been so much easier in C# writing for Unity directly, but we work with what we've got . I'll check out your extension and see if there's a way to clean up my dialog stuff. I also want to add a button to the party sheet to set all the player's emotion for the session (like resetting bennies).

  7. #17

    Join Date
    Mar 2020
    Location
    Sammamish, WA, USA
    Posts
    47
    OK, It's live on the store now. I fixed up the overrides with Mike's guidance, and even got the "reset emotion" button in on the Party Sheet.

    https://forge.fantasygrounds.com/shop/items/2072/view

    I'm not sure what other settings use extra player/ encounter resources like this, but I expect this can be string tweaked pretty easily for other uses.

    Thanks for the help getting this working!

    Rick

    P.S. I've added an [extension] thread for this over at:
    https://www.fantasygrounds.com/forum...-Legend-of-Gho
    Last edited by RickSaada; February 9th, 2025 at 23:07.

Page 2 of 2 First 12

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
  •  
DICE PACKS BUNDLE

Log in

Log in