WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   How can i make this load with the game? (https://www.wowinterface.com/forums/showthread.php?t=16235)

Vayder 05-09-08 03:41 PM

How can i make this load with the game?
 
i would like to make this load automatically with the game

/script MainMenuBarLeftEndCap:Hide() MainMenuBarRightEndCap:Hide()

Sepioth 05-09-08 04:17 PM

There is an addon over at WoWAce to do this...

Alar Art Remover

Everglow 05-09-08 05:47 PM

Quote:

Originally Posted by Vayder (Post 90643)
i would like to make this load automatically with the game

/script MainMenuBarLeftEndCap:Hide() MainMenuBarRightEndCap:Hide()

All you have to do is find a mod that you already have that registers the "PLAYER_ENTERING_WORLD" event. just add your command to the part of the adoon's OnEvent function that handles that event (remove the "/script" from the front)

Vayder 05-09-08 08:09 PM

Ok, I am not a coder so this might look/sound funny to some of you. but after some reading ive come up with this

function grifremove:PLAYER_ENTERING_WORLD()
MainMenuBarLeftEndCap:Hide() MainMenuBarRightEndCap:Hide()
end

but it doesnt work. basically i have just this line in a lua file in a folder in my addons. it shows the addon in my list but when i login it doesnt remove the gryphons. i really wanna make this work as opposed to downloading another mod for this one simple function. any help is greatly appericiated.

rodrick 05-09-08 09:14 PM

you will need to add the line you used in a macro (minus the /script part. Ie. MainMenuBarLeftEndCap:Hide() MainMenuBarRightEndCap:Hide()) to an addon already registered for the event, a new addon, or register the addon you added the lines to for the event yourself.

Vayder 05-09-08 10:20 PM

Quote:

Originally Posted by rodrick (Post 90665)
you will need to add the line you used in a macro (minus the /script part. Ie. MainMenuBarLeftEndCap:Hide() MainMenuBarRightEndCap:Hide()) to an addon already registered for the event, a new addon, or register the addon you added the lines to for the event yourself.

ok this is where i get confused. how do i register an event in an addon? im assuming i need to register PLAYER_ENTERING_WORLD for this to work?

frogofdoom 05-09-08 10:32 PM

Basically, in a function that runs when a mod loads (e.g. the OnLoad for a frame), that's where you register events. The format for doing that is just to add this line into an OnLoad function:

if you're doing it in a specific frame's OnLoad:
Code:

this:RegisterEvent("EVENT_NAME");
otherwise,
Code:

framename:RegisterEvent("EVENT_NAME");
So what people are suggesting here, is to find another mod that has already registered the PLAYER_ENTERING_WORLD event, and then add your code into the event handler under PLAYER_ENTERING_WORLD. So essentially, what you'd be doing, is piggy-backing on another mod's already registered events and sticking your code into its event handler.

Now, if I were to create your code as a standalone mod, I would do it like this:

Assume that I've created a frame named Frame. I would set this function to its OnLoad
Code:

function Frame_OnLoad()
 this:RegisterEvent("PLAYER_ENTERING_WORLD");
end

... And I would set this function to its OnEvent
Code:

function Frame_OnEvent(event)
 if (event == "PLAYER_ENTERING_WORLD") then
  MainMenuBarLeftEndCap:Hide()
  MainMenuBarRightEndCap:Hide()
 end
end

The simplest way to do this, as people have said, is just to insert this code into another mod that's already been created. Using that method, all you have to do to make this code load when the game loads, is to go into any mod's lua code, check to see if it has registered the PLAYER_ENTERING_WORLD event, and then insert your code into the event handler under the PLAYER_ENTERING_WORLD conditional.

Anyway, hope that helps you understand a bit better. ;)

Vayder 05-09-08 10:47 PM

thanks i think i might have it figured out now

Vayder 05-09-08 11:14 PM

ok. this is what i have. from what ive read/seen in other mods i personally think this should work. but alas it is not.

Code:

grifremove = CreateFrame("Frame")

function grifremove:Frame_OnLoad()
 this:RegisterEvent("PLAYER_ENTERING_WORLD");
end

function grifremove:Frame_OnEvent(event)
if (event == "PLAYER_ENTERING_WORLD") then
        MainMenuBarLeftEndCap:Hide()
        MainMenuBarRightEndCap:Hide()
end
end

i would really like to create a stand alone addon for this rather then piggy backing it into someone elses mod.
what am i doing wrong?

Slakah 05-10-08 02:52 AM

Are you sure you need an event to do it, I'm pretty sure you could just do.

Code:

        MainMenuBarLeftEndCap:Hide()
        MainMenuBarRightEndCap:Hide()

as all Blizzard code is executed before addons (unless it's LOD).

and heres an example of a super simple event handler:

Code:

local function OnEvent(f, event, args)
  if event == <Event 1> then
      --Do stuff
  elseif event == <Event 2> then
      --Do other stuff
  end
end

local f = CreateFrame("Frame")
f:RegisterEvent(<Event 1>)
f:RegisterEvent(<Event 2>)
f:SetScript("OnEvent", OnEvent)


ra1d3n 05-10-08 02:59 AM

Quote:

Originally Posted by Slakah (Post 90685)
Are you sure you need an event to do it, I'm pretty sure you could just do.

Code:

        MainMenuBarLeftEndCap:Hide()
        MainMenuBarRightEndCap:Hide()

as all Blizzard code is executed before addons (unless it's LOD).

I think that you're right. :)
BasicBuffHide does it like that, and it works.
Looky here: http://files.wowace.com/BasicBuffHid...ide-r54514.zip


All times are GMT -6. The time now is 10:08 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI