From cbf1c137b6a53652e195f9f87299b4c82d214f39 Mon Sep 17 00:00:00 2001
From: entuland <entuland@gmail.com>
Date: Wed, 20 Jun 2018 10:18:52 +0200
Subject: [PATCH] Reverse directions holding the sneak key down

---
 README.md |  2 ++
 init.lua  | 21 +++++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index bd610dd..07a9d04 100644
--- a/README.md
+++ b/README.md
@@ -47,10 +47,12 @@ Pretty simple:
 - a right click will rotate the face you're pointing in clockwise direction
   - the arrow in the Testing Cube shows how the face will rotate when right-clicked
   - `RT` in the tool stands for `rotate`
+  - hold the sneak key down while clicking to rotate counter-clockwise
 
 - a left click will rotate the node as if you "pushed" the closest edge you're pointing at
   - the colored edges in the Testing Cube indicate the color of the face you'll see when left-clicking near that edge
   - `PS` in the tool stands for `push`
+  - hold the sneak key down while clicking to "pull" instead of "pushing"
 
 The left-click interaction area is not limited to the edges you can see in the Testing Cube. In reality you can click anywhere in a triangle like this (highlighted here just for convenience, you won't see anything like this in the game):
 
diff --git a/init.lua b/init.lua
index 8156450..20cb0b9 100644
--- a/init.lua
+++ b/init.lua
@@ -208,17 +208,30 @@ local function interact(itemstack, player, pointed_thing, click)
 	local unit = extract_unit_vectors(player, pointed_thing)
 
 	local transform = false
-
+	local rotation = rot_matrices[1]
+	
+	local controls = player:get_player_control()
+	
 	if click == PRIMARY_BTN then
 		transform = dir_matrices[vector_to_dir_index(unit.thumb)]
-		notify(player:get_player_name(), "Pushed closest edge (left click)")
+		if controls.sneak then
+			rotation = rot_matrices[3]
+			notify(player:get_player_name(), "Pulled closest edge (sneak + left click)")
+		else
+			notify(player:get_player_name(), "Pushed closest edge (left click)")
+		end
 	else
 		transform = dir_matrices[vector_to_dir_index(unit.back)]
-		notify(player:get_player_name(), "Rotated pointed face (right click)")
+		if controls.sneak then
+			rotation = rot_matrices[3]
+			notify(player:get_player_name(), "Rotated pointed face counter-clockwise (sneak + right click)")
+		else
+			notify(player:get_player_name(), "Rotated pointed face clockwise (right click)")		
+		end
 	end
 
 	local start = get_facedir_transform(node.param2)
-	local stop = transform * rot_matrices[1] * transform:invert() * start
+	local stop = transform * rotation * transform:invert() * start
 
 	minetest.set_node(pointed_thing.under,{
 		name = node.name,
-- 
GitLab