Exemplo n.º 1
0
void PushInstance(UProperty* prop, void* data)
{
    LuaTArrayUD* ud = new LuaTArrayUD(prop, data);

    CLuaObject* metaT = g_Lua->GetMetaTable(MetaName);
    g_Lua->PushUserData(metaT, ud, MetaID);
    metaT->UnReference();
}
Exemplo n.º 2
0
void Register()
{
    CLuaObject* metaT = g_Lua->GetMetaTable(MetaName);
    metaT->SetMember("__index", index);
    metaT->SetMember("__tostring", tostring);
    metaT->SetMember("__gc", gc);
    metaT->UnReference();
}
Exemplo n.º 3
0
bool CTestLuaMgr::LoadConfig()
{
  if (luaL_dofile(GLuaState, "GameData\\lua\\stage.lua"))
    return false;
  CLuaObject LuaObject = CLuaObject("stage", GLuaState);
  BEGIN_LUA(LuaObject)
  {
    int Level = LuaObject.getInt("Level");
    int Type = LuaObject.getInt("Type");
  }
  END_LUA(LuaObject)
  return true;
}
Exemplo n.º 4
0
// *********************************************************
void CPrimLook::init(const CLuaObject &params)
{
	//H_AUTO(R2_CPrimLook_init)
	if (!params.isTable())
	{
		nlwarning("<CPrimLook::init> parameters are not a table");
		return;
	}
	// vertices
	READ_FROM_LUA(VertexShapeName);
	READ_FROM_LUA(VertexShapeScale);
	VertexLook.init(params["VertexLook"]);
	if (!params["FirstVertexLook"].isNil())
	{
		FirstVertexLook.init(params["FirstVertexLook"]);
	}
	else
	{
		FirstVertexLook = VertexLook;
	}
	EdgeLook.init(params["EdgeLook"]);
	READ_FROM_LUA(LastEdgeIsValid);
	READ_FROM_LUA(ClipDownFacing);
	// enums
	uint shape = Star;
	readFromLua(params, "Shape", shape);
	if (shape < ShapeCount) Shape = (TShape) shape;
	//
}
Exemplo n.º 5
0
// ************************************************************************
void CObjectTableClient::pushOnLuaStack(CLuaState &state, CLuaObject &metatable) const
{
	//H_AUTO(R2_CObjectTableClient_pushOnLuaStack)
	// cache refptr here to avoid costly allocations
	CLuaStackChecker lsc(&state, 1);
	if (!_Ref.isValid())
	{
		nlassert(metatable.isValid());
		// return a new refptr on the sub table
		void *block = state.newUserData(sizeof(TRefPtrConst));
		new (block) CObjectTable::TRefPtrConst(this); // create in place
		metatable.push();
		state.setMetaTable(-2);
		_Ref.pop(state);
	}
	nlassert(_Ref.getLuaState() == &state);
	_Ref.push();
}
Exemplo n.º 6
0
// *********************************************************************************************************
bool CDisplayerLua::init(const CLuaObject &parameters)
{
	//H_AUTO(R2_CDisplayerLua_init)
	// parameters should be a function that create the lua displayer
	CLuaStackChecker lsc(parameters.getLuaState());
	_ToLua._LuaTable.release();
	if (parameters.isString())
	{
		getEditor().getEnv()[parameters.toString()].push(); // get method from the R2 env
	}
	else
	{
		parameters.push();
	}
	CLuaState &ls = *parameters.getLuaState();
	getEditor().getEnv().push(); // this is a method call
	if (CLuaIHM::executeFunctionOnStack(ls,  1,  1))
	{
		_ToLua._LuaTable.pop(ls);
	}
	else
	{
		nlwarning("<CDisplayerLua::init> Error while calling displayer ctor (parameter should be a r2 method, or the *name* of a r2 method) : param is : ");
		parameters.dump();
		return false;
	}
	return CDisplayerBase::init(parameters);
}
Exemplo n.º 7
0
// *********************************************************************************************************
void CEntityCustomSelectBox::fromTable(CLuaObject &table)
{
	//H_AUTO(R2_CEntityCustomSelectBox_fromTable)
	if (!table.isTable())
	{
		nlwarning("trying to rerieve bbox from an object that is not a table");
		return;
	}
	Enabled = table["Enabled"].toBoolean();
	Box.setMinMax(CVector((float) table["XMin"].toNumber(),
		                  (float) table["YMin"].toNumber(),
						  (float) table["ZMin"].toNumber()),
				  CVector((float) table["XMax"].toNumber(),
		                  (float) table["YMax"].toNumber(),
						  (float) table["ZMax"].toNumber()));
}
Exemplo n.º 8
0
// *********************************************************************************************************
void CEntityCustomSelectBox::toTable(CLuaObject &table)
{
	//H_AUTO(R2_CEntityCustomSelectBox_toTable)
	if (!table.isTable())
	{
		nlwarning("trying to store bbox in an object that is not a table");
		return;
	}
	table.setValue("Enabled", Enabled);
	//
	table.setValue("XMin", (double) Box.getMin().x);
	table.setValue("YMin", (double) Box.getMin().y);
	table.setValue("ZMin", (double) Box.getMin().z);
	//
	table.setValue("XMax", (double) Box.getMax().x);
	table.setValue("YMax", (double) Box.getMax().y);
	table.setValue("ZMax", (double) Box.getMax().z);


}