Thread Tools Display Modes
04-16-13, 07:45 AM   #41
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Originally Posted by Rainrider View Post
you could take #{...} instead of the first select. Don't know if that's 'cheaper' though.
You could completely avoid using select by iterating over it as a table. This uses more memory but is far more efficient in terms of cpu usage. Cpu cycles are generally more valuable than memory, so it's usually a good trade-off.
Lua Code:
  1. local func = function(...)
  2.     for _, arg in ipairs({...}) do
  3.         -- you can use pairs or ipairs if the order matters
  4.         -- i don't think there's much difference in performance
  5.     end
  6. end

If you did #{...} like your example, you would already be creating a table and throwing it away just to get the number of variables.

There are situations where you wouldn't want to turn it into a table though, for example if you had a very large number of items and couldn't construct a table (there is a size limit) or you only wanted a range of items out of a very large list, then select might be more practical.

Last edited by semlar : 04-16-13 at 08:00 AM.
  Reply With Quote
04-16-13, 10:50 AM   #42
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Originally Posted by Resike View Post
Yeah, but the battleground ui only show scores and time/reinforements remaining, nothing more, and there is no any other battleground related lua file in the framexml, so i'm guessing it's not public.
The WorldStateFrame is the display at the top center of your screen that shows bases/flags capped. When that gets an update event, that should be something that you'll be interested in since it's directly responding to something happening in the state of the battlefield.

On second thought, if you're polling the map POI states and checking their textures to detect base captures, WORLD_MAP_UPDATE would be your best bet since that's directly responsible for updating the map.
__________________
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)
  Reply With Quote
04-16-13, 11:36 AM   #43
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by SDPhantom View Post
The WorldStateFrame is the display at the top center of your screen that shows bases/flags capped. When that gets an update event, that should be something that you'll be interested in since it's directly responding to something happening in the state of the battlefield.

On second thought, if you're polling the map POI states and checking their textures to detect base captures, WORLD_MAP_UPDATE would be your best bet since that's directly responsible for updating the map.
Yes thats what i use for base based bgs, but when someone drops the flag in a battlegorund, then nor the texure id, nor the battlefield score gonna change, and there is no other event to track this stuff, so you can only tell that by the "CHAT_MSG_X" events. At least i couln't find and event which handle this stuff.
  Reply With Quote
04-16-13, 12:43 PM   #44
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
I thought the highlight on the texture changed based on if someone had the flag or not.
__________________
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)
  Reply With Quote
04-16-13, 05:41 PM   #45
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by SDPhantom View Post
I thought the highlight on the texture changed based on if someone had the flag or not.
But i'm pretty sure something has to trigger thoose "CHAT_MSG" messages too, but i couln't find em nowhere.
  Reply With Quote
04-16-13, 08:36 PM   #46
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
All events fire from C code in the game client. What causes the C code to fire the event depends on the event in question. Most of the time, it's in response to the server telling the client something happened.

If this is hard to understand, think of it this way. Unlike a singleplayer game, multiplayer games are actually run by what's called a server. It's the server that actually runs the game, keeps track of where you are, and all additional data about your character as well as handling other functions like chat. The game client is just a glorified remote control and viewer. All it does is render players and mobs where the server tells it to and display messages the server says. This is in addition to being an input for the player, letting the server know you want to move your player around, talk to NPCs, and move things around in your bags and/or inventory.

To add an analogy, the game client is like your monitor, keyboard, mouse, and speakers, and the server is your computer itself, the brain of the entire operation. You give it input using your keyboard and mouse, experience feedback from the monitor and speakers, but it's the computer that does everything.
__________________
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 : 04-17-13 at 10:21 AM.
  Reply With Quote
04-17-13, 01:42 AM   #47
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by SDPhantom View Post
All events fire form C code in the game client. What causes the C code to fire the event depends on the event in question. Most of the time, it's in response to the server telling the client something happened.

If this is hard to understand, think of it this way. Unlike a singleplayer game, multiplayer games are actually run by what's called a server. It's the server that actually runs the game, keeps track of where you are, and all additional data about your character as well as handling other functions like chat. The game client is just a glorified remote control and viewer. All it does is render players and mobs where the server tells it to and display messages the server says. This is in addition to being an input for the player, letting the server know you want to move your player around, talk to NPCs, and move things around in your bags and/or inventory.

To add an analogy, the game client is like your monitor, keyboard, mouse, and speakers, and the server is your computer itself, the brain of the entire operation. You give it input using your keyboard and mouse, experience feedback from the monitor and speakers, but it's the computer that does everything.
So i guess, addon can't really read from that code.
  Reply With Quote
04-17-13, 10:24 AM   #48
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Correct, C code is completely out of the scope of what addons have access to. This barrier is by design to allow UI customization, yet keep people from hacking the game itself from within. This is what is known as a "sandbox". You can do whatever you want within the Lua environment, but you can't affect or respond from anything outside of it, including C code that runs behind the WoW API.
__________________
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 : 04-17-13 at 10:27 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Issue with select() and IsInInstance()

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