PDA

View Full Version : [5E] init rolled?



jkeller
December 11th, 2025, 20:03
In 5E, is there any (programmatic) way to tell if a PC has rolled initiative if it's blank/0?

I can detect when they roll, but they may have rolled in a previous session.

The DB.getValue(nodeCT, "initresult", 0) call returns 0 if they have not rolled, or if they rolled 0. I thought the 3rd parameter might be a default, but that doesn't seem to be the case.

Moon Wizard
December 11th, 2025, 20:05
The third parameter is the default value (if the database value does not exist); but that's also the default value for any numerical database value.

There's no mechanism to determine whether initiative is just zero; or was rolled a zero. It's usually not an issue in most situations, since very few creatures and PCs have negative Dex modifier.

Regards,
JPG

jkeller
December 11th, 2025, 20:19
Thanks. I tried using -1 as the 3rd param, but it returns 0 whether they rolled or not.

It's certainly not an important issue; I'm developing an extension that tries to detect "achievements", and have some related to the initiatives. I'll just assume they have not rolled yet if any are 0.

Moon Wizard
December 11th, 2025, 22:37
By default, the database value is automatically created when the CT entry is created and the init field instantiates, and the default value for a numerical database value is zero. So, it's always going to be zero, unless set to something else. When initiative is reset, it just changes all the initiatives to zero.

The third parameter only returns if the database value does not exist at all.

Regards,
JPG