Xacus / demonlord

Shadow of the Demonlord for FoundryVTT.
28 stars 22 forks source link

How to get dice chat data #115

Closed jacobwojoski closed 1 year ago

jacobwojoski commented 1 year ago

I was asked to add support of my mod dice-stats and was wondering how you post the chat msg's?

It seems like they're not posted as roll data objects like most systems. I can't seem to even view the roll data anywhere in the msg object. The rolls arrays are empty (Chatmessage.rolls) (View image at bottom)

All I can see is the raw html of the msg.context property.

I was wondering if there was any other way to get the data besides parsing the context as getting the die-type and value would be very difficult

Is there a hook or something that I dont know about that could be used?

image

juanferrer commented 1 year ago

The code currently does not pass the roll data to the chatMessage. I don't think there is a specific reason why that is the case, but I will find out if we can support it. Would you expect a Roll to be in the chatMessage.rolls array? Something like this: image

jacobwojoski commented 1 year ago

Normally if you roll you would get a chat msg that has info like this (This was retrieved by rolling /r 20d20 in chat in shadow of the demon lord) image

If I was to roll strength in your system is doesn't set msg type to a roll (msg.isRoll returns false unlike if you do a /r 1d20 normally msg.isRoll returns true)

Looks like when you roll something is just makes an HTML section in the ChatMsg.content area rather then populating the msg.rolls[] like most systems do.

Not a system developer so wish I could be more help as to why. Its nbd Was just asked to add the mod and found this issue when looking into it. Its possible for me to get it working by doing some text parsing in the chatMsg.content area but much harder as if you were to ever change the HTML it would break it.

juanferrer commented 1 year ago

No, I agree that it should be populating those fields. I'll put the necessary changes in a PR and update when it's merged.

To confirm:

  1. Set type to "roll"
  2. Add Roll to chatMessage.rolls
doctorthoss commented 1 year ago

The code currently does not pass the roll data to the chatMessage. I don't think there is a specific reason why that is the case, but I will find out if we can support it. Would you expect a Roll to be in the chatMessage.rolls array? Something like this: image

could this have something to do with the compatibility issues with Dice so Nice? (https://gitlab.com/riccisi/foundryvtt-dice-so-nice/-/issues/367)

jacobwojoski commented 1 year ago

Dice Stats works with Dice So Nice on both PF2e and D&D but this most certainly can be be related to why dice so nice isn't working correctly with the system.

doctorthoss commented 1 year ago

The code currently does not pass the roll data to the chatMessage. I don't think there is a specific reason why that is the case, but I will find out if we can support it. Would you expect a Roll to be in the chatMessage.rolls array? Something like this: image

If this is something the system could be modified to support it would probably fix multiple compatibility issues, I think there a few other modules that don't work wright with SotDL because of this. Not sure if this is helpful but I opened a separate issue for this here: https://github.com/Xacus/demonlord/issues/118

juanferrer commented 1 year ago

@jacobwojoski I just tested with v2.2.5 and was able to retrieve rolls from attributes and weapons. If you are able to confirm this is fixed, we can close the issue.

doctorthoss commented 1 year ago

@juanferrer unfortunately this didn't fix the issue with Dice so Nice where you can only see other player's rolls if they use the roll table (i.e. you don't see them if they do a challenge roll, weapon attack, etc). Was hoping that was related but I guess it's some other weird thing

juanferrer commented 1 year ago

Ah, yeah. I didn't test DSN, only DiceStats. We'll have to investigate.

doctorthoss commented 1 year ago

Ah, yeah. I didn't test DSN, only DiceStats. We'll have to investigate.

I made a post for it on the DSN gitlab but haven't heard anything over there yet https://gitlab.com/riccisi/foundryvtt-dice-so-nice/-/issues/367