Armor widget crash


#1
[f=0023174] [widgets.lua] Error: false
[f=0023174] [widgets.lua] Error: Error in DrawScreen(): [string "LuaUI/Widgets/gui_s44_armor.lua"]:238: attempt to perform arithmetic on local 'tx' (a nil value)
[f=0023174] [widgets.lua] Error: Removed widget: 1944 Armor Display

There was nothing particularly unnatural happening at the time.

Looking at the code, it means this part produced a nil:

				if mouseTargetType == "unit" then
					tx, ty, tz = GetUnitPosition(mouseTarget)
				elseif mouseTargetType == "feature" then
					tx, ty, tz = GetFeaturePosition(mouseTarget)
				elseif mouseTargetType == "ground" then
					tx, ty, tz = mouseTarget[1], mouseTarget[2], mouseTarget[3]
				else
					return
				end

#2

Hmm don’t see how it can happen!

Seems unlikely for featureID or unitID to become nil during a draw frame

And ground positions already return for out of bounds coords.

IMO a bandaid is best;

if not (tx and ty and tz) then return end

Unless you can determine how to reproduce it.