feat: Add multistate compatibility methods (#175)

This commit is contained in:
Foe
2024-06-05 06:19:41 +02:00
committed by GitHub
parent 152a491663
commit cc442de602
2 changed files with 52 additions and 0 deletions

View File

@@ -112,6 +112,42 @@ namespace LuaGlobalFunctions
#endif #endif
return 1; return 1;
} }
/**
* Returns the [Map] pointer of the Lua state. Returns null for the "World" state.
*
* @return [Map] map
*/
int GetStateMap(lua_State* L)
{
// Until AC supports multistate, this will always return nil
Eluna::Push(L);
return 1;
}
/**
* Returns the map ID of the Lua state. Returns -1 for the "World" state.
*
* @return int32 mapId
*/
int GetStateMapId(lua_State* L)
{
// Until AC supports multistate, this will always return -1
Eluna::Push(L, -1);
return 1;
}
/**
* Returns the instance ID of the Lua state. Returns 0 for continent maps and the world state.
*
* @return uint32 instanceId
*/
int GetStateInstanceId(lua_State* L)
{
// Until AC supports multistate, this will always return 0
Eluna::Push(L, 0);
return 1;
}
/** /**
* Returns [Quest] template * Returns [Quest] template
@@ -2565,6 +2601,18 @@ namespace LuaGlobalFunctions
return 1; return 1;
} }
/**
* Returns `true` if Eluna is in compatibility mode, `false` if in multistate.
*
* @return bool isCompatibilityMode
*/
int IsCompatibilityMode(lua_State* L)
{
// Until AC supports multistate, this will always return true
Eluna::Push(L, true);
return 1;
}
/** /**
* Returns `true` if the bag and slot is a valid inventory position, otherwise `false`. * Returns `true` if the bag and slot is a valid inventory position, otherwise `false`.
* *

View File

@@ -84,6 +84,9 @@ luaL_Reg GlobalMethods[] =
{ "GetRealmID", &LuaGlobalFunctions::GetRealmID }, { "GetRealmID", &LuaGlobalFunctions::GetRealmID },
{ "GetCoreVersion", &LuaGlobalFunctions::GetCoreVersion }, { "GetCoreVersion", &LuaGlobalFunctions::GetCoreVersion },
{ "GetCoreExpansion", &LuaGlobalFunctions::GetCoreExpansion }, { "GetCoreExpansion", &LuaGlobalFunctions::GetCoreExpansion },
{ "GetStateMap", &LuaGlobalFunctions::GetStateMap },
{ "GetStateMapId", &LuaGlobalFunctions::GetStateMapId },
{ "GetStateInstanceId", &LuaGlobalFunctions::GetStateInstanceId },
{ "GetQuest", &LuaGlobalFunctions::GetQuest }, { "GetQuest", &LuaGlobalFunctions::GetQuest },
{ "GetPlayerByGUID", &LuaGlobalFunctions::GetPlayerByGUID }, { "GetPlayerByGUID", &LuaGlobalFunctions::GetPlayerByGUID },
{ "GetPlayerByName", &LuaGlobalFunctions::GetPlayerByName }, { "GetPlayerByName", &LuaGlobalFunctions::GetPlayerByName },
@@ -118,6 +121,7 @@ luaL_Reg GlobalMethods[] =
{ "GetActiveGameEvents", &LuaGlobalFunctions::GetActiveGameEvents }, { "GetActiveGameEvents", &LuaGlobalFunctions::GetActiveGameEvents },
// Boolean // Boolean
{ "IsCompatibilityMode", &LuaGlobalFunctions::IsCompatibilityMode },
{ "IsInventoryPos", &LuaGlobalFunctions::IsInventoryPos }, { "IsInventoryPos", &LuaGlobalFunctions::IsInventoryPos },
{ "IsEquipmentPos", &LuaGlobalFunctions::IsEquipmentPos }, { "IsEquipmentPos", &LuaGlobalFunctions::IsEquipmentPos },
{ "IsBankPos", &LuaGlobalFunctions::IsBankPos }, { "IsBankPos", &LuaGlobalFunctions::IsBankPos },