Log in

View Full Version : Issue: FGU Vision settings, sanity check



celestian
March 26th, 2021, 22:54
I am seeing this:



[3/26/2021 4:49:10 PM] [WARNING] buttoncontrol: Could not find normal icon () in control (toggle_unmask) in class (imagewindow_toolbar)
[3/26/2021 4:50:21 PM] [ERROR] Handler error: [string "scripts/manager_vision.lua"]:127: attempt to compare number with string
[3/26/2021 4:50:45 PM] [ERROR] Handler error: [string "scripts/manager_vision.lua"]:127: attempt to compare number with string


When in 5e, edit a vision and incorrectly setting the value to "Darkvision 0". I realize it shouldn't BE that but for some rulesets the value is evaluated immediately (5e is updated when you change focus) when the number is typed so if they backspace and then enter the right number during the backspace removal of the number the error pops up.

I submit that a check to validate the entry should be added and do nothing if NOT valid instead of causing a error popup.

Something like this might help.




function updateTokenVisionHelper(tokenCT, nodeCT)
...
-- Parse senses field
for _,vField in ipairs(VisionManager.getVisionFields()) do
local sSensesLower = DB.getValue(nodeCT, vField, ""):lower();
local tSenses = StringManager.split(sSensesLower, ",;\r", true);
for _,v in ipairs(tSenses) do
local nDistance = tonumber(v:match("(%d+)")) or 0;
VisionManager.addTokenVisionHelper(tokenCT, nodeCT, v, nDistance);
end
end
...



When I tested out the current:

VisionManager.addTokenVisionHelper(tokenCT, nodeCT, v, v:match("(%d+)"));

In addTokenVisionHelper() it was showing nDistance as string "1", not 1 for a senses value of "Blindsight 1".