Hey developers,
I got a problem with a source code.
Inside my function I use the :GetName() ESO LUA function to get the name of a control.
The name is stored inside the local (only known inside my function) variable "
equipmentMarkerControlName"
I'll then determine the digits at the end of the string and remove them.
This works without any problems and the variable will store the new string afterwards, without trailing digits. I know there might be simpler ways to strip the trailing digits in this string but I'm not really well in using RegEx :-(
Afterwards I will use a loop to read an array (markedIcons) and if the iconid from the array differs from a function's parameter (markerId) I try to write the variable "equipmentMarkerControlName" to the chat again.
But it is NIL again here all of sudden? Why?
Lua Code:
--Are we adding a tooltip to an equipment slot?
if pUpdateAllEquipmentTooltips then
--Get current controls name
local equipmentMarkerControlName = markerControl:GetName()
--Get the offset for the ending digit(s)
local replaceEnd = string.len(equipmentMarkerControlName) - locVars.gFCOMaxDigitsForIcons -- locVars.gFCOMaxDigitsForIcons = 1
--Remove the ending number
equipmentMarkerControlName = string.sub(equipmentMarkerControlName, 1, replaceEnd)
d("name: " .. equipmentMarkerControlName)
end
--Check if the item is marked with several icons
local markedIcons = {}
local bagId, slotIndex = MyGetItemDetails(markerControl:GetParent())
_, markedIcons = FCOIsMarked(GetItemInstanceId(bagId, slotIndex), -1)
for iconId, iconIsMarked in pairs(markedIcons) do
if iconIsMarked then
markedCounter = markedCounter + 1
if markedCounter > 1 then
--The variable will be NIL inside this FOR loop, but why?
if iconId ~= markerId and pUpdateAllEquipmentTooltips then
if equipmentMarkerControlName ~= "" then
d("bla: " .. tostring(equipmentMarkerControlName))
else
d("blubb")
end
end
end
end
Chat output will be:
Lua Code:
name: ZO_CharacterEquipmentSlotsRing2FCOIS
bla: nil
bla: nil
The function will be called once!
For the given example the loop at array "markedIcons" generated 2 chat output rows, because iconIsMarked was true 2 times.
I can't see why this variable is NIL. It should contain the string ZO_CharacterEquipmentSlotsRing2FCOIS :-(
If I declare the variable "equipmentMarkerControlName" as global it works all of sudden.
But why do I have to declare a variable global which I'm using locally inside the same function???
Is is because I'm using a global function (FCOIsMarked(...)) inside my function? I don't think so...
Thanks for your help.