lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi, is it possible to create tables with functions inside them and use the table
as reference calls as you can do inside C++? example... 

class TestClass {
public
 .....
 .....
 TestClass& GetObject()
 {
  return *this;
 }
 
 int TestInteger()
 {
   return 55;
 }
};

if(myclass.GetObject().TestInteger() == 55)
{
  statement block
}

Lua example:

Keys = {
   ALT = 18,
   A = 65,
   B = 66,
   C = 67
}

 --[[
   Keyboard is the registered library
   GetState(vk_code) vk_code is the virtual keycode, inside the table Keys
   IsMod(vk_code) modifier key, checks to see if modifier key is applied
 --]]

function test()
   if(Keyboard.GetState(Keys.A).IsMod(Keys.ALT))
    print("A & ALT are down\n");
   else
    print("... implement here\n");
end

test()