summaryrefslogtreecommitdiffstats
path: root/src/Bindings/ManualBindings.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Bindings/ManualBindings.cpp68
1 files changed, 52 insertions, 16 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 37fc20d39..08f324aec 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -1595,27 +1595,56 @@ static int tolua_cPlayer_GetRestrictions(lua_State * tolua_S)
-static int tolua_cPlayer_PermissionMatches(lua_State * tolua_S)
+static int tolua_cPlayer_GetUUID(lua_State * tolua_S)
{
- // Function signature: cPlayer:PermissionMatches(PermissionStr, TemplateStr) -> bool
+ // Check the params:
+ cLuaState L(tolua_S);
+ if (!L.CheckParamSelf("cPlayer"))
+ {
+ return 0;
+ }
+ // Get the params:
+ cPlayer * Self = nullptr;
+ L.GetStackValue(1, Self);
+
+ // Return the UUID as a string
+ L.Push(Self->GetUUID().ToShortString());
+ return 1;
+}
+
+
+
+
+
+static int tolua_cPlayer_PlaceBlock(lua_State * tolua_S)
+{
// Check the params:
cLuaState L(tolua_S);
if (
- !L.CheckParamUserTable(1, "cPlayer") ||
- !L.CheckParamString (2, 3) ||
- !L.CheckParamEnd (4)
+ !L.CheckParamSelf("cPlayer") ||
+ !L.CheckParamUserType(2, "Vector3<int>") ||
+ !L.CheckParamNumber(3, 4) ||
+ !L.CheckParamEnd(5)
)
{
return 0;
}
// Get the params:
- AString Permission, Template;
- L.GetStackValues(2, Permission, Template);
+ cPlayer * Self;
+ Vector3i Position;
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ L.GetStackValues(1, Self, Position, BlockType, BlockMeta);
- // Push the result of the match:
- L.Push(cPlayer::PermissionMatches(StringSplit(Permission, "."), StringSplit(Template, ".")));
+ if (!cChunkDef::IsValidHeight(Position.y))
+ {
+ return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'position'");
+ }
+
+ // Return the result of placement:
+ L.Push(Self->PlaceBlock(Position, BlockType, BlockMeta));
return 1;
}
@@ -1623,21 +1652,27 @@ static int tolua_cPlayer_PermissionMatches(lua_State * tolua_S)
-static int tolua_cPlayer_GetUUID(lua_State * tolua_S)
+static int tolua_cPlayer_PermissionMatches(lua_State * tolua_S)
{
+ // Function signature: cPlayer:PermissionMatches(PermissionStr, TemplateStr) -> bool
+
// Check the params:
cLuaState L(tolua_S);
- if (!L.CheckParamSelf("cPlayer"))
+ if (
+ !L.CheckParamUserTable(1, "cPlayer") ||
+ !L.CheckParamString (2, 3) ||
+ !L.CheckParamEnd (4)
+ )
{
return 0;
}
// Get the params:
- cPlayer * Self = nullptr;
- L.GetStackValue(1, Self);
+ AString Permission, Template;
+ L.GetStackValues(2, Permission, Template);
- // Return the UUID as a string
- L.Push(Self->GetUUID().ToShortString());
+ // Push the result of the match:
+ L.Push(cPlayer::PermissionMatches(StringSplit(Permission, "."), StringSplit(Template, ".")));
return 1;
}
@@ -4601,8 +4636,9 @@ void cManualBindings::Bind(lua_State * tolua_S)
tolua_beginmodule(tolua_S, "cPlayer");
tolua_function(tolua_S, "GetPermissions", tolua_cPlayer_GetPermissions);
tolua_function(tolua_S, "GetRestrictions", tolua_cPlayer_GetRestrictions);
- tolua_function(tolua_S, "PermissionMatches", tolua_cPlayer_PermissionMatches);
tolua_function(tolua_S, "GetUUID", tolua_cPlayer_GetUUID);
+ tolua_function(tolua_S, "PermissionMatches", tolua_cPlayer_PermissionMatches);
+ tolua_function(tolua_S, "PlaceBlock", tolua_cPlayer_PlaceBlock);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cPlugin");