Lua Function

04/24/2020 12:40 gwapingsjericho#1
How you put this in .lua function
Code:
	CLuaBase lua;
	lua.SetGlobalPointer("PRJ", this);
	lua.RegisterFunction("AddLimit", &CProject::AddUpgradeLimit);
	lua.SetGlobalInt32("NOLIMIT", 0);
	lua.SetGlobalInt32("GENERAL", 0);
	lua.SetGlobalInt32("ACCESSORY", 1);
	lua.SetGlobalInt32("ULTIMATE_WEAPON", 2);
	lua.SetGlobalInt32("BARUNA_WEAPON", 3);
	lua.SetGlobalInt32("BARUNA_SUIT", 4);
	lua.SetGlobalInt32("BARUNA_ARMORETC", 5);
	lua.SetGlobalInt32("PIERCING_SUIT", 6);
	lua.SetGlobalInt32("PIERCING_WEAPON", 7);
	lua.SetGlobalInt32("BARUNA_ACCESSORY", 8);
Code:
	lua_getglobal(luastate, "PRJ");
	CProject* ptr = (CProject*)lua_topointer(luastate, -1); // why not practice avoiding globals?
	switch (lua_tointeger(luastate, 1))
	{
		case 0: // GENERAL
			ptr->m_mapUpgradeCap_General.insert(make_pair(lua_tointeger(luastate, 2), lua_tointeger(luastate, 3)));
			break;
		case 1: // ACCESSORY
			ptr->m_mapUpgradeCap_Accessory.insert(make_pair(lua_tointeger(luastate, 2), lua_tointeger(luastate, 3)));
			break;