summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
Diffstat (limited to 'src/Bindings')
-rw-r--r--src/Bindings/ManualBindings_World.cpp63
1 files changed, 61 insertions, 2 deletions
diff --git a/src/Bindings/ManualBindings_World.cpp b/src/Bindings/ManualBindings_World.cpp
index c3588c914..25164f958 100644
--- a/src/Bindings/ManualBindings_World.cpp
+++ b/src/Bindings/ManualBindings_World.cpp
@@ -1427,9 +1427,9 @@ static int tolua_cWorld_QueueTask(lua_State * tolua_S)
static int tolua_cWorld_SetBlock(lua_State * tolua_S)
{
/* Function signature:
- World:SetBlock(BlockX, BlockY, BlockZ)
+ World:SetBlock(BlockX, BlockY, BlockZ, BlockType, BlockMeta)
--or--
- World:SetBlock(Position)
+ World:SetBlock(Position, BlockType, BlockMeta)
*/
cLuaState L(tolua_S);
@@ -1483,6 +1483,64 @@ static int tolua_cWorld_SetBlock(lua_State * tolua_S)
+static int tolua_cWorld_SetBlockMeta(lua_State * tolua_S)
+{
+ /* Function signature:
+ World:SetBlockMeta(BlockX, BlockY, BlockZ, BlockMeta)
+ --or--
+ World:SetBlockMeta(Position, BlockMeta)
+ */
+
+ cLuaState L(tolua_S);
+ int OffsetIndex;
+ if (
+ !L.CheckParamSelf("cWorld") ||
+ !CheckParamVectorOr3Numbers(L, "Vector3<int>", 2, OffsetIndex) ||
+ !L.CheckParamNumber(OffsetIndex) ||
+ !L.CheckParamEnd(OffsetIndex + 1)
+ )
+ {
+ return 0;
+ }
+
+ if (OffsetIndex != 3) // Not the vector overload
+ {
+ L.LogStackTrace();
+ LOGWARN("SetBlockMeta with 3 position arguments is deprecated, use vector-parametered version instead.");
+ }
+
+ cWorld * World;
+ Vector3i Position;
+ NIBBLETYPE Meta;
+
+ // Read the params:
+ if (
+ !L.GetStackValue(1, World) ||
+ !GetStackVectorOr3Numbers(L, 2, Position) ||
+ !L.GetStackValue(OffsetIndex, Meta)
+ )
+ {
+ return 0;
+ }
+
+ if (World == nullptr)
+ {
+ return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'self'");
+ }
+
+ if (!cChunkDef::IsValidHeight(Position.y))
+ {
+ return cManualBindings::lua_do_error(tolua_S, "Error in function call '#funcname#': Invalid 'position'");
+ }
+
+ World->SetBlockMeta(Position, Meta);
+ return 0;
+}
+
+
+
+
+
static int tolua_cWorld_SetSignLines(lua_State * tolua_S)
{
// Exported manually, because tolua would generate useless additional return values (a_Line1 .. a_Line4)
@@ -1725,6 +1783,7 @@ void cManualBindings::BindWorld(lua_State * tolua_S)
tolua_function(tolua_S, "QueueTask", tolua_cWorld_QueueTask);
tolua_function(tolua_S, "ScheduleTask", tolua_cWorld_ScheduleTask);
tolua_function(tolua_S, "SetBlock", tolua_cWorld_SetBlock);
+ tolua_function(tolua_S, "SetBlockMeta", tolua_cWorld_SetBlockMeta);
tolua_function(tolua_S, "SetSignLines", tolua_cWorld_SetSignLines);
tolua_function(tolua_S, "SetTimeOfDay", tolua_cWorld_SetTimeOfDay);
tolua_function(tolua_S, "SpawnSplitExperienceOrbs", tolua_cWorld_SpawnSplitExperienceOrbs);