View Single Post
09-08-23, 10:29 PM   #1
Nyyght
A Defias Bandit
 
Nyyght's Avatar
Join Date: Sep 2023
Posts: 3
Making a Handynotes plugin - Cannot get function to return a value in one part.

Hello! I recently started learning to script LUA, so please forgive me if this is a simple fix/newb question. I have been searching all over the internet for almost a week and I am finally ready to admit defeat and request help from people who actually know what they're doing. Thank you in advance for your time!

My issue is that I've made several functions that all return a value which work in my other functions and even the tooltip function of my script. However, when I try to pull any functions into the the custom iterator function it keeps returning nil. Everything I try to plug in returns nil--even though it displays everywhere else fine. I'm not sure where I'm going wrong.

Here is the function I am trying to call my icon from. It works as intended when I pull it into the tooltip function. The "task_id" section decides if the achievement or quest is completed and if it is it returns "skipme", if not, it returns the criteria id or quest id.

local get_the_best_icon = function(uiMapId, coord, task_id)
local point = points[uiMapId] and points[uiMapId][coord]
if point then
local relevant_icon = point["icon_type"]
local completed_icon = "complete.tga"
local folder_dir = "Interface/AddOns/HandyNotes_EfficientSee/Icons/"

if task_id == "skipme" then
local show_icon = folder_dir..completed_icon
return show_icon
else
local show_icon = folder_dir..relevant_icon
return show_icon
end
return show_icon
end
end


Here is the part I cannot, for the life of me, get to work. This is the custom iterator and I am trying to get it to pull the icon from the get_the_best_icon function (for completed or not) to be shown for each node. All my attempts show nil here, even when working in other functions within the script.
do
local function iter(t, prestate)

if not t then return nil end
local state, value = next(t, prestate)
while state do

if value then

local icon = get_the_best_icon(value[1])
Debug("iter step", state, icon, db.icon_scale, db.icon_alpha)
return state, nil, icon, db.icon_scale, db.icon_alpha

end
state, value = next(t, state) -- Get next data
end
return nil, nil, nil, nil
end

function HLHandler:GetNodes2(uiMapId, minimap)
return iter, points[uiMapId], nil
end
end

Again, thank you so much for your time!
  Reply With Quote