PDA

View Full Version : extracting data from a character node reference



jkeller
October 11th, 2025, 18:33
Can anyone help me display the fields in a character node?

I can iterate through the characters using:

local rAllChars = DB.getChildList("charsheet");
for _,refChar in ipairs(rAllChars) do
...
end

And I can get data out of the reference using functions like:

local sCharName = DB.getValue(refChar, "name", "");

But I'm not sure what other fields I can get. Is there any documentation or debug function to display the fields?

Thanks!

superteddy57
October 11th, 2025, 18:50
No, there is no documentation as each ruleset would provide their own fields. You can open the db.xml of any campaign to see the nodes that get created and check any of the ruleset files like record_char_*.xml for specifics.

RosenMcStern
October 11th, 2025, 19:26
Or, if you do not feel heroic enough to open db.xml with UltraEdit or Notepad++, as our wise Superteddy suggested, you can use Debug to explore the node:




for _, refChar in ipairs(DB.getChildList("charsheet")) do
for name, ref in pairs(refChar.getChildren()) do
Debug.print(name..": "..DB.getType(ref));
end
end


Careful with pairs and ipairs, huh.

jkeller
October 11th, 2025, 21:31
Thank you both! I think that will provide what I need.

jkeller
October 13th, 2025, 01:56
I'm using ChatManager.registerReceiveMessageCallback to check chat messages. In the chat window, the message shows the dice roll. But I don't see that information in the rMessage structure sent to my callback. I see that "hasdice" is true. Is there any way I can get the roll too? Perhaps with a different callback?

Thanks!

RosenMcStern
October 13th, 2025, 09:59
I have a feeling that you posted this on the wrong thread...

Anyway, the best way to handle this is to intercept the roll, and not the message. You could use ActionManager.registerPostRollHandler() or ActionManager.registerResultHandler(). These install a callback that receives the roll as a parameter. In the postrollhandler you have to modify the die roll so that the message is altered (and thus it could not be useful in your case, as it would still only handle one message). In the resulthandler you generate and send the chat message, and here you could send two different messages to host and clients. Examples found in the 5E ruleset.

ATTENTION: the callback is connected to the roll type (attack, damage, etc) so if there is already one installed you will overwrite it.

jkeller
October 13th, 2025, 14:50
Thank you for the guidance!

For the extension I'm working on now, I don't really want to "handle" or change the roll - I just want access to the data so I can log it.

I certainly don't want to overwrite any existing handler(s).

Is there a way I can capture the current handler (if any), and call it in my handler? Or return false to let it continue processing (like I would for handleChatMessage)?
What's the best practice for overriding or installing a handler?

Something like this:



ActionSkill_onRoll = ActionSkill.onRoll;

function onRoll(rSource, rTarget, rRoll)
-- do my stuff here
if (ActionSkill_onRoll) then
ActionSkill_onRoll(rSource, rTarget, rRoll); -- call super
end
return false;
end


I tried that, and it *seemed* to work (at least, I still see the roll result in the chat window).

RosenMcStern
October 13th, 2025, 18:27
This is one approach, and it is certainly valid. However, these handlers are central to many things, so it is useful for you to learn how to use them. Probably not essential for an extension, but fundamental for a ruleset.