View Single Post
03-15-12, 06:03 AM   #2
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
1) Depends on the content of your array. If it is an array with unsorted data, then the second solution should be slightly better, but not by much. If it's sorted then doing a binary search would probably be better.

2) The first counter is local to the scope of xxx(), while the for loops counter is only local to the for loop. quick example:
Lua Code:
  1. Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
  2. > do
  3. >> local c = 0
  4. >> for c=1, 3 do print(c) end
  5. >> print(c)
  6. >> end
  7. 1
  8. 2
  9. 3
  10. 0

3) You can do it by tracking changes to the HP through the combat log or through someones target. No directly easy way to track such when there's no valid unit id to track.
__________________
「貴方は1人じゃないよ」
  Reply With Quote