View Full Version : Issue getting data from CT entry.
celestian
July 17th, 2022, 21:04
I've an issue when PCs attack a target in the CT and the AC value is not able to be read by them.
nDefense = DB.getValue(nodeDefender, "ac");
Debug.console("manager_actor_adnd.lua getDefenseValue XXX 1",nodeDefender,nDefense);
Output
[7/17/2022 2:53:22 PM] s'manager_actor_adnd.lua getDefenseValue XXX 1' | databasenode = { combattracker.list.id-00002 } | nil
Here is the snippet of the combattracker.list.
https://i.imgur.com/90KXoQ5.png
As you can see it should be able to get the AC from the record (it exists) but it comes back nil.
When the DM runs the exact same thing (attacks the npc from the character sheet) it works.
I don't have this issue with any other field. PCs can get name/etc from the ct record w/o issue, but getting the ac returns null if the ac is 0 as player. Once the DM has run a action against the NPC it works fine.
Moon Wizard
July 18th, 2022, 06:57
It's because the default value is zero; which means that the data is never sent to the client because it's the default value.
Just use DB.getValue(nodeDefender, "ac", 0);
Otherwise, you will need to set the variable twice (such as, 10 then 0) to force the data to be sent to the player.
Regards,
JPG
celestian
July 18th, 2022, 06:59
It's because the default value is zero; which means that the data is never sent to the client because it's the default value.
Just use DB.getValue(nodeDefender, "ac", 0);
Otherwise, you will need to set the variable twice (such as, 10 then 0) to force the data to be sent to the player.
Regards,
JPG
The problem is 0 is a valid ac and if there is no AC set the default would be 10. I HAD it set to 10 but when the AC is 0 then it sets it to 10 ;( I mean I can set the default to 0 if it's null but... it would seem logical that the API should be smart enough to know it's a 0, not null.
Moon Wizard
July 18th, 2022, 07:01
That's fine that zero is a valid AC; just put whatever the default value should be if the CT entry data doesn't exist. The only reason the value would not get sent is if it is zero.
Regards,
JPG
celestian
July 18th, 2022, 07:22
That's fine that zero is a valid AC; just put whatever the default value should be if the CT entry data doesn't exist. The only reason the value would not get sent is if it is zero.
Regards,
JPG
Thats the problem. 10 is default ac if no ac is set. When it's set to 0 it sets it to 10.... Just to be clear, incase this is a version understanding, AC 0 is like AC 20 for 5e. I can have AC -10 to 10
Moon Wizard
July 18th, 2022, 07:25
Then, why wouldn't the value in the CT entry be something other than zero, if the default is 10? If I understand correctly, this only happens when AC is set to zero.
When the data is copied, it doesn't get sent if it's the default value, so you have to assume the default value "of the field type" (i.e. zero for numbers), not the default value "of the game".
Regards,
JPG
celestian
July 18th, 2022, 07:42
Then, why wouldn't the value in the CT entry be something other than zero, if the default is 10? If I understand correctly, this only happens when AC is set to zero.
When the data is copied, it doesn't get sent if it's the default value, so you have to assume the default value "of the field type" (i.e. zero for numbers), not the default value "of the game".
Regards,
JPG
If the DM didn't set the AC (or removes the setting), it would be null. Currently if the AC is set to 0 is also is null for players. Currently when you make a new NPC if the DB.getValue(nodeDefender, "ac",10); is set like that it will have AC 10 as default... but I dont block them somehow from changing or removing it after that fact. If I set that to DB.getValue(nodeDefender, "ac",0); the value will be 0 (which really shouldn't be the default and I can't say well if it's 0 then set it to 10 because you CAN have AC 0).
If the API is going to persist with the behavior I have 2 options, have it set it to 10 if it's null and it'll mess up when it's actually AC 0... or have it default to AC 0 if it's not set at all. I'll probably change it to the latter as that will probably lead to less support/confusion than default "10".
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.