Skip to content

Commit d28eb11

Browse files
committed
Merge branch 'CrosRoad95-colshape-type'
2 parents ce48bec + 134cbe6 commit d28eb11

File tree

4 files changed

+64
-3
lines changed

4 files changed

+64
-3
lines changed

Client/mods/deathmatch/logic/luadefs/CLuaColShapeDefs.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ void CLuaColShapeDefs::LoadFunctions(void)
1919
CLuaCFunctions::AddFunction("createColRectangle", CreateColRectangle);
2020
CLuaCFunctions::AddFunction("createColPolygon", CreateColPolygon);
2121
CLuaCFunctions::AddFunction("createColTube", CreateColTube);
22+
CLuaCFunctions::AddFunction("getColShapeType", GetColShapeType);
2223
}
2324

2425
void CLuaColShapeDefs::AddClass(lua_State* luaVM)
@@ -33,11 +34,38 @@ void CLuaColShapeDefs::AddClass(lua_State* luaVM)
3334
lua_classfunction(luaVM, "Polygon", "createColPolygon");
3435

3536
lua_classfunction(luaVM, "getElementsWithin", "getElementsWithinColShape");
36-
lua_classvariable(luaVM, "elementsWithin", NULL, "getElementsWithinColShape");
37+
lua_classfunction(luaVM, "getShapeType", "getColShapeType");
38+
39+
lua_classvariable(luaVM, "shapeType", nullptr, "getColShapeType");
3740

3841
lua_registerclass(luaVM, "ColShape", "Element");
3942
}
4043

44+
int CLuaColShapeDefs::GetColShapeType(lua_State* luaVM)
45+
{
46+
// Verify the arguments
47+
CClientColShape* pColShape = nullptr;
48+
CScriptArgReader argStream(luaVM);
49+
argStream.ReadUserData(pColShape);
50+
51+
if (!argStream.HasErrors())
52+
{
53+
// Grab our VM
54+
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine(luaVM);
55+
if (pLuaMain)
56+
{
57+
lua_pushnumber(luaVM, pColShape->GetShapeType());
58+
return 1;
59+
}
60+
}
61+
else
62+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
63+
64+
// Failed
65+
lua_pushboolean(luaVM, false);
66+
return 1;
67+
}
68+
4169
int CLuaColShapeDefs::CreateColCircle(lua_State* luaVM)
4270
{
4371
CVector2D vecPosition;

Client/mods/deathmatch/logic/luadefs/CLuaColShapeDefs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ class CLuaColShapeDefs : public CLuaDefs
2424
LUA_DECLARE(CreateColRectangle);
2525
LUA_DECLARE(CreateColPolygon);
2626
LUA_DECLARE(CreateColTube);
27+
28+
LUA_DECLARE(GetColShapeType);
2729
};

Server/mods/deathmatch/logic/luadefs/CLuaColShapeDefs.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
void CLuaColShapeDefs::LoadFunctions()
1515
{
16-
// Shape create funcs
1716
CLuaCFunctions::AddFunction("createColCircle", CreateColCircle);
1817
CLuaCFunctions::AddFunction("createColCuboid", CreateColCuboid);
1918
CLuaCFunctions::AddFunction("createColSphere", CreateColSphere);
2019
CLuaCFunctions::AddFunction("createColRectangle", CreateColRectangle);
2120
CLuaCFunctions::AddFunction("createColPolygon", CreateColPolygon);
2221
CLuaCFunctions::AddFunction("createColTube", CreateColTube);
22+
CLuaCFunctions::AddFunction("getColShapeType", GetColShapeType);
2323
}
2424

2525
void CLuaColShapeDefs::AddClass(lua_State* luaVM)
@@ -34,9 +34,38 @@ void CLuaColShapeDefs::AddClass(lua_State* luaVM)
3434
lua_classfunction(luaVM, "Polygon", "createColPolygon");
3535

3636
lua_classfunction(luaVM, "getElementsWithin", "getElementsWithinColShape");
37+
lua_classfunction(luaVM, "getShapeType", "getColShapeType");
38+
39+
lua_classvariable(luaVM, "shapeType", nullptr, "getColShapeType");
40+
3741
lua_registerclass(luaVM, "ColShape", "Element");
3842
}
3943

44+
int CLuaColShapeDefs::GetColShapeType(lua_State* luaVM)
45+
{
46+
// Verify the arguments
47+
CColShape* pColShape = nullptr;
48+
CScriptArgReader argStream(luaVM);
49+
argStream.ReadUserData(pColShape);
50+
51+
if (!argStream.HasErrors())
52+
{
53+
// Grab our VM
54+
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine(luaVM);
55+
if (pLuaMain)
56+
{
57+
lua_pushnumber(luaVM, pColShape->GetShapeType());
58+
return 1;
59+
}
60+
}
61+
else
62+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
63+
64+
// Failed
65+
lua_pushboolean(luaVM, false);
66+
return 1;
67+
}
68+
4069
int CLuaColShapeDefs::CreateColCircle(lua_State* luaVM)
4170
{
4271
CVector2D vecPosition;

Server/mods/deathmatch/logic/luadefs/CLuaColShapeDefs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ class CLuaColShapeDefs : public CLuaDefs
2525
LUA_DECLARE(CreateColRectangle);
2626
LUA_DECLARE(CreateColPolygon);
2727
LUA_DECLARE(CreateColTube);
28-
};
28+
29+
LUA_DECLARE(GetColShapeType);
30+
};

0 commit comments

Comments
 (0)