View Single Post
10-07-15, 03:19 PM   #3
sirann
A Flamescale Wyrmkin
Join Date: Mar 2007
Posts: 142
Originally Posted by Phanx View Post
Code:
local count = GetItemCount(109217)
And here I was thinking I had come up with an elaborate solution to having multiple stacks that, individually, are less than 4, but together would be more than 4.

Originally Posted by Phanx View Post
Declaring all your variables at the file scope instead of the scope where they're actually used isn't a good practice. Your "total" and "equipped" variables are only used in the PLAYER_AVG_ITEM_LEVEL_UPDATE event handler, so you should just stick a "local" in front of the line that assigns them the values returned by GetAverageItemLevel().
I was under the impression that every time, in this case, a ready check went out, or my ilevel changed this would write "new" variables with total and equipped for instance as names. I put them outside of the scope so the variables are only set aside once, so the only change that occurs is the values associated with them, thereby reducing memory usage. Doese LUA just overwrite the variables in the same memory space, thereby not changing memory usage at all? Does overwriting use CPU, moreso than changing the value the variable is equal to? My impression is obviously incorrect, but, could you point me in the right direction of how lua handles variables in the memory/processor? Essentially all of my code lists locals just above (but always outside) functions or event handlers.
  Reply With Quote