aboutsummaryrefslogtreecommitdiff
path: root/advtrains/debugitems.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-05-28 20:05:19 +0200
committerorwell96 <orwell@bleipb.de>2018-06-14 17:39:42 +0200
commit254c32e304a4f279bf99e460727daf1b78050c47 (patch)
tree106c2b6853adb39674886c3c32da0568c3405a27 /advtrains/debugitems.lua
parent24b0639c5f057ccb0fccc3c65be923bee1b571db (diff)
downloadadvtrains-254c32e304a4f279bf99e460727daf1b78050c47.tar.gz
advtrains-254c32e304a4f279bf99e460727daf1b78050c47.tar.bz2
advtrains-254c32e304a4f279bf99e460727daf1b78050c47.zip
Fix yaw calculations, track placement orientation and speed up direction lookup functions
Diffstat (limited to 'advtrains/debugitems.lua')
-rw-r--r--advtrains/debugitems.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/advtrains/debugitems.lua b/advtrains/debugitems.lua
index dcc95d9..e672308 100644
--- a/advtrains/debugitems.lua
+++ b/advtrains/debugitems.lua
@@ -26,3 +26,28 @@ minetest.register_tool("advtrains:tunnelborer",
end,
}
)
+
+minetest.register_chatcommand("atyaw",
+ {
+ params = "angledeg conn1 conn2",
+ description = "",
+ func = function(name, param)
+ local angledegs, conn1s, conn2s = string.match(param, "^(%S+)%s(%S+)%s(%S+)$")
+ if angledegs and conn1s and conn2s then
+ local angledeg, conn1, conn2 = angledegs+0,conn1s+0,conn2s+0
+ local yaw = angledeg*math.pi/180
+ local yaw1 = advtrains.dir_to_angle(conn1)
+ local yaw2 = advtrains.dir_to_angle(conn2)
+ local adiff1 = advtrains.minAngleDiffRad(yaw, yaw1)
+ local adiff2 = advtrains.minAngleDiffRad(yaw, yaw2)
+
+ atdebug("yaw1",atfloor(yaw1*180/math.pi))
+ atdebug("yaw2",atfloor(yaw2*180/math.pi))
+ atdebug("dif1",atfloor(adiff1*180/math.pi))
+ atdebug("dif2",atfloor(adiff2*180/math.pi))
+
+ minetest.chat_send_all(advtrains.yawToAnyDir(yaw))
+ return true, advtrains.yawToDirection(yaw, conn1, conn2)
+ end
+ end,
+})