WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   attempt to index local 'f' (a nil value) (https://www.wowinterface.com/forums/showthread.php?t=56016)

kaimox 02-04-18 05:42 PM

attempt to index local 'f' (a nil value)
 
I have this function in my personal addon which worked until before Legion but it seems that Blizz changed something. Since the error message is kind of generic a search turned up nothing. I'm not really a coder, I just fumble around, so if someone could help me out ...

local function Hide(f)
f:SetScript('OnShow', f.Hide)
f:Hide()
end

Also I have some key bindings defined and I'm too stupid to find out which is the key binding name for lfg groups.
This one just works for manually created groups:

<Binding name="Party" >
ChatFrame_OpenChat("/p");
</Binding>

MunkDev 02-04-18 06:18 PM

The path of least resistance.
Lua Code:
  1. local function Hide(f)
  2.     if f then
  3.         f:SetScript('OnShow', f.Hide)
  4.         f:Hide()
  5.     end
  6. end

Kanegasi 02-04-18 06:46 PM

What MunkDev provided will prevent the error, but that's all anyone can do for you with what you provided. We need to know what is using Hide() and what f is supposed to be if you want to dig deeper and find out why f is nil. There is nothing wrong with the function as seen here.

As for any queue groups, the chat is called "Instance" and uses /i to activate.

kaimox 02-05-18 03:01 AM

Thank you for answering.

I'm attempting to hide (MiniMapMailFrame,VehicleSeatIndicator) and move (BuffFrame) various stuff from the UI

... edited because obsolete - forget about the "f"-stuff.

The old simple way works again after another UI reset. Code now looks like this (I edited this for clarity in case somebody else has similar problems):

Code:

MainMenuBarLeftEndCap:Hide()
MainMenuBarRightEndCap:Hide()
MiniMapMailFrame:SetScript("OnEvent", nil)
MiniMapMailFrame:UnregisterAllEvents()
MiniMapMailFrame:Hide()
VehicleSeatIndicator:SetScript("OnEvent", nil)
VehicleSeatIndicator:UnregisterAllEvents()
VehicleSeatIndicator:Hide() 
BuffFrame:ClearAllPoints()
BuffFrame:SetPoint("CENTER",UIParent,"CENTER",0,0)
BuffFrame.SetPoint = function() end
BuffFrame:SetScale(1.3)     
ObjectiveTrackerFrame:ClearAllPoints()
ObjectiveTrackerFrame:SetScale(1.2)
ObjectiveTrackerFrame:SetPoint("TOPRIGHT",MinimapCluster,"BOTTOMRIGHT",0,50)
ObjectiveTrackerFrame:SetWidth(MinimapCluster:GetWidth() * 2)


Lombra 02-05-18 03:08 AM

Well f in this case is a variable and no offence, but are you sure you should be trying to fix this considering you have to ask that? :P The function Hide is being called somewhere with a nil argument, where it's expecting a frame. Look for references to Hide.

kaimox 02-05-18 04:22 AM

Quote:

Originally Posted by Lombra (Post 326740)
Well f in this case is a variable ...

Yes that's what I thought, but there was no definition of f.

Quote:

Originally Posted by Lombra (Post 326740)
... and no offence, but are you sure you should be trying to fix this considering you have to ask that? :P

I'm debugging my own private addon with very simple code, just keybindings and some Hide() and SetPoint(), that stopped working with legion. That's why I was fiddling with more complicated stuff which shouldn't even be necessary.

Edit: I did another complete UI reset and the simple stuff works again - without "f" and any of the complicated things I tried out of desperation. Now onto the hunt what was interfering ...

Only remaining problem is that the hidden VehicleSeatIndicator is still somehow in the way. Whenever a passenger mount is used the resized ObjectiveTrackerFrame moves left ... Any tips on that?

semlar 02-05-18 01:48 PM

Read the Lua Basics section from this post, and consider clicking through the introduction section of the lua manual, because if you don't understand how a variable gets passed to a function then you are going to be in for a bad time trying to program an addon.

Ammako 02-05-18 02:02 PM

I'd also probably recommend HookScript over SetScript.

Setting OnEvent script to nil is also redundant if you're unregistering all events from the frame anyway (and depending on the frame, could just taint.)

kaimox 02-13-18 05:08 PM

Thank you for your answers. I followed the wrong track with my original question and solved the problem once I realized that. I will do the RTFM work that you recommended.


All times are GMT -6. The time now is 06:44 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI