Thread Tools Display Modes
Prev Previous Post   Next Post Next
02-24-17, 08:39 PM   #22
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
Like I said, the environment is a standalone environment only used by the addon, it has no effect to the global environment. Loading a file would run it as a function, change the function's environment will only affect it's content

Lua Code:
  1. a = 100
  2.  
  3. function testenv()
  4.     setfenv(1, {})
  5.  
  6.     a = 200
  7. end
  8.  
  9. testenv()
  10. print(a) -- still is 100

And also an addon can have multi-modules, so each module can handle system event for their own. This won't set a meta-table to the global environment, the real job is like :

Lua Code:
  1. local _M = Scorpio("MyAddon.Module")
  2.  
  3. Scorpio.__SystemEvent__()
  4. function _M.UNIT_HEALTH(unit)
  5. end

Also _M:RegisterEvent(xxx, handler) can be used by those moduels. the reason use attribute is it can combine several information :

Lua Code:
  1. __Thread__()
  2. __BigWigsEvent__ "BigWigs_EnableFriendlyNameplates"
  3. __DBMEvent__ "BossMod_DisableFriendlyNameplates"
  4. function UpdateFriendlyNameplates()
  5. end

Last edited by kurapica.igas : 02-24-17 at 10:03 PM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Dev Tools » Scorpio A new addon framework


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