summaryrefslogtreecommitdiffstats
path: root/src/Bindings/DeprecatedBindings.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2016-08-20 14:34:29 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2016-08-20 14:34:29 +0200
commit7175b9e435a54cff33914d21384625a445cc5cf0 (patch)
tree7feb44f1e8e4ed7ea4d5bf0ba1d173abd3417f34 /src/Bindings/DeprecatedBindings.cpp
parentAdded cWorld:SetSpawn() API and Lua binding (#3316) (diff)
downloadcuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar
cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.gz
cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.bz2
cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.lz
cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.xz
cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.tar.zst
cuberite-7175b9e435a54cff33914d21384625a445cc5cf0.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/DeprecatedBindings.cpp125
1 files changed, 125 insertions, 0 deletions
diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp
index 0ffc58cbb..4f610eb78 100644
--- a/src/Bindings/DeprecatedBindings.cpp
+++ b/src/Bindings/DeprecatedBindings.cpp
@@ -291,6 +291,126 @@ tolua_lerror:
+/* function: TeleportToCoords */
+static int tolua_cEntity_TeleportToCoords00(lua_State* tolua_S)
+{
+ cLuaState LuaState(tolua_S);
+
+ if (
+ !LuaState.CheckParamUserType(1, "cEntity") ||
+ !LuaState.CheckParamNumber(2, 4) ||
+ !LuaState.CheckParamEnd(5)
+ )
+ return 0;
+ else
+ {
+ cEntity * self = nullptr;
+ double BlockX = 0;
+ double BlockY = 0;
+ double BlockZ = 0;
+
+ LuaState.GetStackValues(1, self, BlockX, BlockY, BlockZ);
+
+ #ifndef TOLUA_RELEASE
+ if (self == nullptr)
+ {
+ tolua_error(LuaState, "invalid 'self' in function 'TeleportToCoords'", nullptr);
+ }
+ #endif
+ {
+ self->TeleportToCoords({ BlockX, BlockY, BlockZ });
+ }
+ }
+ LOGWARNING("Warning in function call 'TeleportToCoords': TeleportToCoords(X, Y, Z) is deprecated. Please use TeleportToCoords(Vector3d)");
+ LuaState.LogStackTrace(0);
+ return 1;
+}
+
+
+
+
+
+/* function: MoveToWorld */
+static int tolua_cEntity_MoveToWorld00(lua_State* tolua_S)
+{
+ cLuaState LuaState(tolua_S);
+
+ if (!LuaState.CheckParamUserType(1, "cEntity"))
+ {
+ return 0;
+ }
+
+ if (LuaState.CheckParamString(2) && (LuaState.CheckParamEnd(3) || LuaState.CheckParamEnd(4)))
+ {
+ cEntity * self = nullptr;
+ std::string WorldName;
+ LuaState.GetStackValues(1, self, WorldName);
+
+ #ifndef TOLUA_RELEASE
+ if (self == nullptr)
+ {
+ tolua_error(LuaState, "invalid 'self' in function 'MoveToWorld'", nullptr);
+ }
+ #endif
+ {
+ self->MoveToWorld(WorldName, self->GetPosition());
+ }
+ }
+ else if (LuaState.CheckParamUserType(2, "cWorld"))
+ {
+ if (LuaState.CheckParamUserType(4, "Vector3d") && LuaState.CheckParamEnd(5))
+ {
+ cEntity * self = nullptr;
+ cWorld * World;
+ Vector3d * Position;
+ LuaState.GetStackValues(1, self, World);
+ LuaState.GetStackValues(4, Position);
+
+ #ifndef TOLUA_RELEASE
+ if (self == nullptr)
+ {
+ tolua_error(LuaState, "invalid 'self' in function 'MoveToWorld'", nullptr);
+ }
+ #endif
+ {
+ self->MoveToWorld(*World, *Position);
+ }
+ }
+ else if (LuaState.CheckParamEnd(4))
+ {
+ cEntity * self = nullptr;
+ std::string WorldName;
+ LuaState.GetStackValues(1, self, WorldName);
+
+ #ifndef TOLUA_RELEASE
+ if (self == nullptr)
+ {
+ tolua_error(LuaState, "invalid 'self' in function 'MoveToWorld'", nullptr);
+ }
+ #endif
+ {
+ self->MoveToWorld(WorldName, self->GetPosition());
+ }
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ return 0;
+ }
+
+ LOGWARNING("Warning in function call 'MoveToWorld': the ShouldSendRespawn parameter is deprecated and a destination position is mandatory.");
+ LuaState.LogStackTrace(0);
+ return 1;
+}
+
+
+
+
+
/** function: cWorld:SetSignLines */
static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
{
@@ -416,6 +536,11 @@ void DeprecatedBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S,"abs", tolua_Vector3_Abs<double>);
tolua_function(tolua_S,"clamp", tolua_Vector3_Clamp<double>);
tolua_endmodule(tolua_S);
+
+ tolua_beginmodule(tolua_S, "cEntity");
+ tolua_function(tolua_S, "MoveToWorld", tolua_cEntity_MoveToWorld00);
+ tolua_function(tolua_S, "TeleportToCoords", tolua_cEntity_TeleportToCoords00);
+ tolua_endmodule(tolua_S);
tolua_endmodule(tolua_S);
}