Quantcast
How to trigger functions in game - WoWInterface
 
Thread Tools Display Modes
08-02-20, 06:39 AM   #1
Lyeeroy
A Defias Bandit
Join Date: Aug 2020
Posts: 2
Question 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.

Last edited by Lyeeroy : 08-02-20 at 06:41 AM.
  Reply With Quote
08-02-20, 06:45 AM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 789
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.
__________________
The cataclysm broke the world ... and the pandas could not fix it!

Last edited by Rilgamon : 08-02-20 at 06:47 AM.
  Reply With Quote
08-02-20, 06:50 AM   #3
Lyeeroy
A Defias Bandit
Join Date: Aug 2020
Posts: 2
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

Last edited by Lyeeroy : 08-02-20 at 09:04 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to trigger functions in game

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