Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose IsPlayer() #42

Merged
merged 7 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/LuaEngine/LuaFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ ElunaRegister<Object> ObjectMethods[] =

// Boolean
{ "IsInWorld", &LuaObject::IsInWorld },
{ "IsPlayer", &LuaObject::IsPlayer },
{ "HasFlag", &LuaObject::HasFlag },

// Other
Expand Down
25 changes: 19 additions & 6 deletions src/LuaEngine/ObjectMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ namespace LuaObject
return 1;
}

/**
* Returns 'true' if the [Object] is a player, 'false' otherwise.
*
* @return bool IsPlayer
*/
int IsPlayer(lua_State* L, Object* obj)
{
#ifdef AZEROTHCORE //AC-only
Eluna::Push(L, obj->IsPlayer());
#endif
return 1;
}

/**
* Returns the data at the specified index, casted to a signed 32-bit integer.
*
Expand Down Expand Up @@ -156,14 +169,14 @@ namespace LuaObject

/**
* Returns the GUID of the [Object].
*
*
* GUID is an unique identifier for the object.
*
*
* However on MaNGOS and cMangos creatures and gameobjects inside different maps can share
* the same GUID but not on the same map.
*
*
* On TrinityCore this value is unique across all maps
*
*
* @return ObjectGuid guid
*/
int GetGUID(lua_State* L, Object* obj)
Expand All @@ -174,10 +187,10 @@ namespace LuaObject

/**
* Returns the low-part of the [Object]'s GUID.
*
*
* On TrinityCore all low GUIDs are different for all objects of the same type.
* For example creatures in instances are assigned new GUIDs when the Map is created.
*
*
* On MaNGOS and cMaNGOS low GUIDs are unique only on the same map.
* For example creatures in instances use the same low GUID assigned for that spawn in the database.
* This is why to identify a creature you have to know the instanceId and low GUID. See [Map:GetIntstanceId]
Expand Down