PDA

View Full Version : How to monitor quantity changes?



Varsuuk
April 25th, 2021, 05:56
I had originally only a handler for onUpdate. I realized that dragging an item to inventory would call on Update if it was a new item but not call update if it was simply increasing the quantity.


DB.addHandler(DB.getPath(node, ".inventorylist.*.carried"), "onUpdate",
onCarriedChanged)


What is the event for changing the entry number?

Tried a few of these:


DB.addHandler(DB.getPath(node, ".inventorylist.*.carried"), "onObserverUpdate",
onObserverUpdate)

DB.addHandler(DB.getPath(node, ".inventorylist.*.carried"), "onChildUpdate",
onChildUpdate)

DB.addHandler(DB.getPath(node, ".inventorylist.*.carried"), "onIntegrityChange",
onIntegrityChange)

Moon Wizard
April 25th, 2021, 06:24
The "carried" field specifically tracks 0=not carried, 1 = carried, 2 = equipped

If you want quantity, you probably want to watch the "count" field.

Regards,
JPG

Varsuuk
April 25th, 2021, 06:44
I'm sorry, I totally vegged out there.

I actually was only interested in weight so I moved on tracking encumbrance.load but having READ "carried" as "carriedWeight" in my head (don't ask...) I figured Id ask to understand. I got it, oops.

(I coppie the carried handler to start off my work - that handler was indeed for tracking if was equipped or not in my code)


Thanks much as always.

YAKO SOMEDAKY
April 25th, 2021, 13:08
Varsuuk, I am curious to know what you plan with this.
I confess that I would not be sad if this could have a link between things on the combat tab and the inventory.
For example, in the combat tab, I can easily create an extension manager, but I cannot create a link between it and the rations, which would be consumed there would decrease in quantity and thus decrease the load of the characters.

Varsuuk
April 25th, 2021, 16:05
I’m just using it to determine movement rate for the sheet. In my game it is a function of just race and weight.

If you want to have rations updated live on CT - I’m no expert and haven’t looked at this but wouldn’t it be easy to create a rations (set vs items entry) field to use as source for a link field to CT then it would update as rations were consumed much like HP.

But I might be totally wrong or not understand what you were looking to do.