Add wrapper for minetest.rotate_and_place. 988/head
author4Evergreen4 <eljohnson@frontier.com>
Thu, 7 Nov 2013 21:20:04 +0000 (16:20 -0500)
committerkwolekr <kwolekr@minetest.net>
Fri, 8 Nov 2013 01:14:26 +0000 (20:14 -0500)
builtin/misc_helpers.lua
doc/lua_api.txt

index c9bc59c3a99af273b982b67f56a9805fd5febb7d..38909ec1dc5384e9fff01f0133caee7d2d6d4a64 100644 (file)
@@ -282,6 +282,20 @@ if minetest then
                        minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack)
                end
        end
+
+
+--------------------------------------------------------------------------------
+--Wrapper for rotate_and_place() to check for sneak and assume Creative mode
+--implies infinite stacks when performing a 6d rotation.
+--------------------------------------------------------------------------------
+
+
+       minetest.rotate_node = function(itemstack, placer, pointed_thing)
+               minetest.rotate_and_place(itemstack, placer, pointed_thing,
+               minetest.setting_getbool("creative_mode"), 
+               {invert_wall = placer:get_player_control().sneak})
+               return itemstack
+       end
 end
 
 --------------------------------------------------------------------------------
index 122fbde9938cd6ad8c63f065582030317c963e28..76eea95cc12f9a09e7d646fd71ac6c9725d9fe5e 100644 (file)
@@ -1561,6 +1561,11 @@ minetest.rotate_and_place(itemstack, placer, pointed_thing, infinitestacks, orie
   force_facedir:       if true, forcably reset the facedir to north when placing on
                                        the floor or ceiling
 
+minetest.rotate_node(itemstack, placer, pointed_thing)
+^ calls rotate_and_place() with infinitestacks set according to the state of
+  the creative mode setting, and checks for "sneak" to set the invert_wall
+  parameter.
+
 Global objects:
 minetest.env - EnvRef of the server environment and world.
 ^ Any function in the minetest namespace can be called using the syntax