WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   How to trigger functions in game (https://www.wowinterface.com/forums/showthread.php?t=58131)

Lyeeroy 08-02-20 06:39 AM

How to trigger functions in game
 
Hi, have simple question..

Have a code with functions like this:

Lua Code:
  1. local version = 0.8
  2.  
  3. print("func " .. version .. " loaded")
  4.  
  5. function func_OnEvent(self, event)
  6.     --some code
  7. end
  8.  
  9. function MsgTop(string)
  10.     --some code
  11. end
  12.  
  13. function MsgChat(string)
  14.     --some code
  15. end

How do I call _OnEvent in game? I cant get it. Is this via XML? Or should I just call it on top of the code by:
Lua Code:
  1. func_OnEvent()
It seems weird.

Rilgamon 08-02-20 06:45 AM

xml is not a programming language. It just describes your frames.
You dont need xml for an addon.

Addons register for events that should trigger functions. Or you can trigger a timed event.
Take a look at SetScript and
RegisterEvent.

Edit: Keep in mind that functions should be local, too.

Lyeeroy 08-02-20 06:50 AM

I saw XML file with:

Code:

                <Scripts>
                        <OnLoad> _OnLoad(); </OnLoad>
                        <OnEvent> _OnEvent(); </OnEvent>
                        <OnUpdate> _OnUpdate(); </OnUpdate>
                </Scripts>

So I thought with these you gotta call them.

That makes more sense now. Thank you


All times are GMT -6. The time now is 02:50 PM.

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