aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2013-07-01 18:04:17 -0400
committerkwolekr <kwolekr@minetest.net>2013-07-01 18:04:51 -0400
commitdd6d1afd8e0ded779fd004f4e83888985cba2102 (patch)
treef72610fc5fe9eb5c5cbddf576f48d92112219cbe /src/script/lua_api
parent131eb56f5202f1e4826c1cacbfcee7f34b7dfe33 (diff)
downloadminetest-dd6d1afd8e0ded779fd004f4e83888985cba2102.tar.gz
minetest-dd6d1afd8e0ded779fd004f4e83888985cba2102.tar.bz2
minetest-dd6d1afd8e0ded779fd004f4e83888985cba2102.zip
Decoration: Add schematic rotation support
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/luaapi.cpp22
-rw-r--r--src/script/lua_api/luaapi.h3
2 files changed, 22 insertions, 3 deletions
diff --git a/src/script/lua_api/luaapi.cpp b/src/script/lua_api/luaapi.cpp
index d457d257e..de0c3a670 100644
--- a/src/script/lua_api/luaapi.cpp
+++ b/src/script/lua_api/luaapi.cpp
@@ -51,6 +51,16 @@ struct EnumString ModApiBasic::es_DecorationType[] =
{0, NULL},
};
+struct EnumString ModApiBasic::es_Rotation[] =
+{
+ {ROTATE_0, "0"},
+ {ROTATE_90, "90"},
+ {ROTATE_180, "180"},
+ {ROTATE_270, "270"},
+ {ROTATE_RAND, "random"},
+ {0, NULL},
+};
+
ModApiBasic::ModApiBasic() : ModApiBase() {
}
@@ -767,7 +777,9 @@ int ModApiBasic::l_register_decoration(lua_State *L)
break; }
case DECO_SCHEMATIC: {
DecoSchematic *dschem = (DecoSchematic *)deco;
- dschem->flags = getflagsfield(L, index, "flags", flagdesc_deco_schematic);
+ dschem->flags = getflagsfield(L, index, "flags", flagdesc_deco_schematic);
+ dschem->rotation = (Rotation)getenumfield(L, index,
+ "rotation", es_Rotation, ROTATE_0);
lua_getfield(L, index, "schematic");
if (!read_schematic(L, -1, dschem, getServer(L))) {
@@ -848,7 +860,7 @@ int ModApiBasic::l_create_schematic(lua_State *L)
}
-// place_schematic(p, schematic)
+// place_schematic(p, schematic, rotation)
int ModApiBasic::l_place_schematic(lua_State *L)
{
DecoSchematic dschem;
@@ -859,6 +871,12 @@ int ModApiBasic::l_place_schematic(lua_State *L)
v3s16 p = read_v3s16(L, 1);
if (!read_schematic(L, 2, &dschem, getServer(L)))
return 0;
+
+ Rotation rot = ROTATE_0;
+ if (lua_isstring(L, 3))
+ string_to_enum(es_Rotation, (int &)rot, std::string(lua_tostring(L, 3)));
+
+ dschem.rotation = rot;
if (!dschem.filename.empty()) {
if (!dschem.loadSchematicFile()) {
diff --git a/src/script/lua_api/luaapi.h b/src/script/lua_api/luaapi.h
index ba76117d4..af73625ba 100644
--- a/src/script/lua_api/luaapi.h
+++ b/src/script/lua_api/luaapi.h
@@ -136,11 +136,12 @@ private:
// create_schematic(p1, p2, filename)
static int l_create_schematic(lua_State *L);
- // place_schematic(p, filename)
+ // place_schematic(p, filename, rotation)
static int l_place_schematic(lua_State *L);
static struct EnumString es_OreType[];
static struct EnumString es_DecorationType[];
+ static struct EnumString es_Rotation[];
};