aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2017-05-30 15:13:04 +0200
committerorwell96 <mono96.mml@gmail.com>2017-05-30 15:16:56 +0200
commitb8a3ac038f3f071c731752484109bf01536f36b1 (patch)
treea9b6086f17427ab5d8024f8c90dba7eebe30f0d8 /advtrains
parent5ebadbd6ff8a698f07614c263a27daf5456e25d2 (diff)
downloadadvtrains-b8a3ac038f3f071c731752484109bf01536f36b1.tar.gz
advtrains-b8a3ac038f3f071c731752484109bf01536f36b1.tar.bz2
advtrains-b8a3ac038f3f071c731752484109bf01536f36b1.zip
Re-add option for debugging features and add option to disable collisions
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/advtrains/init.lua29
-rw-r--r--advtrains/advtrains/settingtypes.txt8
-rw-r--r--advtrains/advtrains/trainlogic.lua4
3 files changed, 29 insertions, 12 deletions
diff --git a/advtrains/advtrains/init.lua b/advtrains/advtrains/init.lua
index 6713343..926619c 100644
--- a/advtrains/advtrains/init.lua
+++ b/advtrains/advtrains/init.lua
@@ -79,21 +79,12 @@ function advtrains.print_concat_table(a)
return str
end
-atprint=function(t, ...)
- local context=advtrains.atprint_context_tid
- if not context then return end
- local text=advtrains.print_concat_table({t, ...})
- advtrains.drb_record(context, text)
-end
+atprint=function() end
+atdebug=function() end
atlog=function(t, ...)
local text=advtrains.print_concat_table({t, ...})
minetest.log("action", "[advtrains]"..text)
end
-atdebug=function(t, ...)
- local text=advtrains.print_concat_table({t, ...})
- minetest.log("action", "[advtrains]"..text)
- minetest.chat_send_all("[advtrains]"..text)
-end
atwarn=function(t, ...)
local text=advtrains.print_concat_table({t, ...})
minetest.log("warning", "[advtrains]"..text)
@@ -101,6 +92,21 @@ atwarn=function(t, ...)
end
sid=function(id) return string.sub(id, -6) end
+if minetest.settings:get_bool("advtrains_enable_debugging") then
+ atprint=function(t, ...)
+ local context=advtrains.atprint_context_tid
+ if not context then return end
+ local text=advtrains.print_concat_table({t, ...})
+ advtrains.drb_record(context, text)
+ end
+ atdebug=function(t, ...)
+ local text=advtrains.print_concat_table({t, ...})
+ minetest.log("action", "[advtrains]"..text)
+ minetest.chat_send_all("[advtrains]"..text)
+ end
+ dofile(advtrains.modpath.."/debugringbuffer.lua")
+end
+
dofile(advtrains.modpath.."/helpers.lua");
--dofile(advtrains.modpath.."/debugitems.lua");
@@ -120,7 +126,6 @@ advtrains.meseconrules =
{x=0, y=-2, z=0}}
-dofile(advtrains.modpath.."/debugringbuffer.lua")
dofile(advtrains.modpath.."/trainlogic.lua")
dofile(advtrains.modpath.."/trainhud.lua")
diff --git a/advtrains/advtrains/settingtypes.txt b/advtrains/advtrains/settingtypes.txt
new file mode 100644
index 0000000..60f8477
--- /dev/null
+++ b/advtrains/advtrains/settingtypes.txt
@@ -0,0 +1,8 @@
+# Disable the train collision behavior. Trains will never collide and just drive through each other.
+# Note that this makes coupling trains impossible, and introduces 'interesting' behavior with detector and ATC rails.
+# Also, it is very hard to separate two subway trains that are stuck inside each other, since it can be impossible to access the driver seat.
+advtrains_disable_collisions (Disable train collisions) bool false
+# Enable the debug ring buffer
+# This has no effect on the user experience, except decreased performance. Debug outputs are saved in a ring buffer to be printed when an error occurs.
+# You probably want to leave this setting set to false.
+advtrains_enable_debugging (Enable debugging) bool false \ No newline at end of file
diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua
index e3581ba..26ee780 100644
--- a/advtrains/advtrains/trainlogic.lua
+++ b/advtrains/advtrains/trainlogic.lua
@@ -780,6 +780,10 @@ function advtrains.trains_facing(train1, train2)
end
function advtrains.collide_and_spawn_couple(id1, pos, id2, t1_is_backpos)
+ if minetest.settings:get_bool("advtrains_disable_collisions") then
+ return
+ end
+
atprint("COLLISION: "..sid(id1).." and "..sid(id2).." at ",pos,", t1_is_backpos="..(t1_is_backpos and "true" or "false"))
--TODO:
local train1=advtrains.trains[id1]