View Single Post
12-25-11, 08:56 PM   #14
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,325
Originally Posted by Vladinator View Post
Just curious, would one be able to make an addon communication spoof-proof?
It depends on the level of sophistication of the addon. For an addon to be completely "spoof-proof", it must accept no data from any source at all. Note request and reply responses such as a standard ping are not considered data. It's a simple triggering of events. if someone were to attempt to send a response without a ping request, the addon would simply ignore it as part of error handling.



Originally Posted by Vladinator View Post
Also, a really offtopic question but since we nerds are gathered here... can you create a lua class/table that acts like jquery? I.e something like:
tableName:get(2):isUnit("player"):call(function(self)print(self)end)

It would in this case run a custom function, but only on the table entry or entries where the get(2) returns the appropriate data, then a sub-function to check if the unit is player, then call something on that/those object/objects.

I am not sure if it's worth making this, performance wise would it bee too bad to practice this in LUA? It works in Javascript but they are totally different languages so, hehe.
I suppose if you made clever use of metatables with backreferences. As far as performance, you can have each filter add its respective value to a list of filters stored in the metatable, then have object:call() run the filter, clear the filter list, and return the filtered table with the metatable propagated. You'll need to manage all this with the __index field of the metatable and define all the functions in the table pointed to it. It'll be up to you if you want to store the filter data as an upvalue or inside the __index table.



Originally Posted by Vladinator View Post
But you get my idea, it would shorten a lot of code and potentially you could even code something for WoW that is jquery like, for example you can select the appropriate object using:
local t = tableName:get("UIParent>Button[name='CloseWindow']")
I.e. a button object owned by UIParent with the name 'CloseWindow' and then you have t where it's either one or many objects fitting the criteria, now you can:
t:IsShown():Click()
Ergo if it's shown then click it.

You'd need to program these functions of course but it's a neat idea, makes writing a bit shorter I think.
There's a lot of balance between short, easy-to-read code, and efficient code. Often writing library code to make the core code look nicer takes the processor through a magnitude of steps that are unnecessary and impacts performance. Depending on how the code is written, it can be by a little or by a lot.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 12-25-11 at 09:13 PM.
  Reply With Quote