aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation/atc_rail.lua
diff options
context:
space:
mode:
authorBlockhead <jbis1337@hotmail.com>2020-07-07 18:19:56 +1000
committerGabriel PĂ©rez-Cerezo <gabriel@gpcf.eu>2020-07-10 22:14:39 +0200
commitad49854fed1ccd426db5ab43d6734856a6b0bc74 (patch)
tree406e9d4cf4d1ac1c06b7ec431c4d70a0e1d70ec6 /advtrains_luaautomation/atc_rail.lua
parent74bf177cc850164a0a6c13a634e7da6410f9f73a (diff)
downloadadvtrains-ad49854fed1ccd426db5ab43d6734856a6b0bc74.tar.gz
advtrains-ad49854fed1ccd426db5ab43d6734856a6b0bc74.tar.bz2
advtrains-ad49854fed1ccd426db5ab43d6734856a6b0bc74.zip
Make using the default tracks optional, even in submods
If advtrains_train_track is disabled, don't register any tracks that use its model like the LuaATC automation rail, point speed restriction rail, station/stop rail. For LuaATC, the definition for firing an event when a train runs over the rail needs to be moved into the common defs so that other mods like linetrack can use that as an interface.
Diffstat (limited to 'advtrains_luaautomation/atc_rail.lua')
-rw-r--r--advtrains_luaautomation/atc_rail.lua71
1 files changed, 32 insertions, 39 deletions
diff --git a/advtrains_luaautomation/atc_rail.lua b/advtrains_luaautomation/atc_rail.lua
index ce9e0fa..0b9c911 100644
--- a/advtrains_luaautomation/atc_rail.lua
+++ b/advtrains_luaautomation/atc_rail.lua
@@ -131,46 +131,39 @@ function r.fire_event(pos, evtdata)
end
-advtrains.register_tracks("default", {
- nodename_prefix="advtrains_luaautomation:dtrack",
- texture_prefix="advtrains_dtrack_atc",
- models_prefix="advtrains_dtrack",
- models_suffix=".b3d",
- shared_texture="advtrains_dtrack_shared_atc.png",
- description=atltrans("LuaAutomation ATC Rail"),
- formats={},
- get_additional_definiton = function(def, preset, suffix, rotation)
- return {
- after_place_node = atlatc.active.after_place_node,
- after_dig_node = atlatc.active.after_dig_node,
-
- on_receive_fields = function(pos, ...)
- atlatc.active.on_receive_fields(pos, ...)
-
- --set arrowconn (for ATC)
- local ph=minetest.pos_to_string(pos)
- local _, conns=advtrains.get_rail_info_at(pos, advtrains.all_tracktypes)
- atlatc.active.nodes[ph].arrowconn=conns[1].c
- end,
-
- advtrains = {
- on_train_enter = function(pos, train_id)
- --do async. Event is fired in train steps
- atlatc.interrupt.add(0, pos, {type="train", train=true, id=train_id})
+if minetest.get_modpath("advtrains_train_track") ~= nil then
+ advtrains.register_tracks("default", {
+ nodename_prefix="advtrains_luaautomation:dtrack",
+ texture_prefix="advtrains_dtrack_atc",
+ models_prefix="advtrains_dtrack",
+ models_suffix=".b3d",
+ shared_texture="advtrains_dtrack_shared_atc.png",
+ description=atltrans("LuaAutomation ATC Rail"),
+ formats={},
+ get_additional_definiton = function(def, preset, suffix, rotation)
+ return {
+ after_place_node = atlatc.active.after_place_node,
+ after_dig_node = atlatc.active.after_dig_node,
+ on_receive_fields = function(pos, ...)
+ atlatc.active.on_receive_fields(pos, ...)
+ --set arrowconn (for ATC)
+ local ph=minetest.pos_to_string(pos)
+ local _, conns=advtrains.get_rail_info_at(pos, advtrains.all_tracktypes)
+ atlatc.active.nodes[ph].arrowconn=conns[1].c
end,
- },
- luaautomation = {
- fire_event=r.fire_event
- },
- digiline = {
- receptor = {},
- effector = {
- action = atlatc.active.on_digiline_receive
+ advtrains = atlatc.active.trackdef_advtrains_defs,
+ luaautomation = {
+ fire_event=r.fire_event
},
- },
- }
- end,
-}, advtrains.trackpresets.t_30deg_straightonly)
-
+ digiline = {
+ receptor = {},
+ effector = {
+ action = atlatc.active.on_digiline_receive
+ },
+ },
+ }
+ end,
+ }, advtrains.trackpresets.t_30deg_straightonly)
+end
atlatc.rail = r