Go to Page... |
Thread Tools | Display Modes |
09-08-23, 10:29 PM | #1 |
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! |
|
![]() |
09-08-23, 11:39 PM | #2 |
In the iterator you:
Lua Code:
In the get_the_best_icon function you Lua Code:
From this (unless there's something unknown not present in the code shown), it appears you're only ever passing the uiMapId arg to the function and never the coord (or task_id). If you haven't installed them yet, I would recommend BugGrabber and Bugsack (they work together) to help with debugging.
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 09-08-23 at 11:58 PM. |
|
![]() |
09-09-23, 03:32 AM | #3 | |
Thank you for the assistance!
I've downloaded the two debuggers you recommended and they have caught a few errors that usually didn't show. Unfortunately, I am still facing issues getting my icon function to show inside that iter function. It's really strange because I'm able to call functions into other sections (like the tooltips). I've even called the icon into the tooltips. The tooltips are only showing for uncompleted tasks (as intended) but the icons don't show unless I add a single static link/folder. Meaning the icons are all or nothing. Sorry about my formatting the first time. This is my first post here. I'm including the rest of the LUA, minus the initializing code, with a few entries of the data to show how I've set things up. I know I'm doing something wrong, but it's driving me up a wall that things seem to work everywhere except the iter function--even if I try to call uiMapId, coord, and task_id with the t and prestate. Lua Code:
|
||
![]() |
09-09-23, 12:22 PM | #4 |
I don't use HandyNotes so I don't know all the ins-n-outs.
The iterator is cycling through your points table for the current map id. (23 [EPL] in the table in your code). for each successful Code:
next(...) To work the function would look more like: Lua Code:
If the function is being used elsewhere you would use something like Lua Code:
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 09-09-23 at 05:19 PM. |
|
![]() |
09-09-23, 11:07 PM | #5 | |
![]()
It took me a little more tinkering around, but I finally got it to work thanks to your direction! I am more grateful for you taking the time to help me than I can properly express! ![]() |
||
![]() |
WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Making a Handynotes plugin - Cannot get function to return a value in one part. |
«
Previous Thread
|
Next Thread
»
|
Thread Tools | |
Display Modes | |
|
|