-
September 8th, 2024, 19:05 #1
- Join Date
- Dec 2016
- Location
- Nashville, TN
- Posts
- 284
Extension Creation Advise for Shadowdark
Wanting try my hand at creating an extension for Shadowdark. This will be the first time I have created an extension so I am wanting to start with something I believe will be simple. I would like to make an automation for applying an encumbrance penalty if a character has used more gear slots than its max.
ChatGPT has given me a basic outline of the code needed, but I'm not sure if it using the correct field names to pull the required info. Here is the code it suggested. Given that I do not have the required password to see how the ruleset is setup I have no way of verifying if this code will work. What I've attempted so far doesn't even produce an extension for me to load for the game.
Using Notepad++ I entered the following lua coding and saved it as an xml file inside of a folder. Zipped it and changed the file to an ext file.
Any advise?
-- Function to calculate Gear Slots and apply Encumbrance
function updateEncumbranceModifier(character)
local gearSlotsUsed = character.getField("gear_slots_used").getValue(); -- Get current gear slots used
local maxGearSlots = character.getField("max_gear_slots").getValue(); -- Get maximum gear slots
if gearSlotsUsed > maxGearSlots then
local encumbrancePenalty = calculateEncumbrancePenalty(gearSlotsUsed - maxGearSlots); -- Calculate penalty
character.getField("encumbrance_modifier").setValu e(encumbrancePenalty); -- Apply penalty
else
character.getField("encumbrance_modifier").setValu e(0); -- No penalty if within limit
end
end
-- Function to calculate Encumbrance Penalty
function calculateEncumbrancePenalty(excessSlots)
-- Example logic: For every excess slot, apply a -1 penalty
return excessSlots * -1;
end
-- Event to trigger Encumbrance calculation when gear is added/removed
function onGearSlotChange(character)
updateEncumbranceModifier(character); -- Update encumbrance when gear slots change
end
-- Register this function to run when the gear slots change on the character sheet
DB.addHandler("charsheet.*.gear_slots_used", "onUpdate", onGearSlotChange);
-
September 9th, 2024, 00:09 #2
ChatGPT does not know FG programming.
You will need to use the /debug tool to identify field names and element names.
A lot of code will also be in CoreRPG and be accessible.
-
September 9th, 2024, 01:14 #3
- Join Date
- Dec 2016
- Location
- Nashville, TN
- Posts
- 284
Shadowdark is not setup the same way. I can see the names of the files in Shadowdark, but do not have access to open them to see the actual lua scripts or even the xml coding (password required for the full unzipping). For example, it does not have the manager_char_encumbrance.lua file like the CoreRPG does. I'm fairly certain that is the file I would use for the lua script if it were CoreRPG. But, even looking at that, I'm not sure how I would change the script for encumbrance penatilities in CoreRPG. I know it already does that, but I can't locate which part of the script actually handles the effect output.
I think the scripting for this is going to be outside of my abilities, at least without being able to see the actual code they use. I might be able to figure it out if I could see it, but still not likely, lol. I have made alterations and cheats for EUIV in the past, but the coding for that is much more simple compared to FG. FG is closer to scripting for NWN & NWN2, which I never was able to wrap my head around either, and that was when my brain worked a lot better than it does now, lol.
-
September 9th, 2024, 02:12 #4
if you cant access the code how will ChatGPT access the code?
/debug will tell you quite a bit.
you might also ask teh ruleset dev if they can share encumbrance code with you.
-
September 9th, 2024, 03:39 #5
@claedawg - Shadowdark runs on top of CoreRPG (like most rulesets). So it probably uses the CoreRPG encumbrance manager, more than likely with modification. Without having access to the ruleset code, as you mention, you'll be struggling. As @damned suggests, the ruleset dev will probably be needed to help with how the Shadowdark ruleset handles gear slots etc..
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!
-
September 9th, 2024, 05:05 #6
- Join Date
- Dec 2016
- Location
- Nashville, TN
- Posts
- 284
I really wasn't expecting it would due to the password requirement, but I have had it recover a corrupted google doc for me. Doesn't hurt to check sometimes. It also seems to have access to some things that I do not (most likely through a college library where they have acquired legal (hopefully) access. Wish I still had access to the University of Phoenix digital library. It had some stuff in there I would like to get now that is not available publicly without contacting the author (or school where it was submitted as a thesis???) for a direct purchase.
The code it gave me was an example of what you might use if it had not already been defined, going by the looks of it.
-
September 9th, 2024, 05:39 #7
The basic structure is what you might take as a starter - i.e. a DB handler that calls a function to run some code when a specific field is updated within the FG database.
Beyond that, you'lll need to:
- Work out which field in the Inventory you need for the DB handler that runs when the number of gear slots changes. Can a single field be used? Or would multiple fields be needed to calculate when the gear slots change? I'm not familiar with the Shadowdark system, either the RPG system itself or the implementation within FG.
- Write the handler function that takes the information from the PC database (not the GUI which the example code uses) and performs the calculations needed, applying the relevant encumbrance penalty to the PC.
EDIT: You might be able to do most of the above by creating an example PC within a Shadowdark campaign and looking at the database structure for the character within the campaign db.xml file. One gotcha maybe if the ruleset already caters for an encumbrance penalty and if you can change that via the PC entry in the database.Last edited by Trenloe; September 9th, 2024 at 05:49.
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!
-
September 9th, 2024, 06:00 #8
You also have to allow for units - some items like arrows will have up to a certain number of units count as 1 whereas 2 swords will count as 2 items.
-
September 9th, 2024, 13:51 #9
What are you trying to do? Shadowdark already uses gear slots for encumbrance. So how are you trying to change it from raw?
https://forge.fantasygrounds.com/shop/items/199/view
Old School Essentials Ruleset
https://www.dmsguild.com/product/352...eon-Builder-5E
5e Random Dungeon Generator!
-
September 9th, 2024, 17:25 #10
- Join Date
- Dec 2016
- Location
- Nashville, TN
- Posts
- 284
Just attempting to add encumbrance penalties. I have not seen any effect of PC die rolls if they are carrying more than the max gear slots. There are other things I would like to try my hand at also, such as codifying the skills, but that would require me to also get the ruleset wizard at some point as I would need to add a new tab to the CS, to make it easier. Basically, just attempting to make the game work better for long term campaigns and such.
Since this system is so simple (compared to other systems) I figured this would be my best bet on learning, rather than attempting to edit D&D the way I want it or creating my own ruleset from scratch.Last edited by claedawg; September 9th, 2024 at 19:41.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks