From 06f0150b61e47b90af424992e47fdd3fb378a250 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Thu, 10 Nov 2016 22:58:27 +0100 Subject: Add detector rails --- advtrains.zip | Bin 1548122 -> 1577814 bytes atc.lua | 4 + depends.txt | 3 +- init.lua | 3 + models/advtrains_dtrack_detector_st.b3d | Bin 0 -> 17157 bytes models/advtrains_dtrack_detector_st_30.b3d | Bin 0 -> 32779 bytes models/advtrains_dtrack_detector_st_45.b3d | Bin 0 -> 17163 bytes models/advtrains_dtrack_detector_st_60.b3d | Bin 0 -> 32779 bytes models/blender/gleis/rail_my_rt_final.blend | Bin 827052 -> 1094836 bytes models/blender/gleis/rail_my_rt_final.blend1 | Bin 843380 -> 827052 bytes textures/advtrains_dtrack_detector_placer.png | Bin 0 -> 1253 bytes textures/advtrains_dtrack_rail_detector_on.png | Bin 0 -> 2844 bytes tracks.lua | 111 ++++++++++++++++++++++--- 13 files changed, 107 insertions(+), 14 deletions(-) create mode 100644 atc.lua create mode 100644 models/advtrains_dtrack_detector_st.b3d create mode 100644 models/advtrains_dtrack_detector_st_30.b3d create mode 100644 models/advtrains_dtrack_detector_st_45.b3d create mode 100644 models/advtrains_dtrack_detector_st_60.b3d create mode 100644 textures/advtrains_dtrack_detector_placer.png create mode 100644 textures/advtrains_dtrack_rail_detector_on.png diff --git a/advtrains.zip b/advtrains.zip index 0073d49..84727b9 100644 Binary files a/advtrains.zip and b/advtrains.zip differ diff --git a/atc.lua b/atc.lua new file mode 100644 index 0000000..0afddb0 --- /dev/null +++ b/atc.lua @@ -0,0 +1,4 @@ +--atc.lua +--registers and controls the ATC system + +--(simple)mesecon detector rails diff --git a/depends.txt b/depends.txt index 331d858..20aa884 100644 --- a/depends.txt +++ b/depends.txt @@ -1 +1,2 @@ -default \ No newline at end of file +default +mesecons? \ No newline at end of file diff --git a/init.lua b/init.lua index c535668..26f5211 100644 --- a/init.lua +++ b/init.lua @@ -12,10 +12,13 @@ print = function(t) minetest.log("action", t) minetest.chat_send_all(t) end dofile(advtrains.modpath.."/helpers.lua"); dofile(advtrains.modpath.."/debugitems.lua"); +advtrains.meseconrules = mesecon.rules.pplate + dofile(advtrains.modpath.."/trainlogic.lua"); dofile(advtrains.modpath.."/trainhud.lua") dofile(advtrains.modpath.."/trackplacer.lua") dofile(advtrains.modpath.."/tracks.lua") +dofile(advtrains.modpath.."/atc.lua") dofile(advtrains.modpath.."/wagons.lua") dofile(advtrains.modpath.."/pseudoload.lua"); diff --git a/models/advtrains_dtrack_detector_st.b3d b/models/advtrains_dtrack_detector_st.b3d new file mode 100644 index 0000000..893c8cd Binary files /dev/null and b/models/advtrains_dtrack_detector_st.b3d differ diff --git a/models/advtrains_dtrack_detector_st_30.b3d b/models/advtrains_dtrack_detector_st_30.b3d new file mode 100644 index 0000000..2e59e93 Binary files /dev/null and b/models/advtrains_dtrack_detector_st_30.b3d differ diff --git a/models/advtrains_dtrack_detector_st_45.b3d b/models/advtrains_dtrack_detector_st_45.b3d new file mode 100644 index 0000000..c73166f Binary files /dev/null and b/models/advtrains_dtrack_detector_st_45.b3d differ diff --git a/models/advtrains_dtrack_detector_st_60.b3d b/models/advtrains_dtrack_detector_st_60.b3d new file mode 100644 index 0000000..b6bc9af Binary files /dev/null and b/models/advtrains_dtrack_detector_st_60.b3d differ diff --git a/models/blender/gleis/rail_my_rt_final.blend b/models/blender/gleis/rail_my_rt_final.blend index 1f346ae..6a9a088 100644 Binary files a/models/blender/gleis/rail_my_rt_final.blend and b/models/blender/gleis/rail_my_rt_final.blend differ diff --git a/models/blender/gleis/rail_my_rt_final.blend1 b/models/blender/gleis/rail_my_rt_final.blend1 index 12beed9..1f346ae 100644 Binary files a/models/blender/gleis/rail_my_rt_final.blend1 and b/models/blender/gleis/rail_my_rt_final.blend1 differ diff --git a/textures/advtrains_dtrack_detector_placer.png b/textures/advtrains_dtrack_detector_placer.png new file mode 100644 index 0000000..e6c6ad6 Binary files /dev/null and b/textures/advtrains_dtrack_detector_placer.png differ diff --git a/textures/advtrains_dtrack_rail_detector_on.png b/textures/advtrains_dtrack_rail_detector_on.png new file mode 100644 index 0000000..3ae0dac Binary files /dev/null and b/textures/advtrains_dtrack_rail_detector_on.png differ diff --git a/tracks.lua b/tracks.lua index a9200c6..0fa9899 100644 --- a/tracks.lua +++ b/tracks.lua @@ -76,6 +76,7 @@ local t_30deg={ swrst="on", swrcr="off", }, + regtp=true, trackplacer={ st=true, cr=true, @@ -107,6 +108,31 @@ local t_30deg_straightonly={ }, switchmc={ }, + regtp=true, + trackplacer={ + }, + tpsingle={ + }, + tpdefault="st", + trackworker={ + ["st"]="st", + }, + rotation={"", "_30", "_45", "_60"}, + increativeinv={st}, +} +local t_30deg_straightonly_noplacer={ + regstep=1, + variant={ + st=conns(0,8), + }, + description={ + st="straight", + }, + switch={ + }, + switchmc={ + }, + regtp=false, trackplacer={ }, tpsingle={ @@ -152,6 +178,7 @@ local t_45deg={ swrst="on", swrcr="off", }, + regtp=true, trackplacer={ st=true, cr=true, @@ -195,7 +222,8 @@ function advtrains.register_tracks(tracktype, def, preset) advtrains.reset_trackdb_position(pos) end return switchfunc, {effector = { - ["action_"..mesecon_state] = switchfunc + ["action_"..mesecon_state] = switchfunc, + rules=advtrains.meseconrules }} end local function make_overdef(suffix, rotation, conns, switchfunc, mesecontbl, in_creative_inv) @@ -260,7 +288,9 @@ function advtrains.register_tracks(tracktype, def, preset) }, def.common or {}) --make trackplacer base def advtrains.trackplacer.register_tracktype(def.nodename_prefix, preset.tpdefault) - advtrains.trackplacer.register_track_placer(def.nodename_prefix, def.texture_prefix, def.description) + if preset.regtp then + advtrains.trackplacer.register_track_placer(def.nodename_prefix, def.texture_prefix, def.description) + end for suffix, conns in pairs(preset.variant) do for rotid, rotation in ipairs(preset.rotation) do if not def.formats[suffix] or def.formats[suffix][rotid] then @@ -268,22 +298,29 @@ function advtrains.register_tracks(tracktype, def, preset) if preset.switch[suffix] then switchfunc, mesecontbl=make_switchfunc(preset.switch[suffix]..rotation, preset.switchmc[suffix]) end - + local adef={} + if def.get_additional_definiton then + adef=def.get_additional_definiton(def, preset, suffix, rotation) + end + minetest.register_node(def.nodename_prefix.."_"..suffix..rotation, advtrains.merge_tables( common_def, make_overdef( suffix, rotation, cycle_conns(conns, rotid), switchfunc, mesecontbl, preset.increativeinv[suffix] - ) + ), + adef ) ) --trackplacer - if preset.trackplacer[suffix] then - advtrains.trackplacer.add_double_conn(def.nodename_prefix, suffix, rotation, cycle_conns(conns, rotid)) - end - if preset.tpsingle[suffix] then - advtrains.trackplacer.add_single_conn(def.nodename_prefix, suffix, rotation, cycle_conns(conns, rotid)) + if preset.regtp then + if preset.trackplacer[suffix] then + advtrains.trackplacer.add_double_conn(def.nodename_prefix, suffix, rotation, cycle_conns(conns, rotid)) + end + if preset.tpsingle[suffix] then + advtrains.trackplacer.add_single_conn(def.nodename_prefix, suffix, rotation, cycle_conns(conns, rotid)) + end end advtrains.trackplacer.add_worked(def.nodename_prefix, suffix, rotation, preset.trackworker[suffix]) end @@ -430,10 +467,58 @@ for _,rot in ipairs({"", "_30", "_45", "_60"}) do minetest.register_alias("advtrains:dtrack_bumper"..rot, "advtrains:dtrack_bumper_st"..rot) end - - - - +if mesecon then + advtrains.register_tracks("default", { + nodename_prefix="advtrains:dtrack_detector_off", + texture_prefix="advtrains_dtrack_detector", + models_prefix="advtrains_dtrack_detector", + models_suffix=".b3d", + shared_texture="advtrains_dtrack_rail.png", + description="Detector Rail", + formats={}, + get_additional_definiton = function(def, preset, suffix, rotation) + return { + mesecons = { + receptor = { + state = mesecon.state.off, + rules = advtrains.meseconrules + } + }, + advtrains = { + on_train_enter=function(pos, train_id) + minetest.swap_node(pos, {name="advtrains:dtrack_detector_on".."_"..suffix..rotation}) + mesecon.receptor_on(pos, advtrains.meseconrules) + end + } + } + end + }, t_30deg_straightonly) + advtrains.register_tracks("default", { + nodename_prefix="advtrains:dtrack_detector_on", + texture_prefix="advtrains_dtrack_detector", + models_prefix="advtrains_dtrack_detector", + models_suffix=".b3d", + shared_texture="advtrains_dtrack_rail_detector_on.png", + description="Detector(on)(you hacker you)", + formats={}, + get_additional_definiton = function(def, preset, suffix, rotation) + return { + mesecons = { + receptor = { + state = mesecon.state.on, + rules = advtrains.meseconrules + } + }, + advtrains = { + on_train_leave=function(pos, train_id) + minetest.swap_node(pos, {name="advtrains:dtrack_detector_off".."_"..suffix..rotation}) + mesecon.receptor_off(pos, advtrains.meseconrules) + end + } + } + end + }, t_30deg_straightonly_noplacer) +end --TODO legacy --I know lbms are better for this purpose for name,rep in pairs({swl_st="swlst", swr_st="swrst", swl_cr="swlcr", swr_cr="swrcr", }) do -- cgit v1.2.3