Quantcast 2.0 misc changes in Beta (JIM the Inventor) - WoWWiki - Your guide to the World of Warcraft
Recent changes Random page
GAMING
Gaming
 
StarCraft Wiki
Super Smash Wiki
Halopedia
Diablo Wiki
FFXIclopedia
Grand Theft Wiki
See more...

2.0 misc changes in Beta (JIM the Inventor)

From WoWWiki

Jump to: navigation, search
Interface Customization » WoW API » API change summaries » 2.0 misc changes in Beta (JIM the Inventor)

Contents


I'm breaking Iriel's templates with this attempt to get information out quickly. The changes I have to note pertain to the leap from the original program (WoW 1.12) to the expansion (BC 2.0), and are listed here in an arbitrary order. Very sloppy, I know. :-) JIM 18:01, 11 November 2006 (EST)

These changes are from the upgrade to LUA 5.1. Full details can be found here.


Getting the Size of a Table

former implementation:

  local atable = {}
  tinsert( atable, "foo" )
  tinsert( atable, "bar" )
  local tableSize = atable.n


current implementation:

  local atable = {}
  tinsert( atable, "foo" )
  tinsert( atable, "bar" )
  local tableSize = select( "#", atable ) -- or more simply:
  tableSize = #atable

However, this does not appear to be a perfect translation across LUA versions. If atable started life as { ["x"] = "any value" } above, then the former implementation would result in tableSize = 2, whereas the current implementation results in tableSize = 3.


For-In-Do Loops Using Tables

former implementation:

  for key, value in atable do


current implementation:

  -- a simple search and replace
  for key, value in pairs( atable ) do


Functions with an Unknown Number of Parameters

former implementation:

  --[[ If "..." was included in the parameters,
     a variable "arg" was provided with:
        arg[1] = first_parameter
        arg[2] = second_parameter
        ..etc..
        arg.n = number of parameters passed to foo.
  ]]
  function foo(...)
     local say = DEFAULT_CHAT_FRAME.AddMessage
     say( "These values were passed to foo:" )
     
     for i = 1, args.n do
        say( tostring( args[i] ) )
     end
  end


current implementation:

  --[[ If "..." is included in the parameters,
     "..." itself behaves like a function
     that returns all parameters passed to foo.
  ]]
  function foo(...)
     local say = DEFAULT_CHAT_FRAME.AddMessage
     say( "These values were passed to foo:" )
     
     for i = 1, select( "#", ... ) do
        say( tostring( select( i, ... ) ) )
     end
  end
Rate this article:
Share this article: