Saagael
October 9th, 2021, 19:49
The D&D 5e character wizard is throwing errors when there's an extension loaded that modifies DataCommon.abilities and DataCommon.ability_ltos. Specifically I've hit errors on lines 151, and 1050 of charwizard.lua, as well as line 12 of charwizard_abilities.lua, but there might be more in there.
The issue on line 151 is that the block below iterates on DataCommon.ability_ltos (which has extra entries from the extension), and then inside the loop it tries to index summary.subwindow by the value from DataCommon.ability_ltos. Summary.subwindow does not have extra entries in it for the new abilities (because why would it, we don't care about the new stats for character building), so it throws an 'attempt to index field (a nil value)' errors.
for k,v in pairs(DataCommon.ability_ltos) do
if summary.subwindow then
summary.subwindow["summary_race_" .. string.lower(v)].setValue(CampaignRegistry.charwizard.race.abiliti es[v]);
end
end
One possible solution for this issue would be to add an extra check on the if statement, like such:
if summary.subwindow and summary.subwindow["summary_race_" .. string.lower(v)] then
The above error also appears on line 1050 of charwizard.lua, and the onInit function of charwizard_abilities.lua. There are attempt to index subwindows by abilities in the abilities arrays. I was able to fix the errors by adding if statements checking to see if the subwindow exists (as in the example code above).
The issue on line 151 is that the block below iterates on DataCommon.ability_ltos (which has extra entries from the extension), and then inside the loop it tries to index summary.subwindow by the value from DataCommon.ability_ltos. Summary.subwindow does not have extra entries in it for the new abilities (because why would it, we don't care about the new stats for character building), so it throws an 'attempt to index field (a nil value)' errors.
for k,v in pairs(DataCommon.ability_ltos) do
if summary.subwindow then
summary.subwindow["summary_race_" .. string.lower(v)].setValue(CampaignRegistry.charwizard.race.abiliti es[v]);
end
end
One possible solution for this issue would be to add an extra check on the if statement, like such:
if summary.subwindow and summary.subwindow["summary_race_" .. string.lower(v)] then
The above error also appears on line 1050 of charwizard.lua, and the onInit function of charwizard_abilities.lua. There are attempt to index subwindows by abilities in the abilities arrays. I was able to fix the errors by adding if statements checking to see if the subwindow exists (as in the example code above).