From 94ab16cff161ce3f521c7a29e1ee053543de16a1 Mon Sep 17 00:00:00 2001 From: Qais Patankar Date: Wed, 10 Jun 2015 03:21:50 +0100 Subject: [PATCH] [luadefs-server] Clean up Element, Pickup, Text & XML --- .../mods/deathmatch/logic/lua/CLuaMain.cpp | 247 ++---------------- .../mods/deathmatch/logic/lua/CLuaMain.h | 5 - .../logic/luadefs/CLuaElementDefs.cpp | 247 +++++++++++++----- .../logic/luadefs/CLuaElementDefs.h | 1 + .../deathmatch/logic/luadefs/CLuaFileDefs.cpp | 32 +-- .../logic/luadefs/CLuaPickupDefs.cpp | 49 +++- .../deathmatch/logic/luadefs/CLuaPickupDefs.h | 1 + .../deathmatch/logic/luadefs/CLuaTextDefs.cpp | 53 ++++ .../deathmatch/logic/luadefs/CLuaTextDefs.h | 1 + .../deathmatch/logic/luadefs/CLuaXMLDefs.cpp | 82 ++++-- .../deathmatch/logic/luadefs/CLuaXMLDefs.h | 1 + 11 files changed, 362 insertions(+), 357 deletions(-) diff --git a/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.cpp b/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.cpp index c541a5b380..d91c733f06 100644 --- a/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.cpp +++ b/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.cpp @@ -165,114 +165,6 @@ void CLuaMain::InitSecurity ( void ) } -// TODO: specials -void CLuaMain::AddElementClass ( lua_State* luaVM ) -{ - lua_newclass ( luaVM ); - - lua_classfunction ( luaVM, "getByID", "getElementByID" ); - lua_classfunction ( luaVM, "getAllByType", "getElementsByType" ); - lua_classfunction ( luaVM, "getByIndex", "getElementByIndex" ); - - lua_classfunction ( luaVM, "create", "createElement" ); - lua_classfunction ( luaVM, "clone", "cloneElement" ); - lua_classfunction ( luaVM, "destroy", "destroyElement" ); - lua_classfunction ( luaVM, "clearVisibility", "clearElementVisibleTo" ); - lua_classfunction ( luaVM, "attach", "attachElements" ); - lua_classfunction ( luaVM, "detach", "detachElements" ); - lua_classfunction ( luaVM, "removeData", "removeElementData" ); - - lua_classfunction ( luaVM, "setParent", "setElementParent" ); - lua_classfunction ( luaVM, "setVelocity", "setElementVelocity" ); - lua_classfunction ( luaVM, "setFrozen", "setElementFrozen" ); - lua_classfunction ( luaVM, "setHealth", "setElementHealth" ); - lua_classfunction ( luaVM, "setModel", "setElementModel" ); - lua_classfunction ( luaVM, "setSyncer", "setElementSyncer" ); - lua_classfunction ( luaVM, "setAlpha", "setElementAlpha" ); - lua_classfunction ( luaVM, "setDoubleSided", "setElementDoubleSided" ); - lua_classfunction ( luaVM, "setCollisionsEnabled", "setElementCollisionsEnabled" ); - lua_classfunction ( luaVM, "setData", "setElementData" ); - lua_classfunction ( luaVM, "setPosition", "setElementPosition" ); - lua_classfunction ( luaVM, "setRotation", "setElementRotation" ); - lua_classfunction ( luaVM, "setVelocity", "setElementVelocity" ); - lua_classfunction ( luaVM, "setMatrix", "setElementMatrix" ); - lua_classfunction ( luaVM, "setID", "setElementID" ); - lua_classfunction ( luaVM, "setInterior", "setElementInterior" ); - lua_classfunction ( luaVM, "setDimension", "setElementDimension" ); - lua_classfunction ( luaVM, "setLowLOD", "setLowLODElement" ); - lua_classfunction ( luaVM, "setAttachedOffsets", "setElementAttachedOffsets" ); - lua_classfunction ( luaVM, "setCallPropagationEnabled", "setElementCallPropagationEnabled" ); - - lua_classfunction ( luaVM, "getAttachedOffsets", "getElementAttachedOffsets" ); - lua_classfunction ( luaVM, "getChild", "getElementChild" ); - lua_classfunction ( luaVM, "getChildren", "getElementChildren" ); - lua_classfunction ( luaVM, "getParent", "getElementParent" ); - lua_classfunction ( luaVM, "getAttachedElements", "getAttachedElements" ); - lua_classfunction ( luaVM, "getAttachedTo", "getElementAttachedTo" ); - lua_classfunction ( luaVM, "getVelocity", "getElementVelocity", CLuaOOPDefs::GetElementVelocity ); - lua_classfunction ( luaVM, "getID", "getElementID" ); - lua_classfunction ( luaVM, "getZoneName", "getElementZoneName" ); - lua_classfunction ( luaVM, "getAlpha", "getElementAlpha" ); - lua_classfunction ( luaVM, "getHealth", "getElementHealth" ); - lua_classfunction ( luaVM, "getModel", "getElementModel" ); - lua_classfunction ( luaVM, "getChildrenCount", "getElementChildrenCount" ); - lua_classfunction ( luaVM, "getSyncer", "getElementSyncer" ); - lua_classfunction ( luaVM, "getAllData", "getAllElementData" ); - lua_classfunction ( luaVM, "getColShape", "getElementColShape" ); - lua_classfunction ( luaVM, "getData", "getElementData" ); - lua_classfunction ( luaVM, "getPosition", "getElementPosition", CLuaOOPDefs::GetElementPosition ); - lua_classfunction ( luaVM, "getRotation", "getElementRotation", CLuaOOPDefs::GetElementRotation ); - lua_classfunction ( luaVM, "getMatrix", "getElementMatrix", CLuaOOPDefs::GetElementMatrix ); - lua_classfunction ( luaVM, "getType", "getElementType" ); - lua_classfunction ( luaVM, "getInterior", "getElementInterior" ); - lua_classfunction ( luaVM, "getDimension", "getElementDimension" ); - lua_classfunction ( luaVM, "getLowLOD", "getLowLODElement" ); - - lua_classfunction ( luaVM, "areCollisionsEnabled", "areElementCollisionsEnabled" ); - lua_classfunction ( luaVM, "isCallPropagationEnabled", "isElementCallPropagationEnabled" ); - lua_classfunction ( luaVM, "isWaitingForGroundToLoad", "isElementWaitingForGroundToLoad" ); - lua_classfunction ( luaVM, "isWithinMarker", "isElementWithinMarker" ); - lua_classfunction ( luaVM, "isWithinColShape", "isElementWithinColShape" ); - lua_classfunction ( luaVM, "isFrozen", "isElementFrozen" ); - lua_classfunction ( luaVM, "isInWater", "isElementInWater" ); - lua_classfunction ( luaVM, "isDoubleSided", "isElementDoubleSided" ); - lua_classfunction ( luaVM, "isVisibleTo", "isElementVisibleTo" ); - lua_classfunction ( luaVM, "isLowLOD", "isElementLowLOD" ); - lua_classfunction ( luaVM, "isAttached", "isElementAttached" ); - - lua_classvariable ( luaVM, "id", "setElementID", "getElementID" ); - lua_classvariable ( luaVM, "callPropagationEnabled", "setElementCallPropagationEnabled", "isElementCallPropagationEnabled" ); - lua_classvariable ( luaVM, "waitingForGroundToLoad", NULL, "isElementWaitingForGroundToLoad" ); - lua_classvariable ( luaVM, "parent", "setElementParent", "getElementParent" ); - lua_classvariable ( luaVM, "zoneName", NULL, "getElementZoneName" ); - lua_classvariable ( luaVM, "attachedTo", "attachElements", "getElementAttachedTo" ); - lua_classvariable ( luaVM, "children", NULL, "getElementChildren" ); - lua_classvariable ( luaVM, "frozen", "setElementFrozen", "isElementFrozen" ); - lua_classvariable ( luaVM, "attachedElements", NULL, "getAttachedElements" ); - lua_classvariable ( luaVM, "inWater", NULL, "isElementInWater" ); - lua_classvariable ( luaVM, "health", "setElementHealth", "getElementHealth" ); - lua_classvariable ( luaVM, "alpha", "setElementAlpha", "getElementAlpha" ); - lua_classvariable ( luaVM, "type", NULL, "getElementType" ); - lua_classvariable ( luaVM, "dimension", "setElementDimension", "getElementDimension" ); - lua_classvariable ( luaVM, "doubleSided", "setElementDoubleSided", "isElementDoubleSided" ); - lua_classvariable ( luaVM, "model", "setElementModel", "getElementModel" ); - lua_classvariable ( luaVM, "lowLOD", "setLowLODElement", "getLowLODElement" ); - lua_classvariable ( luaVM, "syncer", NULL, "isElementSyncer" ); - lua_classvariable ( luaVM, "childrenCount", NULL, "getElementChildrenCount" ); - lua_classvariable ( luaVM, "interior", "setElementInterior", "getElementInterior" ); - lua_classvariable ( luaVM, "colShape", NULL, "getElementColShape" ); - lua_classvariable ( luaVM, "collisions", "setElementCollisionsEnabled", "getElementCollisionsEnabled" ); - lua_classvariable ( luaVM, "position", "setElementPosition", "getElementPosition", CLuaElementDefs::setElementPosition, CLuaOOPDefs::GetElementPosition ); - lua_classvariable ( luaVM, "rotation", "setElementRotation", "getElementRotation", CLuaOOPDefs::SetElementRotation, CLuaOOPDefs::GetElementRotation ); - lua_classvariable ( luaVM, "matrix", "setElementMatrix", "getElementMatrix", CLuaElementDefs::setElementMatrix, CLuaOOPDefs::GetElementMatrix ); - lua_classvariable ( luaVM, "velocity", "setElementVelocity", "getElementVelocity", CLuaElementDefs::setElementVelocity, CLuaOOPDefs::GetElementVelocity ); - lua_classvariable ( luaVM, "isElement", NULL, "isElement" ); - //lua_classvariable ( luaVM, "data", "setElementData", "getElementData", CLuaOOPDefs::SetElementData, CLuaOOPDefs::GetElementData ); - //lua_classvariable ( luaVM, "visibility", "setElementVisibleTo", "isElementVisibleTo", CLuaOOPDefs::SetElementVisibleTo, CLuaOOPDefs::IsElementVisibleTo ); // .visibility[john]=false - - lua_registerclass ( luaVM, "Element" ); -} - // TODO: specials void CLuaMain::AddACLClass ( lua_State* luaVM ) { @@ -586,33 +478,6 @@ void CLuaMain::AddPedClass ( lua_State* luaVM ) lua_registerclass ( luaVM, "Ped", "Element" ); } - -void CLuaMain::AddPickupClass ( lua_State* luaVM ) -{ - lua_newclass ( luaVM ); - - lua_classfunction ( luaVM, "create", "createPickup" ); - lua_classfunction ( luaVM, "use", "usePickup" ); - - lua_classfunction ( luaVM, "getAmmo", "getPickupAmmo" ); - lua_classfunction ( luaVM, "getAmount", "getPickupAmount" ); - lua_classfunction ( luaVM, "getWeapon", "getPickupWeapon" ); - lua_classfunction ( luaVM, "getRespawnInterval", "getPickupRespawnInterval" ); - lua_classfunction ( luaVM, "getType", "getPickupType" ); - lua_classfunction ( luaVM, "setType", "setPickupType" ); - lua_classfunction ( luaVM, "setRespawnInterval", "setPickupRespawnInterval" ); - - lua_classvariable ( luaVM, "ammo", NULL, "getPickupAmmo" ); - lua_classvariable ( luaVM, "amount", NULL, "getPickupAmount" ); - lua_classvariable ( luaVM, "spawned", NULL, "isPickupSpawned" ); - lua_classvariable ( luaVM, "weapon", NULL, "getPickupWeapon" ); - lua_classvariable ( luaVM, "type", "setPickupType", "getPickupType" ); - lua_classvariable ( luaVM, "respawnInterval", "setPickupRespawnInterval", "getPickupRespawnInterval" ); - - lua_registerclass ( luaVM, "Pickup", "Element" ); -} - - // TODO: color class, table specials void CLuaMain::AddPlayerClass ( lua_State* luaVM ) { @@ -845,55 +710,6 @@ void CLuaMain::AddTeamClass ( lua_State* luaVM ) } -void CLuaMain::AddTextDisplayClass ( lua_State* luaVM ) -{ - lua_newclass ( luaVM ); - - lua_classfunction ( luaVM, "create", "textCreateDisplay" ); - lua_classfunction ( luaVM, "destroy", "textDestroyDisplay" ); - lua_classfunction ( luaVM, "addObserver", "textDisplayAddObserver" ); - lua_classfunction ( luaVM, "removeObserver", "textDisplayRemoveObserver" ); - lua_classfunction ( luaVM, "addText", "textDisplayAddText" ); - lua_classfunction ( luaVM, "removeText", "textDisplayRemoveText" ); - - lua_classfunction ( luaVM, "isObserver", "textDisplayIsObserver" ); - lua_classfunction ( luaVM, "getObservers", "textDisplayGetObservers" ); - - lua_classvariable ( luaVM, "observers", NULL, "textDisplayGetObservers" ); - - lua_registerclass ( luaVM, "TextDisplay" ); -} - - -void CLuaMain::AddTextItemClass ( lua_State* luaVM ) -{ - lua_newclass ( luaVM ); - - lua_classfunction ( luaVM, "create", "textCreateTextItem" ); - lua_classfunction ( luaVM, "destroy", "textDestroyTextItem" ); - - lua_classfunction ( luaVM, "getColor", "textItemGetColor" ); - lua_classfunction ( luaVM, "getPosition", "textItemGetPosition" ); - lua_classfunction ( luaVM, "getPriority", "textItemGetPriority" ); - lua_classfunction ( luaVM, "getScale", "textItemGetScale" ); - lua_classfunction ( luaVM, "getText", "textItemGetText" ); - - lua_classfunction ( luaVM, "setColor", "textItemSetColor" ); - lua_classfunction ( luaVM, "setPosition", "textItemSetPosition" ); - lua_classfunction ( luaVM, "setPriority", "textItemSetPriority" ); - lua_classfunction ( luaVM, "setScale", "textItemSetScale" ); - lua_classfunction ( luaVM, "setText", "textItemSetText" ); - - lua_classvariable ( luaVM, "priority", "textItemSetPriority", "textItemGetPriority" ); - lua_classvariable ( luaVM, "scale", "textItemSetScale", "textItemGetScale" ); - lua_classvariable ( luaVM, "text", "textItemSetText", "textItemGetText" ); - //lua_classvariable ( luaVM, "color", "textItemSetColor", "textItemGetColor", CLuaOOPDefs::TextItemSetColor, CLuaOOPDefs::TextItemGetColor ); // color - lua_classvariable ( luaVM, "position", "textItemSetPosition", "textItemGetPosition" ); - - lua_registerclass ( luaVM, "TextItem" ); -} - - void CLuaMain::AddVehicleClass ( lua_State* luaVM ) { lua_newclass ( luaVM ); @@ -1071,43 +887,6 @@ void CLuaMain::AddWaterClass ( lua_State* luaVM ) lua_registerclass ( luaVM, "Water", "Element" ); } - -// TODO: Potential special -void CLuaMain::AddXMLClass ( lua_State* luaVM ) -{ - lua_newclass ( luaVM ); - - lua_classfunction ( luaVM, "load", "xmlLoadFile" ); - lua_classfunction ( luaVM, "unload", "xmlUnloadFile" ); - lua_classfunction ( luaVM, "copy", "xmlCopyFile" ); - lua_classfunction ( luaVM, "create", "xmlCreateFile" ); - lua_classfunction ( luaVM, "destroy", "xmlDestroyNode" ); - lua_classfunction ( luaVM, "loadMapData", "loadMapData" ); - lua_classfunction ( luaVM, "saveMapData", "saveMapData" ); - - lua_classfunction ( luaVM, "getValue", "xmlNodeGetValue" ); - lua_classfunction ( luaVM, "setAttribute", "xmlNodeSetAttribute" ); - lua_classfunction ( luaVM, "setValue", "xmlNodeSetValue" ); - lua_classfunction ( luaVM, "saveFile", "xmlSaveFile" ); - lua_classfunction ( luaVM, "createChild", "xmlCreateChild" ); - lua_classfunction ( luaVM, "findChild", "xmlFindChild" ); - lua_classfunction ( luaVM, "setName", "xmlNodeSetName" ); - - lua_classfunction ( luaVM, "getAttributes", "xmlNodeGetAttributes" ); - lua_classfunction ( luaVM, "getChildren", "xmlNodeGetChildren" ); - lua_classfunction ( luaVM, "getName", "xmlNodeGetName" ); - lua_classfunction ( luaVM, "getParent", "xmlNodeGetParent" ); - lua_classfunction ( luaVM, "getAttribute", "xmlNodeGetAttribute" ); // table classvar? - - lua_classvariable ( luaVM, "value", "xmlNodeSetValue", "xmlNodeGetValue" ); - lua_classvariable ( luaVM, "name", "xmlNodeSetName", "xmlNodeGetName" ); - lua_classvariable ( luaVM, "attributes", NULL, "xmlNodeGetAttributes" ); - lua_classvariable ( luaVM, "children", NULL, "xmlNodeGetChildren" ); - lua_classvariable ( luaVM, "parent", NULL, "xmlNodeGetParent" ); - - lua_registerclass ( luaVM, "XML" ); -} - void CLuaMain::AddTimerClass ( lua_State* luaVM ) { @@ -1132,17 +911,25 @@ void CLuaMain::InitClasses ( lua_State* luaVM ) lua_newclass ( luaVM ); // Vector and Matrix classes - CLuaVector4Defs::AddClass ( luaVM ); - CLuaVector3Defs::AddClass ( luaVM ); - CLuaVector2Defs::AddClass ( luaVM ); - CLuaMatrixDefs ::AddClass ( luaVM ); + CLuaVector4Defs ::AddClass ( luaVM ); + CLuaVector3Defs ::AddClass ( luaVM ); + CLuaVector2Defs ::AddClass ( luaVM ); + CLuaMatrixDefs ::AddClass ( luaVM ); // OOP based classes if ( !m_bEnableOOP ) return; - - CLuaFileDefs::AddClass ( luaVM ); - AddElementClass ( luaVM ); + + // Ordering of classes matters here - + // just make sure that inherited classes + // stay near the top. + // Putting CLuaElementDefs::AddClass near + // the bottom will cause a crash. + CLuaElementDefs ::AddClass ( luaVM ); + CLuaFileDefs ::AddClass ( luaVM ); + CLuaXMLDefs ::AddClass ( luaVM ); + CLuaPickupDefs ::AddClass ( luaVM ); + CLuaTextDefs ::AddClasses ( luaVM ); AddACLClass ( luaVM ); AddACLGroupClass ( luaVM ); AddAccountClass ( luaVM ); @@ -1152,18 +939,14 @@ void CLuaMain::InitClasses ( lua_State* luaVM ) AddMarkerClass ( luaVM ); AddObjectClass ( luaVM ); AddPedClass ( luaVM ); - AddPickupClass ( luaVM ); AddPlayerClass ( luaVM ); AddRadarAreaClass ( luaVM ); AddResourceClass ( luaVM ); AddConnectionClass ( luaVM ); AddQueryHandleClass ( luaVM ); AddTeamClass ( luaVM ); - AddTextDisplayClass ( luaVM ); - AddTextItemClass ( luaVM ); AddVehicleClass ( luaVM ); AddWaterClass ( luaVM ); - AddXMLClass ( luaVM ); AddTimerClass ( luaVM ); } diff --git a/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.h b/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.h index 1544fb70a1..f63406507e 100644 --- a/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.h +++ b/MTA10_Server/mods/deathmatch/logic/lua/CLuaMain.h @@ -129,7 +129,6 @@ class CLuaMain //: public CClient void InitClasses ( lua_State* luaVM ); public: - void AddElementClass ( lua_State* luaVM ); void AddACLClass ( lua_State* luaVM ); void AddACLGroupClass ( lua_State* luaVM ); void AddAccountClass ( lua_State* luaVM ); @@ -139,18 +138,14 @@ class CLuaMain //: public CClient void AddMarkerClass ( lua_State* luaVM ); void AddObjectClass ( lua_State* luaVM ); void AddPedClass ( lua_State* luaVM ); - void AddPickupClass ( lua_State* luaVM ); void AddPlayerClass ( lua_State* luaVM ); void AddRadarAreaClass ( lua_State* luaVM ); void AddResourceClass ( lua_State* luaVM ); void AddConnectionClass ( lua_State* luaVM ); void AddQueryHandleClass ( lua_State* luaVM ); void AddTeamClass ( lua_State* luaVM ); - void AddTextDisplayClass ( lua_State* luaVM ); - void AddTextItemClass ( lua_State* luaVM ); void AddVehicleClass ( lua_State* luaVM ); void AddWaterClass ( lua_State* luaVM ); - void AddXMLClass ( lua_State* luaVM ); void AddTimerClass ( lua_State* luaVM ); bool IsOOPEnabled ( void ) { return m_bEnableOOP; } diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp index 70d762cf2b..1287f03195 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp @@ -17,91 +17,198 @@ void CLuaElementDefs::LoadFunctions ( void ) { // ** BACKWARDS COMPATIBILITY FUNCS. SHOULD BE REMOVED BEFORE FINAL RELEASE! ** - CLuaCFunctions::AddFunction ( "attachElementToElement", CLuaElementDefs::attachElements ); - CLuaCFunctions::AddFunction ( "detachElementFromElement", CLuaElementDefs::detachElements ); + CLuaCFunctions::AddFunction ( "attachElementToElement", attachElements ); + CLuaCFunctions::AddFunction ( "detachElementFromElement", detachElements ); // ** END OF BACKWARDS COMPATIBILITY FUNCS. ** // Create/destroy - CLuaCFunctions::AddFunction ( "createElement", CLuaElementDefs::createElement ); - CLuaCFunctions::AddFunction ( "destroyElement", CLuaElementDefs::destroyElement ); - CLuaCFunctions::AddFunction ( "cloneElement", CLuaElementDefs::cloneElement ); + CLuaCFunctions::AddFunction ( "createElement", createElement ); + CLuaCFunctions::AddFunction ( "destroyElement", destroyElement ); + CLuaCFunctions::AddFunction ( "cloneElement", cloneElement ); // Get - CLuaCFunctions::AddFunction ( "isElement", CLuaElementDefs::isElement ); - CLuaCFunctions::AddFunction ( "isElementWithinColShape", CLuaElementDefs::isElementWithinColShape ); - CLuaCFunctions::AddFunction ( "isElementWithinMarker", CLuaElementDefs::isElementWithinMarker ); - CLuaCFunctions::AddFunction ( "isElementInWater", CLuaElementDefs::isElementInWater ); - CLuaCFunctions::AddFunction ( "isElementFrozen", CLuaElementDefs::isElementFrozen ); - CLuaCFunctions::AddFunction ( "isElementLowLOD", CLuaElementDefs::isElementLowLOD ); - CLuaCFunctions::AddFunction ( "setElementCallPropagationEnabled", CLuaElementDefs::setElementCallPropagationEnabled ); - CLuaCFunctions::AddFunction ( "isElementCallPropagationEnabled", CLuaElementDefs::isElementCallPropagationEnabled ); - - CLuaCFunctions::AddFunction ( "getElementByID", CLuaElementDefs::getElementByID ); - CLuaCFunctions::AddFunction ( "getElementByIndex", CLuaElementDefs::getElementByIndex ); - CLuaCFunctions::AddFunction ( "getElementChildren", CLuaElementDefs::getElementChildren ); - CLuaCFunctions::AddFunction ( "getElementChild", CLuaElementDefs::getElementChild ); - CLuaCFunctions::AddFunction ( "getElementChildrenCount", CLuaElementDefs::getElementChildrenCount ); - CLuaCFunctions::AddFunction ( "getAllElementData", CLuaElementDefs::getAllElementData ); - CLuaCFunctions::AddFunction ( "getElementID", CLuaElementDefs::getElementID ); - CLuaCFunctions::AddFunction ( "getElementParent", CLuaElementDefs::getElementParent ); - CLuaCFunctions::AddFunction ( "getElementMatrix", CLuaElementDefs::getElementMatrix ); - CLuaCFunctions::AddFunction ( "getElementPosition", CLuaElementDefs::getElementPosition ); - CLuaCFunctions::AddFunction ( "getElementRotation", CLuaElementDefs::getElementRotation ); - CLuaCFunctions::AddFunction ( "getElementVelocity", CLuaElementDefs::getElementVelocity ); - CLuaCFunctions::AddFunction ( "getElementsByType", CLuaElementDefs::getElementsByType ); - CLuaCFunctions::AddFunction ( "getElementType", CLuaElementDefs::getElementType ); - CLuaCFunctions::AddFunction ( "getElementInterior", CLuaElementDefs::getElementInterior ); - CLuaCFunctions::AddFunction ( "getElementsWithinColShape", CLuaElementDefs::getElementsWithinColShape ); - CLuaCFunctions::AddFunction ( "getElementDimension", CLuaElementDefs::getElementDimension ); - CLuaCFunctions::AddFunction ( "getElementZoneName", CLuaElementDefs::getElementZoneName ); - CLuaCFunctions::AddFunction ( "getElementColShape", CLuaElementDefs::getElementColShape ); - CLuaCFunctions::AddFunction ( "getElementAlpha", CLuaElementDefs::getElementAlpha ); - CLuaCFunctions::AddFunction ( "isElementDoubleSided", CLuaElementDefs::isElementDoubleSided ); - CLuaCFunctions::AddFunction ( "getElementHealth", CLuaElementDefs::getElementHealth ); - CLuaCFunctions::AddFunction ( "getElementModel", CLuaElementDefs::getElementModel ); - CLuaCFunctions::AddFunction ( "getElementSyncer", CLuaElementDefs::getElementSyncer ); - CLuaCFunctions::AddFunction ( "getElementCollisionsEnabled", CLuaElementDefs::getElementCollisionsEnabled ); - CLuaCFunctions::AddFunction ( "getLowLODElement", CLuaElementDefs::getLowLODElement ); + CLuaCFunctions::AddFunction ( "isElement", isElement ); + CLuaCFunctions::AddFunction ( "isElementWithinColShape", isElementWithinColShape ); + CLuaCFunctions::AddFunction ( "isElementWithinMarker", isElementWithinMarker ); + CLuaCFunctions::AddFunction ( "isElementInWater", isElementInWater ); + CLuaCFunctions::AddFunction ( "isElementFrozen", isElementFrozen ); + CLuaCFunctions::AddFunction ( "isElementLowLOD", isElementLowLOD ); + CLuaCFunctions::AddFunction ( "setElementCallPropagationEnabled", setElementCallPropagationEnabled ); + CLuaCFunctions::AddFunction ( "isElementCallPropagationEnabled", isElementCallPropagationEnabled ); + + CLuaCFunctions::AddFunction ( "getElementByID", getElementByID ); + CLuaCFunctions::AddFunction ( "getElementByIndex", getElementByIndex ); + CLuaCFunctions::AddFunction ( "getElementChildren", getElementChildren ); + CLuaCFunctions::AddFunction ( "getElementChild", getElementChild ); + CLuaCFunctions::AddFunction ( "getElementChildrenCount", getElementChildrenCount ); + CLuaCFunctions::AddFunction ( "getAllElementData", getAllElementData ); + CLuaCFunctions::AddFunction ( "getElementID", getElementID ); + CLuaCFunctions::AddFunction ( "getElementParent", getElementParent ); + CLuaCFunctions::AddFunction ( "getElementMatrix", getElementMatrix ); + CLuaCFunctions::AddFunction ( "getElementPosition", getElementPosition ); + CLuaCFunctions::AddFunction ( "getElementRotation", getElementRotation ); + CLuaCFunctions::AddFunction ( "getElementVelocity", getElementVelocity ); + CLuaCFunctions::AddFunction ( "getElementsByType", getElementsByType ); + CLuaCFunctions::AddFunction ( "getElementType", getElementType ); + CLuaCFunctions::AddFunction ( "getElementInterior", getElementInterior ); + CLuaCFunctions::AddFunction ( "getElementsWithinColShape", getElementsWithinColShape ); + CLuaCFunctions::AddFunction ( "getElementDimension", getElementDimension ); + CLuaCFunctions::AddFunction ( "getElementZoneName", getElementZoneName ); + CLuaCFunctions::AddFunction ( "getElementColShape", getElementColShape ); + CLuaCFunctions::AddFunction ( "getElementAlpha", getElementAlpha ); + CLuaCFunctions::AddFunction ( "isElementDoubleSided", isElementDoubleSided ); + CLuaCFunctions::AddFunction ( "getElementHealth", getElementHealth ); + CLuaCFunctions::AddFunction ( "getElementModel", getElementModel ); + CLuaCFunctions::AddFunction ( "getElementSyncer", getElementSyncer ); + CLuaCFunctions::AddFunction ( "getElementCollisionsEnabled", getElementCollisionsEnabled ); + CLuaCFunctions::AddFunction ( "getLowLODElement", getLowLODElement ); // Attachement - CLuaCFunctions::AddFunction ( "attachElements", CLuaElementDefs::attachElements ); - CLuaCFunctions::AddFunction ( "detachElements", CLuaElementDefs::detachElements ); - CLuaCFunctions::AddFunction ( "isElementAttached", CLuaElementDefs::isElementAttached ); - CLuaCFunctions::AddFunction ( "getAttachedElements", CLuaElementDefs::getAttachedElements ); - CLuaCFunctions::AddFunction ( "getElementAttachedTo", CLuaElementDefs::getElementAttachedTo ); - CLuaCFunctions::AddFunction ( "setElementAttachedOffsets", CLuaElementDefs::setElementAttachedOffsets ); - CLuaCFunctions::AddFunction ( "getElementAttachedOffsets", CLuaElementDefs::getElementAttachedOffsets ); + CLuaCFunctions::AddFunction ( "attachElements", attachElements ); + CLuaCFunctions::AddFunction ( "detachElements", detachElements ); + CLuaCFunctions::AddFunction ( "isElementAttached", isElementAttached ); + CLuaCFunctions::AddFunction ( "getAttachedElements", getAttachedElements ); + CLuaCFunctions::AddFunction ( "getElementAttachedTo", getElementAttachedTo ); + CLuaCFunctions::AddFunction ( "setElementAttachedOffsets", setElementAttachedOffsets ); + CLuaCFunctions::AddFunction ( "getElementAttachedOffsets", getElementAttachedOffsets ); // Element data - CLuaCFunctions::AddFunction ( "getElementData", CLuaElementDefs::getElementData ); - CLuaCFunctions::AddFunction ( "setElementData", CLuaElementDefs::setElementData ); - CLuaCFunctions::AddFunction ( "removeElementData", CLuaElementDefs::removeElementData ); + CLuaCFunctions::AddFunction ( "getElementData", getElementData ); + CLuaCFunctions::AddFunction ( "setElementData", setElementData ); + CLuaCFunctions::AddFunction ( "removeElementData", removeElementData ); // Set - CLuaCFunctions::AddFunction ( "setElementID", CLuaElementDefs::setElementID ); - CLuaCFunctions::AddFunction ( "setElementParent", CLuaElementDefs::setElementParent ); - CLuaCFunctions::AddFunction ( "setElementMatrix", CLuaElementDefs::setElementMatrix ); - CLuaCFunctions::AddFunction ( "setElementPosition", CLuaElementDefs::setElementPosition ); - CLuaCFunctions::AddFunction ( "setElementRotation", CLuaElementDefs::setElementRotation ); - CLuaCFunctions::AddFunction ( "setElementVelocity", CLuaElementDefs::setElementVelocity ); - CLuaCFunctions::AddFunction ( "setElementVisibleTo", CLuaElementDefs::setElementVisibleTo ); - CLuaCFunctions::AddFunction ( "clearElementVisibleTo", CLuaElementDefs::clearElementVisibleTo ); - CLuaCFunctions::AddFunction ( "isElementVisibleTo", CLuaElementDefs::isElementVisibleTo ); - CLuaCFunctions::AddFunction ( "setElementInterior", CLuaElementDefs::setElementInterior ); - CLuaCFunctions::AddFunction ( "setElementDimension", CLuaElementDefs::setElementDimension ); - CLuaCFunctions::AddFunction ( "setElementAlpha", CLuaElementDefs::setElementAlpha ); - CLuaCFunctions::AddFunction ( "setElementDoubleSided", CLuaElementDefs::setElementDoubleSided ); - CLuaCFunctions::AddFunction ( "setElementHealth", CLuaElementDefs::setElementHealth ); - CLuaCFunctions::AddFunction ( "setElementModel", CLuaElementDefs::setElementModel ); - CLuaCFunctions::AddFunction ( "setElementSyncer", CLuaElementDefs::setElementSyncer ); - CLuaCFunctions::AddFunction ( "setElementCollisionsEnabled", CLuaElementDefs::setElementCollisionsEnabled ); - CLuaCFunctions::AddFunction ( "setElementFrozen", CLuaElementDefs::setElementFrozen ); - CLuaCFunctions::AddFunction ( "setLowLODElement", CLuaElementDefs::setLowLODElement ); + CLuaCFunctions::AddFunction ( "setElementID", setElementID ); + CLuaCFunctions::AddFunction ( "setElementParent", setElementParent ); + CLuaCFunctions::AddFunction ( "setElementMatrix", setElementMatrix ); + CLuaCFunctions::AddFunction ( "setElementPosition", setElementPosition ); + CLuaCFunctions::AddFunction ( "setElementRotation", setElementRotation ); + CLuaCFunctions::AddFunction ( "setElementVelocity", setElementVelocity ); + CLuaCFunctions::AddFunction ( "setElementVisibleTo", setElementVisibleTo ); + CLuaCFunctions::AddFunction ( "clearElementVisibleTo", clearElementVisibleTo ); + CLuaCFunctions::AddFunction ( "isElementVisibleTo", isElementVisibleTo ); + CLuaCFunctions::AddFunction ( "setElementInterior", setElementInterior ); + CLuaCFunctions::AddFunction ( "setElementDimension", setElementDimension ); + CLuaCFunctions::AddFunction ( "setElementAlpha", setElementAlpha ); + CLuaCFunctions::AddFunction ( "setElementDoubleSided", setElementDoubleSided ); + CLuaCFunctions::AddFunction ( "setElementHealth", setElementHealth ); + CLuaCFunctions::AddFunction ( "setElementModel", setElementModel ); + CLuaCFunctions::AddFunction ( "setElementSyncer", setElementSyncer ); + CLuaCFunctions::AddFunction ( "setElementCollisionsEnabled", setElementCollisionsEnabled ); + CLuaCFunctions::AddFunction ( "setElementFrozen", setElementFrozen ); + CLuaCFunctions::AddFunction ( "setLowLODElement", setLowLODElement ); +} + +// TODO: specials +void CLuaElementDefs::AddClass ( lua_State* luaVM ) +{ + lua_newclass ( luaVM ); + + lua_classfunction ( luaVM, "getByID", "getElementByID" ); + lua_classfunction ( luaVM, "getAllByType", "getElementsByType" ); + lua_classfunction ( luaVM, "getByIndex", "getElementByIndex" ); + + lua_classfunction ( luaVM, "create", "createElement" ); + lua_classfunction ( luaVM, "clone", "cloneElement" ); + lua_classfunction ( luaVM, "destroy", "destroyElement" ); + lua_classfunction ( luaVM, "clearVisibility", "clearElementVisibleTo" ); + lua_classfunction ( luaVM, "attach", "attachElements" ); + lua_classfunction ( luaVM, "detach", "detachElements" ); + lua_classfunction ( luaVM, "removeData", "removeElementData" ); + + lua_classfunction ( luaVM, "setParent", "setElementParent" ); + lua_classfunction ( luaVM, "setVelocity", "setElementVelocity" ); + lua_classfunction ( luaVM, "setFrozen", "setElementFrozen" ); + lua_classfunction ( luaVM, "setHealth", "setElementHealth" ); + lua_classfunction ( luaVM, "setModel", "setElementModel" ); + lua_classfunction ( luaVM, "setSyncer", "setElementSyncer" ); + lua_classfunction ( luaVM, "setAlpha", "setElementAlpha" ); + lua_classfunction ( luaVM, "setDoubleSided", "setElementDoubleSided" ); + lua_classfunction ( luaVM, "setCollisionsEnabled", "setElementCollisionsEnabled" ); + lua_classfunction ( luaVM, "setData", "setElementData" ); + lua_classfunction ( luaVM, "setPosition", "setElementPosition" ); + lua_classfunction ( luaVM, "setRotation", "setElementRotation" ); + lua_classfunction ( luaVM, "setVelocity", "setElementVelocity" ); + lua_classfunction ( luaVM, "setMatrix", "setElementMatrix" ); + lua_classfunction ( luaVM, "setID", "setElementID" ); + lua_classfunction ( luaVM, "setInterior", "setElementInterior" ); + lua_classfunction ( luaVM, "setDimension", "setElementDimension" ); + lua_classfunction ( luaVM, "setLowLOD", "setLowLODElement" ); + lua_classfunction ( luaVM, "setAttachedOffsets", "setElementAttachedOffsets" ); + lua_classfunction ( luaVM, "setCallPropagationEnabled", "setElementCallPropagationEnabled" ); + + lua_classfunction ( luaVM, "getAttachedOffsets", "getElementAttachedOffsets" ); + lua_classfunction ( luaVM, "getChild", "getElementChild" ); + lua_classfunction ( luaVM, "getChildren", "getElementChildren" ); + lua_classfunction ( luaVM, "getParent", "getElementParent" ); + lua_classfunction ( luaVM, "getAttachedElements", "getAttachedElements" ); + lua_classfunction ( luaVM, "getAttachedTo", "getElementAttachedTo" ); + lua_classfunction ( luaVM, "getVelocity", "getElementVelocity", CLuaOOPDefs::GetElementVelocity ); + lua_classfunction ( luaVM, "getID", "getElementID" ); + lua_classfunction ( luaVM, "getZoneName", "getElementZoneName" ); + lua_classfunction ( luaVM, "getAlpha", "getElementAlpha" ); + lua_classfunction ( luaVM, "getHealth", "getElementHealth" ); + lua_classfunction ( luaVM, "getModel", "getElementModel" ); + lua_classfunction ( luaVM, "getChildrenCount", "getElementChildrenCount" ); + lua_classfunction ( luaVM, "getSyncer", "getElementSyncer" ); + lua_classfunction ( luaVM, "getAllData", "getAllElementData" ); + lua_classfunction ( luaVM, "getColShape", "getElementColShape" ); + lua_classfunction ( luaVM, "getData", "getElementData" ); + lua_classfunction ( luaVM, "getPosition", "getElementPosition", CLuaOOPDefs::GetElementPosition ); + lua_classfunction ( luaVM, "getRotation", "getElementRotation", CLuaOOPDefs::GetElementRotation ); + lua_classfunction ( luaVM, "getMatrix", "getElementMatrix", CLuaOOPDefs::GetElementMatrix ); + lua_classfunction ( luaVM, "getType", "getElementType" ); + lua_classfunction ( luaVM, "getInterior", "getElementInterior" ); + lua_classfunction ( luaVM, "getDimension", "getElementDimension" ); + lua_classfunction ( luaVM, "getLowLOD", "getLowLODElement" ); + + lua_classfunction ( luaVM, "areCollisionsEnabled", "areElementCollisionsEnabled" ); + lua_classfunction ( luaVM, "isCallPropagationEnabled", "isElementCallPropagationEnabled" ); + lua_classfunction ( luaVM, "isWaitingForGroundToLoad", "isElementWaitingForGroundToLoad" ); + lua_classfunction ( luaVM, "isWithinMarker", "isElementWithinMarker" ); + lua_classfunction ( luaVM, "isWithinColShape", "isElementWithinColShape" ); + lua_classfunction ( luaVM, "isFrozen", "isElementFrozen" ); + lua_classfunction ( luaVM, "isInWater", "isElementInWater" ); + lua_classfunction ( luaVM, "isDoubleSided", "isElementDoubleSided" ); + lua_classfunction ( luaVM, "isVisibleTo", "isElementVisibleTo" ); + lua_classfunction ( luaVM, "isLowLOD", "isElementLowLOD" ); + lua_classfunction ( luaVM, "isAttached", "isElementAttached" ); + + lua_classvariable ( luaVM, "id", "setElementID", "getElementID" ); + lua_classvariable ( luaVM, "callPropagationEnabled", "setElementCallPropagationEnabled", "isElementCallPropagationEnabled" ); + lua_classvariable ( luaVM, "waitingForGroundToLoad", NULL, "isElementWaitingForGroundToLoad" ); + lua_classvariable ( luaVM, "parent", "setElementParent", "getElementParent" ); + lua_classvariable ( luaVM, "zoneName", NULL, "getElementZoneName" ); + lua_classvariable ( luaVM, "attachedTo", "attachElements", "getElementAttachedTo" ); + lua_classvariable ( luaVM, "children", NULL, "getElementChildren" ); + lua_classvariable ( luaVM, "frozen", "setElementFrozen", "isElementFrozen" ); + lua_classvariable ( luaVM, "attachedElements", NULL, "getAttachedElements" ); + lua_classvariable ( luaVM, "inWater", NULL, "isElementInWater" ); + lua_classvariable ( luaVM, "health", "setElementHealth", "getElementHealth" ); + lua_classvariable ( luaVM, "alpha", "setElementAlpha", "getElementAlpha" ); + lua_classvariable ( luaVM, "type", NULL, "getElementType" ); + lua_classvariable ( luaVM, "dimension", "setElementDimension", "getElementDimension" ); + lua_classvariable ( luaVM, "doubleSided", "setElementDoubleSided", "isElementDoubleSided" ); + lua_classvariable ( luaVM, "model", "setElementModel", "getElementModel" ); + lua_classvariable ( luaVM, "lowLOD", "setLowLODElement", "getLowLODElement" ); + lua_classvariable ( luaVM, "syncer", NULL, "isElementSyncer" ); + lua_classvariable ( luaVM, "childrenCount", NULL, "getElementChildrenCount" ); + lua_classvariable ( luaVM, "interior", "setElementInterior", "getElementInterior" ); + lua_classvariable ( luaVM, "colShape", NULL, "getElementColShape" ); + lua_classvariable ( luaVM, "collisions", "setElementCollisionsEnabled", "getElementCollisionsEnabled" ); + lua_classvariable ( luaVM, "position", "setElementPosition", "getElementPosition", setElementPosition, CLuaOOPDefs::GetElementPosition ); + lua_classvariable ( luaVM, "rotation", "setElementRotation", "getElementRotation", CLuaOOPDefs::SetElementRotation, CLuaOOPDefs::GetElementRotation ); + lua_classvariable ( luaVM, "matrix", "setElementMatrix", "getElementMatrix", setElementMatrix, CLuaOOPDefs::GetElementMatrix ); + lua_classvariable ( luaVM, "velocity", "setElementVelocity", "getElementVelocity", setElementVelocity, CLuaOOPDefs::GetElementVelocity ); + lua_classvariable ( luaVM, "isElement", NULL, "isElement" ); + //lua_classvariable ( luaVM, "data", "setElementData", "getElementData", CLuaOOPDefs::SetElementData, CLuaOOPDefs::GetElementData ); + //lua_classvariable ( luaVM, "visibility", "setElementVisibleTo", "isElementVisibleTo", CLuaOOPDefs::SetElementVisibleTo, CLuaOOPDefs::IsElementVisibleTo ); // .visibility[john]=false + + lua_registerclass ( luaVM, "Element" ); } - int CLuaElementDefs::createElement ( lua_State* luaVM ) { // element createElement ( string elementType, [ string elementID ] ) diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h index fb2debcc08..dd3f54f94d 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h @@ -21,6 +21,7 @@ class CLuaElementDefs: public CLuaDefs { public: static void LoadFunctions ( void ); + static void AddClass ( lua_State* luaVM ); // Create/destroy static int createElement ( lua_State* luaVM ); diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaFileDefs.cpp b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaFileDefs.cpp index 1be0f566cd..e1782fa597 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaFileDefs.cpp +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaFileDefs.cpp @@ -18,22 +18,22 @@ #define DEFAULT_MAX_FILESIZE 52428800 void CLuaFileDefs::LoadFunctions ( void ) -{ - CLuaCFunctions::AddFunction ( "fileCreate", CLuaFileDefs::fileCreate ); - CLuaCFunctions::AddFunction ( "fileExists", CLuaFileDefs::fileExists ); - CLuaCFunctions::AddFunction ( "fileOpen", CLuaFileDefs::fileOpen ); - CLuaCFunctions::AddFunction ( "fileIsEOF", CLuaFileDefs::fileIsEOF ); - CLuaCFunctions::AddFunction ( "fileGetPos", CLuaFileDefs::fileGetPos ); - CLuaCFunctions::AddFunction ( "fileSetPos", CLuaFileDefs::fileSetPos ); - CLuaCFunctions::AddFunction ( "fileGetSize", CLuaFileDefs::fileGetSize ); - CLuaCFunctions::AddFunction ( "fileRead", CLuaFileDefs::fileRead ); - CLuaCFunctions::AddFunction ( "fileWrite", CLuaFileDefs::fileWrite ); - CLuaCFunctions::AddFunction ( "fileFlush", CLuaFileDefs::fileFlush ); - CLuaCFunctions::AddFunction ( "fileClose", CLuaFileDefs::fileClose ); - CLuaCFunctions::AddFunction ( "fileDelete", CLuaFileDefs::fileDelete ); - CLuaCFunctions::AddFunction ( "fileRename", CLuaFileDefs::fileRename ); - CLuaCFunctions::AddFunction ( "fileCopy", CLuaFileDefs::fileCopy ); - CLuaCFunctions::AddFunction ( "fileGetPath", CLuaFileDefs::fileGetPath ); +{ + CLuaCFunctions::AddFunction ( "fileCreate", fileCreate ); + CLuaCFunctions::AddFunction ( "fileExists", fileExists ); + CLuaCFunctions::AddFunction ( "fileOpen", fileOpen ); + CLuaCFunctions::AddFunction ( "fileIsEOF", fileIsEOF ); + CLuaCFunctions::AddFunction ( "fileGetPos", fileGetPos ); + CLuaCFunctions::AddFunction ( "fileSetPos", fileSetPos ); + CLuaCFunctions::AddFunction ( "fileGetSize", fileGetSize ); + CLuaCFunctions::AddFunction ( "fileRead", fileRead ); + CLuaCFunctions::AddFunction ( "fileWrite", fileWrite ); + CLuaCFunctions::AddFunction ( "fileFlush", fileFlush ); + CLuaCFunctions::AddFunction ( "fileClose", fileClose ); + CLuaCFunctions::AddFunction ( "fileDelete", fileDelete ); + CLuaCFunctions::AddFunction ( "fileRename", fileRename ); + CLuaCFunctions::AddFunction ( "fileCopy", fileCopy ); + CLuaCFunctions::AddFunction ( "fileGetPath", fileGetPath ); } diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaPickupDefs.cpp b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaPickupDefs.cpp index bb2fdc12a7..47ef9b32df 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaPickupDefs.cpp +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaPickupDefs.cpp @@ -16,21 +16,48 @@ void CLuaPickupDefs::LoadFunctions ( void ) { // Create/destroy - CLuaCFunctions::AddFunction ( "createPickup", CLuaPickupDefs::createPickup ); + CLuaCFunctions::AddFunction ( "createPickup", createPickup ); // Get - CLuaCFunctions::AddFunction ( "getPickupType", CLuaPickupDefs::getPickupType ); - CLuaCFunctions::AddFunction ( "getPickupWeapon", CLuaPickupDefs::getPickupWeapon ); - CLuaCFunctions::AddFunction ( "getPickupAmount", CLuaPickupDefs::getPickupAmount ); - CLuaCFunctions::AddFunction ( "getPickupAmmo", CLuaPickupDefs::getPickupAmmo ); - CLuaCFunctions::AddFunction ( "getPickupRespawnInterval", CLuaPickupDefs::getPickupRespawnInterval ); - CLuaCFunctions::AddFunction ( "isPickupSpawned", CLuaPickupDefs::isPickupSpawned ); + CLuaCFunctions::AddFunction ( "getPickupType", getPickupType ); + CLuaCFunctions::AddFunction ( "getPickupWeapon", getPickupWeapon ); + CLuaCFunctions::AddFunction ( "getPickupAmount", getPickupAmount ); + CLuaCFunctions::AddFunction ( "getPickupAmmo", getPickupAmmo ); + CLuaCFunctions::AddFunction ( "getPickupRespawnInterval", getPickupRespawnInterval ); + CLuaCFunctions::AddFunction ( "isPickupSpawned", isPickupSpawned ); // Set - CLuaCFunctions::AddFunction ( "setPickupType", CLuaPickupDefs::setPickupType ); - CLuaCFunctions::AddFunction ( "setPickupRespawnInterval", CLuaPickupDefs::setPickupRespawnInterval ); - CLuaCFunctions::AddFunction ( "usePickup", CLuaPickupDefs::usePickup ); -} + CLuaCFunctions::AddFunction ( "setPickupType", setPickupType ); + CLuaCFunctions::AddFunction ( "setPickupRespawnInterval", setPickupRespawnInterval ); + CLuaCFunctions::AddFunction ( "usePickup", usePickup ); +} + + +void CLuaPickupDefs::AddClass ( lua_State* luaVM ) +{ + lua_newclass ( luaVM ); + + lua_classfunction ( luaVM, "create", "createPickup" ); + lua_classfunction ( luaVM, "use", "usePickup" ); + + lua_classfunction ( luaVM, "getAmmo", "getPickupAmmo" ); + lua_classfunction ( luaVM, "getAmount", "getPickupAmount" ); + lua_classfunction ( luaVM, "getWeapon", "getPickupWeapon" ); + lua_classfunction ( luaVM, "getRespawnInterval", "getPickupRespawnInterval" ); + lua_classfunction ( luaVM, "getType", "getPickupType" ); + lua_classfunction ( luaVM, "setType", "setPickupType" ); + lua_classfunction ( luaVM, "setRespawnInterval", "setPickupRespawnInterval" ); + + lua_classvariable ( luaVM, "ammo", NULL, "getPickupAmmo" ); + lua_classvariable ( luaVM, "amount", NULL, "getPickupAmount" ); + lua_classvariable ( luaVM, "spawned", NULL, "isPickupSpawned" ); + lua_classvariable ( luaVM, "weapon", NULL, "getPickupWeapon" ); + lua_classvariable ( luaVM, "type", "setPickupType", "getPickupType" ); + lua_classvariable ( luaVM, "respawnInterval", "setPickupRespawnInterval", "getPickupRespawnInterval" ); + + lua_registerclass ( luaVM, "Pickup", "Element" ); +} + int CLuaPickupDefs::createPickup ( lua_State* luaVM ) diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaPickupDefs.h b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaPickupDefs.h index 931edf76ae..8cc4243a83 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaPickupDefs.h +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaPickupDefs.h @@ -19,6 +19,7 @@ class CLuaPickupDefs: public CLuaDefs { public: + static void AddClass ( lua_State* luaVM ); static void LoadFunctions ( void ); // Create/destroy diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaTextDefs.cpp b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaTextDefs.cpp index 1b334c878e..28be4e1c21 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaTextDefs.cpp +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaTextDefs.cpp @@ -39,6 +39,59 @@ void CLuaTextDefs::LoadFunctions ( void ) CLuaCFunctions::AddFunction ( "textItemGetPriority", CLuaTextDefs::textItemGetPriority ); } +void CLuaTextDefs::AddClasses ( lua_State* luaVM ) +{ + ////////////////////////// + // TextDisplay class + ////////////////////////// + lua_newclass ( luaVM ); + + lua_classfunction ( luaVM, "create", "textCreateDisplay" ); + lua_classfunction ( luaVM, "destroy", "textDestroyDisplay" ); + lua_classfunction ( luaVM, "addObserver", "textDisplayAddObserver" ); + lua_classfunction ( luaVM, "removeObserver", "textDisplayRemoveObserver" ); + lua_classfunction ( luaVM, "addText", "textDisplayAddText" ); + lua_classfunction ( luaVM, "removeText", "textDisplayRemoveText" ); + + lua_classfunction ( luaVM, "isObserver", "textDisplayIsObserver" ); + lua_classfunction ( luaVM, "getObservers", "textDisplayGetObservers" ); + + lua_classvariable ( luaVM, "observers", NULL, "textDisplayGetObservers" ); + + lua_registerclass ( luaVM, "TextDisplay" ); + ////////////////////////// + + + + ////////////////////////// + // TextItem class + ////////////////////////// + lua_newclass ( luaVM ); + + lua_classfunction ( luaVM, "create", "textCreateTextItem" ); + lua_classfunction ( luaVM, "destroy", "textDestroyTextItem" ); + + lua_classfunction ( luaVM, "getColor", "textItemGetColor" ); + lua_classfunction ( luaVM, "getPosition", "textItemGetPosition" ); + lua_classfunction ( luaVM, "getPriority", "textItemGetPriority" ); + lua_classfunction ( luaVM, "getScale", "textItemGetScale" ); + lua_classfunction ( luaVM, "getText", "textItemGetText" ); + + lua_classfunction ( luaVM, "setColor", "textItemSetColor" ); + lua_classfunction ( luaVM, "setPosition", "textItemSetPosition" ); + lua_classfunction ( luaVM, "setPriority", "textItemSetPriority" ); + lua_classfunction ( luaVM, "setScale", "textItemSetScale" ); + lua_classfunction ( luaVM, "setText", "textItemSetText" ); + + lua_classvariable ( luaVM, "priority", "textItemSetPriority", "textItemGetPriority" ); + lua_classvariable ( luaVM, "scale", "textItemSetScale", "textItemGetScale" ); + lua_classvariable ( luaVM, "text", "textItemSetText", "textItemGetText" ); + //lua_classvariable ( luaVM, "color", "textItemSetColor", "textItemGetColor", CLuaOOPDefs::TextItemSetColor, CLuaOOPDefs::TextItemGetColor ); // color + lua_classvariable ( luaVM, "position", "textItemSetPosition", "textItemGetPosition" ); + + lua_registerclass ( luaVM, "TextItem" ); + ////////////////////////// +} int CLuaTextDefs::textCreateDisplay ( lua_State* luaVM ) { diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaTextDefs.h b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaTextDefs.h index 44374b1720..6b86a9e50c 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaTextDefs.h +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaTextDefs.h @@ -20,6 +20,7 @@ class CLuaTextDefs: public CLuaDefs { public: static void LoadFunctions ( void ); + static void AddClasses ( lua_State* luaVM ); static int textCreateDisplay ( lua_State* luaVM ); static int textDestroyDisplay ( lua_State* luaVM ); diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaXMLDefs.cpp b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaXMLDefs.cpp index b61f29659b..23403b1c16 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaXMLDefs.cpp +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaXMLDefs.cpp @@ -19,31 +19,67 @@ void CLuaXMLDefs::LoadFunctions ( void ) { // ** BACKWARDS COMPATIBILITY FUNCS. SHOULD BE REMOVED BEFORE FINAL RELEASE! ** - CLuaCFunctions::AddFunction ( "xmlNodeGetSubNodes", CLuaXMLDefs::xmlNodeGetChildren ); - CLuaCFunctions::AddFunction ( "xmlCreateSubNode", CLuaXMLDefs::xmlCreateChild ); - CLuaCFunctions::AddFunction ( "xmlFindSubNode", CLuaXMLDefs::xmlNodeFindChild ); + CLuaCFunctions::AddFunction ( "xmlNodeGetSubNodes", xmlNodeGetChildren ); + CLuaCFunctions::AddFunction ( "xmlCreateSubNode", xmlCreateChild ); + CLuaCFunctions::AddFunction ( "xmlFindSubNode", xmlNodeFindChild ); // ** END OF BACKWARDS COMPATIBILITY FUNCS. ** - CLuaCFunctions::AddFunction ( "xmlCreateFile", CLuaXMLDefs::xmlCreateFile ); - CLuaCFunctions::AddFunction ( "xmlLoadFile", CLuaXMLDefs::xmlLoadFile ); - CLuaCFunctions::AddFunction ( "xmlCopyFile", CLuaXMLDefs::xmlCopyFile ); - CLuaCFunctions::AddFunction ( "xmlSaveFile", CLuaXMLDefs::xmlSaveFile ); - CLuaCFunctions::AddFunction ( "xmlUnloadFile", CLuaXMLDefs::xmlUnloadFile ); - - CLuaCFunctions::AddFunction ( "xmlCreateChild", CLuaXMLDefs::xmlCreateChild ); - CLuaCFunctions::AddFunction ( "xmlDestroyNode", CLuaXMLDefs::xmlDestroyNode ); - CLuaCFunctions::AddFunction ( "xmlFindChild", CLuaXMLDefs::xmlNodeFindChild ); - CLuaCFunctions::AddFunction ( "xmlNodeGetChildren", CLuaXMLDefs::xmlNodeGetChildren ); - CLuaCFunctions::AddFunction ( "xmlNodeGetParent", CLuaXMLDefs::xmlNodeGetParent ); - - CLuaCFunctions::AddFunction ( "xmlNodeGetValue", CLuaXMLDefs::xmlNodeGetValue ); - CLuaCFunctions::AddFunction ( "xmlNodeSetValue", CLuaXMLDefs::xmlNodeSetValue ); - CLuaCFunctions::AddFunction ( "xmlNodeGetAttributes", CLuaXMLDefs::xmlNodeGetAttributes ); - CLuaCFunctions::AddFunction ( "xmlNodeGetAttribute", CLuaXMLDefs::xmlNodeGetAttribute ); - CLuaCFunctions::AddFunction ( "xmlNodeSetAttribute", CLuaXMLDefs::xmlNodeSetAttribute ); - - CLuaCFunctions::AddFunction ( "xmlNodeGetName", CLuaXMLDefs::xmlNodeGetName ); - CLuaCFunctions::AddFunction ( "xmlNodeSetName", CLuaXMLDefs::xmlNodeSetName ); + CLuaCFunctions::AddFunction ( "xmlCreateFile", xmlCreateFile ); + CLuaCFunctions::AddFunction ( "xmlLoadFile", xmlLoadFile ); + CLuaCFunctions::AddFunction ( "xmlCopyFile", xmlCopyFile ); + CLuaCFunctions::AddFunction ( "xmlSaveFile", xmlSaveFile ); + CLuaCFunctions::AddFunction ( "xmlUnloadFile", xmlUnloadFile ); + + CLuaCFunctions::AddFunction ( "xmlCreateChild", xmlCreateChild ); + CLuaCFunctions::AddFunction ( "xmlDestroyNode", xmlDestroyNode ); + CLuaCFunctions::AddFunction ( "xmlFindChild", xmlNodeFindChild ); + CLuaCFunctions::AddFunction ( "xmlNodeGetChildren", xmlNodeGetChildren ); + CLuaCFunctions::AddFunction ( "xmlNodeGetParent", xmlNodeGetParent ); + + CLuaCFunctions::AddFunction ( "xmlNodeGetValue", xmlNodeGetValue ); + CLuaCFunctions::AddFunction ( "xmlNodeSetValue", xmlNodeSetValue ); + CLuaCFunctions::AddFunction ( "xmlNodeGetAttributes", xmlNodeGetAttributes ); + CLuaCFunctions::AddFunction ( "xmlNodeGetAttribute", xmlNodeGetAttribute ); + CLuaCFunctions::AddFunction ( "xmlNodeSetAttribute", xmlNodeSetAttribute ); + + CLuaCFunctions::AddFunction ( "xmlNodeGetName", xmlNodeGetName ); + CLuaCFunctions::AddFunction ( "xmlNodeSetName", xmlNodeSetName ); +} + + +void CLuaXMLDefs::AddClass ( lua_State* luaVM ) +{ + lua_newclass ( luaVM ); + + lua_classfunction ( luaVM, "load", "xmlLoadFile" ); + lua_classfunction ( luaVM, "unload", "xmlUnloadFile" ); + lua_classfunction ( luaVM, "copy", "xmlCopyFile" ); + lua_classfunction ( luaVM, "create", "xmlCreateFile" ); + lua_classfunction ( luaVM, "destroy", "xmlDestroyNode" ); + lua_classfunction ( luaVM, "loadMapData", "loadMapData" ); + lua_classfunction ( luaVM, "saveMapData", "saveMapData" ); + + lua_classfunction ( luaVM, "getValue", "xmlNodeGetValue" ); + lua_classfunction ( luaVM, "setAttribute", "xmlNodeSetAttribute" ); + lua_classfunction ( luaVM, "setValue", "xmlNodeSetValue" ); + lua_classfunction ( luaVM, "saveFile", "xmlSaveFile" ); + lua_classfunction ( luaVM, "createChild", "xmlCreateChild" ); + lua_classfunction ( luaVM, "findChild", "xmlFindChild" ); + lua_classfunction ( luaVM, "setName", "xmlNodeSetName" ); + + lua_classfunction ( luaVM, "getAttributes", "xmlNodeGetAttributes" ); + lua_classfunction ( luaVM, "getChildren", "xmlNodeGetChildren" ); + lua_classfunction ( luaVM, "getName", "xmlNodeGetName" ); + lua_classfunction ( luaVM, "getParent", "xmlNodeGetParent" ); + lua_classfunction ( luaVM, "getAttribute", "xmlNodeGetAttribute" ); // table classvar? + + lua_classvariable ( luaVM, "value", "xmlNodeSetValue", "xmlNodeGetValue" ); + lua_classvariable ( luaVM, "name", "xmlNodeSetName", "xmlNodeGetName" ); + lua_classvariable ( luaVM, "attributes", NULL, "xmlNodeGetAttributes" ); + lua_classvariable ( luaVM, "children", NULL, "xmlNodeGetChildren" ); + lua_classvariable ( luaVM, "parent", NULL, "xmlNodeGetParent" ); + + lua_registerclass ( luaVM, "XML" ); } diff --git a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaXMLDefs.h b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaXMLDefs.h index 09c7b3393d..e4bc6913a4 100644 --- a/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaXMLDefs.h +++ b/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaXMLDefs.h @@ -22,6 +22,7 @@ class CLuaXMLDefs: public CLuaDefs { public: + static void AddClass ( lua_State* luaVM ); static void LoadFunctions ( void ); static int xmlCreateFile ( lua_State* luaVM );