Skip to content

Commit 05e6458

Browse files
author
CrosRoad95
committed
shape type function
1 parent 705739b commit 05e6458

File tree

6 files changed

+59
-0
lines changed

6 files changed

+59
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ void CLuaColShapeDefs::AddClass ( lua_State* luaVM )
3333
lua_classfunction ( luaVM, "Polygon", "createColPolygon" );
3434

3535
lua_classfunction ( luaVM, "getElementsWithin", "getElementsWithinColShape" );
36+
lua_classfunction ( luaVM, "getShapeType", "getColShapeType" );
37+
3638
lua_classvariable ( luaVM, "elementsWithin", NULL, "getElementsWithinColShape" );
39+
lua_classvariable ( luaVM, "shape", NULL, "getColShapeType" );
3740

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

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void CLuaElementDefs::LoadFunctions ( void )
3636
CLuaCFunctions::AddFunction ( "isElementWithinColShape", IsElementWithinColShape );
3737
CLuaCFunctions::AddFunction ( "isElementWithinMarker", IsElementWithinMarker );
3838
CLuaCFunctions::AddFunction ( "getElementsWithinColShape", GetElementsWithinColShape );
39+
CLuaCFunctions::AddFunction ( "getColShapeType", GetColShapeType );
3940
CLuaCFunctions::AddFunction ( "getElementDimension", GetElementDimension );
4041
CLuaCFunctions::AddFunction ( "getElementBoundingBox", GetElementBoundingBox );
4142
CLuaCFunctions::AddFunction ( "getElementRadius", GetElementRadius );
@@ -891,6 +892,30 @@ int CLuaElementDefs::IsElementWithinMarker ( lua_State* luaVM )
891892
return 1;
892893
}
893894

895+
int CLuaElementDefs::GetColShapeType ( lua_State* luaVM )
896+
{
897+
// Verify the arguments
898+
CClientColShape* pColShape = NULL;
899+
CScriptArgReader argStream ( luaVM );
900+
argStream.ReadUserData ( pColShape );
901+
902+
if ( ! argStream.HasErrors ( ) )
903+
{
904+
// Grab our VM
905+
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
906+
if (pLuaMain)
907+
{
908+
lua_pushnumber ( luaVM, pColShape->GetShapeType ( ) + 1 );
909+
return 1;
910+
}
911+
}
912+
else
913+
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage ( ) );
914+
915+
// Failed
916+
lua_pushboolean ( luaVM, false );
917+
return 1;
918+
}
894919

895920
int CLuaElementDefs::GetElementsWithinColShape ( lua_State* luaVM )
896921
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class CLuaElementDefs : public CLuaDefs
3838
LUA_DECLARE ( IsElementWithinColShape );
3939
LUA_DECLARE ( IsElementWithinMarker );
4040
LUA_DECLARE ( GetElementsWithinColShape );
41+
LUA_DECLARE ( GetColShapeType );
4142
LUA_DECLARE ( GetElementDimension );
4243
LUA_DECLARE ( GetElementZoneName );
4344
LUA_DECLARE ( GetElementBoundingBox );

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ 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, "shape", NULL, "getColShapeType" );
40+
3741
lua_registerclass ( luaVM, "ColShape", "Element" );
3842
}
3943

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ void CLuaElementDefs::LoadFunctions ( void )
4747
CLuaCFunctions::AddFunction ( "getElementType", getElementType );
4848
CLuaCFunctions::AddFunction ( "getElementInterior", getElementInterior );
4949
CLuaCFunctions::AddFunction ( "getElementsWithinColShape", getElementsWithinColShape );
50+
CLuaCFunctions::AddFunction ( "getColShapeType", getColShapeType );
5051
CLuaCFunctions::AddFunction ( "getElementDimension", getElementDimension );
5152
CLuaCFunctions::AddFunction ( "getElementZoneName", getElementZoneName );
5253
CLuaCFunctions::AddFunction ( "getElementColShape", getElementColShape );
@@ -964,6 +965,30 @@ int CLuaElementDefs::isElementWithinColShape ( lua_State* luaVM )
964965
return 1;
965966
}
966967

968+
int CLuaElementDefs::getColShapeType ( lua_State* luaVM )
969+
{
970+
// Verify the arguments
971+
CColShape* pColShape = NULL;
972+
CScriptArgReader argStream ( luaVM );
973+
argStream.ReadUserData ( pColShape );
974+
975+
if ( ! argStream.HasErrors ( ) )
976+
{
977+
// Grab our VM
978+
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
979+
if (pLuaMain)
980+
{
981+
lua_pushnumber ( luaVM, pColShape->GetShapeType ( ) + 1 ); // start from 1 not 0
982+
return 1;
983+
}
984+
}
985+
else
986+
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage ( ) );
987+
988+
// Failed
989+
lua_pushboolean( luaVM, false );
990+
return 1;
991+
}
967992

968993
int CLuaElementDefs::getElementsWithinColShape ( lua_State* luaVM )
969994
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class CLuaElementDefs: public CLuaDefs
4747
LUA_DECLARE ( getElementsByType );
4848
LUA_DECLARE ( getElementInterior );
4949
LUA_DECLARE ( getElementsWithinColShape );
50+
LUA_DECLARE ( getColShapeType );
5051
LUA_DECLARE ( getElementDimension );
5152
LUA_DECLARE ( getElementZoneName );
5253
LUA_DECLARE ( getElementColShape );

0 commit comments

Comments
 (0)