PDA

View Full Version : Help with Bag of Holding Extension (development)



BloatedNikNak
August 13th, 2020, 15:31
(For use with 5E Ruleset)

So, I might have bitten off a bit more than I can chew with this one.

It's a simple concept, but the implementation is causing me some difficulty.

I do not have a lot of experience with FG, so don't even know if this is possible.

I know some basic LUA and have a reasonable understanding of XML, but I know where to find the resources to help if i get stuck.

What I am attempting to do, is firstly find where (which file) the encumbrance "current" is calculated, and if that can be modified so that if an item has a (in this example) "Bag of Holding" location tag, have its weight deducted from that "current", which then can be added to the Bag of Holdings "current" weight.

If someone can point me in the right direction, to find the script that handles encumbrance "current" weight, or let me know if this is not even possible..

I have attached a screen shot below to show what it looks like on the players inventory tab so far

38531

LordEntrails
August 13th, 2020, 15:49
I don't know, but I can tell you this;
That looks like 5E. 5E is layered on top of CoreRPG, so you'll have to unpack CoreRPG and look in those files as well as the 5E ones. Note that rulesets (.pak) files are just renamed zip files, so you can extract them. I suggest renaming or moving the extracted files because FG will look to unpacked files before using zipped files and it may throw you off when you go to play if you have been modifying ruleset files.

BloatedNikNak
August 13th, 2020, 15:56
I don't know, but I can tell you this;
That looks like 5E. 5E is layered on top of CoreRPG, so you'll have to unpack CoreRPG and look in those files as well as the 5E ones. Note that rulesets (.pak) files are just renamed zip files, so you can extract them. I suggest renaming or moving the extracted files because FG will look to unpacked files before using zipped files and it may throw you off when you go to play if you have been modifying ruleset files.

Yeah. I've had a look in both 5E and CoreRPG, I must be missing something, I will go though it again. Thank You

superteddy57
August 13th, 2020, 16:36
From a search through 5E's files, there are three files that factoring encumbrance is mentioned:
record_char_inventory.xml - where it sits on the character sheet and given the look to display it.
char_invlist.lua - function onEncumbranceChange() - How it affects the character in terms of game mechanics
manager_char.lua - function updateEncumbrance - When to check and possibly change the Encumbrance.

You may still have to keep pulling threads, but this should help get you started.

Three of Swords
August 14th, 2020, 02:31
Out of curiosity, do you really want to develop an extension? Or would a work-around be sufficient?

You could create a Bag of Holding as a Character and have a player take control of it. It's what a number of us do. That way you can easily drag items to it and know they're in the bag. It also calculates how much it is holding in terms of burden.

Just a suggestion.

The High Druid
August 14th, 2020, 15:42
For my characters, I set the location of the item to the bag, and set the "Equipped/Carried/Empty" toggle to "Empty" to zero the weight. If I need to see how much is in actually the bag, I have to change the toggle of the bag, which in turn changes everything underneath it, and then click everything off again, but I don't have to do that often.

BloatedNikNak
August 14th, 2020, 15:57
From a search through 5E's files, there are three files that factoring encumbrance is mentioned:
record_char_inventory.xml - where it sits on the character sheet and given the look to display it.
char_invlist.lua - function onEncumbranceChange() - How it affects the character in terms of game mechanics
manager_char.lua - function updateEncumbrance - When to check and possibly change the Encumbrance.

You may still have to keep pulling threads, but this should help get you started.

Thank you, I will take a look at this today

BloatedNikNak
August 14th, 2020, 15:58
Out of curiosity, do you really want to develop an extension? Or would a work-around be sufficient?

You could create a Bag of Holding as a Character and have a player take control of it. It's what a number of us do. That way you can easily drag items to it and know they're in the bag. It also calculates how much it is holding in terms of burden.

Just a suggestion.

It's more to do with me wanting to learn the process, and make an extension. But being new to it, needed a little guidance.
But your suggestion is a good way to handle it.

BloatedNikNak
August 14th, 2020, 15:59
For my characters, I set the location of the item to the bag, and set the "Equipped/Carried/Empty" toggle to "Empty" to zero the weight. If I need to see how much is in actually the bag, I have to change the toggle of the bag, which in turn changes everything underneath it, and then click everything off again, but I don't have to do that often.

Thats what my DM is doing at the moment, and is fine with that. I just figured I would try giving it a go.
And if it works, I'm more than happy to share.

BloatedNikNak
August 15th, 2020, 19:28
UPDATE:

I have managed to get a working prototype..

I have attached a screen shot below for an example.

If the item has "Bag of Holding" in location, and is "Not Carried" the weight of that item is added to the Bag of Holding, and removed from Current Encumbrance .

Items can be easily removed from the Bag of Holding by either having them marked as "Carried" / "Equipped" - the weight is then removed from the Bag of Holding and added back to Encumbrance Current.

This negates the need to delete "Bag of Holding" from the location column and re typing each time an Item is removed, and then later placed back.

I still want to work on a few things, before I offer it up, namely figuring out how to get it working without having edited the 5E Ruleset directly. (Was done as a quick way to see if it works) - Any pointers on that would be appreciated.
38580

cboillot
August 16th, 2020, 15:52
We just came into this issue. This sounds like a very cool extension. Do you know when you will be releasing it?

BloatedNikNak
August 16th, 2020, 16:12
We just came into this issue. This sounds like a very cool extension. Do you know when you will be releasing it?

I did manage to get it working. I'm currently testing it with friends.

Will need a couple days to make sure there are no apparent issues.

Will aim to get something out on Tuesday, unless there are issues found.

This will be my first extension, so I will advise now, that you should make sure your campaign is backed up before use.

BloatedNikNak
August 18th, 2020, 14:39
I ran into an issue today, while refactoring... ya know how it is..

The way i previously had a working version, was essentially replacing the "manager_char.lua" file with my own, where i copied everything from the original into my own, and added my own lua where needed.

Knowing that this is not best practice, i looked to create and initialize my own script, which is being called as and when it is needed, but now the script does not work.

I have tested that both the onInit() and my function is being called, which it is.

Below is my function.



function onInit()
DB.addHandler(DB.getPath("charsheet.*.inventorylist.*.carried") , "onUpdate", nonDimensionalStorage);
DB.addHandler(DB.getPath("*.count"), "onUpdate", nonDimensionalStorage);
end

function nonDimensionalStorage(nodeChar)


local nDSCurrent = 0;
local nDSMax = 500;
local nDSRemaining = 0;
local nDSNCount, nDSNWeight;

for _,vNode in pairs(DB.getChildren(nodeChar, "inventorylist")) do

if DB.getValue(vNode, "location", 0) == "Bag of Holding"
and DB.getValue(vNode, "carried", 0) == 0 then
nDSNCount = DB.getValue(vNode, "count", 0);

if nDSNCount < 1 then
nDSNCount = 1;
end

nDSNWeight = DB.getValue(vNode, "weight", 0);
nDSCurrent = nDSCurrent + (nDSNCount * nDSNWeight);
end

nDSRemaining = nDSMax - nDSCurrent;
end

DB.setValue(nodeChar, "bagofholding.current", "number", nDSCurrent);
DB.setValue(nodeChar, "bagofholding.remaining", "number", nDSRemaining);
DB.setValue(nodeChar, "bagofholding.max", "number", nDSMax);
end


EDIT: I forgot to mention, that it is the for loop that is not being called, but I do not get any errors in the console

also.. is there a code wrap option on the forum?

EDIT: never mind i found it (in advanced)

BloatedNikNak
September 2nd, 2020, 00:36
Extension has been released:

https://www.fantasygrounds.com/forums/showthread.php?61400-5E-Additional-Storage-(Bag-of-Holding)

cboillot
September 2nd, 2020, 06:35
Awesome! Thank you!