PDA

View Full Version : PFRPG - Character Wealth Extension



WatBot2ndBrkfst
May 26th, 2020, 18:06
Removing due to uncertainty regarding OGL v1.1

FeatherRin
August 11th, 2020, 23:26
Since the first comment is mine, I will add the newest version I made here for easy access.

What's more in my version?
- Handles estimated item ranged prices such as: '101 - 500 gp'

Files:
1102 - My version, throws an error.
110 - Latest version patched by Cast.

FeatherRin
August 12th, 2020, 01:29
So I did this:

https://media.discordapp.net/attachments/720257249452228678/742902342382518463/nn.png

38504

I would post it but your license dosen't allow me. Let me know if you want it.

bmos
August 12th, 2020, 02:33
Wow, why didn't I notice this before 'wasting' my time building this into my inventory UI...
Honestly, I like your approach of posting it in chat much better.

WatBot2ndBrkfst
August 12th, 2020, 16:14
Hi FeatherRin,

Thank you for testing it with 5e. I don't use 5e, so I didn't test it for that ruleset.


I would post it but your license dosen't allow me. Let me know if you want it.

Yes. I can add it to the code if you are willing to share.

FeatherRin
August 12th, 2020, 16:28
My personal upgrades (Tested only in 5E)
-Removed fancy lines to fit the all command.
-Added "/charwealth all" catch, which outputs each pc's total item wealth and also the total party item wealth.
-Currently ignores all characters with 0 wealth even when solo checked, but you dont need it anyway. (I was too lazy to bother)

WatBot2ndBrkfst
August 12th, 2020, 20:23
Released v1.1.0
Updated extension with two arguments. One calculates wealth for characters only on the party sheet. The other calculates wealth for all players, including those not on the party sheet.
Added support for 5E ruleset as well

FeatherRin
August 13th, 2020, 01:07
Hey, its me again!
If you want player coins included as well, stick this in before nodeInventoryItems ;)


local nodeInventoryTreasure = DB.getChildren(nodeChar, "coins");

if nodeInventoryTreasure then -- If the inventory list is not nil --
for k, nodeCoin in pairs(nodeInventoryTreasure) do -- For every item in the inventory list --
local sCoinName = DB.getValue(nodeCoin, "name", ""):upper();
local sCoinAm = DB.getValue(nodeCoin, "amount", "");

if sCoinName == "GP" then
nRunningTotal = nRunningTotal + sCoinAm;
elseif sCoinName == "PP" then
nRunningTotal = nRunningTotal + sCoinAm * 10;
elseif sCoinName == "SP" then
nRunningTotal = nRunningTotal + sCoinAm * 0.1;
elseif sCoinName == "CP" then
nRunningTotal = nRunningTotal + sCoinAm * 0.01;
elseif sCoinName .. " " == " " then -- Don't spam for empty cells. --
--Nothing
else -- Currency is defined, but is not a standard currency --
sChatMessage = "" .. sCoinName .. ": Excluded. Non-standard currency used";
printChatMessage(sChatMessage);
end
end
end

Happy bodging!

ps: might as well credit me in the xml :p
pps: elifs break automatically, you dont need to break them.
ppps: i think everything is core func anyway, just set it to any and let people try it out without guarantee
pppps: no one uses electrum, dont even bother

FeatherRin
August 13th, 2020, 04:33
...also here's a "concat" to solve the '-' problems.

It grabs the second (highest) number of the two with minimal effort and no (extra) memory usage. At higher levels it's inaccurate, but at that point I doubt people care.

'101 - 500 gp' => '500 gp'
'10,000 - 50,000 gp' => '50,000 gp'



if string.match(sItemCost,"-") then
sItemCost = string.sub((string.match(string.reverse(sItemCost) , "(.+)%-")):reverse(), 2);
end



It has to go right before this part, otherwise it will mess up the conversion.


local aCostData = StringManager.split(sItemCost, " ", true);

FeatherRin
August 14th, 2020, 18:38
Here's the file for those who can't wait for WatBot2ndBrkfst and can't do it for themselves.
Added:
-Counts player money (coins/treasure) towards total.
-Support for estmated range prices such as '101 - 500 gp', uses higher number.

bmos
September 9th, 2020, 15:54
...also here's a "concat" to solve the '-' problemsMind if I steal this? I've just been skipping those items and 'complaining' about it in chat (https://github.com/bmos/FG-PFRPG-TotalEncumbrance/blob/40d73f7343a59f645ba7b8da24fd754f11bc15ac/scripts/inventory_cost.lua#L15).

FeatherRin
September 9th, 2020, 15:57
Mind if I steal this? I've just been skipping those items and 'complaining' about it in chat (https://github.com/bmos/FG-PFRPG-TotalEncumbrance/blob/40d73f7343a59f645ba7b8da24fd754f11bc15ac/scripts/inventory_cost.lua#L15).
The whole code is there and the whole file is included one comment below for reference. Feel free to use it as long as you credit me.

orien45
October 20th, 2020, 15:28
40354 What am I doing wrong? This is what I get when I attempt to /charwealth a character or party.

FeatherRin
October 20th, 2020, 15:55
is it my or Brkfast's version?

FeatherRin
October 20th, 2020, 15:57
I suspect you have a problem with your currencies not being properly set up, but this is not enough info to go deeper :)

orien45
October 20th, 2020, 16:14
is it my or Brkfast's version?

It looks to be breakfast

orien45
October 20th, 2020, 16:18
40356

Here is a shot of the character and extensions running

FeatherRin
October 20th, 2020, 16:27
Well, you seem to be running my version (1011).
For me it seems to run fine, but you can try running the original 1.0.1 instead.
Tell me if that works. If it does, its my fault and I will try to find out whats wrong with it.

FeatherRin
October 20th, 2020, 16:32
Ah, yes, I found it.
The '-' concat was just thrown together and is garbage. If an item price is not set up properly it throws and error.
Use 1.0.1 or fix the item prices of items manually for now.
'x - y gp' is the only way it accepts range prices.

orien45
October 20th, 2020, 16:37
Thank you for your answers. I will get 1.01, my 'programming' experience ended with Apple IIe.

FeatherRin
October 20th, 2020, 16:42
btw, does pathfiner use special item prices? like a-b gp or stuff?
Please write down what dosent conform to the current script in your inventory.
If its a range, it has took like this:
https://media.discordapp.net/attachments/472096865857568770/768136954692632626/unknown.png

orien45
October 20th, 2020, 16:47
btw, does pathfiner use special item prices? like a-b gp or stuff?
Please write down what dosent conform to the current script in your inventory.
If its a range, it has took like this:
https://media.discordapp.net/attachments/472096865857568770/768136954692632626/unknown.png

Just about anything I can think of just has one price - haggling or price variations are entirely up to GMs.

FeatherRin
October 20th, 2020, 16:50
Try checking prices of magical items in player inventory.
Some costs are broken by default.
If you find anything thats not a standard price eg (50,000 gp) or (100 - 1,000 gp) on the item prices, you can edit it manually there. Delete the costs lines, or change them to what you want.

orien45
October 20th, 2020, 16:54
Try checking prices of magical items in player inventory.
Some costs are broken by default.
If you find anything thats not a standard price eg (50,000 gp) or (100 - 1,000 gp) on the item prices, you can edit it manually there. Delete the costs lines, or change them to what you want.

FOUND IT! Thanks. The cost of a Sling was -

SO, note to others, check for items that have no cost, lol

FeatherRin
October 20th, 2020, 21:24
This is a small patch that fixes a crash related to my garbage concat.
Now it should ignore '-' containing strings that are too short to handle.
(anything too short is meaningless but was unhandled before)

celebrindal
December 16th, 2021, 21:51
The latest update is throwing an error when this extension loads. 4.1.12
The extension itself seems to be working it just generates this error on start.

Script execution error:[string "scripts/character_wealth.lua"]:12: attempt to call field 'registerLaunchMessage' (a nil value)

Castellanox7
December 31st, 2021, 21:27
Also Getting Cel's error, FeatherRin.

Castellanox7
March 4th, 2022, 16:26
The latest update is throwing an error when this extension loads. 4.1.12
The extension itself seems to be working it just generates this error on start.

Script execution error:[string "scripts/character_wealth.lua"]:12: attempt to call field 'registerLaunchMessage' (a nil value)

Cel,

I went ahead and fixed this by changing the extension to a .zip file, opening up the only file in the scripts folder in notepad, finding line 12 and removing:

ChatManager.registerLaunchMessage(msg);

Save the file, pop it back into the zip file, change it back to a .ext file, and it should run without an error.

Make sure you make a duplicate copy of the extension just in case.

celebrindal
March 4th, 2022, 20:58
Yup that did the trick, figured it would be something simple like that.

Thanks.

FeatherRin
March 4th, 2022, 21:28
Cel,

I went ahead and fixed this by changing the extension to a .zip file, opening up the only file in the scripts folder in notepad, finding line 12 and removing:

ChatManager.registerLaunchMessage(msg);

Save the file, pop it back into the zip file, change it back to a .ext file, and it should run without an error.

Make sure you make a duplicate copy of the extension just in case.

If you want, you can send the file here and I will put it into the first comment.

Castellanox7
March 5th, 2022, 04:10
I'm sure there's a more elegant way to actually use the announcements tag, but I'm not much of a programmer. See attached, Rin.

Thanks!
-Cast

bmos
March 5th, 2022, 11:58
There's also an xml tag you can put in extension.xml such as:

<announcement text="https://www.fantasygrounds.com/forums/showthread.php?58418-PFRPG-Character-Wealth-Extension\rCharacter Wealth Extension v1.1.0" font="emotefont" />
This will auto-post "Character Wealth Extension v1.1.0" in the chat when you load the extension and will make it a link to this thread.

Castellanox7
March 5th, 2022, 16:47
Thanks, BMOS!

I'm only a front-end developer on TV, so without spending some time studying the reference, removing it was the easiest way I knew.

Morenu
June 14th, 2022, 15:33
This looks promising.

Any chance it could default to gp if there is only a number and no gp? IOW if the item says 4000 instead of 4000 gp?

also, could we get this into forge?

Morenu
October 3rd, 2022, 16:53
User error - never mind