Dungeons & Dragons 2024 Core Rulebooks Pre-Order
Page 4 of 7 First ... 23456 ... Last
  1. #31
    Quote Originally Posted by Moon Wizard View Post
    The code allows records to specify that they support inventory and/or currency via flags on the records; and the ItemManager script was updated to support that behavior.

    Regards,
    JPG
    This does not answer my question. It can't work with a combat group entry - which your code feeds it for NPC inventory drops. Do I have to butcher this and fix it myself?

    Also, you did not answer the https://www.fantasygrounds.com/forum...l=1#post721245 bug? question. Am I going to have to fix this myself also?
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  2. #32
    Basically, the ItemManager can't use startsWith to figure out where things are coming from, because NPCs and Vehicles need inventory (for some rulesets) and some will live on the party sheet, character sheet or other places. So, the ItemManager call to figure out the source needs to be different.

    With the standard item transfer mechanics, it didn't need to be as specific, so it was working; but I can see the need for determining source a little better. I've pushed an update that should help.

    Regards,
    JPG

  3. #33
    Quote Originally Posted by Moon Wizard View Post
    Basically, the ItemManager can't use startsWith to figure out where things are coming from, because NPCs and Vehicles need inventory (for some rulesets) and some will live on the party sheet, character sheet or other places. So, the ItemManager call to figure out the source needs to be different.

    With the standard item transfer mechanics, it didn't need to be as specific, so it was working; but I can see the need for determining source a little better. I've pushed an update that should help.

    Regards,
    JPG
    ItemManager.getItemSourceType seems to be working again returning the source type regardless of node level, so that fixed it.

    Currencies still are blocked (one example being combat group entry can't be parsed per previous mail in current new code checks) so I'll have to figure out how to override things to get that working again.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  4. #34
    What function is doing the currency transfer that is getting blocked?

    Regards,
    JPG

  5. #35
    Quote Originally Posted by Moon Wizard View Post
    What function is doing the currency transfer that is getting blocked?

    Regards,
    JPG
    Exactly what I said in here (CurrencyManager.addActorCurrency). But I've worked around that with the following fix to insure combattracker paths return a record type....

    In onInit()...
    Code:
    	RecordDataManager.setRecordTypeOption("npc", "bInventory", true);
    	RecordDataManager.setRecordTypeOption("npc", "bCurrency", true);
    	RecordDataManager.setRecordTypeOption("vehicle", "bInventory", true);
    	RecordDataManager.setRecordTypeOption("vehicle", "bCurrency", true);
    	
    	savegetRecordTypeFromListPath = RecordDataManager.getRecordTypeFromListPath;
    	RecordDataManager.getRecordTypeFromListPath = getRecordTypeFromListPath;
    Code:
    -- insure combattracker entries can return record type
    function getRecordTypeFromListPath(sListPath)
    	local sRecordType = savegetRecordTypeFromListPath(sListPath);
    	if sRecordType == "" and StringManager.startsWith(sListPath, "combattracker") then
    		local nodeCT = DB.findNode(sListPath);
    		if nodeCT then
    			sRecordType, _ = DB.getValue(nodeCT, "link", "npc", "");
    		end
    	end
    	return sRecordType; 
    end
    This is all because the npc/vehicle sheets have inventory tab from charsheet used in them which means I need to "trick" (as I've done for 3 years now) the ItemManager.getItemSourceType returns for npc/vehicle into thinking they are charsheet. Simple/safe and has worked for a very long time.

    Code:
     -- replaced ItemManager.getItemSourceType in order to support NPC inventory list
    function getItemSourceType(vNode)
    	--Debug.console(User.getUsername() .. "(" .. tostring(Session.IsHost) .. ") -> manager_mapparcel:getItemSourceType called");	
    
    	-- Call original code to see if it can resolve it - if not new npc inventory stuff
    	local sReturn = savegetItemSourceType(vNode);
    	if sReturn and sReturn ~= "" then
    		if sReturn == "npc" or sReturn == "vehicle" then
    			sReturn = "charsheet";
    		end
    	end
    
    	return sReturn;
    end
    (above code was simplified from LIVE as I don't think I needed all the additional checking now)

    However, I'm still working through currency and encumbrance issues for npc/vehicle. Map Parcels is designed to allow map parcel treasureparcels to be moved back and forth between charsheet (npc/vehicle) inventories, other treasureparcels, and partysheet inventories where the data is actually moved (not copied though a button in map parcels form can be toggled to allow copying). Many years has done wonders for parcels - just need to recover where I was after this TEST update. Currently I'm down to finding out why (with above fixes) the currencies are not working going back into treasureparcels (no field data so ends up adding a blank field for each currency entry with correct value - still works when currency moved into charsheet/npc/vehicle/partysheet inventories) and figuring out why encumberance for npc/vehicle is not working (not sure when it stopped working as its busted in LIVE also - used to work). Also as party sheet has a link I'd want to support that also (to get full support of moving inventory/currency between any charsheet/npc/vehicle/treasureparcel/partysheet inventory).

    Even with simple fixes like above it takes a lot of debug.console in different function in LIVE and TEST to figure out what has changed so may take a while before I solve the rest.
    Last edited by SilentRuin; July 21st, 2024 at 21:25.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  6. #36
    Well the mystery of why my npc/vehicle charsheet inventory tabs no longer do encumberance is solved. At some point in some past FGU update I missed the functions

    CharEncumbranceManager.enableCharCurrencyHandlers
    CharEncumbranceManager.disableCharCurrencyHandlers

    disappearing - which I overrode to support npc/vehicle inventory encumberances. Any idea what replaced them? This was not in this current TEST update FYI - they have been gone a while I suspect and never noticed.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  7. #37
    Quote Originally Posted by SilentRuin View Post
    Well the mystery of why my npc/vehicle charsheet inventory tabs no longer do encumberance is solved. At some point in some past FGU update I missed the functions

    CharEncumbranceManager.enableCharCurrencyHandlers
    CharEncumbranceManager.disableCharCurrencyHandlers

    disappearing - which I overrode to support npc/vehicle inventory encumberances. Any idea what replaced them? This was not in this current TEST update FYI - they have been gone a while I suspect and never noticed.
    CharEncumbranceManager.enableEncumbranceHandlers
    CharEncumbranceManager.disableEncumbranceHandlers

  8. #38
    Quote Originally Posted by rhagelstrom View Post
    CharEncumbranceManager.enableEncumbranceHandlers
    CharEncumbranceManager.disableEncumbranceHandlers
    Thanks.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  9. #39
    Bug in ItemManager.handleCurrencyTransfer.

    You have to check for treasureparcels and partysheet before you jump off into something else. The if statement is out of order. It should look like this, otherwise it will never process the proper db.xml tags...

    Code:
    -- insure combattracker entries can return record type
    function getRecordTypeFromListPath(sListPath)
    	local sRecordType = savegetRecordTypeFromListPath(sListPath);
    	if sRecordType == "" and StringManager.startsWith(sListPath, "combattracker") then
    		local nodeCT = DB.findNode(sListPath);
    		if nodeCT then
    			sRecordType, _ = DB.getValue(nodeCT, "link", "npc", "");
    		end
    	end
    	return sRecordType; 
    end
    
    function handleCurrencyTransfer(msgOOB)
    	local nodeTargetRecord = DB.findNode(msgOOB.sTarget);
    	if not nodeTargetRecord then
    		return;
    	end
    	
    	local nCurrency = tonumber(msgOOB.nCurrency) or 0;
    	local sCurrency = msgOOB.sCurrency;
    	Debug.console(nCurrency, sCurrency);
    	local sTargetRecordType = ItemManager.getItemSourceType(nodeTargetRecord);
    	Debug.console(sTargetRecordType);
    if sTargetRecordType == "treasureparcel" then
    		local nodeTargetCoin = nil;
    		local sCurrencyLower = sCurrency:lower();
    		for _,vParcelCoin in ipairs(DB.getChildList(nodeTargetRecord, "coinlist")) do
    			Debug.console(DB.getValue(vParcelCoin, "description", ""):lower());
    			Debug.console(sCurrencyLower);
    			if DB.getValue(vParcelCoin, "description", ""):lower() == sCurrencyLower then
    				nodeTargetCoin = vParcelCoin;
    				Debug.console(nodeTargetCoin);
    			end
    		end
    		Debug.console(nodeTargetCoin);
    		if not nodeTargetCoin  then
    			nodeTargetCoin = DB.createChild(DB.createChild(nodeTargetRecord, "coinlist"));
    			DB.setValue(nodeTargetCoin, "description", "string", sCurrency);
    		end
    		DB.setValue(nodeTargetCoin, "amount", "number", nCurrency + DB.getValue(nodeTargetCoin, "amount", 0));
    	elseif sTargetRecordType == "partysheet" then
    		local nodeCurrency = nil;
    		local sCurrencyLower = sCurrency:lower();
    		for _,vPSCurrency in ipairs(DB.getChildList("partysheet.treasureparcelcoinlist")) do
    			if DB.getValue(vPSCurrency, "description", ""):lower() == sCurrencyLower then
    				nodeCurrency = vPSCurrency;
    				break;
    			end
    		end
    		
    		if nodeCurrency then
    			DB.setValue(nodeCurrency, "amount", "number",  DB.getValue(nodeCurrency, "amount", 0) + nCurrency);
    		else
    			nodeCurrency = DB.createChild("partysheet.treasureparcelcoinlist");
    			DB.setValue(nodeCurrency, "description", "string", sCurrency);
    			DB.setValue(nodeCurrency, "amount", "number", nCurrency);
    		end
    	elseif ItemManager.doesRecordTypeHaveCurrency(sTargetRecordType) then
    		CurrencyManager.addActorCurrency(nodeTargetRecord, sCurrency, nCurrency);
    	end
    end
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  10. #40
    Quote Originally Posted by SilentRuin View Post
    Bug in ItemManager.handleCurrencyTransfer.

    You have to check for treasureparcels and partysheet before you jump off into something else. The if statement is out of order. It should look like this, otherwise it will never process the proper db.xml tags...

    Code:
    -- insure combattracker entries can return record type
    function getRecordTypeFromListPath(sListPath)
    	local sRecordType = savegetRecordTypeFromListPath(sListPath);
    	if sRecordType == "" and StringManager.startsWith(sListPath, "combattracker") then
    		local nodeCT = DB.findNode(sListPath);
    		if nodeCT then
    			sRecordType, _ = DB.getValue(nodeCT, "link", "npc", "");
    		end
    	end
    	return sRecordType; 
    end
    
    function handleCurrencyTransfer(msgOOB)
    	local nodeTargetRecord = DB.findNode(msgOOB.sTarget);
    	if not nodeTargetRecord then
    		return;
    	end
    	
    	local nCurrency = tonumber(msgOOB.nCurrency) or 0;
    	local sCurrency = msgOOB.sCurrency;
    	Debug.console(nCurrency, sCurrency);
    	local sTargetRecordType = ItemManager.getItemSourceType(nodeTargetRecord);
    	Debug.console(sTargetRecordType);
    if sTargetRecordType == "treasureparcel" then
    		local nodeTargetCoin = nil;
    		local sCurrencyLower = sCurrency:lower();
    		for _,vParcelCoin in ipairs(DB.getChildList(nodeTargetRecord, "coinlist")) do
    			Debug.console(DB.getValue(vParcelCoin, "description", ""):lower());
    			Debug.console(sCurrencyLower);
    			if DB.getValue(vParcelCoin, "description", ""):lower() == sCurrencyLower then
    				nodeTargetCoin = vParcelCoin;
    				Debug.console(nodeTargetCoin);
    			end
    		end
    		Debug.console(nodeTargetCoin);
    		if not nodeTargetCoin  then
    			nodeTargetCoin = DB.createChild(DB.createChild(nodeTargetRecord, "coinlist"));
    			DB.setValue(nodeTargetCoin, "description", "string", sCurrency);
    		end
    		DB.setValue(nodeTargetCoin, "amount", "number", nCurrency + DB.getValue(nodeTargetCoin, "amount", 0));
    	elseif sTargetRecordType == "partysheet" then
    		local nodeCurrency = nil;
    		local sCurrencyLower = sCurrency:lower();
    		for _,vPSCurrency in ipairs(DB.getChildList("partysheet.treasureparcelcoinlist")) do
    			if DB.getValue(vPSCurrency, "description", ""):lower() == sCurrencyLower then
    				nodeCurrency = vPSCurrency;
    				break;
    			end
    		end
    		
    		if nodeCurrency then
    			DB.setValue(nodeCurrency, "amount", "number",  DB.getValue(nodeCurrency, "amount", 0) + nCurrency);
    		else
    			nodeCurrency = DB.createChild("partysheet.treasureparcelcoinlist");
    			DB.setValue(nodeCurrency, "description", "string", sCurrency);
    			DB.setValue(nodeCurrency, "amount", "number", nCurrency);
    		end
    	elseif ItemManager.doesRecordTypeHaveCurrency(sTargetRecordType) then
    		CurrencyManager.addActorCurrency(nodeTargetRecord, sCurrency, nCurrency);
    	end
    end
    I have everything working now. But I REALLY REALLY don't want to have a hardcoded copy override of ItemManager.handleCurrencyTransfer just to correct this.
    I'm hoping for a fix here so I can delete this out of my TEST code.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

Page 4 of 7 First ... 23456 ... Last

Thread Information

Users Browsing this Thread

There are currently 4 users browsing this thread. (0 members and 4 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