Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
39 changes: 36 additions & 3 deletions Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,10 +1072,43 @@ std::variant<bool, CLuaMultiReturn<float, float, float, float>> CLuaPedDefs::Get
return std::make_tuple(x, y, z, w);
}

bool CLuaPedDefs::SetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, CMatrix boneMatrix)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just implement that "CMatrix" can be read from 4x4 lua table and don't touch this file at all

bool CLuaPedDefs::SetElementBoneMatrix(lua_State* const luaVM)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wont work for argument parser.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case it would be through LUA_DECLARE, correct? I've made the change, if that's all it is, I'll send.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you would have to remove argument parser from the function list. Try to find a different way instead of not using argparser

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to follow the declaration pattern of other functions. I've sent the changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check if it works as intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I never send a commit without testing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didnt check your first commit though 😒

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I did. All the parameters were working and the function worked correctly. I only changed it because you told me to, but it was already working.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you say so, but please try figuring out a way with ArgumentParser and not lua bindings if possible

{
CEntity* theEntity = entity->GetGameEntity();
return theEntity ? theEntity->SetBoneMatrix(static_cast<eBone>(boneId), boneMatrix) : false;
CClientEntity* entity = NULL;
std::uint32_t boneId;
CMatrix boneMatrix;

CScriptArgReader argStream(luaVM);
argStream.ReadUserData(entity);
argStream.ReadNumber(boneId);

if (argStream.NextIsTable())
{
if (!ReadMatrix(luaVM, argStream.m_iIndex, boneMatrix))
{
argStream.SetCustomError("Matrix is not 4 x 4");
}
}
else
{
argStream.ReadMatrix(boneMatrix);
}

if (!argStream.HasErrors())
{
CEntity* theEntity = entity->GetGameEntity();

if (theEntity->SetBoneMatrix(static_cast<eBone>(boneId), boneMatrix))
{
lua_pushboolean(luaVM, true);
return true;
}
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

lua_pushboolean(luaVM, false);
return false;
}

std::variant<bool, std::array<std::array<float, 4>, 4>> CLuaPedDefs::GetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId)
Expand Down
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CLuaPedDefs : public CLuaDefs
static std::variant<bool, CLuaMultiReturn<float, float, float>> GetElementBoneRotation(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId);
static std::variant<bool, CLuaMultiReturn<float, float, float, float>> GetElementBoneQuaternion(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId);

static bool SetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId, CMatrix boneMatrix);
static bool SetElementBoneMatrix(lua_State* const luaVM);

static std::variant<bool, std::array<std::array<float, 4>, 4>> GetElementBoneMatrix(lua_State* const luaVM, CClientPed* entity, std::uint32_t boneId);

Expand Down
Loading