Thread Tools Display Modes
02-24-17, 08:39 PM   #21
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
02-24-17, 09:49 PM   #22
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
Originally Posted by Ketho View Post
老实说我一点都不了解你的帖子和看法
我觉得有语言障碍的问题啦~请问你是台湾还是大陆人吗?
你的问题是,为什么我要用OOP,但实际上OOP用在WOW的任何地方,你用CreateFrame出来的元素,也是在用OOP,blz自己就有一套复杂的继承体系,实际OOP的使用非常广泛,只不过可能像我这样着重提出的很少罢了,但总的来说,使用OOP系统提供的类型并非是一个困难的问题吧。

定义类型是相对过程式编程较为复杂的问题,这点对于普通插件作者来说,的确是很难接受的,因为意味着思维方式的变化,OOP更容易被现实中有对应经验的人接受,所以对PLoop的态度一般是两极分化的。但我一开始也说明,Scorpio这个框架不需要作者去熟悉PLoop。这个框架主体思路是提供便利和固化的开发方式,而并非要求你自己去学习如何制作类型。

如果要进一步说明,为什么我要在wow里面使用PLoop,而不是更轻量级的系统,更多原因是它很全面,基于它我能更快速的组建上层应用框架。但重申一句,我推荐给普通作者的是Scorpio,而非PLoop,即便在现实生活的工作中,我提供给其他人的也会是上层框架的应用,而不会让他们过多接触底层的东西。
  Reply With Quote

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

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