Thread Tools Display Modes
08-28-21, 11:54 PM   #1
Googles
A Murloc Raider
 
Googles's Avatar
AddOn Compiler - Click to view compilations
Join Date: Mar 2007
Posts: 6
Need help in how to write this simple script to lua

Hello.

So basically I have this script in a macro that I have to click everytime I logon. I just want help writing it in an .lua file so it automatically activates on logon. I have tried reading a few guides but could not get it to work.

The script is
  • /run C_NamePlate.SetNamePlateFriendlySize(60, 60)

I have made an addon with a .toc and everything but I'm not sure what to write exactly in the .lua file for the code to work properly. I have tried
  • C_NamePlate.SetNamePlateFriendlySize(60, 60)
  • SetNamePlateFriendlySize(60, 60)
  • local EventFrame = CreateFrame("Frame")
    EventFrame:RegisterEvent("PLAYER_LOGIN")
    EventFrame:SetScript("OnEvent", function(self,event,...)
    C_NamePlate.SetNamePlateFriendlySize(60, 60)
    end)

But none of them seemed to work for me. I have absolutely zero knowledge in coding and I've tried reading a few guides but with no success. If anyone can help I'd be thankful. Cheers
__________________
  Reply With Quote
08-29-21, 03:54 AM   #2
briskman3000
A Flamescale Wyrmkin
 
briskman3000's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 108
In your addon file, you would need to create a function that has that script inside of it, and then trigger than function to run on player login.

Something similar to this should work

Lua Code:
  1. local setnameplateframe = CreateFrame("Frame", setnameplateframe)
  2.  
  3. local function setnameplatesize(self, event, ...)
  4.      C_NamePlate.SetNamePlateFriendlySize(60, 60)
  5. end
  6.  
  7. setnameplateframe:RegisterEvent("PLAYER_LOGIN")
  8. setnameplateframe:SetScript("OnEvent", setnameplatesize)

I have not tested this code and can not guarantee that it works.
__________________
My Addons: Convert Ratings Honor Track
  Reply With Quote
08-29-21, 06:42 AM   #3
Googles
A Murloc Raider
 
Googles's Avatar
AddOn Compiler - Click to view compilations
Join Date: Mar 2007
Posts: 6
Originally Posted by briskman3000 View Post
In your addon file, you would need to create a function that has that script inside of it, and then trigger than function to run on player login.

Something similar to this should work

Lua Code:
  1. local setnameplateframe = CreateFrame("Frame", setnameplateframe)
  2.  
  3. local function setnameplatesize(self, event, ...)
  4.      C_NamePlate.SetNamePlateFriendlySize(60, 60)
  5. end
  6.  
  7. setnameplateframe:RegisterEvent("PLAYER_LOGIN")
  8. setnameplateframe:SetScript("OnEvent", setnameplatesize)

I have not tested this code and can not guarantee that it works.
Worked perfectly thanks a lot!
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help in how to write this simple script to lua

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