Thread Tools Display Modes
02-04-18, 05:42 PM   #1
kaimox
A Fallenroot Satyr
Join Date: Jun 2008
Posts: 25
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>
  Reply With Quote
02-04-18, 06:18 PM   #2
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
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
__________________
  Reply With Quote
02-04-18, 06:46 PM   #3
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
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.
  Reply With Quote
02-05-18, 03:01 AM   #4
kaimox
A Fallenroot Satyr
Join Date: Jun 2008
Posts: 25
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)

Last edited by kaimox : 02-05-18 at 06:22 AM.
  Reply With Quote
02-05-18, 03:08 AM   #5
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
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.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
02-05-18, 04:22 AM   #6
kaimox
A Fallenroot Satyr
Join Date: Jun 2008
Posts: 25
Originally Posted by Lombra View Post
Well f in this case is a variable ...
Yes that's what I thought, but there was no definition of f.

Originally Posted by Lombra View Post
... 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?

Last edited by kaimox : 02-05-18 at 06:21 AM.
  Reply With Quote
02-05-18, 01:48 PM   #7
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
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.
  Reply With Quote
02-05-18, 02:02 PM   #8
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
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.)

Last edited by Ammako : 02-05-18 at 02:05 PM.
  Reply With Quote
02-13-18, 05:08 PM   #9
kaimox
A Fallenroot Satyr
Join Date: Jun 2008
Posts: 25
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.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » attempt to index local 'f' (a nil value)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off