lua-users home
lua-l archive

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


Hi ho... I have the following script.

function testscript()

  local instance = {
	Pos = 0
  }

  function instance:debug()
	print("pos :"..self.Pos)
  end

  return instance

end


and inside my Code I have a loadbuffer and pcall to a string like "myscript = testscript()"

and then do the following

	lua_getglobal(m_LuaVM, "myscript");
	if(lua_istable(m_LuaVM,-1)) {
		lua_pushstring(m_LuaVM,"debug");
		lua_gettable(m_LuaVM,-2);
		if(lua_isfunction(m_LuaVM,-1))
			lua_call(m_LuaVM, 0, 0);
		else
			lua_pop(m_LuaVM,1);
	}

now this actually works if I don't reference self.Pos and will print the string. but if I reference anything that seems to be specified in the table (in this case self.Pos) it blows up inside grabbing something from the table inside the bytecode runner doofer.. is there any obvious reason why this would happen ? I mean if added

myscript = testscript()
myscript:debug()

to the main script, this would work with the reference to self.Pos.. :( any suggestions greatly appreciated..

cheers,

PT