Added stop and reverse rail
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Thu, 22 Dec 2016 11:02:44 +0000 (12:02 +0100)
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Thu, 22 Dec 2016 11:02:44 +0000 (12:02 +0100)
textures/advtrains_dtrack_rail_stop.png [new file with mode: 0644]
textures/advtrains_dtrack_stop_placer.png [new file with mode: 0644]
tracks.lua

diff --git a/textures/advtrains_dtrack_rail_stop.png b/textures/advtrains_dtrack_rail_stop.png
new file mode 100644 (file)
index 0000000..3cfd75f
Binary files /dev/null and b/textures/advtrains_dtrack_rail_stop.png differ
diff --git a/textures/advtrains_dtrack_stop_placer.png b/textures/advtrains_dtrack_stop_placer.png
new file mode 100644 (file)
index 0000000..82622db
Binary files /dev/null and b/textures/advtrains_dtrack_stop_placer.png differ
index 99dbb27..0b7d125 100644 (file)
@@ -584,6 +584,30 @@ for _,rot in ipairs({"", "_30", "_45", "_60"}) do
        minetest.register_alias("advtrains:dtrack_bumper"..rot, "advtrains:dtrack_bumper_st"..rot)\r
 end\r
 \r
+advtrains.register_tracks("default", {\r
+               nodename_prefix="advtrains:dtrack_stop",\r
+               texture_prefix="advtrains_dtrack_stop",\r
+               models_prefix="advtrains_dtrack",\r
+               models_suffix=".b3d",\r
+               shared_texture="advtrains_dtrack_rail_stop.png",\r
+               description="Stop and reverse rail",\r
+               formats={},\r
+               get_additional_definiton = function(def, preset, suffix, rotation)\r
+                       return {\r
+                               advtrains = {\r
+                                       on_train_enter=function(pos, train_id)\r
+                                          local train = advtrains.trains[train_id];\r
+                                          local endsp = train.tarvelocity;\r
+                                          train.tarvelocity = 0;\r
+                                          train.velocity = 0;\r
+                                          minetest.after(10,function(t,sp)     train.movedir = -train.movedir; t.tarvelocity=sp; end, train, endsp);\r
+                                       end\r
+                               }\r
+                       }\r
+               end\r
+}, t_30deg_straightonly)\r
+\r
+\r
 if mesecon then\r
        advtrains.register_tracks("default", {\r
                nodename_prefix="advtrains:dtrack_detector_off",\r