From ec68eaa22975305af3e184bc3c946a253b5504eb Mon Sep 17 00:00:00 2001 From: orwell96 Date: Thu, 29 Nov 2018 17:52:56 +0100 Subject: Added on_train_approach callback, non-permanent external LZB brakepoints and basis for "stop rails" Stop rails ATM use the aforementioned things to add a pointwise "2" speed restriction. Seems to work. --- advtrains_line_automation/depends.txt | 2 ++ advtrains_line_automation/init.lua | 17 +++++++++ advtrains_line_automation/readme.txt | 5 +++ advtrains_line_automation/stoprail.lua | 39 +++++++++++++++++++++ .../textures/advtrains_dtrack_shared_stop.png | Bin 0 -> 3306 bytes .../textures/advtrains_dtrack_stop_placer.png | Bin 0 -> 1238 bytes 6 files changed, 63 insertions(+) create mode 100644 advtrains_line_automation/depends.txt create mode 100644 advtrains_line_automation/init.lua create mode 100644 advtrains_line_automation/readme.txt create mode 100644 advtrains_line_automation/stoprail.lua create mode 100644 advtrains_line_automation/textures/advtrains_dtrack_shared_stop.png create mode 100644 advtrains_line_automation/textures/advtrains_dtrack_stop_placer.png (limited to 'advtrains_line_automation') diff --git a/advtrains_line_automation/depends.txt b/advtrains_line_automation/depends.txt new file mode 100644 index 0000000..53500ee --- /dev/null +++ b/advtrains_line_automation/depends.txt @@ -0,0 +1,2 @@ +advtrains_interlocking +advtrains_train_track \ No newline at end of file diff --git a/advtrains_line_automation/init.lua b/advtrains_line_automation/init.lua new file mode 100644 index 0000000..5521ee9 --- /dev/null +++ b/advtrains_line_automation/init.lua @@ -0,0 +1,17 @@ +-- Advtrains line automation system + +advtrains.lines = {} + + +local modpath = minetest.get_modpath(minetest.get_current_modname()) .. DIR_DELIM + +dofile(modpath.."stoprail.lua") + + +function advtrains.lines.load(data) + +end + +function advtrains.lines.save() + return {} +end diff --git a/advtrains_line_automation/readme.txt b/advtrains_line_automation/readme.txt new file mode 100644 index 0000000..3280ce9 --- /dev/null +++ b/advtrains_line_automation/readme.txt @@ -0,0 +1,5 @@ +== advtrains_line_automation +This mod provides an extension to the interlocking system which allows to automatically operate trains on train lines. + +This extension makes use of the table +advtrains.lines \ No newline at end of file diff --git a/advtrains_line_automation/stoprail.lua b/advtrains_line_automation/stoprail.lua new file mode 100644 index 0000000..a02e501 --- /dev/null +++ b/advtrains_line_automation/stoprail.lua @@ -0,0 +1,39 @@ +-- stoprail.lua +-- adds "stop rail". Recognized by lzb. (part of behavior is implemented there) + + +local adefunc = function(def, preset, suffix, rotation) + return { + after_place_node=function(pos) + + end, + after_dig_node=function(pos) + + end, + on_receive_fields = function(pos, formname, fields, player) + + end, + advtrains = { + on_train_enter = function(pos, train_id) + end, + on_train_approach = function(pos,train_id, train, index) + atdebug("Train approaches stop:",pos,train_id,index) + --TODO conditions + advtrains.interlocking.lzb_add_oncoming_npr(train, index, 2) + end, + }, + } +end + + + +advtrains.register_tracks("default", { + nodename_prefix="advtrains_line_automation:dtrack_stop", + texture_prefix="advtrains_dtrack_stop", + models_prefix="advtrains_dtrack", + models_suffix=".b3d", + shared_texture="advtrains_dtrack_shared_stop.png", + description="Station/Stop Rail", + formats={}, + get_additional_definiton = adefunc, +}, advtrains.trackpresets.t_30deg_straightonly) diff --git a/advtrains_line_automation/textures/advtrains_dtrack_shared_stop.png b/advtrains_line_automation/textures/advtrains_dtrack_shared_stop.png new file mode 100644 index 0000000..b6629cf Binary files /dev/null and b/advtrains_line_automation/textures/advtrains_dtrack_shared_stop.png differ diff --git a/advtrains_line_automation/textures/advtrains_dtrack_stop_placer.png b/advtrains_line_automation/textures/advtrains_dtrack_stop_placer.png new file mode 100644 index 0000000..0d1c769 Binary files /dev/null and b/advtrains_line_automation/textures/advtrains_dtrack_stop_placer.png differ -- cgit v1.2.3