From f806ed9eee8c13eb0b4868641311d25257c63f46 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 20 Dec 2016 14:17:39 +0100 Subject: Turning mod into a modpack and separating the trains from the core mod --- advtrains/atc.lua | 4 + advtrains/couple.lua | 154 ++++ advtrains/crafting.lua | 71 ++ advtrains/damage.lua | 26 + advtrains/debugitems.lua | 36 + advtrains/depends.txt | 2 + advtrains/description.txt | 8 + advtrains/helpers.lua | 249 ++++++ advtrains/init.lua | 42 + advtrains/misc_nodes.lua | 67 ++ advtrains/models/advtrains_dtrack_bumper_st.b3d | Bin 0 -> 32927 bytes advtrains/models/advtrains_dtrack_bumper_st_30.b3d | Bin 0 -> 48546 bytes advtrains/models/advtrains_dtrack_bumper_st_45.b3d | Bin 0 -> 32926 bytes advtrains/models/advtrains_dtrack_bumper_st_60.b3d | Bin 0 -> 48546 bytes advtrains/models/advtrains_dtrack_cr.b3d | Bin 0 -> 27540 bytes advtrains/models/advtrains_dtrack_cr_30.b3d | Bin 0 -> 27543 bytes advtrains/models/advtrains_dtrack_cr_45.b3d | Bin 0 -> 23037 bytes advtrains/models/advtrains_dtrack_cr_60.b3d | Bin 0 -> 23037 bytes advtrains/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 advtrains/models/advtrains_dtrack_st.b3d | Bin 0 -> 15828 bytes advtrains/models/advtrains_dtrack_st_30.b3d | Bin 0 -> 31447 bytes advtrains/models/advtrains_dtrack_st_45.b3d | Bin 0 -> 15831 bytes advtrains/models/advtrains_dtrack_st_60.b3d | Bin 0 -> 31447 bytes advtrains/models/advtrains_dtrack_swlcr.b3d | Bin 0 -> 36743 bytes advtrains/models/advtrains_dtrack_swlcr_30.b3d | Bin 0 -> 45922 bytes advtrains/models/advtrains_dtrack_swlcr_45.b3d | Bin 0 -> 32112 bytes advtrains/models/advtrains_dtrack_swlcr_60.b3d | Bin 0 -> 44864 bytes advtrains/models/advtrains_dtrack_swlst.b3d | Bin 0 -> 36743 bytes advtrains/models/advtrains_dtrack_swlst_30.b3d | Bin 0 -> 45922 bytes advtrains/models/advtrains_dtrack_swlst_45.b3d | Bin 0 -> 32112 bytes advtrains/models/advtrains_dtrack_swlst_60.b3d | Bin 0 -> 44864 bytes advtrains/models/advtrains_dtrack_swrcr.b3d | Bin 0 -> 36743 bytes advtrains/models/advtrains_dtrack_swrcr_30.b3d | Bin 0 -> 44864 bytes advtrains/models/advtrains_dtrack_swrcr_45.b3d | Bin 0 -> 32112 bytes advtrains/models/advtrains_dtrack_swrcr_60.b3d | Bin 0 -> 45922 bytes advtrains/models/advtrains_dtrack_swrst.b3d | Bin 0 -> 36743 bytes advtrains/models/advtrains_dtrack_swrst_30.b3d | Bin 0 -> 44864 bytes advtrains/models/advtrains_dtrack_swrst_45.b3d | Bin 0 -> 32112 bytes advtrains/models/advtrains_dtrack_swrst_60.b3d | Bin 0 -> 45922 bytes advtrains/models/advtrains_dtrack_vst1.b3d | Bin 0 -> 21495 bytes advtrains/models/advtrains_dtrack_vst1_45.b3d | Bin 0 -> 20739 bytes advtrains/models/advtrains_dtrack_vst2.b3d | Bin 0 -> 25143 bytes advtrains/models/advtrains_dtrack_vst2_45.b3d | Bin 0 -> 20919 bytes advtrains/models/advtrains_dtrack_vst31.b3d | Bin 0 -> 19051 bytes advtrains/models/advtrains_dtrack_vst32.b3d | Bin 0 -> 21635 bytes advtrains/models/advtrains_dtrack_vst33.b3d | Bin 0 -> 28795 bytes advtrains/models/advtrains_modernwagon.b3d | Bin 0 -> 172028 bytes advtrains/models/advtrains_retrosignal_off.b3d | Bin 0 -> 13093 bytes advtrains/models/advtrains_retrosignal_off_30.b3d | Bin 0 -> 13093 bytes advtrains/models/advtrains_retrosignal_off_45.b3d | Bin 0 -> 13093 bytes advtrains/models/advtrains_retrosignal_off_60.b3d | Bin 0 -> 13093 bytes advtrains/models/advtrains_retrosignal_on.b3d | Bin 0 -> 13093 bytes advtrains/models/advtrains_retrosignal_on_30.b3d | Bin 0 -> 13093 bytes advtrains/models/advtrains_retrosignal_on_45.b3d | Bin 0 -> 13093 bytes advtrains/models/advtrains_retrosignal_on_60.b3d | Bin 0 -> 13093 bytes advtrains/models/advtrains_signal.b3d | Bin 0 -> 61544 bytes advtrains/models/advtrains_signal_30.b3d | Bin 0 -> 61544 bytes advtrains/models/advtrains_signal_45.b3d | Bin 0 -> 61544 bytes advtrains/models/advtrains_signal_60.b3d | Bin 0 -> 61544 bytes advtrains/models/advtrains_track_cr.b3d | Bin 0 -> 8023 bytes advtrains/models/advtrains_track_st.b3d | Bin 0 -> 15831 bytes advtrains/models/advtrains_track_st_45.b3d | Bin 0 -> 8935 bytes .../models/blender/engine-with-animation.blend | Bin 0 -> 599504 bytes .../models/blender/gleis/infos/Grafik_weiche.png | Bin 0 -> 361700 bytes advtrains/models/blender/gleis/infos/breite | 1 + advtrains/models/blender/gleis/licence.txt~ | 0 advtrains/models/blender/gleis/rail_my.blend | Bin 0 -> 654772 bytes advtrains/models/blender/gleis/rail_my.blend1 | Bin 0 -> 674164 bytes advtrains/models/blender/gleis/rail_my_rt.blend | Bin 0 -> 847060 bytes advtrains/models/blender/gleis/rail_my_rt.blend1 | Bin 0 -> 767780 bytes .../models/blender/gleis/rail_my_rt_final.blend | Bin 0 -> 1094836 bytes .../models/blender/gleis/rail_my_rt_final.blend1 | Bin 0 -> 827052 bytes .../models/blender/gleis/rail_my_rt_switches.blend | Bin 0 -> 2184236 bytes .../blender/gleis/rail_my_rt_switches.blend1 | Bin 0 -> 1945588 bytes .../blender/gleis/rail_my_rt_switches2.blend | Bin 0 -> 2139340 bytes .../blender/gleis/rail_my_rt_switches2.blend1 | Bin 0 -> 2172972 bytes advtrains/models/blender/gleis/rail_together.blend | Bin 0 -> 1016920 bytes advtrains/models/blender/gleis/rail_together.png | Bin 0 -> 233544 bytes advtrains/models/blender/gleis/rail_together2.png | Bin 0 -> 312891 bytes advtrains/models/blender/gleis/rail_together3.png | Bin 0 -> 309398 bytes .../models/blender/gleis/rail_verticals.blend | Bin 0 -> 550748 bytes .../models/blender/gleis/rail_verticals.blend1 | Bin 0 -> 574100 bytes .../models/blender/gleis/rail_verticals3.blend | Bin 0 -> 591800 bytes .../models/blender/gleis/rail_verticals3.blend1 | Bin 0 -> 554196 bytes .../models/blender/gleis/rail_verticals45.blend | Bin 0 -> 547788 bytes .../models/blender/gleis/rail_verticals45.blend1 | Bin 0 -> 547300 bytes .../models/blender/gleis/rail_verticals45.blend11 | Bin 0 -> 547300 bytes advtrains/models/blender/gleis/texturen/rail.png | Bin 0 -> 2616 bytes advtrains/models/blender/gleis/texturen/uv.png | Bin 0 -> 2343 bytes .../models/blender/industrial/industry_loc.blend | Bin 0 -> 652640 bytes .../models/blender/industrial/industry_loc.blend1 | Bin 0 -> 652640 bytes .../models/blender/industrial/industry_loc.blend11 | Bin 0 -> 659096 bytes .../blender/industrial/industry_oil_ wagong.blend | Bin 0 -> 693488 bytes .../blender/industrial/industry_oil_ wagong.blend1 | Bin 0 -> 693488 bytes .../blender/industrial/industry_tree_wagong.blend | Bin 0 -> 640056 bytes .../blender/industrial/industry_tree_wagong.blend1 | Bin 0 -> 640056 bytes .../blender/industrial/industry_tree_wagong.png | Bin 0 -> 316 bytes advtrains/models/blender/locomotive.blend | Bin 0 -> 459600 bytes advtrains/models/blender/magnet_track.blend | Bin 0 -> 516836 bytes .../models/blender/mbb/advtrains_wagon_japan.xcf | Bin 0 -> 814467 bytes .../blender/mbb/modern_japanlocomotive.blend | Bin 0 -> 715116 bytes .../blender/mbb/modern_japanlocomotive.blend1 | Bin 0 -> 715116 bytes .../models/blender/mbb/modern_japanlocomotive.png | Bin 0 -> 204978 bytes .../models/blender/mbb/modern_japanlocomotive.xcf | Bin 0 -> 957175 bytes .../models/blender/mbb/modern_locomotive.blend | Bin 0 -> 732124 bytes advtrains/models/blender/mbb/modern_wagong.blend | Bin 0 -> 471140 bytes advtrains/models/blender/mbb/modern_wagong.blend1 | Bin 0 -> 518316 bytes .../models/blender/mbb/modern_wagong_uv.blend | Bin 0 -> 571364 bytes .../models/blender/mbb/modern_wagong_uv.blend1 | Bin 0 -> 575708 bytes advtrains/models/blender/mbb/modern_wagong_uv.png | Bin 0 -> 189564 bytes advtrains/models/blender/mbb/prellbock.blend | Bin 0 -> 745176 bytes advtrains/models/blender/mbb/prellbock.blend1 | Bin 0 -> 485416 bytes advtrains/models/blender/mbb/prellbock.uv.png | Bin 0 -> 4034 bytes .../models/blender/mbb/regio-lokomotive.blend | Bin 0 -> 704160 bytes advtrains/models/blender/mbb/regio-waron.blend | Bin 0 -> 545620 bytes advtrains/models/blender/mbb/retrosignal.blend | Bin 0 -> 488920 bytes advtrains/models/blender/mbb/retrosignal.blend1 | Bin 0 -> 507800 bytes advtrains/models/blender/mbb/signal(2)_hoch.blend | Bin 0 -> 472092 bytes advtrains/models/blender/mbb/signal(2)_unten.blend | Bin 0 -> 472092 bytes advtrains/models/blender/mbb/signal.blend | Bin 0 -> 570336 bytes advtrains/models/blender/mbb/signal.blend1 | Bin 0 -> 570336 bytes advtrains/models/blender/mbb/signal.png | Bin 0 -> 244314 bytes advtrains/models/blender/mbb/signal.xcf | Bin 0 -> 881142 bytes advtrains/models/blender/mbb/signal2.png | Bin 0 -> 39924 bytes advtrains/models/blender/mbb/tr-logo.png | Bin 0 -> 197 bytes advtrains/models/blender/mbb/weichenhebel1.blend | Bin 0 -> 493028 bytes advtrains/models/blender/mbb/weichenhebel2.blend | Bin 0 -> 492996 bytes advtrains/models/blender/newlocomotive.blend | Bin 0 -> 603376 bytes advtrains/models/blender/newlocomotive.blend1 | Bin 0 -> 603376 bytes advtrains/models/blender/newlocomotive_uvs.png | Bin 0 -> 175030 bytes advtrains/models/blender/newwagon.blend | Bin 0 -> 542188 bytes advtrains/models/blender/newwagon.blend1 | Bin 0 -> 550292 bytes advtrains/models/blender/newwagon.png | Bin 0 -> 108762 bytes advtrains/models/blender/subway-train.blend | Bin 0 -> 536268 bytes advtrains/models/blender/subway-train.blend1 | Bin 0 -> 538188 bytes advtrains/models/blender/subway-train.png | Bin 0 -> 96773 bytes advtrains/models/blender/subway-train.xcf | Bin 0 -> 92558 bytes advtrains/models/blender/trackplane.blend | Bin 0 -> 462200 bytes advtrains/models/blender/trackvertical1.blend | Bin 0 -> 453656 bytes advtrains/models/blender/trackvertical1.blend1 | Bin 0 -> 453344 bytes advtrains/models/blender/trackvertical1.png | Bin 0 -> 59146 bytes advtrains/models/blender/trackvertical2.blend | Bin 0 -> 459216 bytes advtrains/models/blender/trackvertical2.png | Bin 0 -> 66755 bytes advtrains/models/oldmodels/locomotive.b3d | Bin 0 -> 181112 bytes advtrains/models/oldmodels/trackvertical1.b3d | Bin 0 -> 629 bytes advtrains/models/oldmodels/trackvertical2.b3d | Bin 0 -> 869 bytes advtrains/models/trackplane.b3d | Bin 0 -> 262 bytes advtrains/pseudoload.lua | 180 +++++ advtrains/readme.txt | 23 + advtrains/signals.lua | 76 ++ advtrains/textures/advtrains_couple.png | Bin 0 -> 265 bytes advtrains/textures/advtrains_discouple.png | Bin 0 -> 307 bytes .../textures/advtrains_dtrack_bumper_placer.png | Bin 0 -> 2213 bytes .../textures/advtrains_dtrack_detector_placer.png | Bin 0 -> 1253 bytes advtrains/textures/advtrains_dtrack_placer.png | Bin 0 -> 5831 bytes advtrains/textures/advtrains_dtrack_rail.png | Bin 0 -> 2810 bytes .../textures/advtrains_dtrack_rail_detector_on.png | Bin 0 -> 2844 bytes .../textures/advtrains_dtrack_slopeplacer.png | Bin 0 -> 2415 bytes advtrains/textures/advtrains_newlocomotive.xcf | Bin 0 -> 7462378 bytes advtrains/textures/advtrains_platform.png | Bin 0 -> 193 bytes advtrains/textures/advtrains_retrosignal.png | Bin 0 -> 8496 bytes advtrains/textures/advtrains_retrosignal_inv.png | Bin 0 -> 2242 bytes advtrains/textures/advtrains_signal_inv.png | Bin 0 -> 856 bytes advtrains/textures/advtrains_signal_off.png | Bin 0 -> 5882 bytes advtrains/textures/advtrains_signal_on.png | Bin 0 -> 5884 bytes advtrains/textures/advtrains_track_cr.png | Bin 0 -> 33370 bytes advtrains/textures/advtrains_track_cr_45.png | Bin 0 -> 33938 bytes advtrains/textures/advtrains_track_placer.png | Bin 0 -> 32349 bytes advtrains/textures/advtrains_track_st.png | Bin 0 -> 20405 bytes advtrains/textures/advtrains_track_st_45.png | Bin 0 -> 39977 bytes advtrains/textures/advtrains_track_swlcr.png | Bin 0 -> 33378 bytes advtrains/textures/advtrains_track_swlcr_45.png | Bin 0 -> 45772 bytes advtrains/textures/advtrains_track_swlst.png | Bin 0 -> 32321 bytes advtrains/textures/advtrains_track_swlst_45.png | Bin 0 -> 46408 bytes advtrains/textures/advtrains_track_swrcr.png | Bin 0 -> 33670 bytes advtrains/textures/advtrains_track_swrcr_45.png | Bin 0 -> 46865 bytes advtrains/textures/advtrains_track_swrst.png | Bin 0 -> 32654 bytes advtrains/textures/advtrains_track_swrst_45.png | Bin 0 -> 47636 bytes advtrains/textures/advtrains_trackworker.png | Bin 0 -> 328 bytes advtrains/textures/drwho_screwdriver.png | Bin 0 -> 328 bytes advtrains/textures/larger rails.xcf | Bin 0 -> 1239132 bytes advtrains/trackplacer.lua | 282 +++++++ advtrains/tracks.lua | 693 ++++++++++++++++ advtrains/trainhud.lua | 109 +++ advtrains/trainlogic.lua | 895 +++++++++++++++++++++ advtrains/wagons.lua | 607 ++++++++++++++ advtrains_train_industrial/depends.txt | 1 + advtrains_train_industrial/init.lua | 61 ++ .../models/advtrains_engine_industrial.b3d | Bin 0 -> 143659 bytes .../models/advtrains_wagon_tank.b3d | Bin 0 -> 223975 bytes .../models/advtrains_wagon_wood.b3d | Bin 0 -> 193975 bytes .../textures/advtrains_engine_industrial.png | Bin 0 -> 59019 bytes .../textures/advtrains_engine_industrial_inv.png | Bin 0 -> 381 bytes .../textures/advtrains_wagon_tank.png | Bin 0 -> 8975 bytes .../textures/advtrains_wagon_tank_inv.png | Bin 0 -> 408 bytes .../textures/advtrains_wagon_wood.png | Bin 0 -> 5974 bytes .../textures/advtrains_wagon_wood_inv.png | Bin 0 -> 316 bytes advtrains_train_japan/depends.txt | 1 + advtrains_train_japan/init.lua | 34 + .../models/advtrains_engine_japan.b3d | Bin 0 -> 165287 bytes .../models/advtrains_wagon_japan.b3d | Bin 0 -> 171991 bytes .../textures/advtrains_engine_japan.png | Bin 0 -> 12664 bytes .../textures/advtrains_engine_japan_inv.png | Bin 0 -> 434 bytes .../textures/advtrains_wagon_japan.png | Bin 0 -> 11175 bytes .../textures/advtrains_wagon_japan_inv.png | Bin 0 -> 400 bytes advtrains_train_steam/depends.txt | 1 + advtrains_train_steam/init.lua | 115 +++ .../models/advtrains_engine_steam.b3d | Bin 0 -> 298687 bytes advtrains_train_steam/models/advtrains_wagon.b3d | Bin 0 -> 107352 bytes .../textures/advtrains_newlocomotive.png | Bin 0 -> 31800 bytes .../textures/advtrains_newlocomotive_inv.png | Bin 0 -> 469 bytes advtrains_train_steam/textures/advtrains_wagon.png | Bin 0 -> 35724 bytes .../textures/advtrains_wagon_box.png | Bin 0 -> 22503 bytes .../textures/advtrains_wagon_box_inv.png | Bin 0 -> 347 bytes .../textures/advtrains_wagon_inv.png | Bin 0 -> 709 bytes advtrains_train_subway/depends.txt | 1 + advtrains_train_subway/init.lua | 28 + .../models/advtrains_subway_train.b3d | Bin 0 -> 95856 bytes .../textures/advtrains_subway_train.png | Bin 0 -> 12002 bytes .../textures/advtrains_subway_train_inv.png | Bin 0 -> 900 bytes atc.lua | 4 - couple.lua | 154 ---- crafting.lua | 103 --- damage.lua | 26 - debugitems.lua | 36 - depends.txt | 2 - description.txt | 8 - helpers.lua | 249 ------ init.lua | 42 - misc_nodes.lua | 67 -- models/advtrains_dtrack_bumper_st.b3d | Bin 32927 -> 0 bytes models/advtrains_dtrack_bumper_st_30.b3d | Bin 48546 -> 0 bytes models/advtrains_dtrack_bumper_st_45.b3d | Bin 32926 -> 0 bytes models/advtrains_dtrack_bumper_st_60.b3d | Bin 48546 -> 0 bytes models/advtrains_dtrack_cr.b3d | Bin 27540 -> 0 bytes models/advtrains_dtrack_cr_30.b3d | Bin 27543 -> 0 bytes models/advtrains_dtrack_cr_45.b3d | Bin 23037 -> 0 bytes models/advtrains_dtrack_cr_60.b3d | Bin 23037 -> 0 bytes models/advtrains_dtrack_detector_st.b3d | Bin 17157 -> 0 bytes models/advtrains_dtrack_detector_st_30.b3d | Bin 32779 -> 0 bytes models/advtrains_dtrack_detector_st_45.b3d | Bin 17163 -> 0 bytes models/advtrains_dtrack_detector_st_60.b3d | Bin 32779 -> 0 bytes models/advtrains_dtrack_st.b3d | Bin 15828 -> 0 bytes models/advtrains_dtrack_st_30.b3d | Bin 31447 -> 0 bytes models/advtrains_dtrack_st_45.b3d | Bin 15831 -> 0 bytes models/advtrains_dtrack_st_60.b3d | Bin 31447 -> 0 bytes models/advtrains_dtrack_swlcr.b3d | Bin 36743 -> 0 bytes models/advtrains_dtrack_swlcr_30.b3d | Bin 45922 -> 0 bytes models/advtrains_dtrack_swlcr_45.b3d | Bin 32112 -> 0 bytes models/advtrains_dtrack_swlcr_60.b3d | Bin 44864 -> 0 bytes models/advtrains_dtrack_swlst.b3d | Bin 36743 -> 0 bytes models/advtrains_dtrack_swlst_30.b3d | Bin 45922 -> 0 bytes models/advtrains_dtrack_swlst_45.b3d | Bin 32112 -> 0 bytes models/advtrains_dtrack_swlst_60.b3d | Bin 44864 -> 0 bytes models/advtrains_dtrack_swrcr.b3d | Bin 36743 -> 0 bytes models/advtrains_dtrack_swrcr_30.b3d | Bin 44864 -> 0 bytes models/advtrains_dtrack_swrcr_45.b3d | Bin 32112 -> 0 bytes models/advtrains_dtrack_swrcr_60.b3d | Bin 45922 -> 0 bytes models/advtrains_dtrack_swrst.b3d | Bin 36743 -> 0 bytes models/advtrains_dtrack_swrst_30.b3d | Bin 44864 -> 0 bytes models/advtrains_dtrack_swrst_45.b3d | Bin 32112 -> 0 bytes models/advtrains_dtrack_swrst_60.b3d | Bin 45922 -> 0 bytes models/advtrains_dtrack_vst1.b3d | Bin 21495 -> 0 bytes models/advtrains_dtrack_vst1_45.b3d | Bin 20739 -> 0 bytes models/advtrains_dtrack_vst2.b3d | Bin 25143 -> 0 bytes models/advtrains_dtrack_vst2_45.b3d | Bin 20919 -> 0 bytes models/advtrains_dtrack_vst31.b3d | Bin 19051 -> 0 bytes models/advtrains_dtrack_vst32.b3d | Bin 21635 -> 0 bytes models/advtrains_dtrack_vst33.b3d | Bin 28795 -> 0 bytes models/advtrains_engine_industrial.b3d | Bin 143659 -> 0 bytes models/advtrains_engine_japan.b3d | Bin 165287 -> 0 bytes models/advtrains_engine_steam.b3d | Bin 298687 -> 0 bytes models/advtrains_modernwagon.b3d | Bin 172028 -> 0 bytes models/advtrains_retrosignal_off.b3d | Bin 13093 -> 0 bytes models/advtrains_retrosignal_off_30.b3d | Bin 13093 -> 0 bytes models/advtrains_retrosignal_off_45.b3d | Bin 13093 -> 0 bytes models/advtrains_retrosignal_off_60.b3d | Bin 13093 -> 0 bytes models/advtrains_retrosignal_on.b3d | Bin 13093 -> 0 bytes models/advtrains_retrosignal_on_30.b3d | Bin 13093 -> 0 bytes models/advtrains_retrosignal_on_45.b3d | Bin 13093 -> 0 bytes models/advtrains_retrosignal_on_60.b3d | Bin 13093 -> 0 bytes models/advtrains_signal.b3d | Bin 61544 -> 0 bytes models/advtrains_signal_30.b3d | Bin 61544 -> 0 bytes models/advtrains_signal_45.b3d | Bin 61544 -> 0 bytes models/advtrains_signal_60.b3d | Bin 61544 -> 0 bytes models/advtrains_subway_train.b3d | Bin 95856 -> 0 bytes models/advtrains_track_cr.b3d | Bin 8023 -> 0 bytes models/advtrains_track_st.b3d | Bin 15831 -> 0 bytes models/advtrains_track_st_45.b3d | Bin 8935 -> 0 bytes models/advtrains_wagon.b3d | Bin 107352 -> 0 bytes models/advtrains_wagon_japan.b3d | Bin 171991 -> 0 bytes models/advtrains_wagon_tank.b3d | Bin 223975 -> 0 bytes models/advtrains_wagon_wood.b3d | Bin 193975 -> 0 bytes models/blender/engine-with-animation.blend | Bin 599504 -> 0 bytes models/blender/gleis/infos/Grafik_weiche.png | Bin 361700 -> 0 bytes models/blender/gleis/infos/breite | 1 - models/blender/gleis/licence.txt~ | 0 models/blender/gleis/rail_my.blend | Bin 654772 -> 0 bytes models/blender/gleis/rail_my.blend1 | Bin 674164 -> 0 bytes models/blender/gleis/rail_my_rt.blend | Bin 847060 -> 0 bytes models/blender/gleis/rail_my_rt.blend1 | Bin 767780 -> 0 bytes models/blender/gleis/rail_my_rt_final.blend | Bin 1094836 -> 0 bytes models/blender/gleis/rail_my_rt_final.blend1 | Bin 827052 -> 0 bytes models/blender/gleis/rail_my_rt_switches.blend | Bin 2184236 -> 0 bytes models/blender/gleis/rail_my_rt_switches.blend1 | Bin 1945588 -> 0 bytes models/blender/gleis/rail_my_rt_switches2.blend | Bin 2139340 -> 0 bytes models/blender/gleis/rail_my_rt_switches2.blend1 | Bin 2172972 -> 0 bytes models/blender/gleis/rail_together.blend | Bin 1016920 -> 0 bytes models/blender/gleis/rail_together.png | Bin 233544 -> 0 bytes models/blender/gleis/rail_together2.png | Bin 312891 -> 0 bytes models/blender/gleis/rail_together3.png | Bin 309398 -> 0 bytes models/blender/gleis/rail_verticals.blend | Bin 550748 -> 0 bytes models/blender/gleis/rail_verticals.blend1 | Bin 574100 -> 0 bytes models/blender/gleis/rail_verticals3.blend | Bin 591800 -> 0 bytes models/blender/gleis/rail_verticals3.blend1 | Bin 554196 -> 0 bytes models/blender/gleis/rail_verticals45.blend | Bin 547788 -> 0 bytes models/blender/gleis/rail_verticals45.blend1 | Bin 547300 -> 0 bytes models/blender/gleis/rail_verticals45.blend11 | Bin 547300 -> 0 bytes models/blender/gleis/texturen/rail.png | Bin 2616 -> 0 bytes models/blender/gleis/texturen/uv.png | Bin 2343 -> 0 bytes models/blender/industrial/industry_loc.blend | Bin 652640 -> 0 bytes models/blender/industrial/industry_loc.blend1 | Bin 652640 -> 0 bytes models/blender/industrial/industry_loc.blend11 | Bin 659096 -> 0 bytes .../blender/industrial/industry_oil_ wagong.blend | Bin 693488 -> 0 bytes .../blender/industrial/industry_oil_ wagong.blend1 | Bin 693488 -> 0 bytes .../blender/industrial/industry_tree_wagong.blend | Bin 640056 -> 0 bytes .../blender/industrial/industry_tree_wagong.blend1 | Bin 640056 -> 0 bytes models/blender/industrial/industry_tree_wagong.png | Bin 316 -> 0 bytes models/blender/locomotive.blend | Bin 459600 -> 0 bytes models/blender/magnet_track.blend | Bin 516836 -> 0 bytes models/blender/mbb/advtrains_wagon_japan.xcf | Bin 814467 -> 0 bytes models/blender/mbb/modern_japanlocomotive.blend | Bin 715116 -> 0 bytes models/blender/mbb/modern_japanlocomotive.blend1 | Bin 715116 -> 0 bytes models/blender/mbb/modern_japanlocomotive.png | Bin 204978 -> 0 bytes models/blender/mbb/modern_japanlocomotive.xcf | Bin 957175 -> 0 bytes models/blender/mbb/modern_locomotive.blend | Bin 732124 -> 0 bytes models/blender/mbb/modern_wagong.blend | Bin 471140 -> 0 bytes models/blender/mbb/modern_wagong.blend1 | Bin 518316 -> 0 bytes models/blender/mbb/modern_wagong_uv.blend | Bin 571364 -> 0 bytes models/blender/mbb/modern_wagong_uv.blend1 | Bin 575708 -> 0 bytes models/blender/mbb/modern_wagong_uv.png | Bin 189564 -> 0 bytes models/blender/mbb/prellbock.blend | Bin 745176 -> 0 bytes models/blender/mbb/prellbock.blend1 | Bin 485416 -> 0 bytes models/blender/mbb/prellbock.uv.png | Bin 4034 -> 0 bytes models/blender/mbb/regio-lokomotive.blend | Bin 704160 -> 0 bytes models/blender/mbb/regio-waron.blend | Bin 545620 -> 0 bytes models/blender/mbb/retrosignal.blend | Bin 488920 -> 0 bytes models/blender/mbb/retrosignal.blend1 | Bin 507800 -> 0 bytes models/blender/mbb/signal(2)_hoch.blend | Bin 472092 -> 0 bytes models/blender/mbb/signal(2)_unten.blend | Bin 472092 -> 0 bytes models/blender/mbb/signal.blend | Bin 570336 -> 0 bytes models/blender/mbb/signal.blend1 | Bin 570336 -> 0 bytes models/blender/mbb/signal.png | Bin 244314 -> 0 bytes models/blender/mbb/signal.xcf | Bin 881142 -> 0 bytes models/blender/mbb/signal2.png | Bin 39924 -> 0 bytes models/blender/mbb/tr-logo.png | Bin 197 -> 0 bytes models/blender/mbb/weichenhebel1.blend | Bin 493028 -> 0 bytes models/blender/mbb/weichenhebel2.blend | Bin 492996 -> 0 bytes models/blender/newlocomotive.blend | Bin 603376 -> 0 bytes models/blender/newlocomotive.blend1 | Bin 603376 -> 0 bytes models/blender/newlocomotive_uvs.png | Bin 175030 -> 0 bytes models/blender/newwagon.blend | Bin 542188 -> 0 bytes models/blender/newwagon.blend1 | Bin 550292 -> 0 bytes models/blender/newwagon.png | Bin 108762 -> 0 bytes models/blender/subway-train.blend | Bin 536268 -> 0 bytes models/blender/subway-train.blend1 | Bin 538188 -> 0 bytes models/blender/subway-train.png | Bin 96773 -> 0 bytes models/blender/subway-train.xcf | Bin 92558 -> 0 bytes models/blender/trackplane.blend | Bin 462200 -> 0 bytes models/blender/trackvertical1.blend | Bin 453656 -> 0 bytes models/blender/trackvertical1.blend1 | Bin 453344 -> 0 bytes models/blender/trackvertical1.png | Bin 59146 -> 0 bytes models/blender/trackvertical2.blend | Bin 459216 -> 0 bytes models/blender/trackvertical2.png | Bin 66755 -> 0 bytes models/oldmodels/locomotive.b3d | Bin 181112 -> 0 bytes models/oldmodels/trackvertical1.b3d | Bin 629 -> 0 bytes models/oldmodels/trackvertical2.b3d | Bin 869 -> 0 bytes models/trackplane.b3d | Bin 262 -> 0 bytes modpack.txt | 0 pseudoload.lua | 180 ----- readme.txt | 23 - signals.lua | 76 -- textures/advtrains_couple.png | Bin 265 -> 0 bytes textures/advtrains_discouple.png | Bin 307 -> 0 bytes textures/advtrains_dtrack_bumper_placer.png | Bin 2213 -> 0 bytes textures/advtrains_dtrack_detector_placer.png | Bin 1253 -> 0 bytes textures/advtrains_dtrack_placer.png | Bin 5831 -> 0 bytes textures/advtrains_dtrack_rail.png | Bin 2810 -> 0 bytes textures/advtrains_dtrack_rail_detector_on.png | Bin 2844 -> 0 bytes textures/advtrains_dtrack_slopeplacer.png | Bin 2415 -> 0 bytes textures/advtrains_engine_industrial.png | Bin 59019 -> 0 bytes textures/advtrains_engine_industrial_inv.png | Bin 381 -> 0 bytes textures/advtrains_engine_japan.png | Bin 12664 -> 0 bytes textures/advtrains_engine_japan_inv.png | Bin 434 -> 0 bytes textures/advtrains_newlocomotive.png | Bin 31800 -> 0 bytes textures/advtrains_newlocomotive.xcf | Bin 7462378 -> 0 bytes textures/advtrains_newlocomotive_inv.png | Bin 469 -> 0 bytes textures/advtrains_platform.png | Bin 193 -> 0 bytes textures/advtrains_retrosignal.png | Bin 8496 -> 0 bytes textures/advtrains_retrosignal_inv.png | Bin 2242 -> 0 bytes textures/advtrains_signal_inv.png | Bin 856 -> 0 bytes textures/advtrains_signal_off.png | Bin 5882 -> 0 bytes textures/advtrains_signal_on.png | Bin 5884 -> 0 bytes textures/advtrains_subway_train.png | Bin 12002 -> 0 bytes textures/advtrains_subway_train_inv.png | Bin 900 -> 0 bytes textures/advtrains_track_cr.png | Bin 33370 -> 0 bytes textures/advtrains_track_cr_45.png | Bin 33938 -> 0 bytes textures/advtrains_track_placer.png | Bin 32349 -> 0 bytes textures/advtrains_track_st.png | Bin 20405 -> 0 bytes textures/advtrains_track_st_45.png | Bin 39977 -> 0 bytes textures/advtrains_track_swlcr.png | Bin 33378 -> 0 bytes textures/advtrains_track_swlcr_45.png | Bin 45772 -> 0 bytes textures/advtrains_track_swlst.png | Bin 32321 -> 0 bytes textures/advtrains_track_swlst_45.png | Bin 46408 -> 0 bytes textures/advtrains_track_swrcr.png | Bin 33670 -> 0 bytes textures/advtrains_track_swrcr_45.png | Bin 46865 -> 0 bytes textures/advtrains_track_swrst.png | Bin 32654 -> 0 bytes textures/advtrains_track_swrst_45.png | Bin 47636 -> 0 bytes textures/advtrains_trackworker.png | Bin 328 -> 0 bytes textures/advtrains_wagon.png | Bin 35724 -> 0 bytes textures/advtrains_wagon_box.png | Bin 22503 -> 0 bytes textures/advtrains_wagon_box_inv.png | Bin 347 -> 0 bytes textures/advtrains_wagon_inv.png | Bin 709 -> 0 bytes textures/advtrains_wagon_japan.png | Bin 11175 -> 0 bytes textures/advtrains_wagon_japan_inv.png | Bin 400 -> 0 bytes textures/advtrains_wagon_tank.png | Bin 8975 -> 0 bytes textures/advtrains_wagon_tank_inv.png | Bin 408 -> 0 bytes textures/advtrains_wagon_wood.png | Bin 5974 -> 0 bytes textures/advtrains_wagon_wood_inv.png | Bin 316 -> 0 bytes textures/drwho_screwdriver.png | Bin 328 -> 0 bytes textures/larger rails.xcf | Bin 1239132 -> 0 bytes trackplacer.lua | 282 ------- tracks.lua | 693 ---------------- trainhud.lua | 109 --- trainlogic.lua | 895 --------------------- wagons.lua | 790 ------------------ 439 files changed, 3767 insertions(+), 3740 deletions(-) create mode 100644 advtrains/atc.lua create mode 100644 advtrains/couple.lua create mode 100644 advtrains/crafting.lua create mode 100644 advtrains/damage.lua create mode 100644 advtrains/debugitems.lua create mode 100644 advtrains/depends.txt create mode 100644 advtrains/description.txt create mode 100644 advtrains/helpers.lua create mode 100644 advtrains/init.lua create mode 100644 advtrains/misc_nodes.lua create mode 100644 advtrains/models/advtrains_dtrack_bumper_st.b3d create mode 100644 advtrains/models/advtrains_dtrack_bumper_st_30.b3d create mode 100644 advtrains/models/advtrains_dtrack_bumper_st_45.b3d create mode 100644 advtrains/models/advtrains_dtrack_bumper_st_60.b3d create mode 100644 advtrains/models/advtrains_dtrack_cr.b3d create mode 100644 advtrains/models/advtrains_dtrack_cr_30.b3d create mode 100644 advtrains/models/advtrains_dtrack_cr_45.b3d create mode 100644 advtrains/models/advtrains_dtrack_cr_60.b3d create mode 100644 advtrains/models/advtrains_dtrack_detector_st.b3d create mode 100644 advtrains/models/advtrains_dtrack_detector_st_30.b3d create mode 100644 advtrains/models/advtrains_dtrack_detector_st_45.b3d create mode 100644 advtrains/models/advtrains_dtrack_detector_st_60.b3d create mode 100644 advtrains/models/advtrains_dtrack_st.b3d create mode 100644 advtrains/models/advtrains_dtrack_st_30.b3d create mode 100644 advtrains/models/advtrains_dtrack_st_45.b3d create mode 100644 advtrains/models/advtrains_dtrack_st_60.b3d create mode 100644 advtrains/models/advtrains_dtrack_swlcr.b3d create mode 100644 advtrains/models/advtrains_dtrack_swlcr_30.b3d create mode 100644 advtrains/models/advtrains_dtrack_swlcr_45.b3d create mode 100644 advtrains/models/advtrains_dtrack_swlcr_60.b3d create mode 100644 advtrains/models/advtrains_dtrack_swlst.b3d create mode 100644 advtrains/models/advtrains_dtrack_swlst_30.b3d create mode 100644 advtrains/models/advtrains_dtrack_swlst_45.b3d create mode 100644 advtrains/models/advtrains_dtrack_swlst_60.b3d create mode 100644 advtrains/models/advtrains_dtrack_swrcr.b3d create mode 100644 advtrains/models/advtrains_dtrack_swrcr_30.b3d create mode 100644 advtrains/models/advtrains_dtrack_swrcr_45.b3d create mode 100644 advtrains/models/advtrains_dtrack_swrcr_60.b3d create mode 100644 advtrains/models/advtrains_dtrack_swrst.b3d create mode 100644 advtrains/models/advtrains_dtrack_swrst_30.b3d create mode 100644 advtrains/models/advtrains_dtrack_swrst_45.b3d create mode 100644 advtrains/models/advtrains_dtrack_swrst_60.b3d create mode 100644 advtrains/models/advtrains_dtrack_vst1.b3d create mode 100644 advtrains/models/advtrains_dtrack_vst1_45.b3d create mode 100644 advtrains/models/advtrains_dtrack_vst2.b3d create mode 100644 advtrains/models/advtrains_dtrack_vst2_45.b3d create mode 100644 advtrains/models/advtrains_dtrack_vst31.b3d create mode 100644 advtrains/models/advtrains_dtrack_vst32.b3d create mode 100644 advtrains/models/advtrains_dtrack_vst33.b3d create mode 100644 advtrains/models/advtrains_modernwagon.b3d create mode 100644 advtrains/models/advtrains_retrosignal_off.b3d create mode 100644 advtrains/models/advtrains_retrosignal_off_30.b3d create mode 100644 advtrains/models/advtrains_retrosignal_off_45.b3d create mode 100644 advtrains/models/advtrains_retrosignal_off_60.b3d create mode 100644 advtrains/models/advtrains_retrosignal_on.b3d create mode 100644 advtrains/models/advtrains_retrosignal_on_30.b3d create mode 100644 advtrains/models/advtrains_retrosignal_on_45.b3d create mode 100644 advtrains/models/advtrains_retrosignal_on_60.b3d create mode 100644 advtrains/models/advtrains_signal.b3d create mode 100644 advtrains/models/advtrains_signal_30.b3d create mode 100644 advtrains/models/advtrains_signal_45.b3d create mode 100644 advtrains/models/advtrains_signal_60.b3d create mode 100644 advtrains/models/advtrains_track_cr.b3d create mode 100644 advtrains/models/advtrains_track_st.b3d create mode 100644 advtrains/models/advtrains_track_st_45.b3d create mode 100644 advtrains/models/blender/engine-with-animation.blend create mode 100644 advtrains/models/blender/gleis/infos/Grafik_weiche.png create mode 100644 advtrains/models/blender/gleis/infos/breite create mode 100644 advtrains/models/blender/gleis/licence.txt~ create mode 100644 advtrains/models/blender/gleis/rail_my.blend create mode 100644 advtrains/models/blender/gleis/rail_my.blend1 create mode 100644 advtrains/models/blender/gleis/rail_my_rt.blend create mode 100644 advtrains/models/blender/gleis/rail_my_rt.blend1 create mode 100644 advtrains/models/blender/gleis/rail_my_rt_final.blend create mode 100644 advtrains/models/blender/gleis/rail_my_rt_final.blend1 create mode 100644 advtrains/models/blender/gleis/rail_my_rt_switches.blend create mode 100644 advtrains/models/blender/gleis/rail_my_rt_switches.blend1 create mode 100644 advtrains/models/blender/gleis/rail_my_rt_switches2.blend create mode 100644 advtrains/models/blender/gleis/rail_my_rt_switches2.blend1 create mode 100644 advtrains/models/blender/gleis/rail_together.blend create mode 100644 advtrains/models/blender/gleis/rail_together.png create mode 100644 advtrains/models/blender/gleis/rail_together2.png create mode 100644 advtrains/models/blender/gleis/rail_together3.png create mode 100644 advtrains/models/blender/gleis/rail_verticals.blend create mode 100644 advtrains/models/blender/gleis/rail_verticals.blend1 create mode 100644 advtrains/models/blender/gleis/rail_verticals3.blend create mode 100644 advtrains/models/blender/gleis/rail_verticals3.blend1 create mode 100644 advtrains/models/blender/gleis/rail_verticals45.blend create mode 100644 advtrains/models/blender/gleis/rail_verticals45.blend1 create mode 100644 advtrains/models/blender/gleis/rail_verticals45.blend11 create mode 100644 advtrains/models/blender/gleis/texturen/rail.png create mode 100644 advtrains/models/blender/gleis/texturen/uv.png create mode 100644 advtrains/models/blender/industrial/industry_loc.blend create mode 100644 advtrains/models/blender/industrial/industry_loc.blend1 create mode 100644 advtrains/models/blender/industrial/industry_loc.blend11 create mode 100644 advtrains/models/blender/industrial/industry_oil_ wagong.blend create mode 100644 advtrains/models/blender/industrial/industry_oil_ wagong.blend1 create mode 100644 advtrains/models/blender/industrial/industry_tree_wagong.blend create mode 100644 advtrains/models/blender/industrial/industry_tree_wagong.blend1 create mode 100644 advtrains/models/blender/industrial/industry_tree_wagong.png create mode 100644 advtrains/models/blender/locomotive.blend create mode 100644 advtrains/models/blender/magnet_track.blend create mode 100644 advtrains/models/blender/mbb/advtrains_wagon_japan.xcf create mode 100644 advtrains/models/blender/mbb/modern_japanlocomotive.blend create mode 100644 advtrains/models/blender/mbb/modern_japanlocomotive.blend1 create mode 100644 advtrains/models/blender/mbb/modern_japanlocomotive.png create mode 100644 advtrains/models/blender/mbb/modern_japanlocomotive.xcf create mode 100644 advtrains/models/blender/mbb/modern_locomotive.blend create mode 100644 advtrains/models/blender/mbb/modern_wagong.blend create mode 100644 advtrains/models/blender/mbb/modern_wagong.blend1 create mode 100644 advtrains/models/blender/mbb/modern_wagong_uv.blend create mode 100644 advtrains/models/blender/mbb/modern_wagong_uv.blend1 create mode 100644 advtrains/models/blender/mbb/modern_wagong_uv.png create mode 100644 advtrains/models/blender/mbb/prellbock.blend create mode 100644 advtrains/models/blender/mbb/prellbock.blend1 create mode 100644 advtrains/models/blender/mbb/prellbock.uv.png create mode 100644 advtrains/models/blender/mbb/regio-lokomotive.blend create mode 100644 advtrains/models/blender/mbb/regio-waron.blend create mode 100644 advtrains/models/blender/mbb/retrosignal.blend create mode 100644 advtrains/models/blender/mbb/retrosignal.blend1 create mode 100644 advtrains/models/blender/mbb/signal(2)_hoch.blend create mode 100644 advtrains/models/blender/mbb/signal(2)_unten.blend create mode 100644 advtrains/models/blender/mbb/signal.blend create mode 100644 advtrains/models/blender/mbb/signal.blend1 create mode 100644 advtrains/models/blender/mbb/signal.png create mode 100644 advtrains/models/blender/mbb/signal.xcf create mode 100644 advtrains/models/blender/mbb/signal2.png create mode 100644 advtrains/models/blender/mbb/tr-logo.png create mode 100644 advtrains/models/blender/mbb/weichenhebel1.blend create mode 100644 advtrains/models/blender/mbb/weichenhebel2.blend create mode 100644 advtrains/models/blender/newlocomotive.blend create mode 100644 advtrains/models/blender/newlocomotive.blend1 create mode 100644 advtrains/models/blender/newlocomotive_uvs.png create mode 100644 advtrains/models/blender/newwagon.blend create mode 100644 advtrains/models/blender/newwagon.blend1 create mode 100644 advtrains/models/blender/newwagon.png create mode 100644 advtrains/models/blender/subway-train.blend create mode 100644 advtrains/models/blender/subway-train.blend1 create mode 100644 advtrains/models/blender/subway-train.png create mode 100644 advtrains/models/blender/subway-train.xcf create mode 100644 advtrains/models/blender/trackplane.blend create mode 100644 advtrains/models/blender/trackvertical1.blend create mode 100644 advtrains/models/blender/trackvertical1.blend1 create mode 100644 advtrains/models/blender/trackvertical1.png create mode 100644 advtrains/models/blender/trackvertical2.blend create mode 100644 advtrains/models/blender/trackvertical2.png create mode 100644 advtrains/models/oldmodels/locomotive.b3d create mode 100644 advtrains/models/oldmodels/trackvertical1.b3d create mode 100644 advtrains/models/oldmodels/trackvertical2.b3d create mode 100644 advtrains/models/trackplane.b3d create mode 100644 advtrains/pseudoload.lua create mode 100644 advtrains/readme.txt create mode 100644 advtrains/signals.lua create mode 100644 advtrains/textures/advtrains_couple.png create mode 100644 advtrains/textures/advtrains_discouple.png create mode 100644 advtrains/textures/advtrains_dtrack_bumper_placer.png create mode 100644 advtrains/textures/advtrains_dtrack_detector_placer.png create mode 100644 advtrains/textures/advtrains_dtrack_placer.png create mode 100644 advtrains/textures/advtrains_dtrack_rail.png create mode 100644 advtrains/textures/advtrains_dtrack_rail_detector_on.png create mode 100644 advtrains/textures/advtrains_dtrack_slopeplacer.png create mode 100644 advtrains/textures/advtrains_newlocomotive.xcf create mode 100644 advtrains/textures/advtrains_platform.png create mode 100644 advtrains/textures/advtrains_retrosignal.png create mode 100644 advtrains/textures/advtrains_retrosignal_inv.png create mode 100644 advtrains/textures/advtrains_signal_inv.png create mode 100644 advtrains/textures/advtrains_signal_off.png create mode 100644 advtrains/textures/advtrains_signal_on.png create mode 100644 advtrains/textures/advtrains_track_cr.png create mode 100644 advtrains/textures/advtrains_track_cr_45.png create mode 100644 advtrains/textures/advtrains_track_placer.png create mode 100644 advtrains/textures/advtrains_track_st.png create mode 100644 advtrains/textures/advtrains_track_st_45.png create mode 100644 advtrains/textures/advtrains_track_swlcr.png create mode 100644 advtrains/textures/advtrains_track_swlcr_45.png create mode 100644 advtrains/textures/advtrains_track_swlst.png create mode 100644 advtrains/textures/advtrains_track_swlst_45.png create mode 100644 advtrains/textures/advtrains_track_swrcr.png create mode 100644 advtrains/textures/advtrains_track_swrcr_45.png create mode 100644 advtrains/textures/advtrains_track_swrst.png create mode 100644 advtrains/textures/advtrains_track_swrst_45.png create mode 100644 advtrains/textures/advtrains_trackworker.png create mode 100644 advtrains/textures/drwho_screwdriver.png create mode 100644 advtrains/textures/larger rails.xcf create mode 100644 advtrains/trackplacer.lua create mode 100644 advtrains/tracks.lua create mode 100644 advtrains/trainhud.lua create mode 100644 advtrains/trainlogic.lua create mode 100644 advtrains/wagons.lua create mode 100644 advtrains_train_industrial/depends.txt create mode 100644 advtrains_train_industrial/init.lua create mode 100644 advtrains_train_industrial/models/advtrains_engine_industrial.b3d create mode 100644 advtrains_train_industrial/models/advtrains_wagon_tank.b3d create mode 100644 advtrains_train_industrial/models/advtrains_wagon_wood.b3d create mode 100644 advtrains_train_industrial/textures/advtrains_engine_industrial.png create mode 100644 advtrains_train_industrial/textures/advtrains_engine_industrial_inv.png create mode 100644 advtrains_train_industrial/textures/advtrains_wagon_tank.png create mode 100644 advtrains_train_industrial/textures/advtrains_wagon_tank_inv.png create mode 100644 advtrains_train_industrial/textures/advtrains_wagon_wood.png create mode 100644 advtrains_train_industrial/textures/advtrains_wagon_wood_inv.png create mode 100644 advtrains_train_japan/depends.txt create mode 100644 advtrains_train_japan/init.lua create mode 100644 advtrains_train_japan/models/advtrains_engine_japan.b3d create mode 100644 advtrains_train_japan/models/advtrains_wagon_japan.b3d create mode 100644 advtrains_train_japan/textures/advtrains_engine_japan.png create mode 100644 advtrains_train_japan/textures/advtrains_engine_japan_inv.png create mode 100644 advtrains_train_japan/textures/advtrains_wagon_japan.png create mode 100644 advtrains_train_japan/textures/advtrains_wagon_japan_inv.png create mode 100644 advtrains_train_steam/depends.txt create mode 100644 advtrains_train_steam/init.lua create mode 100644 advtrains_train_steam/models/advtrains_engine_steam.b3d create mode 100644 advtrains_train_steam/models/advtrains_wagon.b3d create mode 100644 advtrains_train_steam/textures/advtrains_newlocomotive.png create mode 100644 advtrains_train_steam/textures/advtrains_newlocomotive_inv.png create mode 100644 advtrains_train_steam/textures/advtrains_wagon.png create mode 100644 advtrains_train_steam/textures/advtrains_wagon_box.png create mode 100644 advtrains_train_steam/textures/advtrains_wagon_box_inv.png create mode 100644 advtrains_train_steam/textures/advtrains_wagon_inv.png create mode 100644 advtrains_train_subway/depends.txt create mode 100644 advtrains_train_subway/init.lua create mode 100644 advtrains_train_subway/models/advtrains_subway_train.b3d create mode 100644 advtrains_train_subway/textures/advtrains_subway_train.png create mode 100644 advtrains_train_subway/textures/advtrains_subway_train_inv.png delete mode 100644 atc.lua delete mode 100644 couple.lua delete mode 100644 crafting.lua delete mode 100644 damage.lua delete mode 100644 debugitems.lua delete mode 100644 depends.txt delete mode 100644 description.txt delete mode 100644 helpers.lua delete mode 100644 init.lua delete mode 100644 misc_nodes.lua delete mode 100644 models/advtrains_dtrack_bumper_st.b3d delete mode 100644 models/advtrains_dtrack_bumper_st_30.b3d delete mode 100644 models/advtrains_dtrack_bumper_st_45.b3d delete mode 100644 models/advtrains_dtrack_bumper_st_60.b3d delete mode 100644 models/advtrains_dtrack_cr.b3d delete mode 100644 models/advtrains_dtrack_cr_30.b3d delete mode 100644 models/advtrains_dtrack_cr_45.b3d delete mode 100644 models/advtrains_dtrack_cr_60.b3d delete mode 100644 models/advtrains_dtrack_detector_st.b3d delete mode 100644 models/advtrains_dtrack_detector_st_30.b3d delete mode 100644 models/advtrains_dtrack_detector_st_45.b3d delete mode 100644 models/advtrains_dtrack_detector_st_60.b3d delete mode 100644 models/advtrains_dtrack_st.b3d delete mode 100644 models/advtrains_dtrack_st_30.b3d delete mode 100644 models/advtrains_dtrack_st_45.b3d delete mode 100644 models/advtrains_dtrack_st_60.b3d delete mode 100644 models/advtrains_dtrack_swlcr.b3d delete mode 100644 models/advtrains_dtrack_swlcr_30.b3d delete mode 100644 models/advtrains_dtrack_swlcr_45.b3d delete mode 100644 models/advtrains_dtrack_swlcr_60.b3d delete mode 100644 models/advtrains_dtrack_swlst.b3d delete mode 100644 models/advtrains_dtrack_swlst_30.b3d delete mode 100644 models/advtrains_dtrack_swlst_45.b3d delete mode 100644 models/advtrains_dtrack_swlst_60.b3d delete mode 100644 models/advtrains_dtrack_swrcr.b3d delete mode 100644 models/advtrains_dtrack_swrcr_30.b3d delete mode 100644 models/advtrains_dtrack_swrcr_45.b3d delete mode 100644 models/advtrains_dtrack_swrcr_60.b3d delete mode 100644 models/advtrains_dtrack_swrst.b3d delete mode 100644 models/advtrains_dtrack_swrst_30.b3d delete mode 100644 models/advtrains_dtrack_swrst_45.b3d delete mode 100644 models/advtrains_dtrack_swrst_60.b3d delete mode 100644 models/advtrains_dtrack_vst1.b3d delete mode 100644 models/advtrains_dtrack_vst1_45.b3d delete mode 100644 models/advtrains_dtrack_vst2.b3d delete mode 100644 models/advtrains_dtrack_vst2_45.b3d delete mode 100644 models/advtrains_dtrack_vst31.b3d delete mode 100644 models/advtrains_dtrack_vst32.b3d delete mode 100644 models/advtrains_dtrack_vst33.b3d delete mode 100644 models/advtrains_engine_industrial.b3d delete mode 100644 models/advtrains_engine_japan.b3d delete mode 100644 models/advtrains_engine_steam.b3d delete mode 100644 models/advtrains_modernwagon.b3d delete mode 100644 models/advtrains_retrosignal_off.b3d delete mode 100644 models/advtrains_retrosignal_off_30.b3d delete mode 100644 models/advtrains_retrosignal_off_45.b3d delete mode 100644 models/advtrains_retrosignal_off_60.b3d delete mode 100644 models/advtrains_retrosignal_on.b3d delete mode 100644 models/advtrains_retrosignal_on_30.b3d delete mode 100644 models/advtrains_retrosignal_on_45.b3d delete mode 100644 models/advtrains_retrosignal_on_60.b3d delete mode 100644 models/advtrains_signal.b3d delete mode 100644 models/advtrains_signal_30.b3d delete mode 100644 models/advtrains_signal_45.b3d delete mode 100644 models/advtrains_signal_60.b3d delete mode 100644 models/advtrains_subway_train.b3d delete mode 100644 models/advtrains_track_cr.b3d delete mode 100644 models/advtrains_track_st.b3d delete mode 100644 models/advtrains_track_st_45.b3d delete mode 100644 models/advtrains_wagon.b3d delete mode 100644 models/advtrains_wagon_japan.b3d delete mode 100644 models/advtrains_wagon_tank.b3d delete mode 100644 models/advtrains_wagon_wood.b3d delete mode 100644 models/blender/engine-with-animation.blend delete mode 100644 models/blender/gleis/infos/Grafik_weiche.png delete mode 100644 models/blender/gleis/infos/breite delete mode 100644 models/blender/gleis/licence.txt~ delete mode 100644 models/blender/gleis/rail_my.blend delete mode 100644 models/blender/gleis/rail_my.blend1 delete mode 100644 models/blender/gleis/rail_my_rt.blend delete mode 100644 models/blender/gleis/rail_my_rt.blend1 delete mode 100644 models/blender/gleis/rail_my_rt_final.blend delete mode 100644 models/blender/gleis/rail_my_rt_final.blend1 delete mode 100644 models/blender/gleis/rail_my_rt_switches.blend delete mode 100644 models/blender/gleis/rail_my_rt_switches.blend1 delete mode 100644 models/blender/gleis/rail_my_rt_switches2.blend delete mode 100644 models/blender/gleis/rail_my_rt_switches2.blend1 delete mode 100644 models/blender/gleis/rail_together.blend delete mode 100644 models/blender/gleis/rail_together.png delete mode 100644 models/blender/gleis/rail_together2.png delete mode 100644 models/blender/gleis/rail_together3.png delete mode 100644 models/blender/gleis/rail_verticals.blend delete mode 100644 models/blender/gleis/rail_verticals.blend1 delete mode 100644 models/blender/gleis/rail_verticals3.blend delete mode 100644 models/blender/gleis/rail_verticals3.blend1 delete mode 100644 models/blender/gleis/rail_verticals45.blend delete mode 100644 models/blender/gleis/rail_verticals45.blend1 delete mode 100644 models/blender/gleis/rail_verticals45.blend11 delete mode 100644 models/blender/gleis/texturen/rail.png delete mode 100644 models/blender/gleis/texturen/uv.png delete mode 100644 models/blender/industrial/industry_loc.blend delete mode 100644 models/blender/industrial/industry_loc.blend1 delete mode 100644 models/blender/industrial/industry_loc.blend11 delete mode 100644 models/blender/industrial/industry_oil_ wagong.blend delete mode 100644 models/blender/industrial/industry_oil_ wagong.blend1 delete mode 100644 models/blender/industrial/industry_tree_wagong.blend delete mode 100644 models/blender/industrial/industry_tree_wagong.blend1 delete mode 100644 models/blender/industrial/industry_tree_wagong.png delete mode 100644 models/blender/locomotive.blend delete mode 100644 models/blender/magnet_track.blend delete mode 100644 models/blender/mbb/advtrains_wagon_japan.xcf delete mode 100644 models/blender/mbb/modern_japanlocomotive.blend delete mode 100644 models/blender/mbb/modern_japanlocomotive.blend1 delete mode 100644 models/blender/mbb/modern_japanlocomotive.png delete mode 100644 models/blender/mbb/modern_japanlocomotive.xcf delete mode 100644 models/blender/mbb/modern_locomotive.blend delete mode 100644 models/blender/mbb/modern_wagong.blend delete mode 100644 models/blender/mbb/modern_wagong.blend1 delete mode 100644 models/blender/mbb/modern_wagong_uv.blend delete mode 100644 models/blender/mbb/modern_wagong_uv.blend1 delete mode 100644 models/blender/mbb/modern_wagong_uv.png delete mode 100644 models/blender/mbb/prellbock.blend delete mode 100644 models/blender/mbb/prellbock.blend1 delete mode 100644 models/blender/mbb/prellbock.uv.png delete mode 100644 models/blender/mbb/regio-lokomotive.blend delete mode 100644 models/blender/mbb/regio-waron.blend delete mode 100644 models/blender/mbb/retrosignal.blend delete mode 100644 models/blender/mbb/retrosignal.blend1 delete mode 100644 models/blender/mbb/signal(2)_hoch.blend delete mode 100644 models/blender/mbb/signal(2)_unten.blend delete mode 100644 models/blender/mbb/signal.blend delete mode 100644 models/blender/mbb/signal.blend1 delete mode 100644 models/blender/mbb/signal.png delete mode 100644 models/blender/mbb/signal.xcf delete mode 100644 models/blender/mbb/signal2.png delete mode 100644 models/blender/mbb/tr-logo.png delete mode 100644 models/blender/mbb/weichenhebel1.blend delete mode 100644 models/blender/mbb/weichenhebel2.blend delete mode 100644 models/blender/newlocomotive.blend delete mode 100644 models/blender/newlocomotive.blend1 delete mode 100644 models/blender/newlocomotive_uvs.png delete mode 100644 models/blender/newwagon.blend delete mode 100644 models/blender/newwagon.blend1 delete mode 100644 models/blender/newwagon.png delete mode 100644 models/blender/subway-train.blend delete mode 100644 models/blender/subway-train.blend1 delete mode 100644 models/blender/subway-train.png delete mode 100644 models/blender/subway-train.xcf delete mode 100644 models/blender/trackplane.blend delete mode 100644 models/blender/trackvertical1.blend delete mode 100644 models/blender/trackvertical1.blend1 delete mode 100644 models/blender/trackvertical1.png delete mode 100644 models/blender/trackvertical2.blend delete mode 100644 models/blender/trackvertical2.png delete mode 100644 models/oldmodels/locomotive.b3d delete mode 100644 models/oldmodels/trackvertical1.b3d delete mode 100644 models/oldmodels/trackvertical2.b3d delete mode 100644 models/trackplane.b3d create mode 100644 modpack.txt delete mode 100644 pseudoload.lua delete mode 100644 readme.txt delete mode 100644 signals.lua delete mode 100644 textures/advtrains_couple.png delete mode 100644 textures/advtrains_discouple.png delete mode 100644 textures/advtrains_dtrack_bumper_placer.png delete mode 100644 textures/advtrains_dtrack_detector_placer.png delete mode 100644 textures/advtrains_dtrack_placer.png delete mode 100644 textures/advtrains_dtrack_rail.png delete mode 100644 textures/advtrains_dtrack_rail_detector_on.png delete mode 100644 textures/advtrains_dtrack_slopeplacer.png delete mode 100644 textures/advtrains_engine_industrial.png delete mode 100644 textures/advtrains_engine_industrial_inv.png delete mode 100644 textures/advtrains_engine_japan.png delete mode 100644 textures/advtrains_engine_japan_inv.png delete mode 100644 textures/advtrains_newlocomotive.png delete mode 100644 textures/advtrains_newlocomotive.xcf delete mode 100755 textures/advtrains_newlocomotive_inv.png delete mode 100644 textures/advtrains_platform.png delete mode 100644 textures/advtrains_retrosignal.png delete mode 100644 textures/advtrains_retrosignal_inv.png delete mode 100644 textures/advtrains_signal_inv.png delete mode 100644 textures/advtrains_signal_off.png delete mode 100644 textures/advtrains_signal_on.png delete mode 100644 textures/advtrains_subway_train.png delete mode 100644 textures/advtrains_subway_train_inv.png delete mode 100644 textures/advtrains_track_cr.png delete mode 100644 textures/advtrains_track_cr_45.png delete mode 100644 textures/advtrains_track_placer.png delete mode 100644 textures/advtrains_track_st.png delete mode 100644 textures/advtrains_track_st_45.png delete mode 100644 textures/advtrains_track_swlcr.png delete mode 100644 textures/advtrains_track_swlcr_45.png delete mode 100644 textures/advtrains_track_swlst.png delete mode 100644 textures/advtrains_track_swlst_45.png delete mode 100644 textures/advtrains_track_swrcr.png delete mode 100644 textures/advtrains_track_swrcr_45.png delete mode 100644 textures/advtrains_track_swrst.png delete mode 100644 textures/advtrains_track_swrst_45.png delete mode 100644 textures/advtrains_trackworker.png delete mode 100644 textures/advtrains_wagon.png delete mode 100644 textures/advtrains_wagon_box.png delete mode 100644 textures/advtrains_wagon_box_inv.png delete mode 100755 textures/advtrains_wagon_inv.png delete mode 100644 textures/advtrains_wagon_japan.png delete mode 100644 textures/advtrains_wagon_japan_inv.png delete mode 100644 textures/advtrains_wagon_tank.png delete mode 100644 textures/advtrains_wagon_tank_inv.png delete mode 100644 textures/advtrains_wagon_wood.png delete mode 100644 textures/advtrains_wagon_wood_inv.png delete mode 100644 textures/drwho_screwdriver.png delete mode 100644 textures/larger rails.xcf delete mode 100644 trackplacer.lua delete mode 100644 tracks.lua delete mode 100644 trainhud.lua delete mode 100644 trainlogic.lua delete mode 100644 wagons.lua diff --git a/advtrains/atc.lua b/advtrains/atc.lua new file mode 100644 index 0000000..0afddb0 --- /dev/null +++ b/advtrains/atc.lua @@ -0,0 +1,4 @@ +--atc.lua +--registers and controls the ATC system + +--(simple)mesecon detector rails diff --git a/advtrains/couple.lua b/advtrains/couple.lua new file mode 100644 index 0000000..a846c8b --- /dev/null +++ b/advtrains/couple.lua @@ -0,0 +1,154 @@ +--couple.lua +--defines couple entities. + +--advtrains:discouple +--set into existing trains to split them when punched. +--they are attached to the wagons. +--[[fields +wagon + +wagons keep their couple entity minetest-internal id inside the field discouple_id. if it refers to nowhere, they will spawn a new one if player is near +]] +local print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end + + +minetest.register_entity("advtrains:discouple", { + visual="sprite", + textures = {"advtrains_discouple.png"}, + collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, + visual_size = {x=1, y=1}, + initial_sprite_basepos = {x=0, y=0}, + + is_discouple=true, + on_activate=function(self, staticdata) + if staticdata=="DISCOUPLE" then + --couple entities have no right to exist further... + self.object:remove() + return + end + self.object:set_armor_groups({immortal=1}) + end, + get_staticdata=function() return "DISCOUPLE" end, + on_punch=function(self, player) + --only if player owns at least one wagon next to this + local own=player:get_player_name() + if self.wagon.owner and self.wagon.owner~=own then + local train=advtrains.trains[self.wagon.train_id] + local nextwgn_id=train.trainparts[self.wagon.pos_in_trainparts-1] + for aoi, le in pairs(minetest.luaentities) do + if le and le.is_wagon then + if le.unique_id==nextwgn_id then + if le.owner and le.owner~=own then + minetest.chat_send_player(own, "You need to own at least one neighboring wagon to destroy this couple.") + return + end + end + end + end + end + advtrains.split_train_at_wagon(self.wagon)--found in trainlogic.lua + end, + on_step=function(self, dtime) + local t=os.clock() + if not self.wagon then + self.object:remove() + return + end + --getyaw seems to be a reliable method to check if an object is loaded...if it returns nil, it is not. + if not self.wagon.object:getyaw() then + self.object:remove() + return + end + local velocityvec=self.wagon.object:getvelocity() + self.updatepct_timer=(self.updatepct_timer or 0)-dtime + if not self.old_velocity_vector or not vector.equals(velocityvec, self.old_velocity_vector) or self.updatepct_timer<=0 then--only send update packet if something changed + local flipsign=self.wagon.wagon_flipped and -1 or 1 + self.object:setpos(vector.add(self.wagon.object:getpos(), {y=0, x=-math.sin(self.wagon.object:getyaw())*self.wagon.wagon_span*flipsign, z=math.cos(self.wagon.object:getyaw())*self.wagon.wagon_span*flipsign})) + self.object:setvelocity(velocityvec) + self.updatepct_timer=2 + end + printbm("discouple_step", t) + end, +}) + +--advtrains:couple +--when two trains overlap with their end-positions, this entity will be spawned and both trains set its id into appropiate fields for them to know when to free them again. The entity will destroy automatically when it recognizes that any of the trains left the common position. +--[[fields +train_id_1 +train_id_2 +train1_is_backpos +train2_is_backpos +]] + + +minetest.register_entity("advtrains:couple", { + visual="sprite", + textures = {"advtrains_couple.png"}, + collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, + visual_size = {x=1, y=1}, + initial_sprite_basepos = {x=0, y=0}, + + is_couple=true, + on_activate=function(self, staticdata) + if staticdata=="COUPLE" then + --couple entities have no right to exist further... + self.object:remove() + return + end + end, + get_staticdata=function(self) return "COUPLE" end, + on_rightclick=function(self) + if not self.train_id_1 or not self.train_id_2 then return end + + local id1, id2=self.train_id_1, self.train_id_2 + + if self.train1_is_backpos and not self.train2_is_backpos then + advtrains.do_connect_trains(id1, id2) + --case 2 (second train is front) + elseif self.train2_is_backpos and not self.train1_is_backpos then + advtrains.do_connect_trains(id2, id1) + --case 3 + elseif self.train1_is_backpos and self.train2_is_backpos then + advtrains.invert_train(id2) + advtrains.do_connect_trains(id1, id2) + --case 4 + elseif not self.train1_is_backpos and not self.train2_is_backpos then + advtrains.invert_train(id1) + advtrains.do_connect_trains(id1, id2) + end + self.object:remove() + end, + on_step=function(self, dtime) + local t=os.clock() + if not self.train_id_1 or not self.train_id_2 then print("wtf no train ids?")return end + local train1=advtrains.trains[self.train_id_1] + local train2=advtrains.trains[self.train_id_2] + if not train1 or not train2 or not train1.path or not train2.path or not train1.index or not train2.index then + self.object:remove() + return + end + + local tp1 + if not self.train1_is_backpos then + tp1=advtrains.get_real_index_position(train1.path, train1.index) + else + tp1=advtrains.get_real_index_position(train1.path, advtrains.get_train_end_index(train1)) + end + local tp2 + if not self.train2_is_backpos then + tp2=advtrains.get_real_index_position(train2.path, train2.index) + else + tp2=advtrains.get_real_index_position(train2.path, advtrains.get_train_end_index(train2)) + end + if not tp1 or not tp2 or not (vector.distance(tp1,tp2)<0.5) then + self.object:remove() + return + else + local pos_median=advtrains.pos_median(tp1, tp2) + if not vector.equals(pos_median, self.object:getpos()) then + self.object:setpos(pos_median) + end + end + printbm("couple step", t) + end, +}) diff --git a/advtrains/crafting.lua b/advtrains/crafting.lua new file mode 100644 index 0000000..5ba12ce --- /dev/null +++ b/advtrains/crafting.lua @@ -0,0 +1,71 @@ +--advtrains by orwell96, see readme.txt and license.txt +--crafting.lua +--registers crafting recipes + +--tracks +minetest.register_craft({ + output = 'advtrains:dtrack_placer 50', + recipe = { + {'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, + {'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, + {'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, + }, +}) +minetest.register_craft({ + type = "shapeless", + output = 'advtrains:dtrack_slopeplacer 2', + recipe = { + "advtrains:dtrack_placer", + "advtrains:dtrack_placer", + "default:gravel", + }, +}) + +minetest.register_craft({ + output = 'advtrains:dtrack_bumper_placer 2', + recipe = { + {'default:wood', 'dye:red'}, + {'default:steel_ingot', 'default:steel_ingot'}, + {'advtrains:dtrack_placer', 'advtrains:dtrack_placer'}, + }, +}) +minetest.register_craft({ + type="shapeless", + output = 'advtrains:dtrack_detector_off_placer', + recipe = { + "advtrains:dtrack_placer", + "mesecons:wire_00000000_off" + }, +}) +--signals +minetest.register_craft({ + output = 'advtrains:retrosignal_off 2', + recipe = { + {'dye:red', 'default:steel_ingot', 'default:steel_ingot'}, + {'', '', 'default:steel_ingot'}, + {'', '', 'default:steel_ingot'}, + }, +}) +minetest.register_craft({ + output = 'advtrains:signal_off 2', + recipe = { + {'', 'dye:red', 'default:steel_ingot'}, + {'', 'dye:dark_green', 'default:steel_ingot'}, + {'', '', 'default:steel_ingot'}, + }, +}) + +--trackworker +minetest.register_craft({ + output = 'advtrains:trackworker', + recipe = { + {'default:diamond'}, + {'screwdriver:screwdriver'}, + {'default:steel_ingot'}, + }, +}) + + + +--misc_nodes +--crafts for platforms see misc_nodes.lua diff --git a/advtrains/damage.lua b/advtrains/damage.lua new file mode 100644 index 0000000..b39fe67 --- /dev/null +++ b/advtrains/damage.lua @@ -0,0 +1,26 @@ +--damage.lua +--a globalstep that damages players overrolled by trains. + +advtrains.player_to_train_mapping={} + +local tmr=0 +minetest.register_globalstep(function(dtime) + tmr=tmr-dtime + if tmr<=0 then + + for _, player in pairs(minetest.get_connected_players()) do + local pos=player:getpos() + for _, object in pairs(minetest.get_objects_inside_radius(pos, 1)) do + local le=object:get_luaentity() + if le and le.is_wagon and le.initialized and le:train() then + if (not advtrains.player_to_train_mapping[player:get_player_name()] or le.train_id~=advtrains.player_to_train_mapping[player:get_player_name()]) and math.abs(le:train().velocity)>2 then + --player:punch(object, 1000, {damage={fleshy=3*math.abs(le:train().velocity)}}) + player:set_hp(player:get_hp()-math.abs(le:train().velocity)-3) + end + end + end + end + + tmr=0.5 + end +end) diff --git a/advtrains/debugitems.lua b/advtrains/debugitems.lua new file mode 100644 index 0000000..b3164ff --- /dev/null +++ b/advtrains/debugitems.lua @@ -0,0 +1,36 @@ +minetest.register_tool("advtrains:tunnelborer", +{ + description = "tunnelborer", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + + on_place = function(itemstack, placer, pointed_thing) + + end, + --[[ + ^ Shall place item and return the leftover itemstack + ^ default: minetest.item_place ]] + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type=="node" then + for x=-1,1 do + for y=-1,1 do + for z=-1,1 do + minetest.remove_node(vector.add(pointed_thing.under, {x=x, y=y, z=z})) + end + end + end + end + end, +--[[ +^ default: nil +^ Function must return either nil if no item shall be removed from +inventory, or an itemstack to replace the original itemstack. +e.g. itemstack:take_item(); return itemstack +^ Otherwise, the function is free to do what it wants. +^ The default functions handle regular use cases. +]] +} +) diff --git a/advtrains/depends.txt b/advtrains/depends.txt new file mode 100644 index 0000000..20aa884 --- /dev/null +++ b/advtrains/depends.txt @@ -0,0 +1,2 @@ +default +mesecons? \ No newline at end of file diff --git a/advtrains/description.txt b/advtrains/description.txt new file mode 100644 index 0000000..ecc5d58 --- /dev/null +++ b/advtrains/description.txt @@ -0,0 +1,8 @@ +Advanced Trains v1.3.0, by orwell and contributors. Also see readme. +Good-looking, realistic trains for minetest. + +For crafting recipes, see manual.pdf + +Website: http://advtrains.bleipb.de/ +Manual: https://github.com/orwell96/advtrains/blob/master/manual.pdf +Forum : https://forum.minetest.net/viewtopic.php?f=11&t=14726 \ No newline at end of file diff --git a/advtrains/helpers.lua b/advtrains/helpers.lua new file mode 100644 index 0000000..6a8175f --- /dev/null +++ b/advtrains/helpers.lua @@ -0,0 +1,249 @@ +--advtrains by orwell96, see readme.txt +local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end + +advtrains.dir_trans_tbl={ + [0]={x=0, z=1}, + [1]={x=1, z=2}, + [2]={x=1, z=1}, + [3]={x=2, z=1}, + [4]={x=1, z=0}, + [5]={x=2, z=-1}, + [6]={x=1, z=-1}, + [7]={x=1, z=-2}, + [8]={x=0, z=-1}, + [9]={x=-1, z=-2}, + [10]={x=-1, z=-1}, + [11]={x=-2, z=-1}, + [12]={x=-1, z=0}, + [13]={x=-2, z=1}, + [14]={x=-1, z=1}, + [15]={x=-1, z=2}, +} + +function advtrains.dirCoordSet(coord, dir) + local x,z + if advtrains.dir_trans_tbl[dir] then + x,z=advtrains.dir_trans_tbl[dir].x, advtrains.dir_trans_tbl[dir].z + else + error("advtrains: in helpers.lua/dirCoordSet() given dir="..(dir or "nil")) + end + return {x=coord.x+x, y=coord.y, z=coord.z+z} +end +function advtrains.dirToCoord(dir) + return advtrains.dirCoordSet({x=0, y=0, z=0}, dir) +end + +function advtrains.maxN(list, expectstart) + local n=expectstart or 0 + while list[n] do + n=n+1 + end + return n-1 +end + +function advtrains.minN(list, expectstart) + local n=expectstart or 0 + while list[n] do + n=n-1 + end + return n+1 +end + +--vertical_transmit: +--[[ +rely1, rely2 tell to which height the connections are pointed to. 1 means it will go up the next node + +]] + +function advtrains.conway(midreal, prev, traintype)--in order prev,mid,return + local mid=advtrains.round_vector_floor_y(midreal) + local drives_on=advtrains.all_traintypes[traintype].drives_on + + if not advtrains.get_rail_info_at(advtrains.round_vector_floor_y(prev), traintype) then + return nil + end + + local midnode_ok, middir1, middir2, midrely1, midrely2=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(mid), traintype) + if not midnode_ok then + return nil + end + + local next, chkdir, chkrely, y_offset + y_offset=0 + --print("[advtrains] in order mid1,mid2",middir1,middir2) + --try if it is dir1 + local cor1=advtrains.dirCoordSet(mid, middir2)--<<<< + if math.floor(cor1.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor1.z+0.5)==math.floor(prev.z+0.5) then--this was previous + next=advtrains.dirCoordSet(mid, middir1) + if midrely1>=1 then + next.y=next.y+1 + --print("[advtrains]found midrely1 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) + y_offset=1 + end + chkdir=middir1 + chkrely=midrely1 + --print("[advtrains]dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") + end + --dir2??? + local cor2=advtrains.dirCoordSet(mid, middir1)--<<<< + if math.floor(cor2.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor2.z+0.5)==math.floor(prev.z+0.5) then + next=advtrains.dirCoordSet(mid, middir2)--dir2 wird überprüft, alles gut. + if midrely2>=1 then + next.y=next.y+1 + --print("[advtrains]found midrely2 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) + y_offset=1 + end + chkdir=middir2 + chkrely=midrely2 + --print("[advtrains] dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") + end + --print("[advtrains]dir applied next pos: "..(next and minetest.pos_to_string(next) or "nil").."(chkdir is "..(chkdir or "nil")..", y-offset "..y_offset..")") + --is there a next + if not next then + --print("[advtrains]in conway: no next rail(nil), returning!") + return nil + end + + local nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), traintype) + + --is it a rail? + if(not nextnode_ok) then + --print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not a rail, trying one node below!") + next.y=next.y-1 + y_offset=y_offset-1 + + nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), traintype) + if(not nextnode_ok) then + --print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!") + return nil + end + end + + --is this next rail connecting to the mid? + if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely-y_offset) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely-y_offset) ) then + --print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not connecting, trying one node below!") + next.y=next.y-1 + y_offset=y_offset-1 + + nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), traintype) + if(not nextnode_ok) then + --print("[advtrains]in conway: (at connecting if check again) one below "..minetest.pos_to_string(next).." is not a rail either, returning!") + return nil + end + if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely) ) then + --print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." rail not connecting, returning!") + --print("[advtrains] in order mid1,2,next1,2,chkdir "..middir1.." "..middir2.." "..nextdir1.." "..nextdir2.." "..chkdir) + return nil + end + end + + --print("[advtrains]conway found rail.") + return vector.add(advtrains.round_vector_floor_y(next), {x=0, y=nextrailheight, z=0}), chkdir +end +--TODO use this +function advtrains.oppd(dir) + return ((dir+8)%16) +end + +function advtrains.round_vector_floor_y(vec) + return {x=math.floor(vec.x+0.5), y=math.floor(vec.y), z=math.floor(vec.z+0.5)} +end + +function advtrains.yawToDirection(yaw, conn1, conn2) + if not conn1 or not conn2 then + error("given nil to yawToDirection: conn1="..(conn1 or "nil").." conn2="..(conn1 or "nil")) + end + local yaw1=math.pi*(conn1/4) + local yaw2=math.pi*(conn2/4) + if advtrains.minAngleDiffRad(yaw, yaw1) if weird behavior + return conn2 + else + return conn1 + end +end + +function advtrains.minAngleDiffRad(r1, r2) + local try1=r2-r1 + local try2=(r2+2*math.pi)-r1 + local try3=r2-(r1+2*math.pi) + if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try1) then + return try1 + end + if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try2) then + return try2 + end + if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try3) then + return try3 + end +end +function advtrains.dumppath(path) + if not path then print("dumppath: no path(nil)") return end + local min=advtrains.minN(path) + local max=advtrains.maxN(path) + for i=min, max do print("["..i.."] "..(path[i] and minetest.pos_to_string(path[i]) or "nil")) end +end + +function advtrains.merge_tables(a, ...) + local new={} + for _,t in ipairs({a,...}) do + for k,v in pairs(t) do new[k]=v end + end + return new +end +function advtrains.yaw_from_3_positions(prev, curr, next) + local pts=minetest.pos_to_string + --print("p3 "..pts(prev)..pts(curr)..pts(next)) + local prev2curr=math.atan2((curr.x-prev.x), (prev.z-curr.z)) + local curr2next=math.atan2((next.x-curr.x), (curr.z-next.z)) + --print("y3 "..(prev2curr*360/(2*math.pi)).." "..(curr2next*360/(2*math.pi))) + return prev2curr+(advtrains.minAngleDiffRad(prev2curr, curr2next)/2) +end +function advtrains.get_wagon_yaw(front, first, second, back, pct) + local pts=minetest.pos_to_string + --print("p "..pts(front)..pts(first)..pts(second)..pts(back)) + local y2=advtrains.yaw_from_3_positions(second, first, front) + local y1=advtrains.yaw_from_3_positions(back, second, first) + --print("y "..(y1*360/(2*math.pi)).." "..(y2*360/(2*math.pi))) + return y1+advtrains.minAngleDiffRad(y1, y2)*pct +end +function advtrains.get_real_index_position(path, index) + if not path or not index then return end + + local first_pos=path[math.floor(index)] + local second_pos=path[math.floor(index)+1] + + if not first_pos or not second_pos then return nil end + + local factor=index-math.floor(index) + local actual_pos={x=first_pos.x-(first_pos.x-second_pos.x)*factor, y=first_pos.y-(first_pos.y-second_pos.y)*factor, z=first_pos.z-(first_pos.z-second_pos.z)*factor,} + return actual_pos +end +function advtrains.pos_median(pos1, pos2) + return {x=pos1.x-(pos1.x-pos2.x)*0.5, y=pos1.y-(pos1.y-pos2.y)*0.5, z=pos1.z-(pos1.z-pos2.z)*0.5} +end +function advtrains.abs_ceil(i) + return math.ceil(math.abs(i))*math.sign(i) +end + +function advtrains.serialize_inventory(inv) + local ser={} + local liszts=inv:get_lists() + for lisztname, liszt in pairs(liszts) do + ser[lisztname]={} + for idx, item in ipairs(liszt) do + local istring=item:to_string() + if istring~="" then + ser[lisztname][idx]=istring + end + end + end + return minetest.serialize(ser) +end +function advtrains.deserialize_inventory(sers, inv) + local ser=minetest.deserialize(sers) + if ser then + inv:set_lists(ser) + return true + end + return false +end diff --git a/advtrains/init.lua b/advtrains/init.lua new file mode 100644 index 0000000..41b624e --- /dev/null +++ b/advtrains/init.lua @@ -0,0 +1,42 @@ +--advtrains + +advtrains={} + +advtrains.modpath = minetest.get_modpath("advtrains") + +--print=function(text) +-- minetest.log("action", tostring(text) or "") +--end +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 = +{{x=0, y=0, z=-1}, + {x=1, y=0, z=0}, + {x=-1, y=0, z=0}, + {x=0, y=0, z=1}, + {x=1, y=1, z=0}, + {x=1, y=-1, z=0}, + {x=-1, y=1, z=0}, + {x=-1, y=-1, z=0}, + {x=0, y=1, z=1}, + {x=0, y=-1, z=1}, + {x=0, y=1, z=-1}, + {x=0, y=-1, z=-1}, + {x=0, y=-2, z=0}} +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") +dofile(advtrains.modpath.."/couple.lua") +dofile(advtrains.modpath.."/damage.lua") + +dofile(advtrains.modpath.."/signals.lua") +dofile(advtrains.modpath.."/misc_nodes.lua") +dofile(advtrains.modpath.."/crafting.lua") diff --git a/advtrains/misc_nodes.lua b/advtrains/misc_nodes.lua new file mode 100644 index 0000000..93829f0 --- /dev/null +++ b/advtrains/misc_nodes.lua @@ -0,0 +1,67 @@ +--all nodes that do not fit in any other category + +function advtrains.register_platform(preset) + local ndef=minetest.registered_nodes[preset] + if not ndef then + minetest.log("warning", "[advtrains] register_platform couldn't find preset node "..preset) + return + end + local btex=ndef.tiles + if type(btex)=="table" then + btex=btex[1] + end + local desc=ndef.description or "" + local nodename=string.match(preset, ":(.+)$") + minetest.register_node("advtrains:platform_low_"..nodename, { + description = desc.." Platform (low)", + tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex}, + groups = {cracky = 1, not_blocking_trains = 1, platform=1}, + sounds = default.node_sound_stone_defaults(), + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.1, -0.1, 0.5, 0 , 0.5}, + {-0.5, -0.5, 0 , 0.5, -0.1, 0.5} + }, + }, + paramtype2="facedir", + paramtype = "light", + sunlight_propagates = true, + }) + minetest.register_node("advtrains:platform_high_"..nodename, { + description = desc.." Platform (high)", + tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex}, + groups = {cracky = 1, not_blocking_trains = 1, platform=2}, + sounds = default.node_sound_stone_defaults(), + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, 0.3, -0.1, 0.5, 0.5, 0.5}, + {-0.5, -0.5, 0 , 0.5, 0.3, 0.5} + }, + }, + paramtype2="facedir", + paramtype = "light", + sunlight_propagates = true, + }) + minetest.register_craft({ + type="shapeless", + output = "advtrains:platform_high_"..nodename.." 4", + recipe = { + "dye:yellow", preset, preset + }, + }) + minetest.register_craft({ + type="shapeless", + output = "advtrains:platform_low_"..nodename.." 4", + recipe = { + "dye:yellow", preset + }, + }) +end + + +advtrains.register_platform("default:stonebrick") +advtrains.register_platform("default:sandstonebrick") diff --git a/advtrains/models/advtrains_dtrack_bumper_st.b3d b/advtrains/models/advtrains_dtrack_bumper_st.b3d new file mode 100644 index 0000000..a6d9745 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_bumper_st.b3d differ diff --git a/advtrains/models/advtrains_dtrack_bumper_st_30.b3d b/advtrains/models/advtrains_dtrack_bumper_st_30.b3d new file mode 100644 index 0000000..5f5b3f4 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_bumper_st_30.b3d differ diff --git a/advtrains/models/advtrains_dtrack_bumper_st_45.b3d b/advtrains/models/advtrains_dtrack_bumper_st_45.b3d new file mode 100644 index 0000000..f13ae75 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_bumper_st_45.b3d differ diff --git a/advtrains/models/advtrains_dtrack_bumper_st_60.b3d b/advtrains/models/advtrains_dtrack_bumper_st_60.b3d new file mode 100644 index 0000000..59a2285 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_bumper_st_60.b3d differ diff --git a/advtrains/models/advtrains_dtrack_cr.b3d b/advtrains/models/advtrains_dtrack_cr.b3d new file mode 100644 index 0000000..159717e Binary files /dev/null and b/advtrains/models/advtrains_dtrack_cr.b3d differ diff --git a/advtrains/models/advtrains_dtrack_cr_30.b3d b/advtrains/models/advtrains_dtrack_cr_30.b3d new file mode 100644 index 0000000..09cdb1f Binary files /dev/null and b/advtrains/models/advtrains_dtrack_cr_30.b3d differ diff --git a/advtrains/models/advtrains_dtrack_cr_45.b3d b/advtrains/models/advtrains_dtrack_cr_45.b3d new file mode 100644 index 0000000..176da81 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_cr_45.b3d differ diff --git a/advtrains/models/advtrains_dtrack_cr_60.b3d b/advtrains/models/advtrains_dtrack_cr_60.b3d new file mode 100644 index 0000000..00313c8 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_cr_60.b3d differ diff --git a/advtrains/models/advtrains_dtrack_detector_st.b3d b/advtrains/models/advtrains_dtrack_detector_st.b3d new file mode 100644 index 0000000..893c8cd Binary files /dev/null and b/advtrains/models/advtrains_dtrack_detector_st.b3d differ diff --git a/advtrains/models/advtrains_dtrack_detector_st_30.b3d b/advtrains/models/advtrains_dtrack_detector_st_30.b3d new file mode 100644 index 0000000..2e59e93 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_detector_st_30.b3d differ diff --git a/advtrains/models/advtrains_dtrack_detector_st_45.b3d b/advtrains/models/advtrains_dtrack_detector_st_45.b3d new file mode 100644 index 0000000..c73166f Binary files /dev/null and b/advtrains/models/advtrains_dtrack_detector_st_45.b3d differ diff --git a/advtrains/models/advtrains_dtrack_detector_st_60.b3d b/advtrains/models/advtrains_dtrack_detector_st_60.b3d new file mode 100644 index 0000000..b6bc9af Binary files /dev/null and b/advtrains/models/advtrains_dtrack_detector_st_60.b3d differ diff --git a/advtrains/models/advtrains_dtrack_st.b3d b/advtrains/models/advtrains_dtrack_st.b3d new file mode 100644 index 0000000..f3e2753 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_st.b3d differ diff --git a/advtrains/models/advtrains_dtrack_st_30.b3d b/advtrains/models/advtrains_dtrack_st_30.b3d new file mode 100644 index 0000000..7a35c8d Binary files /dev/null and b/advtrains/models/advtrains_dtrack_st_30.b3d differ diff --git a/advtrains/models/advtrains_dtrack_st_45.b3d b/advtrains/models/advtrains_dtrack_st_45.b3d new file mode 100644 index 0000000..b2a1702 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_st_45.b3d differ diff --git a/advtrains/models/advtrains_dtrack_st_60.b3d b/advtrains/models/advtrains_dtrack_st_60.b3d new file mode 100644 index 0000000..0a59f77 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_st_60.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swlcr.b3d b/advtrains/models/advtrains_dtrack_swlcr.b3d new file mode 100644 index 0000000..1adc23f Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swlcr.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swlcr_30.b3d b/advtrains/models/advtrains_dtrack_swlcr_30.b3d new file mode 100644 index 0000000..7d8373b Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swlcr_30.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swlcr_45.b3d b/advtrains/models/advtrains_dtrack_swlcr_45.b3d new file mode 100644 index 0000000..9679b9e Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swlcr_45.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swlcr_60.b3d b/advtrains/models/advtrains_dtrack_swlcr_60.b3d new file mode 100644 index 0000000..3efc924 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swlcr_60.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swlst.b3d b/advtrains/models/advtrains_dtrack_swlst.b3d new file mode 100644 index 0000000..93841a4 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swlst.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swlst_30.b3d b/advtrains/models/advtrains_dtrack_swlst_30.b3d new file mode 100644 index 0000000..e9a90c7 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swlst_30.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swlst_45.b3d b/advtrains/models/advtrains_dtrack_swlst_45.b3d new file mode 100644 index 0000000..49c707c Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swlst_45.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swlst_60.b3d b/advtrains/models/advtrains_dtrack_swlst_60.b3d new file mode 100644 index 0000000..c9a6ffe Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swlst_60.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swrcr.b3d b/advtrains/models/advtrains_dtrack_swrcr.b3d new file mode 100644 index 0000000..ee29b62 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swrcr.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swrcr_30.b3d b/advtrains/models/advtrains_dtrack_swrcr_30.b3d new file mode 100644 index 0000000..ba065e1 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swrcr_30.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swrcr_45.b3d b/advtrains/models/advtrains_dtrack_swrcr_45.b3d new file mode 100644 index 0000000..7f9dc43 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swrcr_45.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swrcr_60.b3d b/advtrains/models/advtrains_dtrack_swrcr_60.b3d new file mode 100644 index 0000000..b8ffa61 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swrcr_60.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swrst.b3d b/advtrains/models/advtrains_dtrack_swrst.b3d new file mode 100644 index 0000000..0b3e7ad Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swrst.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swrst_30.b3d b/advtrains/models/advtrains_dtrack_swrst_30.b3d new file mode 100644 index 0000000..4aea19b Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swrst_30.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swrst_45.b3d b/advtrains/models/advtrains_dtrack_swrst_45.b3d new file mode 100644 index 0000000..4182fe5 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swrst_45.b3d differ diff --git a/advtrains/models/advtrains_dtrack_swrst_60.b3d b/advtrains/models/advtrains_dtrack_swrst_60.b3d new file mode 100644 index 0000000..6d2c891 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_swrst_60.b3d differ diff --git a/advtrains/models/advtrains_dtrack_vst1.b3d b/advtrains/models/advtrains_dtrack_vst1.b3d new file mode 100644 index 0000000..c9d7427 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_vst1.b3d differ diff --git a/advtrains/models/advtrains_dtrack_vst1_45.b3d b/advtrains/models/advtrains_dtrack_vst1_45.b3d new file mode 100644 index 0000000..14d438c Binary files /dev/null and b/advtrains/models/advtrains_dtrack_vst1_45.b3d differ diff --git a/advtrains/models/advtrains_dtrack_vst2.b3d b/advtrains/models/advtrains_dtrack_vst2.b3d new file mode 100644 index 0000000..c128650 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_vst2.b3d differ diff --git a/advtrains/models/advtrains_dtrack_vst2_45.b3d b/advtrains/models/advtrains_dtrack_vst2_45.b3d new file mode 100644 index 0000000..263276d Binary files /dev/null and b/advtrains/models/advtrains_dtrack_vst2_45.b3d differ diff --git a/advtrains/models/advtrains_dtrack_vst31.b3d b/advtrains/models/advtrains_dtrack_vst31.b3d new file mode 100644 index 0000000..df0f383 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_vst31.b3d differ diff --git a/advtrains/models/advtrains_dtrack_vst32.b3d b/advtrains/models/advtrains_dtrack_vst32.b3d new file mode 100644 index 0000000..01d2978 Binary files /dev/null and b/advtrains/models/advtrains_dtrack_vst32.b3d differ diff --git a/advtrains/models/advtrains_dtrack_vst33.b3d b/advtrains/models/advtrains_dtrack_vst33.b3d new file mode 100644 index 0000000..7fe418d Binary files /dev/null and b/advtrains/models/advtrains_dtrack_vst33.b3d differ diff --git a/advtrains/models/advtrains_modernwagon.b3d b/advtrains/models/advtrains_modernwagon.b3d new file mode 100644 index 0000000..aacddca Binary files /dev/null and b/advtrains/models/advtrains_modernwagon.b3d differ diff --git a/advtrains/models/advtrains_retrosignal_off.b3d b/advtrains/models/advtrains_retrosignal_off.b3d new file mode 100644 index 0000000..3d231dd Binary files /dev/null and b/advtrains/models/advtrains_retrosignal_off.b3d differ diff --git a/advtrains/models/advtrains_retrosignal_off_30.b3d b/advtrains/models/advtrains_retrosignal_off_30.b3d new file mode 100644 index 0000000..da258e1 Binary files /dev/null and b/advtrains/models/advtrains_retrosignal_off_30.b3d differ diff --git a/advtrains/models/advtrains_retrosignal_off_45.b3d b/advtrains/models/advtrains_retrosignal_off_45.b3d new file mode 100644 index 0000000..338224a Binary files /dev/null and b/advtrains/models/advtrains_retrosignal_off_45.b3d differ diff --git a/advtrains/models/advtrains_retrosignal_off_60.b3d b/advtrains/models/advtrains_retrosignal_off_60.b3d new file mode 100644 index 0000000..c560ca1 Binary files /dev/null and b/advtrains/models/advtrains_retrosignal_off_60.b3d differ diff --git a/advtrains/models/advtrains_retrosignal_on.b3d b/advtrains/models/advtrains_retrosignal_on.b3d new file mode 100644 index 0000000..3d19439 Binary files /dev/null and b/advtrains/models/advtrains_retrosignal_on.b3d differ diff --git a/advtrains/models/advtrains_retrosignal_on_30.b3d b/advtrains/models/advtrains_retrosignal_on_30.b3d new file mode 100644 index 0000000..98f8a92 Binary files /dev/null and b/advtrains/models/advtrains_retrosignal_on_30.b3d differ diff --git a/advtrains/models/advtrains_retrosignal_on_45.b3d b/advtrains/models/advtrains_retrosignal_on_45.b3d new file mode 100644 index 0000000..414e121 Binary files /dev/null and b/advtrains/models/advtrains_retrosignal_on_45.b3d differ diff --git a/advtrains/models/advtrains_retrosignal_on_60.b3d b/advtrains/models/advtrains_retrosignal_on_60.b3d new file mode 100644 index 0000000..a51529a Binary files /dev/null and b/advtrains/models/advtrains_retrosignal_on_60.b3d differ diff --git a/advtrains/models/advtrains_signal.b3d b/advtrains/models/advtrains_signal.b3d new file mode 100644 index 0000000..7f69560 Binary files /dev/null and b/advtrains/models/advtrains_signal.b3d differ diff --git a/advtrains/models/advtrains_signal_30.b3d b/advtrains/models/advtrains_signal_30.b3d new file mode 100644 index 0000000..0b949a7 Binary files /dev/null and b/advtrains/models/advtrains_signal_30.b3d differ diff --git a/advtrains/models/advtrains_signal_45.b3d b/advtrains/models/advtrains_signal_45.b3d new file mode 100644 index 0000000..ccaebf4 Binary files /dev/null and b/advtrains/models/advtrains_signal_45.b3d differ diff --git a/advtrains/models/advtrains_signal_60.b3d b/advtrains/models/advtrains_signal_60.b3d new file mode 100644 index 0000000..cf41e6d Binary files /dev/null and b/advtrains/models/advtrains_signal_60.b3d differ diff --git a/advtrains/models/advtrains_track_cr.b3d b/advtrains/models/advtrains_track_cr.b3d new file mode 100644 index 0000000..b0f5e4b Binary files /dev/null and b/advtrains/models/advtrains_track_cr.b3d differ diff --git a/advtrains/models/advtrains_track_st.b3d b/advtrains/models/advtrains_track_st.b3d new file mode 100644 index 0000000..10b5d90 Binary files /dev/null and b/advtrains/models/advtrains_track_st.b3d differ diff --git a/advtrains/models/advtrains_track_st_45.b3d b/advtrains/models/advtrains_track_st_45.b3d new file mode 100644 index 0000000..32505a1 Binary files /dev/null and b/advtrains/models/advtrains_track_st_45.b3d differ diff --git a/advtrains/models/blender/engine-with-animation.blend b/advtrains/models/blender/engine-with-animation.blend new file mode 100644 index 0000000..2649587 Binary files /dev/null and b/advtrains/models/blender/engine-with-animation.blend differ diff --git a/advtrains/models/blender/gleis/infos/Grafik_weiche.png b/advtrains/models/blender/gleis/infos/Grafik_weiche.png new file mode 100644 index 0000000..6674eb3 Binary files /dev/null and b/advtrains/models/blender/gleis/infos/Grafik_weiche.png differ diff --git a/advtrains/models/blender/gleis/infos/breite b/advtrains/models/blender/gleis/infos/breite new file mode 100644 index 0000000..b2862c6 --- /dev/null +++ b/advtrains/models/blender/gleis/infos/breite @@ -0,0 +1 @@ +1435mm diff --git a/advtrains/models/blender/gleis/licence.txt~ b/advtrains/models/blender/gleis/licence.txt~ new file mode 100644 index 0000000..e69de29 diff --git a/advtrains/models/blender/gleis/rail_my.blend b/advtrains/models/blender/gleis/rail_my.blend new file mode 100644 index 0000000..3c741bc Binary files /dev/null and b/advtrains/models/blender/gleis/rail_my.blend differ diff --git a/advtrains/models/blender/gleis/rail_my.blend1 b/advtrains/models/blender/gleis/rail_my.blend1 new file mode 100644 index 0000000..6322856 Binary files /dev/null and b/advtrains/models/blender/gleis/rail_my.blend1 differ diff --git a/advtrains/models/blender/gleis/rail_my_rt.blend b/advtrains/models/blender/gleis/rail_my_rt.blend new file mode 100644 index 0000000..8372a0c Binary files /dev/null and b/advtrains/models/blender/gleis/rail_my_rt.blend differ diff --git a/advtrains/models/blender/gleis/rail_my_rt.blend1 b/advtrains/models/blender/gleis/rail_my_rt.blend1 new file mode 100644 index 0000000..7d0978e Binary files /dev/null and b/advtrains/models/blender/gleis/rail_my_rt.blend1 differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_final.blend b/advtrains/models/blender/gleis/rail_my_rt_final.blend new file mode 100644 index 0000000..6a9a088 Binary files /dev/null and b/advtrains/models/blender/gleis/rail_my_rt_final.blend differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_final.blend1 b/advtrains/models/blender/gleis/rail_my_rt_final.blend1 new file mode 100644 index 0000000..1f346ae Binary files /dev/null and b/advtrains/models/blender/gleis/rail_my_rt_final.blend1 differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_switches.blend b/advtrains/models/blender/gleis/rail_my_rt_switches.blend new file mode 100644 index 0000000..fdce427 Binary files /dev/null and b/advtrains/models/blender/gleis/rail_my_rt_switches.blend differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_switches.blend1 b/advtrains/models/blender/gleis/rail_my_rt_switches.blend1 new file mode 100644 index 0000000..04370ba Binary files /dev/null and b/advtrains/models/blender/gleis/rail_my_rt_switches.blend1 differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_switches2.blend b/advtrains/models/blender/gleis/rail_my_rt_switches2.blend new file mode 100644 index 0000000..9562e4d Binary files /dev/null and b/advtrains/models/blender/gleis/rail_my_rt_switches2.blend differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_switches2.blend1 b/advtrains/models/blender/gleis/rail_my_rt_switches2.blend1 new file mode 100644 index 0000000..07a155f Binary files /dev/null and b/advtrains/models/blender/gleis/rail_my_rt_switches2.blend1 differ diff --git a/advtrains/models/blender/gleis/rail_together.blend b/advtrains/models/blender/gleis/rail_together.blend new file mode 100644 index 0000000..cff51ea Binary files /dev/null and b/advtrains/models/blender/gleis/rail_together.blend differ diff --git a/advtrains/models/blender/gleis/rail_together.png b/advtrains/models/blender/gleis/rail_together.png new file mode 100644 index 0000000..386cd5c Binary files /dev/null and b/advtrains/models/blender/gleis/rail_together.png differ diff --git a/advtrains/models/blender/gleis/rail_together2.png b/advtrains/models/blender/gleis/rail_together2.png new file mode 100644 index 0000000..3effe34 Binary files /dev/null and b/advtrains/models/blender/gleis/rail_together2.png differ diff --git a/advtrains/models/blender/gleis/rail_together3.png b/advtrains/models/blender/gleis/rail_together3.png new file mode 100644 index 0000000..4a183c1 Binary files /dev/null and b/advtrains/models/blender/gleis/rail_together3.png differ diff --git a/advtrains/models/blender/gleis/rail_verticals.blend b/advtrains/models/blender/gleis/rail_verticals.blend new file mode 100644 index 0000000..45c37e1 Binary files /dev/null and b/advtrains/models/blender/gleis/rail_verticals.blend differ diff --git a/advtrains/models/blender/gleis/rail_verticals.blend1 b/advtrains/models/blender/gleis/rail_verticals.blend1 new file mode 100644 index 0000000..320f30b Binary files /dev/null and b/advtrains/models/blender/gleis/rail_verticals.blend1 differ diff --git a/advtrains/models/blender/gleis/rail_verticals3.blend b/advtrains/models/blender/gleis/rail_verticals3.blend new file mode 100644 index 0000000..5d62959 Binary files /dev/null and b/advtrains/models/blender/gleis/rail_verticals3.blend differ diff --git a/advtrains/models/blender/gleis/rail_verticals3.blend1 b/advtrains/models/blender/gleis/rail_verticals3.blend1 new file mode 100644 index 0000000..893f2ea Binary files /dev/null and b/advtrains/models/blender/gleis/rail_verticals3.blend1 differ diff --git a/advtrains/models/blender/gleis/rail_verticals45.blend b/advtrains/models/blender/gleis/rail_verticals45.blend new file mode 100644 index 0000000..a1589e3 Binary files /dev/null and b/advtrains/models/blender/gleis/rail_verticals45.blend differ diff --git a/advtrains/models/blender/gleis/rail_verticals45.blend1 b/advtrains/models/blender/gleis/rail_verticals45.blend1 new file mode 100644 index 0000000..6b44d1c Binary files /dev/null and b/advtrains/models/blender/gleis/rail_verticals45.blend1 differ diff --git a/advtrains/models/blender/gleis/rail_verticals45.blend11 b/advtrains/models/blender/gleis/rail_verticals45.blend11 new file mode 100644 index 0000000..48316e8 Binary files /dev/null and b/advtrains/models/blender/gleis/rail_verticals45.blend11 differ diff --git a/advtrains/models/blender/gleis/texturen/rail.png b/advtrains/models/blender/gleis/texturen/rail.png new file mode 100644 index 0000000..8478cf6 Binary files /dev/null and b/advtrains/models/blender/gleis/texturen/rail.png differ diff --git a/advtrains/models/blender/gleis/texturen/uv.png b/advtrains/models/blender/gleis/texturen/uv.png new file mode 100644 index 0000000..fb0af3e Binary files /dev/null and b/advtrains/models/blender/gleis/texturen/uv.png differ diff --git a/advtrains/models/blender/industrial/industry_loc.blend b/advtrains/models/blender/industrial/industry_loc.blend new file mode 100644 index 0000000..1a6cb2b Binary files /dev/null and b/advtrains/models/blender/industrial/industry_loc.blend differ diff --git a/advtrains/models/blender/industrial/industry_loc.blend1 b/advtrains/models/blender/industrial/industry_loc.blend1 new file mode 100644 index 0000000..af54c3f Binary files /dev/null and b/advtrains/models/blender/industrial/industry_loc.blend1 differ diff --git a/advtrains/models/blender/industrial/industry_loc.blend11 b/advtrains/models/blender/industrial/industry_loc.blend11 new file mode 100644 index 0000000..a089a65 Binary files /dev/null and b/advtrains/models/blender/industrial/industry_loc.blend11 differ diff --git a/advtrains/models/blender/industrial/industry_oil_ wagong.blend b/advtrains/models/blender/industrial/industry_oil_ wagong.blend new file mode 100644 index 0000000..30bde51 Binary files /dev/null and b/advtrains/models/blender/industrial/industry_oil_ wagong.blend differ diff --git a/advtrains/models/blender/industrial/industry_oil_ wagong.blend1 b/advtrains/models/blender/industrial/industry_oil_ wagong.blend1 new file mode 100644 index 0000000..849971d Binary files /dev/null and b/advtrains/models/blender/industrial/industry_oil_ wagong.blend1 differ diff --git a/advtrains/models/blender/industrial/industry_tree_wagong.blend b/advtrains/models/blender/industrial/industry_tree_wagong.blend new file mode 100644 index 0000000..23de208 Binary files /dev/null and b/advtrains/models/blender/industrial/industry_tree_wagong.blend differ diff --git a/advtrains/models/blender/industrial/industry_tree_wagong.blend1 b/advtrains/models/blender/industrial/industry_tree_wagong.blend1 new file mode 100644 index 0000000..bf2c9ed Binary files /dev/null and b/advtrains/models/blender/industrial/industry_tree_wagong.blend1 differ diff --git a/advtrains/models/blender/industrial/industry_tree_wagong.png b/advtrains/models/blender/industrial/industry_tree_wagong.png new file mode 100644 index 0000000..87109dd Binary files /dev/null and b/advtrains/models/blender/industrial/industry_tree_wagong.png differ diff --git a/advtrains/models/blender/locomotive.blend b/advtrains/models/blender/locomotive.blend new file mode 100644 index 0000000..8fd6059 Binary files /dev/null and b/advtrains/models/blender/locomotive.blend differ diff --git a/advtrains/models/blender/magnet_track.blend b/advtrains/models/blender/magnet_track.blend new file mode 100644 index 0000000..0ab14e7 Binary files /dev/null and b/advtrains/models/blender/magnet_track.blend differ diff --git a/advtrains/models/blender/mbb/advtrains_wagon_japan.xcf b/advtrains/models/blender/mbb/advtrains_wagon_japan.xcf new file mode 100644 index 0000000..4fc88c0 Binary files /dev/null and b/advtrains/models/blender/mbb/advtrains_wagon_japan.xcf differ diff --git a/advtrains/models/blender/mbb/modern_japanlocomotive.blend b/advtrains/models/blender/mbb/modern_japanlocomotive.blend new file mode 100644 index 0000000..6eb8f3d Binary files /dev/null and b/advtrains/models/blender/mbb/modern_japanlocomotive.blend differ diff --git a/advtrains/models/blender/mbb/modern_japanlocomotive.blend1 b/advtrains/models/blender/mbb/modern_japanlocomotive.blend1 new file mode 100644 index 0000000..a2e745d Binary files /dev/null and b/advtrains/models/blender/mbb/modern_japanlocomotive.blend1 differ diff --git a/advtrains/models/blender/mbb/modern_japanlocomotive.png b/advtrains/models/blender/mbb/modern_japanlocomotive.png new file mode 100644 index 0000000..b80d16f Binary files /dev/null and b/advtrains/models/blender/mbb/modern_japanlocomotive.png differ diff --git a/advtrains/models/blender/mbb/modern_japanlocomotive.xcf b/advtrains/models/blender/mbb/modern_japanlocomotive.xcf new file mode 100644 index 0000000..bb28534 Binary files /dev/null and b/advtrains/models/blender/mbb/modern_japanlocomotive.xcf differ diff --git a/advtrains/models/blender/mbb/modern_locomotive.blend b/advtrains/models/blender/mbb/modern_locomotive.blend new file mode 100644 index 0000000..8e72233 Binary files /dev/null and b/advtrains/models/blender/mbb/modern_locomotive.blend differ diff --git a/advtrains/models/blender/mbb/modern_wagong.blend b/advtrains/models/blender/mbb/modern_wagong.blend new file mode 100644 index 0000000..f32710a Binary files /dev/null and b/advtrains/models/blender/mbb/modern_wagong.blend differ diff --git a/advtrains/models/blender/mbb/modern_wagong.blend1 b/advtrains/models/blender/mbb/modern_wagong.blend1 new file mode 100644 index 0000000..376831c Binary files /dev/null and b/advtrains/models/blender/mbb/modern_wagong.blend1 differ diff --git a/advtrains/models/blender/mbb/modern_wagong_uv.blend b/advtrains/models/blender/mbb/modern_wagong_uv.blend new file mode 100644 index 0000000..4c10fb3 Binary files /dev/null and b/advtrains/models/blender/mbb/modern_wagong_uv.blend differ diff --git a/advtrains/models/blender/mbb/modern_wagong_uv.blend1 b/advtrains/models/blender/mbb/modern_wagong_uv.blend1 new file mode 100644 index 0000000..ce77416 Binary files /dev/null and b/advtrains/models/blender/mbb/modern_wagong_uv.blend1 differ diff --git a/advtrains/models/blender/mbb/modern_wagong_uv.png b/advtrains/models/blender/mbb/modern_wagong_uv.png new file mode 100644 index 0000000..68018ea Binary files /dev/null and b/advtrains/models/blender/mbb/modern_wagong_uv.png differ diff --git a/advtrains/models/blender/mbb/prellbock.blend b/advtrains/models/blender/mbb/prellbock.blend new file mode 100644 index 0000000..1c20ab2 Binary files /dev/null and b/advtrains/models/blender/mbb/prellbock.blend differ diff --git a/advtrains/models/blender/mbb/prellbock.blend1 b/advtrains/models/blender/mbb/prellbock.blend1 new file mode 100644 index 0000000..981538e Binary files /dev/null and b/advtrains/models/blender/mbb/prellbock.blend1 differ diff --git a/advtrains/models/blender/mbb/prellbock.uv.png b/advtrains/models/blender/mbb/prellbock.uv.png new file mode 100644 index 0000000..7730753 Binary files /dev/null and b/advtrains/models/blender/mbb/prellbock.uv.png differ diff --git a/advtrains/models/blender/mbb/regio-lokomotive.blend b/advtrains/models/blender/mbb/regio-lokomotive.blend new file mode 100644 index 0000000..210e60e Binary files /dev/null and b/advtrains/models/blender/mbb/regio-lokomotive.blend differ diff --git a/advtrains/models/blender/mbb/regio-waron.blend b/advtrains/models/blender/mbb/regio-waron.blend new file mode 100644 index 0000000..19b07ce Binary files /dev/null and b/advtrains/models/blender/mbb/regio-waron.blend differ diff --git a/advtrains/models/blender/mbb/retrosignal.blend b/advtrains/models/blender/mbb/retrosignal.blend new file mode 100644 index 0000000..b795215 Binary files /dev/null and b/advtrains/models/blender/mbb/retrosignal.blend differ diff --git a/advtrains/models/blender/mbb/retrosignal.blend1 b/advtrains/models/blender/mbb/retrosignal.blend1 new file mode 100644 index 0000000..94af470 Binary files /dev/null and b/advtrains/models/blender/mbb/retrosignal.blend1 differ diff --git a/advtrains/models/blender/mbb/signal(2)_hoch.blend b/advtrains/models/blender/mbb/signal(2)_hoch.blend new file mode 100644 index 0000000..70391f6 Binary files /dev/null and b/advtrains/models/blender/mbb/signal(2)_hoch.blend differ diff --git a/advtrains/models/blender/mbb/signal(2)_unten.blend b/advtrains/models/blender/mbb/signal(2)_unten.blend new file mode 100644 index 0000000..4e917bc Binary files /dev/null and b/advtrains/models/blender/mbb/signal(2)_unten.blend differ diff --git a/advtrains/models/blender/mbb/signal.blend b/advtrains/models/blender/mbb/signal.blend new file mode 100644 index 0000000..135c7b4 Binary files /dev/null and b/advtrains/models/blender/mbb/signal.blend differ diff --git a/advtrains/models/blender/mbb/signal.blend1 b/advtrains/models/blender/mbb/signal.blend1 new file mode 100644 index 0000000..63a8c99 Binary files /dev/null and b/advtrains/models/blender/mbb/signal.blend1 differ diff --git a/advtrains/models/blender/mbb/signal.png b/advtrains/models/blender/mbb/signal.png new file mode 100644 index 0000000..779cdda Binary files /dev/null and b/advtrains/models/blender/mbb/signal.png differ diff --git a/advtrains/models/blender/mbb/signal.xcf b/advtrains/models/blender/mbb/signal.xcf new file mode 100644 index 0000000..f667739 Binary files /dev/null and b/advtrains/models/blender/mbb/signal.xcf differ diff --git a/advtrains/models/blender/mbb/signal2.png b/advtrains/models/blender/mbb/signal2.png new file mode 100644 index 0000000..7af4e2d Binary files /dev/null and b/advtrains/models/blender/mbb/signal2.png differ diff --git a/advtrains/models/blender/mbb/tr-logo.png b/advtrains/models/blender/mbb/tr-logo.png new file mode 100644 index 0000000..9bc0f10 Binary files /dev/null and b/advtrains/models/blender/mbb/tr-logo.png differ diff --git a/advtrains/models/blender/mbb/weichenhebel1.blend b/advtrains/models/blender/mbb/weichenhebel1.blend new file mode 100644 index 0000000..70b997d Binary files /dev/null and b/advtrains/models/blender/mbb/weichenhebel1.blend differ diff --git a/advtrains/models/blender/mbb/weichenhebel2.blend b/advtrains/models/blender/mbb/weichenhebel2.blend new file mode 100644 index 0000000..c1c3aac Binary files /dev/null and b/advtrains/models/blender/mbb/weichenhebel2.blend differ diff --git a/advtrains/models/blender/newlocomotive.blend b/advtrains/models/blender/newlocomotive.blend new file mode 100644 index 0000000..858882b Binary files /dev/null and b/advtrains/models/blender/newlocomotive.blend differ diff --git a/advtrains/models/blender/newlocomotive.blend1 b/advtrains/models/blender/newlocomotive.blend1 new file mode 100644 index 0000000..4b8b24f Binary files /dev/null and b/advtrains/models/blender/newlocomotive.blend1 differ diff --git a/advtrains/models/blender/newlocomotive_uvs.png b/advtrains/models/blender/newlocomotive_uvs.png new file mode 100644 index 0000000..879be65 Binary files /dev/null and b/advtrains/models/blender/newlocomotive_uvs.png differ diff --git a/advtrains/models/blender/newwagon.blend b/advtrains/models/blender/newwagon.blend new file mode 100644 index 0000000..1cedc55 Binary files /dev/null and b/advtrains/models/blender/newwagon.blend differ diff --git a/advtrains/models/blender/newwagon.blend1 b/advtrains/models/blender/newwagon.blend1 new file mode 100644 index 0000000..eb30fde Binary files /dev/null and b/advtrains/models/blender/newwagon.blend1 differ diff --git a/advtrains/models/blender/newwagon.png b/advtrains/models/blender/newwagon.png new file mode 100644 index 0000000..812bc32 Binary files /dev/null and b/advtrains/models/blender/newwagon.png differ diff --git a/advtrains/models/blender/subway-train.blend b/advtrains/models/blender/subway-train.blend new file mode 100644 index 0000000..690d87b Binary files /dev/null and b/advtrains/models/blender/subway-train.blend differ diff --git a/advtrains/models/blender/subway-train.blend1 b/advtrains/models/blender/subway-train.blend1 new file mode 100644 index 0000000..86d1f92 Binary files /dev/null and b/advtrains/models/blender/subway-train.blend1 differ diff --git a/advtrains/models/blender/subway-train.png b/advtrains/models/blender/subway-train.png new file mode 100644 index 0000000..d0b9731 Binary files /dev/null and b/advtrains/models/blender/subway-train.png differ diff --git a/advtrains/models/blender/subway-train.xcf b/advtrains/models/blender/subway-train.xcf new file mode 100644 index 0000000..775b87c Binary files /dev/null and b/advtrains/models/blender/subway-train.xcf differ diff --git a/advtrains/models/blender/trackplane.blend b/advtrains/models/blender/trackplane.blend new file mode 100644 index 0000000..79365f7 Binary files /dev/null and b/advtrains/models/blender/trackplane.blend differ diff --git a/advtrains/models/blender/trackvertical1.blend b/advtrains/models/blender/trackvertical1.blend new file mode 100644 index 0000000..fca6742 Binary files /dev/null and b/advtrains/models/blender/trackvertical1.blend differ diff --git a/advtrains/models/blender/trackvertical1.blend1 b/advtrains/models/blender/trackvertical1.blend1 new file mode 100644 index 0000000..b146b56 Binary files /dev/null and b/advtrains/models/blender/trackvertical1.blend1 differ diff --git a/advtrains/models/blender/trackvertical1.png b/advtrains/models/blender/trackvertical1.png new file mode 100644 index 0000000..a998dcb Binary files /dev/null and b/advtrains/models/blender/trackvertical1.png differ diff --git a/advtrains/models/blender/trackvertical2.blend b/advtrains/models/blender/trackvertical2.blend new file mode 100644 index 0000000..a066b84 Binary files /dev/null and b/advtrains/models/blender/trackvertical2.blend differ diff --git a/advtrains/models/blender/trackvertical2.png b/advtrains/models/blender/trackvertical2.png new file mode 100644 index 0000000..43142f9 Binary files /dev/null and b/advtrains/models/blender/trackvertical2.png differ diff --git a/advtrains/models/oldmodels/locomotive.b3d b/advtrains/models/oldmodels/locomotive.b3d new file mode 100644 index 0000000..5e16be3 Binary files /dev/null and b/advtrains/models/oldmodels/locomotive.b3d differ diff --git a/advtrains/models/oldmodels/trackvertical1.b3d b/advtrains/models/oldmodels/trackvertical1.b3d new file mode 100644 index 0000000..5620f60 Binary files /dev/null and b/advtrains/models/oldmodels/trackvertical1.b3d differ diff --git a/advtrains/models/oldmodels/trackvertical2.b3d b/advtrains/models/oldmodels/trackvertical2.b3d new file mode 100644 index 0000000..22dbb20 Binary files /dev/null and b/advtrains/models/oldmodels/trackvertical2.b3d differ diff --git a/advtrains/models/trackplane.b3d b/advtrains/models/trackplane.b3d new file mode 100644 index 0000000..b4728c3 Binary files /dev/null and b/advtrains/models/trackplane.b3d differ diff --git a/advtrains/pseudoload.lua b/advtrains/pseudoload.lua new file mode 100644 index 0000000..8511811 --- /dev/null +++ b/advtrains/pseudoload.lua @@ -0,0 +1,180 @@ +local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end + +--pseudoload.lua +--responsible for keeping up a database of all rail nodes existant in the world, regardless of whether the mapchunk is loaded. + +advtrains.trackdb={} +--trackdb[tt][y][x][z]={conn1, conn2, rely1, rely2, railheight} +--serialization format: +--(2byte x)(2byte y)(2byte z)(4bits conn1, 4bits conn2)[(plain rely1)|(plain rely2)|(plain railheight)]\n +--[] may be missing if 0,0,0 + +--load initially + +--[[ TODO temporary outcomment + +--delayed since all traintypes need to be registered +minetest.after(0, function() + +for tt, _ in pairs(advtrains.all_traintypes) do + local pl_fpath=minetest.get_worldpath().."/advtrains_trackdb_"..tt + advtrains.trackdb[tt]={} + local file, err = io.open(pl_fpath, "r") + if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed loading advtrains trackdb save file "..er) + else + --custom format to save memory + while true do + local xbytes=file:read(2) + if not xbytes or #xbytes<2 then + break --eof reached + end + print(xbytes) + local ybytes=file:read(2) + local zbytes=file:read(2) + local x=(string.byte(xbytes[1])-128)*256+(string.byte(xbytes[2])) + local y=(string.byte(ybytes[1])-128)*256+(string.byte(ybytes[2])) + local z=(string.byte(zbytes[1])-128)*256+(string.byte(zbytes[2])) + + local conn1=string.byte(file:read(1)) + local conn1=string.byte(file:read(1)) + + if not advtrains.trackdb[tt][y] then advtrains.trackdb[tt][y]={} end + if not advtrains.trackdb[tt][y][x] then advtrains.trackdb[tt][y][x]={} end + + local rest=file.read("*l") + if rest~="" then + local rely1, rely2, railheight=string.match(rest, "([^|]+)|([^|]+)|([^|]+)") + if rely1 and rely2 and railheight then + advtrains.trackdb[tt][y][x][z]={ + conn1=conn1, conn2=conn2, + rely1=rely1, rely2=rely2, + railheight=railheight + } + else + advtrains.trackdb[tt][y][x][z]={ + conn1=conn1, conn2=conn2 + } + end + else + advtrains.trackdb[tt][y][x][z]={ + conn1=conn1, conn2=conn2 + } + end + end + file:close() + end +end + +--end minetest.after +end) + +function advtrains.save_trackdb() + for tt, _ in pairs(advtrains.all_traintypes) do + local pl_fpath=minetest.get_worldpath().."/advtrains_trackdb_"..tt + local file, err = io.open(pl_fpath, "w") + if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed saving advtrains trackdb save file "..er) + else + --custom format to save memory + for y,tyl in pairs(advtrains.trackdb[tt]) do + for x,txl in pairs(tyl) do + for z,rail in pairs(txl) do + print("write "..x.." "..y.." "..z.." "..minetest.serialize(rail)) + file:write(string.char(math.floor(x/256)+128)..string.char((x%256))) + file:write(string.char(math.floor(y/256)+128)..string.char((y%256))) + file:write(string.char(math.floor(z/256)+128)..string.char((z%256))) + file:write(string.char(rail.conn1)) + file:write(string.char(rail.conn2)) + if (rail.rely1 and rail.rely1~=0) or (rail.rely2 and rail.rely2~=0) or (rail.railheight and rail.railheight~=0) then + file:write(rail.rely1.."|"..rail.rely2.."|"..rail.railheight) + end + file:write("\n") + end + end + end + file:close() + end + end +end +]]--end temp outcomment +advtrains.trackdb={} +advtrains.fpath_tdb=minetest.get_worldpath().."/advtrains_trackdb" +local file, err = io.open(advtrains.fpath_tdb, "r") +if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed loading advtrains save file "..er) +else + local tbl = minetest.deserialize(file:read("*a")) + if type(tbl) == "table" then + advtrains.trackdb=tbl + end + file:close() +end +function advtrains.save_trackdb() + local datastr = minetest.serialize(advtrains.trackdb) + if not datastr then + minetest.log("error", "[advtrains] Failed to serialize trackdb data!") + return + end + local file, err = io.open(advtrains.fpath_tdb, "w") + if err then + return err + end + file:write(datastr) + file:close() +end + +--get_node with pseudoload. +--returns: +--true, conn1, conn2, rely1, rely2, railheight in case everything's right. +--false if it's not a rail or the train does not drive on this rail, but it is loaded or +--nil if the node is neither loaded nor in trackdb +--the distraction between false and nil will be needed only in special cases.(train initpos) +function advtrains.get_rail_info_at(pos, traintype) + local node=minetest.get_node_or_nil(pos) + if not node then + --try raildb + local rdp=vector.round(pos) + local dbe=(advtrains.trackdb[traintype] and advtrains.trackdb[traintype][rdp.y] and advtrains.trackdb[traintype][rdp.y][rdp.x] and advtrains.trackdb[traintype][rdp.y][rdp.x][rdp.z]) + if dbe then + return true, dbe.conn1, dbe.conn2, dbe.rely1 or 0, dbe.rely2 or 0, dbe.railheight or 0 + else + return nil + end + end + local nodename=node.name + if(not advtrains.is_track_and_drives_on(nodename, advtrains.all_traintypes[traintype].drives_on)) then + return false + end + local conn1, conn2, rely1, rely2, railheight=advtrains.get_track_connections(node.name, node.param2) + + --already in trackdb? + local rdp=vector.round(pos) + if not (advtrains.trackdb[traintype] and advtrains.trackdb[traintype][rdp.y] and advtrains.trackdb[traintype][rdp.y][rdp.x] and advtrains.trackdb[traintype][rdp.y][rdp.x][rdp.z]) then--TODO is this necessary? + if not advtrains.trackdb[traintype] then advtrains.trackdb[traintype]={} end + if not advtrains.trackdb[traintype][rdp.y] then advtrains.trackdb[traintype][rdp.y]={} end + if not advtrains.trackdb[traintype][rdp.y][rdp.x] then advtrains.trackdb[traintype][rdp.y][rdp.x]={} end + advtrains.trackdb[traintype][rdp.y][rdp.x][rdp.z]={ + conn1=conn1, conn2=conn2, + rely1=rely1, rely2=rely2, + railheight=railheight + } + end + + return true, conn1, conn2, rely1, rely2, railheight +end +function advtrains.reset_trackdb_position(pos) + local rdp=vector.round(pos) + for tt, _ in pairs(advtrains.all_traintypes) do + if not advtrains.trackdb[tt] then advtrains.trackdb[tt]={} end + if not advtrains.trackdb[tt][rdp.y] then advtrains.trackdb[tt][rdp.y]={} end + if not advtrains.trackdb[tt][rdp.y][rdp.x] then advtrains.trackdb[tt][rdp.y][rdp.x]={} end + advtrains.trackdb[tt][rdp.y][rdp.x][rdp.z]=nil + advtrains.get_rail_info_at(pos, tt)--to restore it. + end +end + + diff --git a/advtrains/readme.txt b/advtrains/readme.txt new file mode 100644 index 0000000..ad093bd --- /dev/null +++ b/advtrains/readme.txt @@ -0,0 +1,23 @@ + +## ADVTRAINS ## realistic trains in Minetest! +by orwell96 and contributors(see below) + +For up-to-date information, visit https://forum.minetest.net/viewtopic.php?f=9&t=14726 + + +Manual: +If manual.pdf is not present (which is the case when you downloaded the zip file), see https://github.com/orwell96/advtrains/blob/master/manual.pdf + +License of code: LGPL 2.1 +License of media: CC-BY-NC-SA 3.0 + +Contributions: + +Gravel Texture : from Minetest Game +Initial rail model/texture : DS-minetest +Models for signals/bumpers : mbb +Steam engine / wagon texture: mbb +Industrial engine/wagons : mbb +Inventory images : mbb +Small code contributions : NaruTrey / gpcf +Mod Description : hajo \ No newline at end of file diff --git a/advtrains/signals.lua b/advtrains/signals.lua new file mode 100644 index 0000000..8be65e0 --- /dev/null +++ b/advtrains/signals.lua @@ -0,0 +1,76 @@ +--advtrains by orwell96 +--signals.lua +for r,f in pairs({on="off", off="on"}) do + + advtrains.trackplacer.register_tracktype("advtrains:retrosignal", "") + advtrains.trackplacer.register_tracktype("advtrains:signal", "") + + for rotid, rotation in ipairs({"", "_30", "_45", "_60"}) do + local crea=1 + if rotid==1 and r=="off" then crea=0 end + + minetest.register_node("advtrains:retrosignal_"..r..rotation, { + drawtype = "mesh", + paramtype="light", + paramtype2="facedir", + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4}, + }, + mesh = "advtrains_retrosignal_"..r..rotation..".b3d", + tiles = {"advtrains_retrosignal.png"}, + inventory_image="advtrains_retrosignal_inv.png", + drop="advtrains:retrosignal_off", + description="Lampless Signal ("..r..rotation..")", + on_rightclick=switchfunc, + sunlight_propagates=true, + groups = { + choppy=3, + not_blocking_trains=1, + not_in_creative_inventory=crea, + }, + mesecons = {effector = { + ["action_"..f] = function (pos, node) + minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2}) + end + }}, + on_rightclick=function(pos, node, clicker) + minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2}) + end, + }) + advtrains.trackplacer.add_worked("advtrains:retrosignal", r, rotation, nil) + minetest.register_node("advtrains:signal_"..r..rotation, { + drawtype = "mesh", + paramtype="light", + paramtype2="facedir", + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4}, + }, + mesh = "advtrains_signal"..rotation..".b3d", + tiles = {"advtrains_signal_"..r..".png"}, + inventory_image="advtrains_signal_inv.png", + drop="advtrains:signal_off", + description="Signal ("..r..rotation..")", + on_rightclick=switchfunc, + groups = { + choppy=3, + not_blocking_trains=1, + not_in_creative_inventory=crea, + }, + light_source = 1, + sunlight_propagates=true, + mesecons = {effector = { + ["action_"..f] = function (pos, node) + minetest.swap_node(pos, {name = "advtrains:signal_"..f..rotation, param2 = node.param2}) + end + }}, + on_rightclick=function(pos, node, clicker) + minetest.swap_node(pos, {name = "advtrains:signal_"..f..rotation, param2 = node.param2}) + end, + }) + advtrains.trackplacer.add_worked("advtrains:signal", r, rotation, nil) + end +end diff --git a/advtrains/textures/advtrains_couple.png b/advtrains/textures/advtrains_couple.png new file mode 100644 index 0000000..9e997e4 Binary files /dev/null and b/advtrains/textures/advtrains_couple.png differ diff --git a/advtrains/textures/advtrains_discouple.png b/advtrains/textures/advtrains_discouple.png new file mode 100644 index 0000000..b27c4fb Binary files /dev/null and b/advtrains/textures/advtrains_discouple.png differ diff --git a/advtrains/textures/advtrains_dtrack_bumper_placer.png b/advtrains/textures/advtrains_dtrack_bumper_placer.png new file mode 100644 index 0000000..27191fe Binary files /dev/null and b/advtrains/textures/advtrains_dtrack_bumper_placer.png differ diff --git a/advtrains/textures/advtrains_dtrack_detector_placer.png b/advtrains/textures/advtrains_dtrack_detector_placer.png new file mode 100644 index 0000000..e6c6ad6 Binary files /dev/null and b/advtrains/textures/advtrains_dtrack_detector_placer.png differ diff --git a/advtrains/textures/advtrains_dtrack_placer.png b/advtrains/textures/advtrains_dtrack_placer.png new file mode 100644 index 0000000..c49777c Binary files /dev/null and b/advtrains/textures/advtrains_dtrack_placer.png differ diff --git a/advtrains/textures/advtrains_dtrack_rail.png b/advtrains/textures/advtrains_dtrack_rail.png new file mode 100644 index 0000000..568e533 Binary files /dev/null and b/advtrains/textures/advtrains_dtrack_rail.png differ diff --git a/advtrains/textures/advtrains_dtrack_rail_detector_on.png b/advtrains/textures/advtrains_dtrack_rail_detector_on.png new file mode 100644 index 0000000..3ae0dac Binary files /dev/null and b/advtrains/textures/advtrains_dtrack_rail_detector_on.png differ diff --git a/advtrains/textures/advtrains_dtrack_slopeplacer.png b/advtrains/textures/advtrains_dtrack_slopeplacer.png new file mode 100644 index 0000000..1d456b0 Binary files /dev/null and b/advtrains/textures/advtrains_dtrack_slopeplacer.png differ diff --git a/advtrains/textures/advtrains_newlocomotive.xcf b/advtrains/textures/advtrains_newlocomotive.xcf new file mode 100644 index 0000000..9ad5187 Binary files /dev/null and b/advtrains/textures/advtrains_newlocomotive.xcf differ diff --git a/advtrains/textures/advtrains_platform.png b/advtrains/textures/advtrains_platform.png new file mode 100644 index 0000000..5ba9663 Binary files /dev/null and b/advtrains/textures/advtrains_platform.png differ diff --git a/advtrains/textures/advtrains_retrosignal.png b/advtrains/textures/advtrains_retrosignal.png new file mode 100644 index 0000000..141198d Binary files /dev/null and b/advtrains/textures/advtrains_retrosignal.png differ diff --git a/advtrains/textures/advtrains_retrosignal_inv.png b/advtrains/textures/advtrains_retrosignal_inv.png new file mode 100644 index 0000000..1036594 Binary files /dev/null and b/advtrains/textures/advtrains_retrosignal_inv.png differ diff --git a/advtrains/textures/advtrains_signal_inv.png b/advtrains/textures/advtrains_signal_inv.png new file mode 100644 index 0000000..ed64ed9 Binary files /dev/null and b/advtrains/textures/advtrains_signal_inv.png differ diff --git a/advtrains/textures/advtrains_signal_off.png b/advtrains/textures/advtrains_signal_off.png new file mode 100644 index 0000000..8046e52 Binary files /dev/null and b/advtrains/textures/advtrains_signal_off.png differ diff --git a/advtrains/textures/advtrains_signal_on.png b/advtrains/textures/advtrains_signal_on.png new file mode 100644 index 0000000..5228bb3 Binary files /dev/null and b/advtrains/textures/advtrains_signal_on.png differ diff --git a/advtrains/textures/advtrains_track_cr.png b/advtrains/textures/advtrains_track_cr.png new file mode 100644 index 0000000..40f0cc5 Binary files /dev/null and b/advtrains/textures/advtrains_track_cr.png differ diff --git a/advtrains/textures/advtrains_track_cr_45.png b/advtrains/textures/advtrains_track_cr_45.png new file mode 100644 index 0000000..54966b3 Binary files /dev/null and b/advtrains/textures/advtrains_track_cr_45.png differ diff --git a/advtrains/textures/advtrains_track_placer.png b/advtrains/textures/advtrains_track_placer.png new file mode 100644 index 0000000..03e17ed Binary files /dev/null and b/advtrains/textures/advtrains_track_placer.png differ diff --git a/advtrains/textures/advtrains_track_st.png b/advtrains/textures/advtrains_track_st.png new file mode 100644 index 0000000..5ad7e4f Binary files /dev/null and b/advtrains/textures/advtrains_track_st.png differ diff --git a/advtrains/textures/advtrains_track_st_45.png b/advtrains/textures/advtrains_track_st_45.png new file mode 100644 index 0000000..63b4c96 Binary files /dev/null and b/advtrains/textures/advtrains_track_st_45.png differ diff --git a/advtrains/textures/advtrains_track_swlcr.png b/advtrains/textures/advtrains_track_swlcr.png new file mode 100644 index 0000000..d9b5c0b Binary files /dev/null and b/advtrains/textures/advtrains_track_swlcr.png differ diff --git a/advtrains/textures/advtrains_track_swlcr_45.png b/advtrains/textures/advtrains_track_swlcr_45.png new file mode 100644 index 0000000..f098fc9 Binary files /dev/null and b/advtrains/textures/advtrains_track_swlcr_45.png differ diff --git a/advtrains/textures/advtrains_track_swlst.png b/advtrains/textures/advtrains_track_swlst.png new file mode 100644 index 0000000..314bd2d Binary files /dev/null and b/advtrains/textures/advtrains_track_swlst.png differ diff --git a/advtrains/textures/advtrains_track_swlst_45.png b/advtrains/textures/advtrains_track_swlst_45.png new file mode 100644 index 0000000..765d0ec Binary files /dev/null and b/advtrains/textures/advtrains_track_swlst_45.png differ diff --git a/advtrains/textures/advtrains_track_swrcr.png b/advtrains/textures/advtrains_track_swrcr.png new file mode 100644 index 0000000..f74e1bc Binary files /dev/null and b/advtrains/textures/advtrains_track_swrcr.png differ diff --git a/advtrains/textures/advtrains_track_swrcr_45.png b/advtrains/textures/advtrains_track_swrcr_45.png new file mode 100644 index 0000000..fa432aa Binary files /dev/null and b/advtrains/textures/advtrains_track_swrcr_45.png differ diff --git a/advtrains/textures/advtrains_track_swrst.png b/advtrains/textures/advtrains_track_swrst.png new file mode 100644 index 0000000..06ea29e Binary files /dev/null and b/advtrains/textures/advtrains_track_swrst.png differ diff --git a/advtrains/textures/advtrains_track_swrst_45.png b/advtrains/textures/advtrains_track_swrst_45.png new file mode 100644 index 0000000..be477b7 Binary files /dev/null and b/advtrains/textures/advtrains_track_swrst_45.png differ diff --git a/advtrains/textures/advtrains_trackworker.png b/advtrains/textures/advtrains_trackworker.png new file mode 100644 index 0000000..b50bcae Binary files /dev/null and b/advtrains/textures/advtrains_trackworker.png differ diff --git a/advtrains/textures/drwho_screwdriver.png b/advtrains/textures/drwho_screwdriver.png new file mode 100644 index 0000000..b50bcae Binary files /dev/null and b/advtrains/textures/drwho_screwdriver.png differ diff --git a/advtrains/textures/larger rails.xcf b/advtrains/textures/larger rails.xcf new file mode 100644 index 0000000..42ae592 Binary files /dev/null and b/advtrains/textures/larger rails.xcf differ diff --git a/advtrains/trackplacer.lua b/advtrains/trackplacer.lua new file mode 100644 index 0000000..eebf2ae --- /dev/null +++ b/advtrains/trackplacer.lua @@ -0,0 +1,282 @@ +--trackplacer.lua +--holds code for the track-placing system. the default 'track' item will be a craftitem that places rails as needed. this will neither place or change switches nor place vertical rails. + +--all new trackplacer code +local tp={ + tracks={} +} + +function tp.register_tracktype(nnprefix, n_suffix) + tp.tracks[nnprefix]={ + default=n_suffix, + single_conn={}, + double_conn={}, + --keys:conn1_conn2 (example:1_4) + --values:{name=x, param2=x} + twcycle={}, + twrotate={},--indexed by suffix, list, tells order of rotations + modify={} + } +end +function tp.add_double_conn(nnprefix, suffix, rotation, conns) + local nodename=nnprefix.."_"..suffix..rotation + for i=0,3 do + tp.tracks[nnprefix].double_conn[((conns.conn1+4*i)%16).."_"..((conns.conn2+4*i)%16)]={name=nodename, param2=i} + tp.tracks[nnprefix].double_conn[((conns.conn2+4*i)%16).."_"..((conns.conn1+4*i)%16)]={name=nodename, param2=i} + end + tp.tracks[nnprefix].modify[nodename]=true +end +function tp.add_single_conn(nnprefix, suffix, rotation, conns) + local nodename=nnprefix.."_"..suffix..rotation + for i=0,3 do + tp.tracks[nnprefix].single_conn[((conns.conn1+4*i)%16)]={name=nodename, param2=i} + tp.tracks[nnprefix].single_conn[((conns.conn2+4*i)%16)]={name=nodename, param2=i} + end + tp.tracks[nnprefix].modify[nodename]=true +end + +function tp.add_worked(nnprefix, suffix, rotation, cycle_follows) + tp.tracks[nnprefix].twcycle[suffix]=cycle_follows + if not tp.tracks[nnprefix].twrotate[suffix] then tp.tracks[nnprefix].twrotate[suffix]={} end + table.insert(tp.tracks[nnprefix].twrotate[suffix], rotation) +end + + +--[[ + rewrite algorithm. + selection criteria: these will never be changed or even selected: + - tracks being already connected on both sides + - tracks that are already connected on one side but are not bendable to the desired position + the following situations can occur: + 1. there are two more than two rails around + 1.1 there is one or more subset(s) that can be directly connected + -> choose the first possibility + 2.2 not + -> choose the first one and orient straight + 2. there's exactly 1 rail around + -> choose and orient straight + 3. there's no rail around + -> set straight +]] +function tp.find_already_connected(pos)--TODO vertical calculations(check node below) + local function istrackandbc(pos, conn) + local cnode=minetest.get_node(advtrains.dirCoordSet(pos, conn)) + local bconn=(conn+8)%16 + if advtrains.is_track_and_drives_on(cnode.name, advtrains.all_tracktypes) then + local cconn1, cconn2=advtrains.get_track_connections(cnode.name, cnode.param2) + return cconn1==bconn or cconn2==bconn + end + return false + end + local dnode=minetest.get_node(pos) + local dconn1, dconn2=advtrains.get_track_connections(dnode.name, dnode.param2) + local t={[true]="true", [false]="false"} + if istrackandbc(pos, dconn1) and istrackandbc(pos, dconn2) then return dconn1, dconn2 + elseif istrackandbc(pos, dconn1) then return dconn1 + elseif istrackandbc(pos, dconn2) then return dconn2 + end + return nil +end +function tp.rail_and_can_be_bent(originpos, conn, nnpref) + local pos=advtrains.dirCoordSet(originpos, conn) + local newdir=(conn+8)%16 + local node=minetest.get_node(pos) + local tr=tp.tracks[nnpref] + if not advtrains.is_track_and_drives_on(node.name, advtrains.all_tracktypes) then + return false + end + --rail at other end? + local adj1, adj2=tp.find_already_connected(pos) + if adj1 and adj2 then + return false--dont destroy existing track + elseif adj1 and not adj2 then + if tr.double_conn[adj1.."_"..newdir] then + return true--if exists, connect new rail and old end + end + return false + else + if tr.single_conn[newdir] then--just rotate old rail to right orientation + return true + end + return false + end +end +function tp.bend_rail(originpos, conn, nnpref) + local pos=advtrains.dirCoordSet(originpos, conn) + local newdir=(conn+8)%16 + local node=minetest.get_node(pos) + local tr=tp.tracks[nnpref] + --is rail already connected? no need to bend. + local conn1, conn2=advtrains.get_track_connections(node.name, node.param2) + if newdir==conn1 or newdir==conn2 then + return + end + --rail at other end? + local adj1, adj2=tp.find_already_connected(pos) + if adj1 and adj2 then + return false--dont destroy existing track + elseif adj1 and not adj2 then + if tr.double_conn[adj1.."_"..newdir] then + minetest.set_node(pos, tr.double_conn[adj1.."_"..newdir]) + return true--if exists, connect new rail and old end + end + return false + else + if tr.single_conn[newdir] then--just rotate old rail to right orientation + minetest.set_node(pos, tr.single_conn[newdir]) + return true + end + return false + end +end +function tp.placetrack(pos, nnpref) + --1. find all rails that are likely to be connected + local tr=tp.tracks[nnpref] + local p_rails={} + for i=0,15 do + if tp.rail_and_can_be_bent(pos, i, nnpref) then + p_rails[#p_rails+1]=i + end + end + if #p_rails==0 then + minetest.set_node(pos, {name=nnpref.."_"..tr.default}) + elseif #p_rails==1 then + tp.bend_rail(pos, p_rails[1], nnpref) + minetest.set_node(pos, tr.single_conn[p_rails[1]]) + else + --iterate subsets + for k1, conn1 in ipairs(p_rails) do + for k2, conn2 in ipairs(p_rails) do + if k1~=k2 then + if (tr.double_conn[conn1.."_"..conn2]) then + tp.bend_rail(pos, conn1, nnpref) + tp.bend_rail(pos, conn2, nnpref) + minetest.set_node(pos, tr.double_conn[conn1.."_"..conn2]) + return + end + end + end + end + --not found + tp.bend_rail(pos, p_rails[1], nnpref) + minetest.set_node(pos, tr.single_conn[p_rails[1]]) + end +end + + +function tp.register_track_placer(nnprefix, imgprefix, dispname) + minetest.register_craftitem(nnprefix.."_placer",{ + description = dispname, + inventory_image = imgprefix.."_placer.png", + wield_image = imgprefix.."_placer.png", + groups={}, + on_place = function(itemstack, placer, pointed_thing) + local name = placer:get_player_name() + if not name then + return itemstack + end + if pointed_thing.type=="node" then + local pos=pointed_thing.above + local upos=pointed_thing.under + if minetest.is_protected(pos,name) and minetest.is_protected(upos,name) then + return itemstack + end + if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to + and minetest.registered_nodes[minetest.get_node(upos).name] and minetest.registered_nodes[minetest.get_node(upos).name].walkable then + tp.placetrack(pos, nnprefix) + if not minetest.setting_getbool("creative_mode") then + itemstack:take_item() + end + end + end + return itemstack + end, + }) +end + + + +minetest.register_craftitem("advtrains:trackworker",{ + description = "Track Worker Tool\n\nLeft-click: change rail type (straight/curve/switch)\nRight-click: rotate rail/bumper/signal/etc.", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "advtrains_trackworker.png", + wield_image = "advtrains_trackworker.png", + stack_max = 1, + on_place = function(itemstack, placer, pointed_thing) + local name = placer:get_player_name() + if not name then + return + end + if pointed_thing.type=="node" then + local pos=pointed_thing.under + if minetest.is_protected(pos, name) then + return + end + local node=minetest.get_node(pos) + + --if not advtrains.is_track_and_drives_on(minetest.get_node(pos).name, advtrains.all_tracktypes) then return end + if advtrains.is_train_at_pos(pos) then return end + + local nnprefix, suffix, rotation=string.match(node.name, "^(.+)_([^_]+)(_[^_]+)$") + --print(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) + if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then + nnprefix, suffix=string.match(node.name, "^(.+)_([^_]+)$") + rotation = "" + if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then + minetest.chat_send_player(placer:get_player_name(), "This node can't be rotated using the trackworker!") + return + end + end + local modext=tp.tracks[nnprefix].twrotate[suffix] + + if rotation==modext[#modext] then --increase param2 + minetest.set_node(pos, {name=nnprefix.."_"..suffix..modext[1], param2=(node.param2+1)%4}) + return + else + local modpos + for k,v in pairs(modext) do if v==rotation then modpos=k end end + if not modpos then + minetest.chat_send_player(placer:get_player_name(), "This node can't be rotated using the trackworker!") + return + end + minetest.set_node(pos, {name=nnprefix.."_"..suffix..modext[modpos+1], param2=node.param2}) + end + advtrains.invalidate_all_paths() + end + end, + on_use=function(itemstack, user, pointed_thing) + local name = user:get_player_name() + if not name then + return + end + if pointed_thing.type=="node" then + local pos=pointed_thing.under + local node=minetest.get_node(pos) + if minetest.is_protected(pos, name) then + return + end + + --if not advtrains.is_track_and_drives_on(minetest.get_node(pos).name, advtrains.all_tracktypes) then return end + if advtrains.is_train_at_pos(pos) then return end + local nnprefix, suffix, rotation=string.match(node.name, "^(.+)_([^_]+)(_[^_]+)$") + --print(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) + if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twcycle[suffix] then + nnprefix, suffix=string.match(node.name, "^(.+)_([^_]+)$") + rotation = "" + if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twcycle[suffix] then + minetest.chat_send_player(user:get_player_name(), "This node can't be changed using the trackworker!") + return + end + end + local nextsuffix=tp.tracks[nnprefix].twcycle[suffix] + minetest.set_node(pos, {name=nnprefix.."_"..nextsuffix..rotation, param2=node.param2}) + --invalidate trains + advtrains.invalidate_all_paths() + else + print(name, dump(tp.tracks)) + end + end, +}) + +--putting into right place +advtrains.trackplacer=tp diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua new file mode 100644 index 0000000..99dbb27 --- /dev/null +++ b/advtrains/tracks.lua @@ -0,0 +1,693 @@ +--advtrains by orwell96, see readme.txt + +--dev-time settings: +--EDIT HERE +--If the old non-model rails on straight tracks should be replaced by the new... +--false: no +--true: yes +advtrains.register_replacement_lbms=false + +--[[TracksDefinition +nodename_prefix +texture_prefix +description +common={} +straight={} +straight45={} +curve={} +curve45={} +lswitchst={} +lswitchst45={} +rswitchst={} +rswitchst45={} +lswitchcr={} +lswitchcr45={} +rswitchcr={} +rswitchcr45={} +vert1={ + --you'll probably want to override mesh here +} +vert2={ + --you'll probably want to override mesh here +} +]]-- +advtrains.all_tracktypes={} + +--definition preparation +local function conns(c1, c2, r1, r2, rh, rots) return {conn1=c1, conn2=c2, rely1=r1, rely2=r2, railheight=rh} end + +local t_30deg={ + regstep=1, + variant={ + st=conns(0,8), + cr=conns(0,7), + swlst=conns(0,8), + swlcr=conns(0,7), + swrst=conns(0,8), + swrcr=conns(0,9), + vst1=conns(8,0,0,0.5,0.25), + vst2=conns(8,0,0.5,1,0.75), + vst31=conns(8,0,0,0.33,0.16), + vst32=conns(8,0,0.33,0.66,0.5), + vst33=conns(8,0,0.66,1,0.83), + }, + description={ + st="straight", + cr="curve", + swlst="left switch (straight)", + swlcr="left switch (curve)", + swrst="right switch (straight)", + swrcr="right switch (curve)", + vst1="steep uphill 1/2", + vst2="steep uphill 2/2", + vst31="uphill 1/3", + vst32="uphill 2/3", + vst33="uphill 3/3", + }, + switch={ + swlst="swlcr", + swlcr="swlst", + swrst="swrcr", + swrcr="swrst", + }, + switchmc={ + swlst="on", + swlcr="off", + swrst="on", + swrcr="off", + }, + regtp=true, + trackplacer={ + st=true, + cr=true, + }, + tpsingle={ + st=true, + }, + tpdefault="st", + trackworker={ + ["swrcr"]="st", + ["swrst"]="st", + ["st"]="cr", + ["cr"]="swlst", + ["swlcr"]="swrcr", + ["swlst"]="swrst", + }, + regsp=true, + slopenodes={ + vst1=true, vst2=true, + vst31=true, vst32=true, vst33=true, + }, + slopeplacer={ + [2]={"vst1", "vst2"}, + [3]={"vst31", "vst32", "vst33"}, + max=3,--highest entry + }, + slopeplacer_45={ + [2]={"vst1_45", "vst2_45"}, + max=2, + }, + rotation={"", "_30", "_45", "_60"}, + increativeinv={}, +} +local t_30deg_straightonly={ + regstep=1, + variant={ + st=conns(0,8), + }, + description={ + st="straight", + }, + switch={ + }, + switchmc={ + }, + regtp=true, + trackplacer={ + }, + tpsingle={ + }, + tpdefault="st", + trackworker={ + ["st"]="st", + }, + slopenodes={}, + 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={ + }, + tpdefault="st", + trackworker={ + ["st"]="st", + }, + slopenodes={}, + rotation={"", "_30", "_45", "_60"}, + increativeinv={st}, +} +local t_45deg={ + regstep=2, + variant={ + st=conns(0,8), + cr=conns(0,6), + swlst=conns(0,8), + swlcr=conns(0,6), + swrst=conns(0,8), + swrcr=conns(0,10), + vst1=conns(8,0,0,0.5,0.25), + vst2=conns(8,0,0.5,1,0.75), + }, + description={ + st="straight", + cr="curve", + swlst="left switch (straight)", + swlcr="left switch (curve)", + swrst="right switch (straight)", + swrcr="right switch (curve)", + vst1="vertical lower node", + vst2="vertical upper node", + }, + switch={ + swlst="swlcr", + swlcr="swlst", + swrst="swrcr", + swrcr="swrst", + }, + switchmc={ + swlst="on", + swlcr="off", + swrst="on", + swrcr="off", + }, + regtp=true, + trackplacer={ + st=true, + cr=true, + }, + tpsingle={ + st=true, + }, + tpdefault="st", + trackworker={ + ["swrcr"]="st", + ["swrst"]="st", + ["st"]="cr", + ["cr"]="swlst", + ["swlcr"]="swrcr", + ["swlst"]="swrst", + }, + slopenodes={}, + rotation={"", "_45"}, + increativeinv={vst1=true, vst2=true} +} + +--definition format: ([] optional) +--[[{ + nodename_prefix + texture_prefix + [shared_texture] + models_prefix + models_suffix (with dot) + [shared_model] + formats={ + st,cr,swlst,swlcr,swrst,swrcr,vst1,vst2 + (each a table with indices 0-3, for if to register a rail with this 'rotation' table entry. nil is assumed as 'all', set {} to not register at all) + } + common={} change something on common rail appearance +}]] +function advtrains.register_tracks(tracktype, def, preset) + local function make_switchfunc(suffix_target, mesecon_state) + local switchfunc=function(pos, node) + if advtrains.is_train_at_pos(pos) then return end + minetest.set_node(pos, {name=def.nodename_prefix.."_"..suffix_target, param2=node.param2}) + advtrains.invalidate_all_paths() + advtrains.reset_trackdb_position(pos) + end + return switchfunc, {effector = { + ["action_"..mesecon_state] = switchfunc, + rules=advtrains.meseconrules + }} + end + local function make_overdef(suffix, rotation, conns, switchfunc, mesecontbl, in_creative_inv, drop_slope) + local img_suffix=suffix..rotation + return { + mesh = def.shared_model or (def.models_prefix.."_"..img_suffix..def.models_suffix), + tiles = {def.shared_texture or (def.texture_prefix.."_"..img_suffix..".png")}, + --inventory_image = def.texture_prefix.."_"..img_suffix..".png", + --wield_image = def.texture_prefix.."_"..img_suffix..".png", + description=def.description.."("..preset.description[suffix]..rotation..")", + connect1=conns.conn1, + connect2=conns.conn2, + rely1=conns.rely1 or 0, + rely2=conns.rely2 or 0, + railheight=conns.railheight or 0, + on_rightclick=switchfunc, + groups = { + attached_node=1, + ["advtrains_track_"..tracktype]=1, + dig_immediate=2, + not_in_creative_inventory=(not in_creative_inv and 1 or nil), + not_blocking_trains=1, + }, + mesecons=mesecontbl, + drop = increativeinv and def.nodename_prefix.."_"..suffix..rotation or (drop_slope and def.nodename_prefix.."_slopeplacer" or def.nodename_prefix.."_placer"), + } + end + local function cycle_conns(conns, rotid) + local add=(rotid-1)*preset.regstep + return { + conn1=(conns.conn1+add)%16, + conn2=(conns.conn2+add)%16, + rely1=conns.rely1 or 0, + rely2=conns.rely2 or 0, + railheight=conns.railheight or 0, + } + end + local common_def=advtrains.merge_tables({ + description = def.description, + drawtype = "mesh", + paramtype="light", + paramtype2="facedir", + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2}, + }, + rely1=0, + rely2=0, + railheight=0, + drop=def.nodename_prefix.."_placer", + can_dig=function(pos) + return not advtrains.is_train_at_pos(pos) + end, + after_dig_node=function(pos) + advtrains.invalidate_all_paths() + advtrains.reset_trackdb_position(pos) + end, + after_place_node=function(pos) + advtrains.reset_trackdb_position(pos) + end, + }, def.common or {}) + --make trackplacer base def + advtrains.trackplacer.register_tracktype(def.nodename_prefix, preset.tpdefault) + if preset.regtp then + advtrains.trackplacer.register_track_placer(def.nodename_prefix, def.texture_prefix, def.description) + end + if preset.regsp then + advtrains.slope.register_placer(def, preset) + 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 + local switchfunc, mesecontbl + 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], preset.slopenodes[suffix] + ), + adef + ) + ) + --trackplacer + 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 + end + end + table.insert(advtrains.all_tracktypes, tracktype) +end + + +function advtrains.is_track_and_drives_on(nodename, drives_on) + if not minetest.registered_nodes[nodename] then + return false + end + local nodedef=minetest.registered_nodes[nodename] + for k,v in ipairs(drives_on) do + if nodedef.groups["advtrains_track_"..v] then + return true + end + end + return false +end + +function advtrains.get_track_connections(name, param2) + local nodedef=minetest.registered_nodes[name] + if not nodedef then print("[advtrains] get_track_connections couldn't find nodedef for nodename "..(name or "nil")) return 0, 8, 0, 0, 0 end + local noderot=param2 + if not param2 then noderot=0 end + if noderot > 3 then print("[advtrains] get_track_connections: rail has invaild param2 of "..noderot) noderot=0 end + + return (nodedef.connect1 + 4 * noderot)%16, (nodedef.connect2 + 4 * noderot)%16, nodedef.rely1 or 0, nodedef.rely2 or 0, nodedef.railheight or 0 +end + +--detector code +--holds a table with nodes on which trains are on. + +advtrains.detector = {} +advtrains.detector.on_node = {} +advtrains.detector.on_node_restore = {} +--set if paths were invalidated before. tells trainlogic.lua to call advtrains.detector.finalize_restore() +advtrains.detector.clean_step_before = false + +--when train enters a node, call this +--The entry already being contained in advtrains.detector.on_node_restore will not trigger an on_train_enter event on the node. (when path is reset, this is saved). +function advtrains.detector.enter_node(pos, train_id) + local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) + --print("enterNode "..pts.." "..train_id) + if not advtrains.detector.on_node[pts] then + advtrains.detector.on_node[pts]=train_id + if advtrains.detector.on_node_restore[pts] then + advtrains.detector.on_node_restore[pts]=nil + else + advtrains.detector.call_enter_callback(advtrains.round_vector_floor_y(pos), train_id) + end + end +end +function advtrains.detector.leave_node(pos, train_id) + local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) + --print("leaveNode "..pts.." "..train_id) + if advtrains.detector.on_node[pts] then + advtrains.detector.call_leave_callback(advtrains.round_vector_floor_y(pos), train_id) + advtrains.detector.on_node[pts]=nil + end +end +--called immediately before invalidating paths +function advtrains.detector.setup_restore() + --print("setup_restore") + advtrains.detector.on_node_restore = advtrains.detector.on_node + advtrains.detector.on_node = {} +end +--called one step after invalidating paths, when all trains have restored their path and called enter_node for their contents. +function advtrains.detector.finalize_restore() + --print("finalize_restore") + for pts, train_id in pairs(advtrains.detector.on_node_restore) do + --print("called leave callback "..pts.." "..train_id) + advtrains.detector.call_leave_callback(minetest.string_to_pos(pts), train_id) + end + advtrains.detector.on_node_restore = {} +end +function advtrains.detector.call_enter_callback(pos, train_id) + --print("instructed to call enter calback") + + local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case + local mregnode=minetest.registered_nodes[node.name] + if mregnode and mregnode.advtrains and mregnode.advtrains.on_train_enter then + mregnode.advtrains.on_train_enter(pos, train_id) + end +end +function advtrains.detector.call_leave_callback(pos, train_id) + --print("instructed to call leave calback") + + local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case + local mregnode=minetest.registered_nodes[node.name] + if mregnode and mregnode.advtrains and mregnode.advtrains.on_train_leave then + mregnode.advtrains.on_train_leave(pos, train_id) + end +end + +-- slope placer. Defined in register_tracks. +--crafted with rail and gravel +local sl={} +function sl.register_placer(def, preset) + minetest.register_craftitem(def.nodename_prefix.."_slopeplacer",{ + description = def.description.." Slope", + inventory_image = def.texture_prefix.."_slopeplacer.png", + wield_image = def.texture_prefix.."_slopeplacer.png", + groups={}, + on_place = sl.create_slopeplacer_on_place(def, preset) + }) +end +--(itemstack, placer, pointed_thing) +function sl.create_slopeplacer_on_place(def, preset) + return function(istack, player, pt) + if not pt.type=="node" then + minetest.chat_send_player(player:get_player_name(), "Can't place: not pointing at node") + return istack + end + local pos=pt.above + if not pos then + minetest.chat_send_player(player:get_player_name(), "Can't place: not pointing at node") + return istack + end + local node=minetest.get_node(pos) + if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].buildable_to then + minetest.chat_send_player(player:get_player_name(), "Can't place: space occupied!") + return istack + end + if minetest.is_protected(pos, player:get_player_name()) then + minetest.chat_send_player(player:get_player_name(), "Can't place: protected position!") + return istack + end + --determine player orientation (only horizontal component) + --get_look_horizontal may not be available + local yaw=player.get_look_horizontal and player:get_look_horizontal() or (player:get_look_yaw() - math.pi/2) + + --rounding unit vectors is a nice way for selecting 1 of 8 directions since sin(30°) is 0.5. + dirvec={x=math.floor(math.sin(-yaw)+0.5), y=0, z=math.floor(math.cos(-yaw)+0.5)} + --translate to direction to look up inside the preset table + local param2, rot45=({ + [-1]={ + [-1]=2, + [0]=3, + [1]=3, + }, + [0]={ + [-1]=2, + [1]=0, + }, + [1]={ + [-1]=1, + [0]=1, + [1]=0, + }, + })[dirvec.x][dirvec.z], dirvec.x~=0 and dirvec.z~=0 + local lookup=preset.slopeplacer + if rot45 then lookup=preset.slopeplacer_45 end + + --go unitvector forward and look how far the next node is + local step=1 + while step<=lookup.max do + local node=minetest.get_node(vector.add(pos, dirvec)) + --next node solid? + if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].buildable_to or minetest.is_protected(pos, player:get_player_name()) then + --do slopes of this distance exist? + if lookup[step] then + if minetest.setting_getbool("creative_mode") or istack:get_count()>=step then + --start placing + local placenodes=lookup[step] + while step>0 do + minetest.set_node(pos, {name=def.nodename_prefix.."_"..placenodes[step], param2=param2}) + if not minetest.setting_getbool("creative_mode") then + istack:take_item() + end + step=step-1 + pos=vector.subtract(pos, dirvec) + end + else + minetest.chat_send_player(player:get_player_name(), "Can't place: Not enough slope items left ("..step.." required)") + end + else + minetest.chat_send_player(player:get_player_name(), "Can't place: There's no slope of length "..step) + end + return istack + end + step=step+1 + pos=vector.add(pos, dirvec) + end + minetest.chat_send_player(player:get_player_name(), "Can't place: no supporting node at upper end.") + return itemstack + end +end + +advtrains.slope=sl + +--END code, BEGIN definition +--definition format: ([] optional) +--[[{ + nodename_prefix + texture_prefix + [shared_texture] + models_prefix + models_suffix (with dot) + [shared_model] + formats={ + st,cr,swlst,swlcr,swrst,swrcr,vst1,vst2 + (each a table with indices 0-3, for if to register a rail with this 'rotation' table entry. nil is assumed as 'all', set {} to not register at all) + } + common={} change something on common rail appearance +}]] + +advtrains.register_tracks("regular", { + nodename_prefix="advtrains:track", + texture_prefix="advtrains_track", + shared_model="trackplane.b3d", + description="Deprecated Track", + formats={vst1={}, vst2={}}, +}, t_45deg) + + +advtrains.register_tracks("default", { + nodename_prefix="advtrains:dtrack", + texture_prefix="advtrains_dtrack", + models_prefix="advtrains_dtrack", + models_suffix=".b3d", + shared_texture="advtrains_dtrack_rail.png", + description="Track", + formats={vst1={true, false, true}, vst2={true, false, true}, vst31={true}, vst32={true}, vst33={true}}, +}, t_30deg) + +--bumpers +advtrains.register_tracks("default", { + nodename_prefix="advtrains:dtrack_bumper", + texture_prefix="advtrains_dtrack_bumper", + models_prefix="advtrains_dtrack_bumper", + models_suffix=".b3d", + shared_texture="advtrains_dtrack_rail.png", + description="Bumper", + formats={}, +}, t_30deg_straightonly) +--legacy bumpers +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, param2=minetest.get_node(pos).param2}) + 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, param2=minetest.get_node(pos).param2}) + 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 + minetest.register_abm({ + -- In the following two fields, also group:groupname will work. + nodenames = {"advtrains:track_"..name}, + interval = 1.0, -- Operation interval in seconds + chance = 1, -- Chance of trigger per-node per-interval is 1.0 / this + action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:track_"..rep, param2=node.param2}) end, + }) + minetest.register_abm({ + -- In the following two fields, also group:groupname will work. + nodenames = {"advtrains:track_"..name.."_45"}, + interval = 1.0, -- Operation interval in seconds + chance = 1, -- Chance of trigger per-node per-interval is 1.0 / this + action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:track_"..rep.."_45", param2=node.param2}) end, + }) +end + +if advtrains.register_replacement_lbms then +minetest.register_lbm({ + name = "advtrains:ramp_replacement_1", +-- In the following two fields, also group:groupname will work. + nodenames = {"advtrains:track_vert1"}, + action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_vst1", param2=(node.param2+2)%4}) end, +}) +minetest.register_lbm({ + name = "advtrains:ramp_replacement_1", +-- -- In the following two fields, also group:groupname will work. + nodenames = {"advtrains:track_vert2"}, + action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_vst2", param2=(node.param2+2)%4}) end, +}) + minetest.register_abm({ + name = "advtrains:st_rep_1", + -- In the following two fields, also group:groupname will work. + nodenames = {"advtrains:track_st"}, + interval=1, + chance=1, + action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_st", param2=node.param2}) end, + }) + minetest.register_lbm({ + name = "advtrains:st_rep_1", + -- -- In the following two fields, also group:groupname will work. + nodenames = {"advtrains:track_st_45"}, + action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_st_45", param2=node.param2}) end, + }) +end + + + + + + + + diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua new file mode 100644 index 0000000..aead246 --- /dev/null +++ b/advtrains/trainhud.lua @@ -0,0 +1,109 @@ +--trainhud.lua: holds all the code for train controlling + +advtrains.hud = {} + +minetest.register_on_leaveplayer(function(player) +advtrains.hud[player:get_player_name()] = nil +end) + +local mletter={[1]="F", [-1]="R", [0]="N"} + +function advtrains.on_control_change(pc, train, flip) + if pc.sneak then + if pc.up then + train.tarvelocity = advtrains.all_traintypes[train.traintype].max_speed or 10 + end + if pc.down then + train.tarvelocity = 0 + end + if pc.left then + train.tarvelocity = 4 + end + if pc.right then + train.tarvelocity = 8 + end + if pc.jump then + train.brake = true + --0: released, 1: brake and pressed, 2: released and brake, 3: pressed and brake + if not train.brake_hold_state or train.brake_hold_state==0 then + train.brake_hold_state = 1 + elseif train.brake_hold_state==2 then + train.brake_hold_state = 3 + end + elseif train.brake_hold_state==1 then + train.brake_hold_state = 2 + elseif train.brake_hold_state==3 then + train.brake = false + train.brake_hold_state = 0 + end + --shift+use:see wagons.lua + else + if pc.up then + train.tarvelocity = train.tarvelocity + 1 + end + if pc.down then + if train.velocity>0 then + train.tarvelocity = math.max(train.tarvelocity - 1, 0) + else + train.movedir = -train.movedir + end + end + if train.brake_hold_state~=2 then + train.brake = false + end + if pc.jump then + train.brake = true + end + if pc.aux1 then + --horn + end + end +end +function advtrains.update_driver_hud(pname, train, flip) + advtrains.set_trainhud(pname, advtrains.hud_train_format(train, flip)) +end +function advtrains.clear_driver_hud(pname) + advtrains.set_trainhud(pname, "") +end + +function advtrains.set_trainhud(name, text) + local hud = advtrains.hud[name] + local player=minetest.get_player_by_name(name) + if not player then + return + end + if not hud then + hud = {} + advtrains.hud[name] = hud + hud.id = player:hud_add({ + hud_elem_type = "text", + name = "ADVTRAINS", + number = 0xFFFFFF, + position = {x=0.5, y=0.7}, + offset = {x=0, y=0}, + text = text, + scale = {x=200, y=60}, + alignment = {x=0, y=0}, + }) + hud.oldText=text + return + elseif hud.oldText ~= text then + player:hud_change(hud.id, "text", text) + hud.oldText=text + end +end +function advtrains.hud_train_format(train, flip) + local fct=flip and -1 or 1 + if not train or not train.traintype then return "" end + + local max=advtrains.all_traintypes[train.traintype].max_speed or 10 + local vel=advtrains.abs_ceil(train.velocity) + local tvel=advtrains.abs_ceil(train.tarvelocity) + local topLine, firstLine, secondLine + + topLine=train.traintype.." ["..mletter[fct*train.movedir].."] "..(train.brake and "="..( train.brake_hold_state==2 and "^" or "" ).."B=" or "") + firstLine="Speed: |"..string.rep("+", vel)..string.rep("_", max-vel)..">" + secondLine="Target: |"..string.rep("+", tvel)..string.rep("_", max-tvel)..">" + + return topLine.."\n"..firstLine.."\n"..secondLine +end diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua new file mode 100644 index 0000000..5e3936f --- /dev/null +++ b/advtrains/trainlogic.lua @@ -0,0 +1,895 @@ +--trainlogic.lua +--controls train entities stuff about connecting/disconnecting/colliding trains and other things + +--local print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end +local print=function() end + +local benchmark=false +--printbm=function(str, t) print("[advtrains]"..str.." "..((os.clock()-t)*1000).."ms") end +local bm={} +local bmlt=0 +local bmsteps=0 +local bmstepint=200 +printbm=function(action, ta) + if not benchmark then return end + local t=(os.clock()-ta)*1000 + if not bm[action] then + bm[action]=t + else + bm[action]=bm[action]+t + end + bmlt=bmlt+t +end +function endstep() + if not benchmark then return end + bmsteps=bmsteps-1 + if bmsteps<=0 then + bmsteps=bmstepint + for key, value in pairs(bm) do + minetest.chat_send_all(key.." "..(value/bmstepint).." ms avg.") + end + minetest.chat_send_all("Total time consumed by all advtrains actions per step: "..(bmlt/bmstepint).." ms avg.") + bm={} + bmlt=0 + end +end + +--TODO: these values need to be integrated when i remove traintypes. +advtrains.train_accel_force=2--per second and divided by number of wagons +advtrains.train_brake_force=3--per second, not divided by number of wagons +advtrains.train_roll_force=0.5--per second, not divided by number of wagons, acceleration when rolling without brake +advtrains.train_emerg_force=10--for emergency brakes(when going off track) + +advtrains.audit_interval=30 + +advtrains.all_traintypes={} +function advtrains.register_train_type(name, drives_on, max_speed) + advtrains.all_traintypes[name]={} + advtrains.all_traintypes[name].drives_on=drives_on + advtrains.all_traintypes[name].max_speed=max_speed or 10 +end + + +advtrains.trains={} +advtrains.wagon_save={} + +--load initially +advtrains.fpath=minetest.get_worldpath().."/advtrains" +local file, err = io.open(advtrains.fpath, "r") +if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed loading advtrains save file "..er) +else + local tbl = minetest.deserialize(file:read("*a")) + if type(tbl) == "table" then + advtrains.trains=tbl + end + file:close() +end +advtrains.fpath_ws=minetest.get_worldpath().."/advtrains_wagon_save" +local file, err = io.open(advtrains.fpath_ws, "r") +if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed loading advtrains save file "..er) +else + local tbl = minetest.deserialize(file:read("*a")) + if type(tbl) == "table" then + advtrains.wagon_save=tbl + end + file:close() +end + + +advtrains.save = function() + --print("[advtrains]saving") + advtrains.invalidate_all_paths() + local datastr = minetest.serialize(advtrains.trains) + if not datastr then + minetest.log("error", "[advtrains] Failed to serialize train data!") + return + end + local file, err = io.open(advtrains.fpath, "w") + if err then + return err + end + file:write(datastr) + file:close() + + -- update wagon saves + for _,wagon in pairs(minetest.luaentities) do + if wagon.is_wagon and wagon.initialized then + wagon:get_staticdata() + end + end + --cross out userdata + for w_id, data in pairs(advtrains.wagon_save) do + data.name=nil + data.object=nil + if data.driver then + data.driver_name=data.driver:get_player_name() + data.driver=nil + else + data.driver_name=nil + end + if data.discouple then + data.discouple.object:remove() + data.discouple=nil + end + end + --print(dump(advtrains.wagon_save)) + datastr = minetest.serialize(advtrains.wagon_save) + if not datastr then + minetest.log("error", "[advtrains] Failed to serialize train data!") + return + end + file, err = io.open(advtrains.fpath_ws, "w") + if err then + return err + end + file:write(datastr) + file:close() + + advtrains.save_trackdb() +end +minetest.register_on_shutdown(advtrains.save) + +advtrains.save_and_audit_timer=advtrains.audit_interval +minetest.register_globalstep(function(dtime) + advtrains.save_and_audit_timer=advtrains.save_and_audit_timer-dtime + if advtrains.save_and_audit_timer<=0 then + local t=os.clock() + --print("[advtrains] audit step") + --clean up orphaned trains + for k,v in pairs(advtrains.trains) do + --advtrains.update_trainpart_properties(k) + if #v.trainparts==0 then + print("[advtrains][train "..k.."] has empty trainparts, removing.") + advtrains.trains[k]=nil + end + end + --save + advtrains.save() + advtrains.save_and_audit_timer=advtrains.audit_interval + printbm("saving", t) + end + --regular train step + local t=os.clock() + for k,v in pairs(advtrains.trains) do + advtrains.train_step(k, v, dtime) + end + + --see tracks.lua + if advtrains.detector.clean_step_before then + advtrains.detector.finalize_restore() + end + + printbm("trainsteps", t) + endstep() +end) + +function advtrains.train_step(id, train, dtime) + + --TODO check for all vars to be present + if not train.velocity then + train.velocity=0 + end + if not train.movedir or (train.movedir~=1 and train.movedir~=-1) then + train.movedir=1 + end + --very unimportant thing: check if couple is here + if train.couple_eid_front and (not minetest.luaentities[train.couple_eid_front] or not minetest.luaentities[train.couple_eid_front].is_couple) then train.couple_eid_front=nil end + if train.couple_eid_back and (not minetest.luaentities[train.couple_eid_back] or not minetest.luaentities[train.couple_eid_back].is_couple) then train.couple_eid_back=nil end + + --skip certain things (esp. collision) when not moving + local train_moves=(train.velocity~=0) + + --if not train.last_pos then advtrains.trains[id]=nil return end + + if not advtrains.pathpredict(id, train) then + print("pathpredict failed(returned false)") + train.velocity=0 + train.tarvelocity=0 + return + end + + local path=advtrains.get_or_create_path(id, train) + if not path then + train.velocity=0 + train.tarvelocity=0 + print("train has no path for whatever reason") + return + end + + local train_end_index=advtrains.get_train_end_index(train) + --apply off-track handling: + local front_off_track=train.max_index_on_track and train.index>train.max_index_on_track + local back_off_track=train.min_index_on_track and train_end_index1 then train.tarvelocity=1 end + elseif front_off_track then--allow movement only backward + if train.movedir==1 and train.tarvelocity>0 then train.tarvelocity=0 end + if train.movedir==-1 and train.tarvelocity>1 then train.tarvelocity=1 end + elseif back_off_track then--allow movement only forward + if train.movedir==-1 and train.tarvelocity>0 then train.tarvelocity=0 end + if train.movedir==1 and train.tarvelocity>1 then train.tarvelocity=1 end + end + + --update advtrains.detector + if not train.detector_old_index then + train.detector_old_index = math.floor(train_end_index) + train.detector_old_end_index = math.floor(train_end_index) + end + local ifo, ifn, ibo, ibn = train.detector_old_index, math.floor(train.index), train.detector_old_end_index, math.floor(train_end_index) + if ifn>ifo then + for i=ifo, ifn do + if path[i] then + advtrains.detector.enter_node(path[i], id) + end + end + elseif ifnibo then + for i=ibo, ibn do + if path[i] then + advtrains.detector.leave_node(path[i], id) + end + end + end + train.detector_old_index = math.floor(train.index) + train.detector_old_end_index = math.floor(train_end_index) + + if train_moves then + --check for collisions by finding objects + --front + local search_radius=4 + + --coupling + local couple_outward=1 + local posfront=advtrains.get_real_index_position(path, train.index+couple_outward) + local posback=advtrains.get_real_index_position(path, train_end_index-couple_outward) + for _,pos in ipairs({posfront, posback}) do + if pos then + local objrefs=minetest.get_objects_inside_radius(pos, search_radius) + for _,v in pairs(objrefs) do + local le=v:get_luaentity() + if le and le.is_wagon and le.initialized and le.train_id~=id then + advtrains.try_connect_trains(id, le.train_id) + end + end + end + end + --heh, new collision again. + --this time, based on NODES and the advtrains.detector.on_node table. + local collpos + local coll_grace=1 + if train.movedir==1 then + collpos=advtrains.get_real_index_position(path, train.index-coll_grace) + else + collpos=advtrains.get_real_index_position(path, train_end_index+coll_grace) + end + if collpos then + local rcollpos=advtrains.round_vector_floor_y(collpos) + for x=-1,1 do + for z=-1,1 do + local testpts=minetest.pos_to_string(vector.add(rcollpos, {x=x, y=0, z=z})) + if advtrains.detector.on_node[testpts] and advtrains.detector.on_node[testpts]~=id then + --collides + train.recently_collided_with_env=true + train.velocity=0.5*train.velocity + train.movedir=train.movedir*-1 + train.tarvelocity=0 + end + end + end + end + end + --check for any trainpart entities if they have been unloaded. do this only if train is near a player, to not spawn entities into unloaded areas + train.check_trainpartload=(train.check_trainpartload or 0)-dtime + local node_range=(math.max((minetest.setting_get("active_block_range") or 0),1)*16) + if train.check_trainpartload<=0 then + local ori_pos=advtrains.get_real_index_position(path, train.index) --not much to calculate + print("[advtrains][train "..id.."] at "..minetest.pos_to_string(vector.round(ori_pos))) + + local should_check=false + for _,p in ipairs(minetest.get_connected_players()) do + should_check=should_check or ((vector.distance(ori_pos, p:getpos())0 then--accelerating, force will be brought on only by locomotives. + --print("accelerating with default force") + applydiff=(math.min((advtrains.train_accel_force*train.locomotives_in_train*dtime)/mass, math.abs(diff))) + else--decelerating + if front_off_track or back_off_track or train.recently_collided_with_env then --every wagon has a brake, so not divided by mass. + --print("braking with emergency force") + applydiff= -(math.min((advtrains.train_emerg_force*dtime), math.abs(diff))) + elseif train.brake then + --print("braking with default force") + --no math.min, because it can grow beyond tarvelocity, see up there + --dont worry, it will never fall below zero. + applydiff= -((advtrains.train_brake_force*dtime)) + else + --print("roll") + applydiff= -(math.min((advtrains.train_roll_force*dtime), math.abs(diff))) + end + end + train.last_accel=(applydiff*train.movedir) + train.velocity=math.min(math.max( train.velocity+applydiff , 0), advtrains.all_traintypes[train.traintype].max_speed) + else + train.last_accel=0 + end + + --move + --TODO 3,5 + 0.7 + train.index=train.index and train.index+(((train.velocity*train.movedir)/(train.path_dist[math.floor(train.index)] or 1))*dtime) or 0 + +end + + +--structure of train table: +--[[ +trains={ + [train_id]={ + trainparts={ + [n]=wagon_id + } + path={path} + velocity + tarvelocity + index + trainlen + path_inv_level + last_pos | + last_dir | for pathpredicting. + } +} +--a wagon itself has the following properties: +wagon={ + unique_id + train_id + pos_in_train (is index difference, including train_span stuff) + pos_in_trainparts (is index in trainparts tabel of trains) +} +inherited by metatable: +wagon_proto={ + wagon_span +} +]] + +--returns new id +function advtrains.create_new_train_at(pos, pos_prev, traintype) + local newtrain_id=os.time()..os.clock() + while advtrains.trains[newtrain_id] do newtrain_id=os.time()..os.clock() end--ensure uniqueness(will be unneccessary) + + advtrains.trains[newtrain_id]={} + advtrains.trains[newtrain_id].last_pos=pos + advtrains.trains[newtrain_id].last_pos_prev=pos_prev + advtrains.trains[newtrain_id].traintype=traintype + advtrains.trains[newtrain_id].tarvelocity=0 + advtrains.trains[newtrain_id].velocity=0 + advtrains.trains[newtrain_id].trainparts={} + return newtrain_id +end + +--returns false on failure. handle this case! +function advtrains.pathpredict(id, train) + + --print("pos ",x,y,z) + --::rerun:: + if not train.index then train.index=0 end + if not train.path or #train.path<2 then + if not train.last_pos then + --no chance to recover + print("[advtrains]train hasn't saved last-pos, removing train.") + advtrains.train[id]=nil + return false + end + + local node_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(train.last_pos), train.traintype) + + if node_ok==nil then + --block not loaded, do nothing + return nil + elseif node_ok==false then + print("[advtrains]no track here, (fail) removing train.") + advtrains.trains[id]=nil + return false + end + + if not train.last_pos_prev then + --no chance to recover + print("[advtrains]train hasn't saved last-pos_prev, removing train.") + advtrains.trains[id]=nil + return false + end + + local prevnode_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(train.last_pos_prev), train.traintype) + + if prevnode_ok==nil then + --block not loaded, do nothing + return nil + elseif prevnode_ok==false then + print("[advtrains]no track at prev, (fail) removing train.") + advtrains.trains[id]=nil + return false + end + + train.index=(train.restore_add_index or 0)+(train.savedpos_off_track_index_offset or 0) + --restore_add_index is set by save() to prevent trains hopping to next round index. should be between -0.5 and 0.5 + --savedpos_off_track_index_offset is set if train went off track. see below. + train.path={} + train.path_dist={} + train.path[0]=train.last_pos + train.path[-1]=train.last_pos_prev + train.path_dist[-1]=vector.distance(train.last_pos, train.last_pos_prev) + end + + local pregen_front=2 + local pregen_back=2 + if train.velocity>0 then + if train.movedir>0 then + pregen_front=2+math.ceil(train.velocity*0.15) --assumes server step of 0.1 seconds, +50% tolerance + else + pregen_back=2+math.ceil(train.velocity*0.15) + end + end + + + local maxn=advtrains.maxN(train.path) + while (maxn-train.index) < pregen_front do--pregenerate + --print("[advtrains]maxn conway for ",maxn,minetest.pos_to_string(path[maxn]),maxn-1,minetest.pos_to_string(path[maxn-1])) + local conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.traintype) + if conway then + train.path[maxn+1]=conway + train.max_index_on_track=maxn + else + --do as if nothing has happened and preceed with path + --but do not update max_index_on_track + --print("over-generating path max to index "..maxn+1) + train.path[maxn+1]=vector.add(train.path[maxn], vector.subtract(train.path[maxn], train.path[maxn-1])) + end + train.path_dist[maxn]=vector.distance(train.path[maxn+1], train.path[maxn]) + maxn=advtrains.maxN(train.path) + end + + local minn=advtrains.minN(train.path) + while (train.index-minn) < (train.trainlen or 0) + pregen_back do --post_generate. has to be at least trainlen. (we let go of the exact calculation here since this would be unuseful here) + --print("[advtrains]minn conway for ",minn,minetest.pos_to_string(path[minn]),minn+1,minetest.pos_to_string(path[minn+1])) + local conway=advtrains.conway(train.path[minn], train.path[minn+1], train.traintype) + if conway then + train.path[minn-1]=conway + train.min_index_on_track=minn + else + --do as if nothing has happened and preceed with path + --but do not update min_index_on_track + --print("over-generating path min to index "..minn-1) + train.path[minn-1]=vector.add(train.path[minn], vector.subtract(train.path[minn], train.path[minn+1])) + end + train.path_dist[minn-1]=vector.distance(train.path[minn], train.path[minn-1]) + minn=advtrains.minN(train.path) + end + if not train.min_index_on_track then train.min_index_on_track=0 end + if not train.max_index_on_track then train.max_index_on_track=0 end + + --make pos/yaw available for possible recover calls + if train.max_index_on_tracktrain.index then --whoops, train went even more far. same behavior + train.savedpos_off_track_index_offset=train.index-train.min_index_on_track + train.last_pos=train.path[train.min_index_on_track+1] + train.last_pos_prev=train.path[train.min_index_on_track] + --print("train is off-track (back), last positions kept at "..minetest.pos_to_string(train.last_pos).." / "..minetest.pos_to_string(train.last_pos_prev)) + else --regular case + train.savedpos_off_track_index_offset=nil + train.last_pos=train.path[math.floor(train.index+0.5)] + train.last_pos_prev=train.path[math.floor(train.index-0.5)] + end + return train.path +end +function advtrains.get_train_end_index(train) + return advtrains.get_real_path_index(train, train.trainlen or 2)--this function can be found inside wagons.lua since it's more related to wagons. we just set trainlen as pos_in_train +end + +function advtrains.get_or_create_path(id, train) + if not train.path then return advtrains.pathpredict(id, train) end + return train.path +end + +function advtrains.add_wagon_to_train(wagon, train_id, index) + local train=advtrains.trains[train_id] + if index then + table.insert(train.trainparts, index, wagon.unique_id) + else + table.insert(train.trainparts, wagon.unique_id) + end + --this is not the usual case!!! + --we may set initialized because the wagon has no chance to step() + wagon.initialized=true + --TODO is this art or can we throw it away? + advtrains.update_trainpart_properties(train_id) +end +function advtrains.update_trainpart_properties(train_id, invert_flipstate) + local train=advtrains.trains[train_id] + local rel_pos=0 + local count_l=0 + for i, w_id in ipairs(train.trainparts) do + local any_loaded=false + for _,wagon in pairs(minetest.luaentities) do + if wagon.is_wagon and wagon.initialized and wagon.unique_id==w_id then + rel_pos=rel_pos+wagon.wagon_span + wagon.train_id=train_id + wagon.pos_in_train=rel_pos + wagon.pos_in_trainparts=i + wagon.old_velocity_vector=nil + if wagon.is_locomotive then + count_l=count_l+1 + end + if invert_flipstate then + wagon.wagon_flipped = not wagon.wagon_flipped + end + rel_pos=rel_pos+wagon.wagon_span + any_loaded=true + end + end + if not any_loaded then + print("update_trainpart_properties wagon "..w_id.." not loaded, ignoring it.") + end + end + train.trainlen=rel_pos + train.locomotives_in_train=count_l +end + +function advtrains.split_train_at_wagon(wagon) + --get train + local train=advtrains.trains[wagon.train_id] + local real_pos_in_train=advtrains.get_real_path_index(train, wagon.pos_in_train) + local pos_for_new_train=advtrains.get_or_create_path(wagon.train_id, train)[math.floor(real_pos_in_train+wagon.wagon_span)] + local pos_for_new_train_prev=advtrains.get_or_create_path(wagon.train_id, train)[math.floor(real_pos_in_train-1+wagon.wagon_span)] + + --before doing anything, check if both are rails. else do not allow + if not pos_for_new_train then + print("split_train: pos_for_new_train not set") + return false + end + local node_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.traintype) + if not node_ok then + print("split_train: pos_for_new_train "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") + return false + end + + if not train.last_pos_prev then + print("split_train: pos_for_new_train_prev not set") + return false + end + + local prevnode_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.traintype) + if not prevnode_ok then + print("split_train: pos_for_new_train_prev "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") + return false + end + + --create subtrain + local newtrain_id=advtrains.create_new_train_at(pos_for_new_train, pos_for_new_train_prev, train.traintype) + local newtrain=advtrains.trains[newtrain_id] + --insert all wagons to new train + for k,v in ipairs(train.trainparts) do + if k>=wagon.pos_in_trainparts then + table.insert(newtrain.trainparts, v) + train.trainparts[k]=nil + end + end + --update train parts + advtrains.update_trainpart_properties(wagon.train_id)--atm it still is the desierd id. + advtrains.update_trainpart_properties(newtrain_id) + train.tarvelocity=0 + newtrain.velocity=train.velocity + newtrain.tarvelocity=0 +end + +--there are 4 cases: +--1/2. F<->R F<->R regular, put second train behind first +--->frontpos of first train will match backpos of second +--3. F<->R R<->F flip one of these trains, take the other as new train +--->backpos's will match +--4. R<->F F<->R flip one of these trains and take it as new parent +--->frontpos's will match +function advtrains.try_connect_trains(id1, id2) + local train1=advtrains.trains[id1] + local train2=advtrains.trains[id2] + if not train1 or not train2 then return end + if not train1.path or not train2.path then return end + if #train1.trainparts==0 or #train2.trainparts==0 then return end + + local frontpos1=advtrains.get_real_index_position(train1.path, train1.index) + local backpos1=advtrains.get_real_index_position(train1.path, advtrains.get_train_end_index(train1)) + --couple logic + if train1.traintype==train2.traintype then + local frontpos2=advtrains.get_real_index_position(train2.path, train2.index) + local backpos2=advtrains.get_real_index_position(train2.path, advtrains.get_train_end_index(train2)) + + if not frontpos1 or not frontpos2 or not backpos1 or not backpos2 then return end + + local couple_spawnradius=0.7 + --case 1 (first train is front) + if vector.distance(frontpos2, backpos1)1 then + if gp.velocity==0 then + if not self.discouple or not self.discouple.object:getyaw() then + local object=minetest.add_entity(pos, "advtrains:discouple") + if object then + local le=object:get_luaentity() + le.wagon=self + --box is hidden when attached, so unuseful. + --object:set_attach(self.object, "", {x=0, y=0, z=self.wagon_span*10}, {x=0, y=0, z=0}) + self.discouple=le + else + print("Couldn't spawn DisCouple") + end + end + else + if self.discouple and self.discouple.object:getyaw() then + self.discouple.object:remove() + end + end + end + --for path to be available. if not, skip step + if not advtrains.get_or_create_path(self.train_id, gp) then + self.object:setvelocity({x=0, y=0, z=0}) + return + end + if not self.pos_in_train then + --why ever. but better continue next step... + advtrains.update_trainpart_properties(self.train_id) + return + end + + local index=advtrains.get_real_path_index(self:train(), self.pos_in_train) + --print("trainindex "..gp.index.." wagonindex "..index) + + --position recalculation + local first_pos=gp.path[math.floor(index)] + local second_pos=gp.path[math.floor(index)+1] + if not first_pos or not second_pos then + --print("[advtrains] object "..self.unique_id.." path end reached!") + self.object:setvelocity({x=0,y=0,z=0}) + return + end + + --checking for environment collisions(a 3x3 cube around the center) + if not gp.recently_collided_with_env then + local collides=false + for x=-1,1 do + for y=0,2 do + for z=-1,1 do + local node=minetest.get_node_or_nil(vector.add(first_pos, {x=x, y=y, z=z})) + if (advtrains.train_collides(node)) then + collides=true + end + end + end + end + if collides then + gp.recently_collided_with_env=true + gp.velocity=-0.5*gp.velocity + gp.tarvelocity=0 + end + end + + --FIX: use index of the wagon, not of the train. + local velocity=(gp.velocity*gp.movedir)/(gp.path_dist[math.floor(index)] or 1) + local acceleration=(gp.last_accel or 0)/(gp.path_dist[math.floor(index)] or 1) + local factor=index-math.floor(index) + local actual_pos={x=first_pos.x-(first_pos.x-second_pos.x)*factor, y=first_pos.y-(first_pos.y-second_pos.y)*factor, z=first_pos.z-(first_pos.z-second_pos.z)*factor,} + local velocityvec={x=(first_pos.x-second_pos.x)*velocity*-1, z=(first_pos.z-second_pos.z)*velocity*-1, y=(first_pos.y-second_pos.y)*velocity*-1} + local accelerationvec={x=(first_pos.x-second_pos.x)*acceleration*-1, z=(first_pos.z-second_pos.z)*acceleration*-1, y=(first_pos.y-second_pos.y)*acceleration*-1} + + --some additional positions to determine orientation + local aposfwd=gp.path[math.floor(index+2)] + local aposbwd=gp.path[math.floor(index-1)] + + local yaw + if aposfwd and aposbwd then + yaw=advtrains.get_wagon_yaw(aposfwd, second_pos, first_pos, aposbwd, factor)+math.pi--TODO remove when cleaning up + else + yaw=math.atan2((first_pos.x-second_pos.x), (second_pos.z-first_pos.z)) + end + if self.wagon_flipped then + yaw=yaw+math.pi + end + + self.updatepct_timer=(self.updatepct_timer or 0)-dtime + if not self.old_velocity_vector + or not vector.equals(velocityvec, self.old_velocity_vector) + or not self.old_acceleration_vector + or not vector.equals(accelerationvec, self.old_acceleration_vector) + or self.old_yaw~=yaw + or self.updatepct_timer<=0 then--only send update packet if something changed + self.object:setpos(actual_pos) + self.object:setvelocity(velocityvec) + self.object:setacceleration(accelerationvec) + self.object:setyaw(yaw) + self.updatepct_timer=2 + if self.update_animation then + self:update_animation(gp.velocity) + end + end + + + self.old_velocity_vector=velocityvec + self.old_acceleration_vector=accelerationvec + self.old_yaw=yaw + printbm("wagon step", t) +end + +function advtrains.get_real_path_index(train, pit) + local pos_in_train_left=pit + local index=train.index + if pos_in_train_left>(index-math.floor(index))*(train.path_dist[math.floor(index)] or 1) then + pos_in_train_left=pos_in_train_left - (index-math.floor(index))*(train.path_dist[math.floor(index)] or 1) + index=math.floor(index) + while pos_in_train_left>(train.path_dist[index-1] or 1) do + pos_in_train_left=pos_in_train_left - (train.path_dist[index-1] or 1) + index=index-1 + end + index=index-(pos_in_train_left/(train.path_dist[index-1] or 1)) + else + index=index-(pos_in_train_left/(train.path_dist[math.floor(index-1)] or 1)) + end + return index +end + +function wagon:get_on(clicker, seatno) + if not self.seatp then + self.seatp={} + end + if not self.seats[seatno] then return end + if self.seatp[seatno] and self.seatp[seatno]~=clicker:get_player_name() then + self:get_off(seatno) + end + self.seatp[seatno] = clicker:get_player_name() + advtrains.player_to_train_mapping[clicker:get_player_name()]=self.train_id + clicker:set_attach(self.object, "", self.seats[seatno].attach_offset, {x=0,y=0,z=0}) + clicker:set_eye_offset(self.seats[seatno].view_offset, self.seats[seatno].view_offset) +end +function wagon:get_off_plr(pname) + local no=self:get_seatno(pname) + if no then + self:get_off(no) + end +end +function wagon:get_seatno(pname) + for no, cont in pairs(self.seatp) do + if cont==pname then + return no + end + end + return nil +end +function wagon:get_off(seatno) + if not self.seatp[seatno] then return end + local pname = self.seatp[seatno] + local clicker = minetest.get_player_by_name(pname) + advtrains.player_to_train_mapping[pname]=nil + advtrains.clear_driver_hud(pname) + if clicker then + clicker:set_detach() + clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0}) + local objpos=advtrains.round_vector_floor_y(self.object:getpos()) + local yaw=self.object:getyaw() + local isx=(yaw < math.pi/4) or (yaw > 3*math.pi/4 and yaw < 5*math.pi/4) or (yaw > 7*math.pi/4) + --abuse helper function + for _,r in ipairs({-1, 1}) do + local p=vector.add({x=isx and r or 0, y=0, z=not isx and r or 0}, objpos) + if minetest.get_item_group(minetest.get_node(p).name, "platform")>0 then + minetest.after(0.2, function() clicker:setpos({x=p.x, y=p.y+1, z=p.z}) end) + end + end + end + self.seatp[seatno]=nil +end +function wagon:show_get_on_form(pname) + if not self.initialized then return end + if #self.seats==0 then + if self.has_inventory and self.get_inventory_formspec then + minetest.show_formspec(pname, "advtrains_inv_"..self.unique_id, self:get_inventory_formspec()) + end + return + end + local form, comma="size[5,8]label[0.5,0.5;Select seat:]textlist[0.5,1;4,6;seat;", "" + for seatno, seattbl in ipairs(self.seats) do + local addtext, colorcode="", "" + if self.seatp and self.seatp[seatno] then + colorcode="#FF0000" + addtext=" ("..self.seatp[seatno]..")" + end + form=form..comma..colorcode..seattbl.name..addtext + comma="," + end + form=form..";0,false]" + if self.has_inventory and self.get_inventory_formspec then + form=form.."button_exit[1,7;3,1;inv;Show Inventory]" + end + minetest.show_formspec(pname, "advtrains_geton_"..self.unique_id, form) +end +minetest.register_on_player_receive_fields(function(player, formname, fields) + local uid=string.match(formname, "^advtrains_geton_(.+)$") + if uid then + for _,wagon in pairs(minetest.luaentities) do + if wagon.is_wagon and wagon.initialized and wagon.unique_id==uid then + if fields.inv then + if wagon.has_inventory and wagon.get_inventory_formspec then + minetest.show_formspec(player:get_player_name(), "advtrains_inv_"..uid, wagon:get_inventory_formspec()) + end + elseif fields.seat then + local val=minetest.explode_textlist_event(fields.seat) + if val and val.type~="INV" and not self.seatp[player:get_player_name()] then + --get on + wagon:get_on(player, val.index) + --will work with the new close_formspec functionality. close exactly this formspec. + minetest.show_formspec(player:get_player_name(), formname, "") + end + end + end + end + end +end) +function wagon:reattach_all() + if not self.seatp then self.seatp={} end + for seatno, pname in pairs(self.seatp) do + local p=minetest.get_player_by_name(pname) + if p then + self:get_on(p ,seatno) + end + end +end +minetest.register_on_joinplayer(function(player) + for _,wagon in pairs(minetest.luaentities) do + if wagon.is_wagon and wagon.initialized then + wagon:reattach_all() + end + end +end) + +function advtrains.register_wagon(sysname, traintype, prototype, desc, inv_img) + setmetatable(prototype, {__index=wagon}) + minetest.register_entity(":advtrains:"..sysname,prototype) + + minetest.register_craftitem(":advtrains:"..sysname, { + description = desc, + inventory_image = inv_img, + wield_image = inv_img, + stack_max = 1, + + on_place = function(itemstack, placer, pointed_thing) + if not pointed_thing.type == "node" then + return + end + + local node=minetest.env:get_node_or_nil(pointed_thing.under) + if not node then print("[advtrains]Ignore at placer position") return itemstack end + local nodename=node.name + if(not advtrains.is_track_and_drives_on(nodename, advtrains.all_traintypes[traintype].drives_on)) then + print("[advtrains]no track here, not placing.") + return itemstack + end + local conn1=advtrains.get_track_connections(node.name, node.param2) + local id=advtrains.create_new_train_at(pointed_thing.under, advtrains.dirCoordSet(pointed_thing.under, conn1), traintype) + + local ob=minetest.env:add_entity(pointed_thing.under, "advtrains:"..sysname) + if not ob then + print("[advtrains]couldn't add_entity, aborting") + end + local le=ob:get_luaentity() + + le.owner=placer:get_player_name() + le.infotext=desc..", owned by "..placer:get_player_name() + + local wagon_uid=le:init_new_instance(id, {}) + + advtrains.add_wagon_to_train(le, id) + if not minetest.setting_getbool("creative_mode") then + itemstack:take_item() + end + return itemstack + + end, + }) +end +advtrains.register_train_type("steam", {"regular", "default"}) + +--[[advtrains.register_wagon("blackwagon", "steam",{textures = {"black.png"}}) +advtrains.register_wagon("bluewagon", "steam",{textures = {"blue.png"}}) +advtrains.register_wagon("greenwagon", "steam",{textures = {"green.png"}}) +advtrains.register_wagon("redwagon", "steam",{textures = {"red.png"}}) +advtrains.register_wagon("yellowwagon", "steam",{textures = {"yellow.png"}}) +]] + +--[[ + wagons can define update_animation(self, velocity) if they have a speed-dependent animation + this function will be called when the velocity vector changes or every 2 seconds. +]] + + +advtrains.register_train_type("electric", {"regular", "default"}, 20) + + + +advtrains.register_train_type("subway", {"default"}, 15) + +advtrains.register_wagon("subway_wagon", "subway",{ + mesh="advtrains_subway_train.b3d", + textures = {"advtrains_subway_train.png"}, + seats = { + { + name="Default Seat (driver stand)", + attach_offset={x=0, y=10, z=0}, + view_offset={x=0, y=6, z=0}, + driving_ctrl_access=true, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=1.8, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + is_locomotive=true, + drops={"default:steelblock 4"}, +}, "Subway Passenger Wagon", "advtrains_subway_train_inv.png") + + + diff --git a/advtrains_train_industrial/depends.txt b/advtrains_train_industrial/depends.txt new file mode 100644 index 0000000..6f00bf6 --- /dev/null +++ b/advtrains_train_industrial/depends.txt @@ -0,0 +1 @@ +advtrains \ No newline at end of file diff --git a/advtrains_train_industrial/init.lua b/advtrains_train_industrial/init.lua new file mode 100644 index 0000000..93c75af --- /dev/null +++ b/advtrains_train_industrial/init.lua @@ -0,0 +1,61 @@ +advtrains.register_wagon("engine_industrial", "electric",{ + mesh="advtrains_engine_industrial.b3d", + textures = {"advtrains_engine_industrial.png"}, + seats = { + { + name="Driver Stand (left)", + attach_offset={x=-5, y=10, z=-10}, + view_offset={x=0, y=10, z=0}, + driving_ctrl_access=true, + }, + { + name="Driver Stand (right)", + attach_offset={x=5, y=10, z=-10}, + view_offset={x=0, y=10, z=0}, + driving_ctrl_access=true, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=2.6, + is_locomotive=true, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, +}, "Industrial Train Engine", "advtrains_engine_industrial_inv.png") +advtrains.register_wagon("wagon_tank", "electric",{ + mesh="advtrains_wagon_tank.b3d", + textures = {"advtrains_wagon_tank.png"}, + seats = {}, + visual_size = {x=1, y=1}, + wagon_span=2.2, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, + has_inventory = true, + get_inventory_formspec = function(self) + return "size[8,11]".. + "list[detached:advtrains_wgn_"..self.unique_id..";box;0,0;8,6;]".. + "list[current_player;main;0,7;8,4;]".. + "listring[]" + end, + inventory_list_sizes = { + box=8*6, + }, +}, "Industrial tank wagon", "advtrains_wagon_tank_inv.png") +advtrains.register_wagon("wagon_wood", "electric",{ + mesh="advtrains_wagon_wood.b3d", + textures = {"advtrains_wagon_wood.png"}, + seats = {}, + visual_size = {x=1, y=1}, + wagon_span=1.8, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, + has_inventory = true, + get_inventory_formspec = function(self) + return "size[8,11]".. + "list[detached:advtrains_wgn_"..self.unique_id..";box;0,0;8,6;]".. + "list[current_player;main;0,7;8,4;]".. + "listring[]" + end, + inventory_list_sizes = { + box=8*6, + }, +}, "Industrial wood wagon", "advtrains_wagon_wood_inv.png") diff --git a/advtrains_train_industrial/models/advtrains_engine_industrial.b3d b/advtrains_train_industrial/models/advtrains_engine_industrial.b3d new file mode 100644 index 0000000..f1ea485 Binary files /dev/null and b/advtrains_train_industrial/models/advtrains_engine_industrial.b3d differ diff --git a/advtrains_train_industrial/models/advtrains_wagon_tank.b3d b/advtrains_train_industrial/models/advtrains_wagon_tank.b3d new file mode 100644 index 0000000..af2604b Binary files /dev/null and b/advtrains_train_industrial/models/advtrains_wagon_tank.b3d differ diff --git a/advtrains_train_industrial/models/advtrains_wagon_wood.b3d b/advtrains_train_industrial/models/advtrains_wagon_wood.b3d new file mode 100644 index 0000000..0e7fb4b Binary files /dev/null and b/advtrains_train_industrial/models/advtrains_wagon_wood.b3d differ diff --git a/advtrains_train_industrial/textures/advtrains_engine_industrial.png b/advtrains_train_industrial/textures/advtrains_engine_industrial.png new file mode 100644 index 0000000..38a872f Binary files /dev/null and b/advtrains_train_industrial/textures/advtrains_engine_industrial.png differ diff --git a/advtrains_train_industrial/textures/advtrains_engine_industrial_inv.png b/advtrains_train_industrial/textures/advtrains_engine_industrial_inv.png new file mode 100644 index 0000000..be4e80f Binary files /dev/null and b/advtrains_train_industrial/textures/advtrains_engine_industrial_inv.png differ diff --git a/advtrains_train_industrial/textures/advtrains_wagon_tank.png b/advtrains_train_industrial/textures/advtrains_wagon_tank.png new file mode 100644 index 0000000..79b1316 Binary files /dev/null and b/advtrains_train_industrial/textures/advtrains_wagon_tank.png differ diff --git a/advtrains_train_industrial/textures/advtrains_wagon_tank_inv.png b/advtrains_train_industrial/textures/advtrains_wagon_tank_inv.png new file mode 100644 index 0000000..03401be Binary files /dev/null and b/advtrains_train_industrial/textures/advtrains_wagon_tank_inv.png differ diff --git a/advtrains_train_industrial/textures/advtrains_wagon_wood.png b/advtrains_train_industrial/textures/advtrains_wagon_wood.png new file mode 100644 index 0000000..acc6f72 Binary files /dev/null and b/advtrains_train_industrial/textures/advtrains_wagon_wood.png differ diff --git a/advtrains_train_industrial/textures/advtrains_wagon_wood_inv.png b/advtrains_train_industrial/textures/advtrains_wagon_wood_inv.png new file mode 100644 index 0000000..87109dd Binary files /dev/null and b/advtrains_train_industrial/textures/advtrains_wagon_wood_inv.png differ diff --git a/advtrains_train_japan/depends.txt b/advtrains_train_japan/depends.txt new file mode 100644 index 0000000..6f00bf6 --- /dev/null +++ b/advtrains_train_japan/depends.txt @@ -0,0 +1 @@ +advtrains \ No newline at end of file diff --git a/advtrains_train_japan/init.lua b/advtrains_train_japan/init.lua new file mode 100644 index 0000000..7cef69c --- /dev/null +++ b/advtrains_train_japan/init.lua @@ -0,0 +1,34 @@ +advtrains.register_wagon("engine_japan", "electric",{ + mesh="advtrains_engine_japan.b3d", + textures = {"advtrains_engine_japan.png"}, + seats = { + { + name="Default Seat (driver stand)", + attach_offset={x=0, y=10, z=0}, + view_offset={x=0, y=6, z=0}, + driving_ctrl_access=true, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=2.5, + is_locomotive=true, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, +}, "Japanese Train Engine", "advtrains_engine_japan_inv.png") + +advtrains.register_wagon("wagon_japan", "electric",{ + mesh="advtrains_wagon_japan.b3d", + textures = {"advtrains_wagon_japan.png"}, + seats = { + { + name="Default Seat", + attach_offset={x=0, y=10, z=0}, + view_offset={x=0, y=6, z=0}, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=2.3, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, +}, "Japanese Train Wagon", "advtrains_wagon_japan_inv.png") + diff --git a/advtrains_train_japan/models/advtrains_engine_japan.b3d b/advtrains_train_japan/models/advtrains_engine_japan.b3d new file mode 100644 index 0000000..f82c33e Binary files /dev/null and b/advtrains_train_japan/models/advtrains_engine_japan.b3d differ diff --git a/advtrains_train_japan/models/advtrains_wagon_japan.b3d b/advtrains_train_japan/models/advtrains_wagon_japan.b3d new file mode 100644 index 0000000..7970438 Binary files /dev/null and b/advtrains_train_japan/models/advtrains_wagon_japan.b3d differ diff --git a/advtrains_train_japan/textures/advtrains_engine_japan.png b/advtrains_train_japan/textures/advtrains_engine_japan.png new file mode 100644 index 0000000..b286b38 Binary files /dev/null and b/advtrains_train_japan/textures/advtrains_engine_japan.png differ diff --git a/advtrains_train_japan/textures/advtrains_engine_japan_inv.png b/advtrains_train_japan/textures/advtrains_engine_japan_inv.png new file mode 100644 index 0000000..6af0636 Binary files /dev/null and b/advtrains_train_japan/textures/advtrains_engine_japan_inv.png differ diff --git a/advtrains_train_japan/textures/advtrains_wagon_japan.png b/advtrains_train_japan/textures/advtrains_wagon_japan.png new file mode 100644 index 0000000..bee565e Binary files /dev/null and b/advtrains_train_japan/textures/advtrains_wagon_japan.png differ diff --git a/advtrains_train_japan/textures/advtrains_wagon_japan_inv.png b/advtrains_train_japan/textures/advtrains_wagon_japan_inv.png new file mode 100644 index 0000000..3e6357c Binary files /dev/null and b/advtrains_train_japan/textures/advtrains_wagon_japan_inv.png differ diff --git a/advtrains_train_steam/depends.txt b/advtrains_train_steam/depends.txt new file mode 100644 index 0000000..6f00bf6 --- /dev/null +++ b/advtrains_train_steam/depends.txt @@ -0,0 +1 @@ +advtrains \ No newline at end of file diff --git a/advtrains_train_steam/init.lua b/advtrains_train_steam/init.lua new file mode 100644 index 0000000..7b66a51 --- /dev/null +++ b/advtrains_train_steam/init.lua @@ -0,0 +1,115 @@ +advtrains.register_wagon("newlocomotive", "steam",{ + mesh="advtrains_engine_steam.b3d", + textures = {"advtrains_newlocomotive.png"}, + is_locomotive=true, + seats = { + { + name="Driver Stand (left)", + attach_offset={x=-5, y=10, z=-10}, + view_offset={x=0, y=6, z=0}, + driving_ctrl_access=true, + }, + { + name="Driver Stand (right)", + attach_offset={x=5, y=10, z=-10}, + view_offset={x=0, y=6, z=0}, + driving_ctrl_access=true, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=1.85, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + update_animation=function(self, velocity) + --if self.old_anim_velocity~=advtrains.abs_ceil(velocity) then + self.object:set_animation({x=1,y=60}, 100)--math.floor(velocity)) + --self.old_anim_velocity=advtrains.abs_ceil(velocity) + --end + end, + custom_on_activate = function(self, staticdata_table, dtime_s) + minetest.add_particlespawner({ + amount = 10, + time = 0, + -- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base + minpos = {x=0, y=2, z=1.2}, + maxpos = {x=0, y=2, z=1.2}, + minvel = {x=-0.2, y=1.8, z=-0.2}, + maxvel = {x=0.2, y=2, z=0.2}, + minacc = {x=0, y=-0.1, z=0}, + maxacc = {x=0, y=-0.3, z=0}, + minexptime = 2, + maxexptime = 4, + minsize = 1, + maxsize = 5, + -- ^ The particle's properties are random values in between the bounds: + -- ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration), + -- ^ minsize/maxsize, minexptime/maxexptime (expirationtime) + collisiondetection = true, + -- ^ collisiondetection: if true uses collision detection + vertical = false, + -- ^ vertical: if true faces player using y axis only + texture = "smoke_puff.png", + -- ^ Uses texture (string) + attached = self.object, + }) + end, + drops={"default:steelblock 4"}, +}, "Steam Engine", "advtrains_newlocomotive_inv.png") +advtrains.register_wagon("wagon_default", "steam",{ + mesh="advtrains_wagon.b3d", + textures = {"advtrains_wagon.png"}, + seats = { + { + name="Default Seat", + attach_offset={x=0, y=10, z=0}, + view_offset={x=0, y=6, z=0}, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=1.8, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, +}, "Passenger Wagon", "advtrains_wagon_inv.png") +advtrains.register_wagon("wagon_box", "steam",{ + mesh="advtrains_wagon.b3d", + textures = {"advtrains_wagon_box.png"}, + seats = {}, + visual_size = {x=1, y=1}, + wagon_span=1.8, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, + has_inventory = true, + get_inventory_formspec = function(self) + return "size[8,11]".. + "list[detached:advtrains_wgn_"..self.unique_id..";box;0,0;8,6;]".. + "list[current_player;main;0,7;8,4;]".. + "listring[]" + end, + inventory_list_sizes = { + box=8*6, + }, +}, "Box Wagon", "advtrains_wagon_box_inv.png") + +minetest.register_craft({ + output = 'advtrains:newlocomotive', + recipe = { + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + {'default:steelblock', 'dye:black', 'default:steelblock'}, + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + }, +}) +minetest.register_craft({ + output = 'advtrains:wagon_default', + recipe = { + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + {'default:steelblock', 'dye:dark_green', 'default:steelblock'}, + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + }, +}) +minetest.register_craft({ + output = 'advtrains:wagon_box', + recipe = { + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + {'default:steelblock', 'default:chest', 'default:steelblock'}, + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + }, +}) diff --git a/advtrains_train_steam/models/advtrains_engine_steam.b3d b/advtrains_train_steam/models/advtrains_engine_steam.b3d new file mode 100644 index 0000000..36bdd15 Binary files /dev/null and b/advtrains_train_steam/models/advtrains_engine_steam.b3d differ diff --git a/advtrains_train_steam/models/advtrains_wagon.b3d b/advtrains_train_steam/models/advtrains_wagon.b3d new file mode 100644 index 0000000..5c8214c Binary files /dev/null and b/advtrains_train_steam/models/advtrains_wagon.b3d differ diff --git a/advtrains_train_steam/textures/advtrains_newlocomotive.png b/advtrains_train_steam/textures/advtrains_newlocomotive.png new file mode 100644 index 0000000..e461bc7 Binary files /dev/null and b/advtrains_train_steam/textures/advtrains_newlocomotive.png differ diff --git a/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png b/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png new file mode 100644 index 0000000..8d3fafb Binary files /dev/null and b/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png differ diff --git a/advtrains_train_steam/textures/advtrains_wagon.png b/advtrains_train_steam/textures/advtrains_wagon.png new file mode 100644 index 0000000..c37c979 Binary files /dev/null and b/advtrains_train_steam/textures/advtrains_wagon.png differ diff --git a/advtrains_train_steam/textures/advtrains_wagon_box.png b/advtrains_train_steam/textures/advtrains_wagon_box.png new file mode 100644 index 0000000..8bfbe06 Binary files /dev/null and b/advtrains_train_steam/textures/advtrains_wagon_box.png differ diff --git a/advtrains_train_steam/textures/advtrains_wagon_box_inv.png b/advtrains_train_steam/textures/advtrains_wagon_box_inv.png new file mode 100644 index 0000000..480f245 Binary files /dev/null and b/advtrains_train_steam/textures/advtrains_wagon_box_inv.png differ diff --git a/advtrains_train_steam/textures/advtrains_wagon_inv.png b/advtrains_train_steam/textures/advtrains_wagon_inv.png new file mode 100644 index 0000000..0b72ac3 Binary files /dev/null and b/advtrains_train_steam/textures/advtrains_wagon_inv.png differ diff --git a/advtrains_train_subway/depends.txt b/advtrains_train_subway/depends.txt new file mode 100644 index 0000000..6f00bf6 --- /dev/null +++ b/advtrains_train_subway/depends.txt @@ -0,0 +1 @@ +advtrains \ No newline at end of file diff --git a/advtrains_train_subway/init.lua b/advtrains_train_subway/init.lua new file mode 100644 index 0000000..c933fff --- /dev/null +++ b/advtrains_train_subway/init.lua @@ -0,0 +1,28 @@ + +advtrains.register_wagon("subway_wagon", "subway",{ + mesh="advtrains_subway_train.b3d", + textures = {"advtrains_subway_train.png"}, + seats = { + { + name="Default Seat (driver stand)", + attach_offset={x=0, y=10, z=0}, + view_offset={x=0, y=6, z=0}, + driving_ctrl_access=true, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=1.8, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + is_locomotive=true, + drops={"default:steelblock 4"}, +}, "Subway Passenger Wagon", "advtrains_subway_train_inv.png") + +--wagons +minetest.register_craft({ + output = 'advtrains:subway_wagon', + recipe = { + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + {'default:steelblock', 'dye:yellow', 'default:steelblock'}, + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + }, +}) diff --git a/advtrains_train_subway/models/advtrains_subway_train.b3d b/advtrains_train_subway/models/advtrains_subway_train.b3d new file mode 100644 index 0000000..a824d33 Binary files /dev/null and b/advtrains_train_subway/models/advtrains_subway_train.b3d differ diff --git a/advtrains_train_subway/textures/advtrains_subway_train.png b/advtrains_train_subway/textures/advtrains_subway_train.png new file mode 100644 index 0000000..1d569f3 Binary files /dev/null and b/advtrains_train_subway/textures/advtrains_subway_train.png differ diff --git a/advtrains_train_subway/textures/advtrains_subway_train_inv.png b/advtrains_train_subway/textures/advtrains_subway_train_inv.png new file mode 100644 index 0000000..1d0e809 Binary files /dev/null and b/advtrains_train_subway/textures/advtrains_subway_train_inv.png differ diff --git a/atc.lua b/atc.lua deleted file mode 100644 index 0afddb0..0000000 --- a/atc.lua +++ /dev/null @@ -1,4 +0,0 @@ ---atc.lua ---registers and controls the ATC system - ---(simple)mesecon detector rails diff --git a/couple.lua b/couple.lua deleted file mode 100644 index a846c8b..0000000 --- a/couple.lua +++ /dev/null @@ -1,154 +0,0 @@ ---couple.lua ---defines couple entities. - ---advtrains:discouple ---set into existing trains to split them when punched. ---they are attached to the wagons. ---[[fields -wagon - -wagons keep their couple entity minetest-internal id inside the field discouple_id. if it refers to nowhere, they will spawn a new one if player is near -]] -local print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end - - -minetest.register_entity("advtrains:discouple", { - visual="sprite", - textures = {"advtrains_discouple.png"}, - collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, - visual_size = {x=1, y=1}, - initial_sprite_basepos = {x=0, y=0}, - - is_discouple=true, - on_activate=function(self, staticdata) - if staticdata=="DISCOUPLE" then - --couple entities have no right to exist further... - self.object:remove() - return - end - self.object:set_armor_groups({immortal=1}) - end, - get_staticdata=function() return "DISCOUPLE" end, - on_punch=function(self, player) - --only if player owns at least one wagon next to this - local own=player:get_player_name() - if self.wagon.owner and self.wagon.owner~=own then - local train=advtrains.trains[self.wagon.train_id] - local nextwgn_id=train.trainparts[self.wagon.pos_in_trainparts-1] - for aoi, le in pairs(minetest.luaentities) do - if le and le.is_wagon then - if le.unique_id==nextwgn_id then - if le.owner and le.owner~=own then - minetest.chat_send_player(own, "You need to own at least one neighboring wagon to destroy this couple.") - return - end - end - end - end - end - advtrains.split_train_at_wagon(self.wagon)--found in trainlogic.lua - end, - on_step=function(self, dtime) - local t=os.clock() - if not self.wagon then - self.object:remove() - return - end - --getyaw seems to be a reliable method to check if an object is loaded...if it returns nil, it is not. - if not self.wagon.object:getyaw() then - self.object:remove() - return - end - local velocityvec=self.wagon.object:getvelocity() - self.updatepct_timer=(self.updatepct_timer or 0)-dtime - if not self.old_velocity_vector or not vector.equals(velocityvec, self.old_velocity_vector) or self.updatepct_timer<=0 then--only send update packet if something changed - local flipsign=self.wagon.wagon_flipped and -1 or 1 - self.object:setpos(vector.add(self.wagon.object:getpos(), {y=0, x=-math.sin(self.wagon.object:getyaw())*self.wagon.wagon_span*flipsign, z=math.cos(self.wagon.object:getyaw())*self.wagon.wagon_span*flipsign})) - self.object:setvelocity(velocityvec) - self.updatepct_timer=2 - end - printbm("discouple_step", t) - end, -}) - ---advtrains:couple ---when two trains overlap with their end-positions, this entity will be spawned and both trains set its id into appropiate fields for them to know when to free them again. The entity will destroy automatically when it recognizes that any of the trains left the common position. ---[[fields -train_id_1 -train_id_2 -train1_is_backpos -train2_is_backpos -]] - - -minetest.register_entity("advtrains:couple", { - visual="sprite", - textures = {"advtrains_couple.png"}, - collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, - visual_size = {x=1, y=1}, - initial_sprite_basepos = {x=0, y=0}, - - is_couple=true, - on_activate=function(self, staticdata) - if staticdata=="COUPLE" then - --couple entities have no right to exist further... - self.object:remove() - return - end - end, - get_staticdata=function(self) return "COUPLE" end, - on_rightclick=function(self) - if not self.train_id_1 or not self.train_id_2 then return end - - local id1, id2=self.train_id_1, self.train_id_2 - - if self.train1_is_backpos and not self.train2_is_backpos then - advtrains.do_connect_trains(id1, id2) - --case 2 (second train is front) - elseif self.train2_is_backpos and not self.train1_is_backpos then - advtrains.do_connect_trains(id2, id1) - --case 3 - elseif self.train1_is_backpos and self.train2_is_backpos then - advtrains.invert_train(id2) - advtrains.do_connect_trains(id1, id2) - --case 4 - elseif not self.train1_is_backpos and not self.train2_is_backpos then - advtrains.invert_train(id1) - advtrains.do_connect_trains(id1, id2) - end - self.object:remove() - end, - on_step=function(self, dtime) - local t=os.clock() - if not self.train_id_1 or not self.train_id_2 then print("wtf no train ids?")return end - local train1=advtrains.trains[self.train_id_1] - local train2=advtrains.trains[self.train_id_2] - if not train1 or not train2 or not train1.path or not train2.path or not train1.index or not train2.index then - self.object:remove() - return - end - - local tp1 - if not self.train1_is_backpos then - tp1=advtrains.get_real_index_position(train1.path, train1.index) - else - tp1=advtrains.get_real_index_position(train1.path, advtrains.get_train_end_index(train1)) - end - local tp2 - if not self.train2_is_backpos then - tp2=advtrains.get_real_index_position(train2.path, train2.index) - else - tp2=advtrains.get_real_index_position(train2.path, advtrains.get_train_end_index(train2)) - end - if not tp1 or not tp2 or not (vector.distance(tp1,tp2)<0.5) then - self.object:remove() - return - else - local pos_median=advtrains.pos_median(tp1, tp2) - if not vector.equals(pos_median, self.object:getpos()) then - self.object:setpos(pos_median) - end - end - printbm("couple step", t) - end, -}) diff --git a/crafting.lua b/crafting.lua deleted file mode 100644 index dd43512..0000000 --- a/crafting.lua +++ /dev/null @@ -1,103 +0,0 @@ ---advtrains by orwell96, see readme.txt and license.txt ---crafting.lua ---registers crafting recipes - ---tracks -minetest.register_craft({ - output = 'advtrains:dtrack_placer 50', - recipe = { - {'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, - {'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, - {'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, - }, -}) -minetest.register_craft({ - type = "shapeless", - output = 'advtrains:dtrack_slopeplacer 2', - recipe = { - "advtrains:dtrack_placer", - "advtrains:dtrack_placer", - "default:gravel", - }, -}) - -minetest.register_craft({ - output = 'advtrains:dtrack_bumper_placer 2', - recipe = { - {'default:wood', 'dye:red'}, - {'default:steel_ingot', 'default:steel_ingot'}, - {'advtrains:dtrack_placer', 'advtrains:dtrack_placer'}, - }, -}) -minetest.register_craft({ - type="shapeless", - output = 'advtrains:dtrack_detector_off_placer', - recipe = { - "advtrains:dtrack_placer", - "mesecons:wire_00000000_off" - }, -}) ---signals -minetest.register_craft({ - output = 'advtrains:retrosignal_off 2', - recipe = { - {'dye:red', 'default:steel_ingot', 'default:steel_ingot'}, - {'', '', 'default:steel_ingot'}, - {'', '', 'default:steel_ingot'}, - }, -}) -minetest.register_craft({ - output = 'advtrains:signal_off 2', - recipe = { - {'', 'dye:red', 'default:steel_ingot'}, - {'', 'dye:dark_green', 'default:steel_ingot'}, - {'', '', 'default:steel_ingot'}, - }, -}) - ---trackworker -minetest.register_craft({ - output = 'advtrains:trackworker', - recipe = { - {'default:diamond'}, - {'screwdriver:screwdriver'}, - {'default:steel_ingot'}, - }, -}) - ---wagons -minetest.register_craft({ - output = 'advtrains:newlocomotive', - recipe = { - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - {'default:steelblock', 'dye:black', 'default:steelblock'}, - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - }, -}) -minetest.register_craft({ - output = 'advtrains:wagon_default', - recipe = { - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - {'default:steelblock', 'dye:dark_green', 'default:steelblock'}, - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - }, -}) -minetest.register_craft({ - output = 'advtrains:wagon_box', - recipe = { - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - {'default:steelblock', 'default:junglewood', 'default:steelblock'}, - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - }, -}) -minetest.register_craft({ - output = 'advtrains:subway_wagon', - recipe = { - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - {'default:steelblock', 'dye:yellow', 'default:steelblock'}, - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - }, -}) - ---misc_nodes ---crafts for platforms see misc_nodes.lua diff --git a/damage.lua b/damage.lua deleted file mode 100644 index b39fe67..0000000 --- a/damage.lua +++ /dev/null @@ -1,26 +0,0 @@ ---damage.lua ---a globalstep that damages players overrolled by trains. - -advtrains.player_to_train_mapping={} - -local tmr=0 -minetest.register_globalstep(function(dtime) - tmr=tmr-dtime - if tmr<=0 then - - for _, player in pairs(minetest.get_connected_players()) do - local pos=player:getpos() - for _, object in pairs(minetest.get_objects_inside_radius(pos, 1)) do - local le=object:get_luaentity() - if le and le.is_wagon and le.initialized and le:train() then - if (not advtrains.player_to_train_mapping[player:get_player_name()] or le.train_id~=advtrains.player_to_train_mapping[player:get_player_name()]) and math.abs(le:train().velocity)>2 then - --player:punch(object, 1000, {damage={fleshy=3*math.abs(le:train().velocity)}}) - player:set_hp(player:get_hp()-math.abs(le:train().velocity)-3) - end - end - end - end - - tmr=0.5 - end -end) diff --git a/debugitems.lua b/debugitems.lua deleted file mode 100644 index b3164ff..0000000 --- a/debugitems.lua +++ /dev/null @@ -1,36 +0,0 @@ -minetest.register_tool("advtrains:tunnelborer", -{ - description = "tunnelborer", - groups = {cracky=1}, -- key=name, value=rating; rating=1..3. - inventory_image = "drwho_screwdriver.png", - wield_image = "drwho_screwdriver.png", - stack_max = 1, - range = 7.0, - - on_place = function(itemstack, placer, pointed_thing) - - end, - --[[ - ^ Shall place item and return the leftover itemstack - ^ default: minetest.item_place ]] - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type=="node" then - for x=-1,1 do - for y=-1,1 do - for z=-1,1 do - minetest.remove_node(vector.add(pointed_thing.under, {x=x, y=y, z=z})) - end - end - end - end - end, ---[[ -^ default: nil -^ Function must return either nil if no item shall be removed from -inventory, or an itemstack to replace the original itemstack. -e.g. itemstack:take_item(); return itemstack -^ Otherwise, the function is free to do what it wants. -^ The default functions handle regular use cases. -]] -} -) diff --git a/depends.txt b/depends.txt deleted file mode 100644 index 20aa884..0000000 --- a/depends.txt +++ /dev/null @@ -1,2 +0,0 @@ -default -mesecons? \ No newline at end of file diff --git a/description.txt b/description.txt deleted file mode 100644 index ecc5d58..0000000 --- a/description.txt +++ /dev/null @@ -1,8 +0,0 @@ -Advanced Trains v1.3.0, by orwell and contributors. Also see readme. -Good-looking, realistic trains for minetest. - -For crafting recipes, see manual.pdf - -Website: http://advtrains.bleipb.de/ -Manual: https://github.com/orwell96/advtrains/blob/master/manual.pdf -Forum : https://forum.minetest.net/viewtopic.php?f=11&t=14726 \ No newline at end of file diff --git a/helpers.lua b/helpers.lua deleted file mode 100644 index 6a8175f..0000000 --- a/helpers.lua +++ /dev/null @@ -1,249 +0,0 @@ ---advtrains by orwell96, see readme.txt -local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end - -advtrains.dir_trans_tbl={ - [0]={x=0, z=1}, - [1]={x=1, z=2}, - [2]={x=1, z=1}, - [3]={x=2, z=1}, - [4]={x=1, z=0}, - [5]={x=2, z=-1}, - [6]={x=1, z=-1}, - [7]={x=1, z=-2}, - [8]={x=0, z=-1}, - [9]={x=-1, z=-2}, - [10]={x=-1, z=-1}, - [11]={x=-2, z=-1}, - [12]={x=-1, z=0}, - [13]={x=-2, z=1}, - [14]={x=-1, z=1}, - [15]={x=-1, z=2}, -} - -function advtrains.dirCoordSet(coord, dir) - local x,z - if advtrains.dir_trans_tbl[dir] then - x,z=advtrains.dir_trans_tbl[dir].x, advtrains.dir_trans_tbl[dir].z - else - error("advtrains: in helpers.lua/dirCoordSet() given dir="..(dir or "nil")) - end - return {x=coord.x+x, y=coord.y, z=coord.z+z} -end -function advtrains.dirToCoord(dir) - return advtrains.dirCoordSet({x=0, y=0, z=0}, dir) -end - -function advtrains.maxN(list, expectstart) - local n=expectstart or 0 - while list[n] do - n=n+1 - end - return n-1 -end - -function advtrains.minN(list, expectstart) - local n=expectstart or 0 - while list[n] do - n=n-1 - end - return n+1 -end - ---vertical_transmit: ---[[ -rely1, rely2 tell to which height the connections are pointed to. 1 means it will go up the next node - -]] - -function advtrains.conway(midreal, prev, traintype)--in order prev,mid,return - local mid=advtrains.round_vector_floor_y(midreal) - local drives_on=advtrains.all_traintypes[traintype].drives_on - - if not advtrains.get_rail_info_at(advtrains.round_vector_floor_y(prev), traintype) then - return nil - end - - local midnode_ok, middir1, middir2, midrely1, midrely2=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(mid), traintype) - if not midnode_ok then - return nil - end - - local next, chkdir, chkrely, y_offset - y_offset=0 - --print("[advtrains] in order mid1,mid2",middir1,middir2) - --try if it is dir1 - local cor1=advtrains.dirCoordSet(mid, middir2)--<<<< - if math.floor(cor1.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor1.z+0.5)==math.floor(prev.z+0.5) then--this was previous - next=advtrains.dirCoordSet(mid, middir1) - if midrely1>=1 then - next.y=next.y+1 - --print("[advtrains]found midrely1 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) - y_offset=1 - end - chkdir=middir1 - chkrely=midrely1 - --print("[advtrains]dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") - end - --dir2??? - local cor2=advtrains.dirCoordSet(mid, middir1)--<<<< - if math.floor(cor2.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor2.z+0.5)==math.floor(prev.z+0.5) then - next=advtrains.dirCoordSet(mid, middir2)--dir2 wird überprüft, alles gut. - if midrely2>=1 then - next.y=next.y+1 - --print("[advtrains]found midrely2 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) - y_offset=1 - end - chkdir=middir2 - chkrely=midrely2 - --print("[advtrains] dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") - end - --print("[advtrains]dir applied next pos: "..(next and minetest.pos_to_string(next) or "nil").."(chkdir is "..(chkdir or "nil")..", y-offset "..y_offset..")") - --is there a next - if not next then - --print("[advtrains]in conway: no next rail(nil), returning!") - return nil - end - - local nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), traintype) - - --is it a rail? - if(not nextnode_ok) then - --print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not a rail, trying one node below!") - next.y=next.y-1 - y_offset=y_offset-1 - - nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), traintype) - if(not nextnode_ok) then - --print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!") - return nil - end - end - - --is this next rail connecting to the mid? - if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely-y_offset) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely-y_offset) ) then - --print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not connecting, trying one node below!") - next.y=next.y-1 - y_offset=y_offset-1 - - nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), traintype) - if(not nextnode_ok) then - --print("[advtrains]in conway: (at connecting if check again) one below "..minetest.pos_to_string(next).." is not a rail either, returning!") - return nil - end - if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely) ) then - --print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." rail not connecting, returning!") - --print("[advtrains] in order mid1,2,next1,2,chkdir "..middir1.." "..middir2.." "..nextdir1.." "..nextdir2.." "..chkdir) - return nil - end - end - - --print("[advtrains]conway found rail.") - return vector.add(advtrains.round_vector_floor_y(next), {x=0, y=nextrailheight, z=0}), chkdir -end ---TODO use this -function advtrains.oppd(dir) - return ((dir+8)%16) -end - -function advtrains.round_vector_floor_y(vec) - return {x=math.floor(vec.x+0.5), y=math.floor(vec.y), z=math.floor(vec.z+0.5)} -end - -function advtrains.yawToDirection(yaw, conn1, conn2) - if not conn1 or not conn2 then - error("given nil to yawToDirection: conn1="..(conn1 or "nil").." conn2="..(conn1 or "nil")) - end - local yaw1=math.pi*(conn1/4) - local yaw2=math.pi*(conn2/4) - if advtrains.minAngleDiffRad(yaw, yaw1) if weird behavior - return conn2 - else - return conn1 - end -end - -function advtrains.minAngleDiffRad(r1, r2) - local try1=r2-r1 - local try2=(r2+2*math.pi)-r1 - local try3=r2-(r1+2*math.pi) - if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try1) then - return try1 - end - if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try2) then - return try2 - end - if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try3) then - return try3 - end -end -function advtrains.dumppath(path) - if not path then print("dumppath: no path(nil)") return end - local min=advtrains.minN(path) - local max=advtrains.maxN(path) - for i=min, max do print("["..i.."] "..(path[i] and minetest.pos_to_string(path[i]) or "nil")) end -end - -function advtrains.merge_tables(a, ...) - local new={} - for _,t in ipairs({a,...}) do - for k,v in pairs(t) do new[k]=v end - end - return new -end -function advtrains.yaw_from_3_positions(prev, curr, next) - local pts=minetest.pos_to_string - --print("p3 "..pts(prev)..pts(curr)..pts(next)) - local prev2curr=math.atan2((curr.x-prev.x), (prev.z-curr.z)) - local curr2next=math.atan2((next.x-curr.x), (curr.z-next.z)) - --print("y3 "..(prev2curr*360/(2*math.pi)).." "..(curr2next*360/(2*math.pi))) - return prev2curr+(advtrains.minAngleDiffRad(prev2curr, curr2next)/2) -end -function advtrains.get_wagon_yaw(front, first, second, back, pct) - local pts=minetest.pos_to_string - --print("p "..pts(front)..pts(first)..pts(second)..pts(back)) - local y2=advtrains.yaw_from_3_positions(second, first, front) - local y1=advtrains.yaw_from_3_positions(back, second, first) - --print("y "..(y1*360/(2*math.pi)).." "..(y2*360/(2*math.pi))) - return y1+advtrains.minAngleDiffRad(y1, y2)*pct -end -function advtrains.get_real_index_position(path, index) - if not path or not index then return end - - local first_pos=path[math.floor(index)] - local second_pos=path[math.floor(index)+1] - - if not first_pos or not second_pos then return nil end - - local factor=index-math.floor(index) - local actual_pos={x=first_pos.x-(first_pos.x-second_pos.x)*factor, y=first_pos.y-(first_pos.y-second_pos.y)*factor, z=first_pos.z-(first_pos.z-second_pos.z)*factor,} - return actual_pos -end -function advtrains.pos_median(pos1, pos2) - return {x=pos1.x-(pos1.x-pos2.x)*0.5, y=pos1.y-(pos1.y-pos2.y)*0.5, z=pos1.z-(pos1.z-pos2.z)*0.5} -end -function advtrains.abs_ceil(i) - return math.ceil(math.abs(i))*math.sign(i) -end - -function advtrains.serialize_inventory(inv) - local ser={} - local liszts=inv:get_lists() - for lisztname, liszt in pairs(liszts) do - ser[lisztname]={} - for idx, item in ipairs(liszt) do - local istring=item:to_string() - if istring~="" then - ser[lisztname][idx]=istring - end - end - end - return minetest.serialize(ser) -end -function advtrains.deserialize_inventory(sers, inv) - local ser=minetest.deserialize(sers) - if ser then - inv:set_lists(ser) - return true - end - return false -end diff --git a/init.lua b/init.lua deleted file mode 100644 index 41b624e..0000000 --- a/init.lua +++ /dev/null @@ -1,42 +0,0 @@ ---advtrains - -advtrains={} - -advtrains.modpath = minetest.get_modpath("advtrains") - ---print=function(text) --- minetest.log("action", tostring(text) or "") ---end -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 = -{{x=0, y=0, z=-1}, - {x=1, y=0, z=0}, - {x=-1, y=0, z=0}, - {x=0, y=0, z=1}, - {x=1, y=1, z=0}, - {x=1, y=-1, z=0}, - {x=-1, y=1, z=0}, - {x=-1, y=-1, z=0}, - {x=0, y=1, z=1}, - {x=0, y=-1, z=1}, - {x=0, y=1, z=-1}, - {x=0, y=-1, z=-1}, - {x=0, y=-2, z=0}} -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") -dofile(advtrains.modpath.."/couple.lua") -dofile(advtrains.modpath.."/damage.lua") - -dofile(advtrains.modpath.."/signals.lua") -dofile(advtrains.modpath.."/misc_nodes.lua") -dofile(advtrains.modpath.."/crafting.lua") diff --git a/misc_nodes.lua b/misc_nodes.lua deleted file mode 100644 index 93829f0..0000000 --- a/misc_nodes.lua +++ /dev/null @@ -1,67 +0,0 @@ ---all nodes that do not fit in any other category - -function advtrains.register_platform(preset) - local ndef=minetest.registered_nodes[preset] - if not ndef then - minetest.log("warning", "[advtrains] register_platform couldn't find preset node "..preset) - return - end - local btex=ndef.tiles - if type(btex)=="table" then - btex=btex[1] - end - local desc=ndef.description or "" - local nodename=string.match(preset, ":(.+)$") - minetest.register_node("advtrains:platform_low_"..nodename, { - description = desc.." Platform (low)", - tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex}, - groups = {cracky = 1, not_blocking_trains = 1, platform=1}, - sounds = default.node_sound_stone_defaults(), - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = { - {-0.5, -0.1, -0.1, 0.5, 0 , 0.5}, - {-0.5, -0.5, 0 , 0.5, -0.1, 0.5} - }, - }, - paramtype2="facedir", - paramtype = "light", - sunlight_propagates = true, - }) - minetest.register_node("advtrains:platform_high_"..nodename, { - description = desc.." Platform (high)", - tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex}, - groups = {cracky = 1, not_blocking_trains = 1, platform=2}, - sounds = default.node_sound_stone_defaults(), - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = { - {-0.5, 0.3, -0.1, 0.5, 0.5, 0.5}, - {-0.5, -0.5, 0 , 0.5, 0.3, 0.5} - }, - }, - paramtype2="facedir", - paramtype = "light", - sunlight_propagates = true, - }) - minetest.register_craft({ - type="shapeless", - output = "advtrains:platform_high_"..nodename.." 4", - recipe = { - "dye:yellow", preset, preset - }, - }) - minetest.register_craft({ - type="shapeless", - output = "advtrains:platform_low_"..nodename.." 4", - recipe = { - "dye:yellow", preset - }, - }) -end - - -advtrains.register_platform("default:stonebrick") -advtrains.register_platform("default:sandstonebrick") diff --git a/models/advtrains_dtrack_bumper_st.b3d b/models/advtrains_dtrack_bumper_st.b3d deleted file mode 100644 index a6d9745..0000000 Binary files a/models/advtrains_dtrack_bumper_st.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_bumper_st_30.b3d b/models/advtrains_dtrack_bumper_st_30.b3d deleted file mode 100644 index 5f5b3f4..0000000 Binary files a/models/advtrains_dtrack_bumper_st_30.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_bumper_st_45.b3d b/models/advtrains_dtrack_bumper_st_45.b3d deleted file mode 100644 index f13ae75..0000000 Binary files a/models/advtrains_dtrack_bumper_st_45.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_bumper_st_60.b3d b/models/advtrains_dtrack_bumper_st_60.b3d deleted file mode 100644 index 59a2285..0000000 Binary files a/models/advtrains_dtrack_bumper_st_60.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_cr.b3d b/models/advtrains_dtrack_cr.b3d deleted file mode 100644 index 159717e..0000000 Binary files a/models/advtrains_dtrack_cr.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_cr_30.b3d b/models/advtrains_dtrack_cr_30.b3d deleted file mode 100644 index 09cdb1f..0000000 Binary files a/models/advtrains_dtrack_cr_30.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_cr_45.b3d b/models/advtrains_dtrack_cr_45.b3d deleted file mode 100644 index 176da81..0000000 Binary files a/models/advtrains_dtrack_cr_45.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_cr_60.b3d b/models/advtrains_dtrack_cr_60.b3d deleted file mode 100644 index 00313c8..0000000 Binary files a/models/advtrains_dtrack_cr_60.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_detector_st.b3d b/models/advtrains_dtrack_detector_st.b3d deleted file mode 100644 index 893c8cd..0000000 Binary files a/models/advtrains_dtrack_detector_st.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_detector_st_30.b3d b/models/advtrains_dtrack_detector_st_30.b3d deleted file mode 100644 index 2e59e93..0000000 Binary files a/models/advtrains_dtrack_detector_st_30.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_detector_st_45.b3d b/models/advtrains_dtrack_detector_st_45.b3d deleted file mode 100644 index c73166f..0000000 Binary files a/models/advtrains_dtrack_detector_st_45.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_detector_st_60.b3d b/models/advtrains_dtrack_detector_st_60.b3d deleted file mode 100644 index b6bc9af..0000000 Binary files a/models/advtrains_dtrack_detector_st_60.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_st.b3d b/models/advtrains_dtrack_st.b3d deleted file mode 100644 index f3e2753..0000000 Binary files a/models/advtrains_dtrack_st.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_st_30.b3d b/models/advtrains_dtrack_st_30.b3d deleted file mode 100644 index 7a35c8d..0000000 Binary files a/models/advtrains_dtrack_st_30.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_st_45.b3d b/models/advtrains_dtrack_st_45.b3d deleted file mode 100644 index b2a1702..0000000 Binary files a/models/advtrains_dtrack_st_45.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_st_60.b3d b/models/advtrains_dtrack_st_60.b3d deleted file mode 100644 index 0a59f77..0000000 Binary files a/models/advtrains_dtrack_st_60.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swlcr.b3d b/models/advtrains_dtrack_swlcr.b3d deleted file mode 100644 index 1adc23f..0000000 Binary files a/models/advtrains_dtrack_swlcr.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swlcr_30.b3d b/models/advtrains_dtrack_swlcr_30.b3d deleted file mode 100644 index 7d8373b..0000000 Binary files a/models/advtrains_dtrack_swlcr_30.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swlcr_45.b3d b/models/advtrains_dtrack_swlcr_45.b3d deleted file mode 100644 index 9679b9e..0000000 Binary files a/models/advtrains_dtrack_swlcr_45.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swlcr_60.b3d b/models/advtrains_dtrack_swlcr_60.b3d deleted file mode 100644 index 3efc924..0000000 Binary files a/models/advtrains_dtrack_swlcr_60.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swlst.b3d b/models/advtrains_dtrack_swlst.b3d deleted file mode 100644 index 93841a4..0000000 Binary files a/models/advtrains_dtrack_swlst.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swlst_30.b3d b/models/advtrains_dtrack_swlst_30.b3d deleted file mode 100644 index e9a90c7..0000000 Binary files a/models/advtrains_dtrack_swlst_30.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swlst_45.b3d b/models/advtrains_dtrack_swlst_45.b3d deleted file mode 100644 index 49c707c..0000000 Binary files a/models/advtrains_dtrack_swlst_45.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swlst_60.b3d b/models/advtrains_dtrack_swlst_60.b3d deleted file mode 100644 index c9a6ffe..0000000 Binary files a/models/advtrains_dtrack_swlst_60.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swrcr.b3d b/models/advtrains_dtrack_swrcr.b3d deleted file mode 100644 index ee29b62..0000000 Binary files a/models/advtrains_dtrack_swrcr.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swrcr_30.b3d b/models/advtrains_dtrack_swrcr_30.b3d deleted file mode 100644 index ba065e1..0000000 Binary files a/models/advtrains_dtrack_swrcr_30.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swrcr_45.b3d b/models/advtrains_dtrack_swrcr_45.b3d deleted file mode 100644 index 7f9dc43..0000000 Binary files a/models/advtrains_dtrack_swrcr_45.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swrcr_60.b3d b/models/advtrains_dtrack_swrcr_60.b3d deleted file mode 100644 index b8ffa61..0000000 Binary files a/models/advtrains_dtrack_swrcr_60.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swrst.b3d b/models/advtrains_dtrack_swrst.b3d deleted file mode 100644 index 0b3e7ad..0000000 Binary files a/models/advtrains_dtrack_swrst.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swrst_30.b3d b/models/advtrains_dtrack_swrst_30.b3d deleted file mode 100644 index 4aea19b..0000000 Binary files a/models/advtrains_dtrack_swrst_30.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swrst_45.b3d b/models/advtrains_dtrack_swrst_45.b3d deleted file mode 100644 index 4182fe5..0000000 Binary files a/models/advtrains_dtrack_swrst_45.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_swrst_60.b3d b/models/advtrains_dtrack_swrst_60.b3d deleted file mode 100644 index 6d2c891..0000000 Binary files a/models/advtrains_dtrack_swrst_60.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_vst1.b3d b/models/advtrains_dtrack_vst1.b3d deleted file mode 100644 index c9d7427..0000000 Binary files a/models/advtrains_dtrack_vst1.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_vst1_45.b3d b/models/advtrains_dtrack_vst1_45.b3d deleted file mode 100644 index 14d438c..0000000 Binary files a/models/advtrains_dtrack_vst1_45.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_vst2.b3d b/models/advtrains_dtrack_vst2.b3d deleted file mode 100644 index c128650..0000000 Binary files a/models/advtrains_dtrack_vst2.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_vst2_45.b3d b/models/advtrains_dtrack_vst2_45.b3d deleted file mode 100644 index 263276d..0000000 Binary files a/models/advtrains_dtrack_vst2_45.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_vst31.b3d b/models/advtrains_dtrack_vst31.b3d deleted file mode 100644 index df0f383..0000000 Binary files a/models/advtrains_dtrack_vst31.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_vst32.b3d b/models/advtrains_dtrack_vst32.b3d deleted file mode 100644 index 01d2978..0000000 Binary files a/models/advtrains_dtrack_vst32.b3d and /dev/null differ diff --git a/models/advtrains_dtrack_vst33.b3d b/models/advtrains_dtrack_vst33.b3d deleted file mode 100644 index 7fe418d..0000000 Binary files a/models/advtrains_dtrack_vst33.b3d and /dev/null differ diff --git a/models/advtrains_engine_industrial.b3d b/models/advtrains_engine_industrial.b3d deleted file mode 100644 index f1ea485..0000000 Binary files a/models/advtrains_engine_industrial.b3d and /dev/null differ diff --git a/models/advtrains_engine_japan.b3d b/models/advtrains_engine_japan.b3d deleted file mode 100644 index f82c33e..0000000 Binary files a/models/advtrains_engine_japan.b3d and /dev/null differ diff --git a/models/advtrains_engine_steam.b3d b/models/advtrains_engine_steam.b3d deleted file mode 100644 index 36bdd15..0000000 Binary files a/models/advtrains_engine_steam.b3d and /dev/null differ diff --git a/models/advtrains_modernwagon.b3d b/models/advtrains_modernwagon.b3d deleted file mode 100644 index aacddca..0000000 Binary files a/models/advtrains_modernwagon.b3d and /dev/null differ diff --git a/models/advtrains_retrosignal_off.b3d b/models/advtrains_retrosignal_off.b3d deleted file mode 100644 index 3d231dd..0000000 Binary files a/models/advtrains_retrosignal_off.b3d and /dev/null differ diff --git a/models/advtrains_retrosignal_off_30.b3d b/models/advtrains_retrosignal_off_30.b3d deleted file mode 100644 index da258e1..0000000 Binary files a/models/advtrains_retrosignal_off_30.b3d and /dev/null differ diff --git a/models/advtrains_retrosignal_off_45.b3d b/models/advtrains_retrosignal_off_45.b3d deleted file mode 100644 index 338224a..0000000 Binary files a/models/advtrains_retrosignal_off_45.b3d and /dev/null differ diff --git a/models/advtrains_retrosignal_off_60.b3d b/models/advtrains_retrosignal_off_60.b3d deleted file mode 100644 index c560ca1..0000000 Binary files a/models/advtrains_retrosignal_off_60.b3d and /dev/null differ diff --git a/models/advtrains_retrosignal_on.b3d b/models/advtrains_retrosignal_on.b3d deleted file mode 100644 index 3d19439..0000000 Binary files a/models/advtrains_retrosignal_on.b3d and /dev/null differ diff --git a/models/advtrains_retrosignal_on_30.b3d b/models/advtrains_retrosignal_on_30.b3d deleted file mode 100644 index 98f8a92..0000000 Binary files a/models/advtrains_retrosignal_on_30.b3d and /dev/null differ diff --git a/models/advtrains_retrosignal_on_45.b3d b/models/advtrains_retrosignal_on_45.b3d deleted file mode 100644 index 414e121..0000000 Binary files a/models/advtrains_retrosignal_on_45.b3d and /dev/null differ diff --git a/models/advtrains_retrosignal_on_60.b3d b/models/advtrains_retrosignal_on_60.b3d deleted file mode 100644 index a51529a..0000000 Binary files a/models/advtrains_retrosignal_on_60.b3d and /dev/null differ diff --git a/models/advtrains_signal.b3d b/models/advtrains_signal.b3d deleted file mode 100644 index 7f69560..0000000 Binary files a/models/advtrains_signal.b3d and /dev/null differ diff --git a/models/advtrains_signal_30.b3d b/models/advtrains_signal_30.b3d deleted file mode 100644 index 0b949a7..0000000 Binary files a/models/advtrains_signal_30.b3d and /dev/null differ diff --git a/models/advtrains_signal_45.b3d b/models/advtrains_signal_45.b3d deleted file mode 100644 index ccaebf4..0000000 Binary files a/models/advtrains_signal_45.b3d and /dev/null differ diff --git a/models/advtrains_signal_60.b3d b/models/advtrains_signal_60.b3d deleted file mode 100644 index cf41e6d..0000000 Binary files a/models/advtrains_signal_60.b3d and /dev/null differ diff --git a/models/advtrains_subway_train.b3d b/models/advtrains_subway_train.b3d deleted file mode 100644 index a824d33..0000000 Binary files a/models/advtrains_subway_train.b3d and /dev/null differ diff --git a/models/advtrains_track_cr.b3d b/models/advtrains_track_cr.b3d deleted file mode 100644 index b0f5e4b..0000000 Binary files a/models/advtrains_track_cr.b3d and /dev/null differ diff --git a/models/advtrains_track_st.b3d b/models/advtrains_track_st.b3d deleted file mode 100644 index 10b5d90..0000000 Binary files a/models/advtrains_track_st.b3d and /dev/null differ diff --git a/models/advtrains_track_st_45.b3d b/models/advtrains_track_st_45.b3d deleted file mode 100644 index 32505a1..0000000 Binary files a/models/advtrains_track_st_45.b3d and /dev/null differ diff --git a/models/advtrains_wagon.b3d b/models/advtrains_wagon.b3d deleted file mode 100644 index 5c8214c..0000000 Binary files a/models/advtrains_wagon.b3d and /dev/null differ diff --git a/models/advtrains_wagon_japan.b3d b/models/advtrains_wagon_japan.b3d deleted file mode 100644 index 7970438..0000000 Binary files a/models/advtrains_wagon_japan.b3d and /dev/null differ diff --git a/models/advtrains_wagon_tank.b3d b/models/advtrains_wagon_tank.b3d deleted file mode 100644 index af2604b..0000000 Binary files a/models/advtrains_wagon_tank.b3d and /dev/null differ diff --git a/models/advtrains_wagon_wood.b3d b/models/advtrains_wagon_wood.b3d deleted file mode 100644 index 0e7fb4b..0000000 Binary files a/models/advtrains_wagon_wood.b3d and /dev/null differ diff --git a/models/blender/engine-with-animation.blend b/models/blender/engine-with-animation.blend deleted file mode 100644 index 2649587..0000000 Binary files a/models/blender/engine-with-animation.blend and /dev/null differ diff --git a/models/blender/gleis/infos/Grafik_weiche.png b/models/blender/gleis/infos/Grafik_weiche.png deleted file mode 100644 index 6674eb3..0000000 Binary files a/models/blender/gleis/infos/Grafik_weiche.png and /dev/null differ diff --git a/models/blender/gleis/infos/breite b/models/blender/gleis/infos/breite deleted file mode 100644 index b2862c6..0000000 --- a/models/blender/gleis/infos/breite +++ /dev/null @@ -1 +0,0 @@ -1435mm diff --git a/models/blender/gleis/licence.txt~ b/models/blender/gleis/licence.txt~ deleted file mode 100644 index e69de29..0000000 diff --git a/models/blender/gleis/rail_my.blend b/models/blender/gleis/rail_my.blend deleted file mode 100644 index 3c741bc..0000000 Binary files a/models/blender/gleis/rail_my.blend and /dev/null differ diff --git a/models/blender/gleis/rail_my.blend1 b/models/blender/gleis/rail_my.blend1 deleted file mode 100644 index 6322856..0000000 Binary files a/models/blender/gleis/rail_my.blend1 and /dev/null differ diff --git a/models/blender/gleis/rail_my_rt.blend b/models/blender/gleis/rail_my_rt.blend deleted file mode 100644 index 8372a0c..0000000 Binary files a/models/blender/gleis/rail_my_rt.blend and /dev/null differ diff --git a/models/blender/gleis/rail_my_rt.blend1 b/models/blender/gleis/rail_my_rt.blend1 deleted file mode 100644 index 7d0978e..0000000 Binary files a/models/blender/gleis/rail_my_rt.blend1 and /dev/null differ diff --git a/models/blender/gleis/rail_my_rt_final.blend b/models/blender/gleis/rail_my_rt_final.blend deleted file mode 100644 index 6a9a088..0000000 Binary files a/models/blender/gleis/rail_my_rt_final.blend and /dev/null differ diff --git a/models/blender/gleis/rail_my_rt_final.blend1 b/models/blender/gleis/rail_my_rt_final.blend1 deleted file mode 100644 index 1f346ae..0000000 Binary files a/models/blender/gleis/rail_my_rt_final.blend1 and /dev/null differ diff --git a/models/blender/gleis/rail_my_rt_switches.blend b/models/blender/gleis/rail_my_rt_switches.blend deleted file mode 100644 index fdce427..0000000 Binary files a/models/blender/gleis/rail_my_rt_switches.blend and /dev/null differ diff --git a/models/blender/gleis/rail_my_rt_switches.blend1 b/models/blender/gleis/rail_my_rt_switches.blend1 deleted file mode 100644 index 04370ba..0000000 Binary files a/models/blender/gleis/rail_my_rt_switches.blend1 and /dev/null differ diff --git a/models/blender/gleis/rail_my_rt_switches2.blend b/models/blender/gleis/rail_my_rt_switches2.blend deleted file mode 100644 index 9562e4d..0000000 Binary files a/models/blender/gleis/rail_my_rt_switches2.blend and /dev/null differ diff --git a/models/blender/gleis/rail_my_rt_switches2.blend1 b/models/blender/gleis/rail_my_rt_switches2.blend1 deleted file mode 100644 index 07a155f..0000000 Binary files a/models/blender/gleis/rail_my_rt_switches2.blend1 and /dev/null differ diff --git a/models/blender/gleis/rail_together.blend b/models/blender/gleis/rail_together.blend deleted file mode 100644 index cff51ea..0000000 Binary files a/models/blender/gleis/rail_together.blend and /dev/null differ diff --git a/models/blender/gleis/rail_together.png b/models/blender/gleis/rail_together.png deleted file mode 100644 index 386cd5c..0000000 Binary files a/models/blender/gleis/rail_together.png and /dev/null differ diff --git a/models/blender/gleis/rail_together2.png b/models/blender/gleis/rail_together2.png deleted file mode 100644 index 3effe34..0000000 Binary files a/models/blender/gleis/rail_together2.png and /dev/null differ diff --git a/models/blender/gleis/rail_together3.png b/models/blender/gleis/rail_together3.png deleted file mode 100644 index 4a183c1..0000000 Binary files a/models/blender/gleis/rail_together3.png and /dev/null differ diff --git a/models/blender/gleis/rail_verticals.blend b/models/blender/gleis/rail_verticals.blend deleted file mode 100644 index 45c37e1..0000000 Binary files a/models/blender/gleis/rail_verticals.blend and /dev/null differ diff --git a/models/blender/gleis/rail_verticals.blend1 b/models/blender/gleis/rail_verticals.blend1 deleted file mode 100644 index 320f30b..0000000 Binary files a/models/blender/gleis/rail_verticals.blend1 and /dev/null differ diff --git a/models/blender/gleis/rail_verticals3.blend b/models/blender/gleis/rail_verticals3.blend deleted file mode 100644 index 5d62959..0000000 Binary files a/models/blender/gleis/rail_verticals3.blend and /dev/null differ diff --git a/models/blender/gleis/rail_verticals3.blend1 b/models/blender/gleis/rail_verticals3.blend1 deleted file mode 100644 index 893f2ea..0000000 Binary files a/models/blender/gleis/rail_verticals3.blend1 and /dev/null differ diff --git a/models/blender/gleis/rail_verticals45.blend b/models/blender/gleis/rail_verticals45.blend deleted file mode 100644 index a1589e3..0000000 Binary files a/models/blender/gleis/rail_verticals45.blend and /dev/null differ diff --git a/models/blender/gleis/rail_verticals45.blend1 b/models/blender/gleis/rail_verticals45.blend1 deleted file mode 100644 index 6b44d1c..0000000 Binary files a/models/blender/gleis/rail_verticals45.blend1 and /dev/null differ diff --git a/models/blender/gleis/rail_verticals45.blend11 b/models/blender/gleis/rail_verticals45.blend11 deleted file mode 100644 index 48316e8..0000000 Binary files a/models/blender/gleis/rail_verticals45.blend11 and /dev/null differ diff --git a/models/blender/gleis/texturen/rail.png b/models/blender/gleis/texturen/rail.png deleted file mode 100644 index 8478cf6..0000000 Binary files a/models/blender/gleis/texturen/rail.png and /dev/null differ diff --git a/models/blender/gleis/texturen/uv.png b/models/blender/gleis/texturen/uv.png deleted file mode 100644 index fb0af3e..0000000 Binary files a/models/blender/gleis/texturen/uv.png and /dev/null differ diff --git a/models/blender/industrial/industry_loc.blend b/models/blender/industrial/industry_loc.blend deleted file mode 100644 index 1a6cb2b..0000000 Binary files a/models/blender/industrial/industry_loc.blend and /dev/null differ diff --git a/models/blender/industrial/industry_loc.blend1 b/models/blender/industrial/industry_loc.blend1 deleted file mode 100644 index af54c3f..0000000 Binary files a/models/blender/industrial/industry_loc.blend1 and /dev/null differ diff --git a/models/blender/industrial/industry_loc.blend11 b/models/blender/industrial/industry_loc.blend11 deleted file mode 100644 index a089a65..0000000 Binary files a/models/blender/industrial/industry_loc.blend11 and /dev/null differ diff --git a/models/blender/industrial/industry_oil_ wagong.blend b/models/blender/industrial/industry_oil_ wagong.blend deleted file mode 100644 index 30bde51..0000000 Binary files a/models/blender/industrial/industry_oil_ wagong.blend and /dev/null differ diff --git a/models/blender/industrial/industry_oil_ wagong.blend1 b/models/blender/industrial/industry_oil_ wagong.blend1 deleted file mode 100644 index 849971d..0000000 Binary files a/models/blender/industrial/industry_oil_ wagong.blend1 and /dev/null differ diff --git a/models/blender/industrial/industry_tree_wagong.blend b/models/blender/industrial/industry_tree_wagong.blend deleted file mode 100644 index 23de208..0000000 Binary files a/models/blender/industrial/industry_tree_wagong.blend and /dev/null differ diff --git a/models/blender/industrial/industry_tree_wagong.blend1 b/models/blender/industrial/industry_tree_wagong.blend1 deleted file mode 100644 index bf2c9ed..0000000 Binary files a/models/blender/industrial/industry_tree_wagong.blend1 and /dev/null differ diff --git a/models/blender/industrial/industry_tree_wagong.png b/models/blender/industrial/industry_tree_wagong.png deleted file mode 100644 index 87109dd..0000000 Binary files a/models/blender/industrial/industry_tree_wagong.png and /dev/null differ diff --git a/models/blender/locomotive.blend b/models/blender/locomotive.blend deleted file mode 100644 index 8fd6059..0000000 Binary files a/models/blender/locomotive.blend and /dev/null differ diff --git a/models/blender/magnet_track.blend b/models/blender/magnet_track.blend deleted file mode 100644 index 0ab14e7..0000000 Binary files a/models/blender/magnet_track.blend and /dev/null differ diff --git a/models/blender/mbb/advtrains_wagon_japan.xcf b/models/blender/mbb/advtrains_wagon_japan.xcf deleted file mode 100644 index 4fc88c0..0000000 Binary files a/models/blender/mbb/advtrains_wagon_japan.xcf and /dev/null differ diff --git a/models/blender/mbb/modern_japanlocomotive.blend b/models/blender/mbb/modern_japanlocomotive.blend deleted file mode 100644 index 6eb8f3d..0000000 Binary files a/models/blender/mbb/modern_japanlocomotive.blend and /dev/null differ diff --git a/models/blender/mbb/modern_japanlocomotive.blend1 b/models/blender/mbb/modern_japanlocomotive.blend1 deleted file mode 100644 index a2e745d..0000000 Binary files a/models/blender/mbb/modern_japanlocomotive.blend1 and /dev/null differ diff --git a/models/blender/mbb/modern_japanlocomotive.png b/models/blender/mbb/modern_japanlocomotive.png deleted file mode 100644 index b80d16f..0000000 Binary files a/models/blender/mbb/modern_japanlocomotive.png and /dev/null differ diff --git a/models/blender/mbb/modern_japanlocomotive.xcf b/models/blender/mbb/modern_japanlocomotive.xcf deleted file mode 100644 index bb28534..0000000 Binary files a/models/blender/mbb/modern_japanlocomotive.xcf and /dev/null differ diff --git a/models/blender/mbb/modern_locomotive.blend b/models/blender/mbb/modern_locomotive.blend deleted file mode 100644 index 8e72233..0000000 Binary files a/models/blender/mbb/modern_locomotive.blend and /dev/null differ diff --git a/models/blender/mbb/modern_wagong.blend b/models/blender/mbb/modern_wagong.blend deleted file mode 100644 index f32710a..0000000 Binary files a/models/blender/mbb/modern_wagong.blend and /dev/null differ diff --git a/models/blender/mbb/modern_wagong.blend1 b/models/blender/mbb/modern_wagong.blend1 deleted file mode 100644 index 376831c..0000000 Binary files a/models/blender/mbb/modern_wagong.blend1 and /dev/null differ diff --git a/models/blender/mbb/modern_wagong_uv.blend b/models/blender/mbb/modern_wagong_uv.blend deleted file mode 100644 index 4c10fb3..0000000 Binary files a/models/blender/mbb/modern_wagong_uv.blend and /dev/null differ diff --git a/models/blender/mbb/modern_wagong_uv.blend1 b/models/blender/mbb/modern_wagong_uv.blend1 deleted file mode 100644 index ce77416..0000000 Binary files a/models/blender/mbb/modern_wagong_uv.blend1 and /dev/null differ diff --git a/models/blender/mbb/modern_wagong_uv.png b/models/blender/mbb/modern_wagong_uv.png deleted file mode 100644 index 68018ea..0000000 Binary files a/models/blender/mbb/modern_wagong_uv.png and /dev/null differ diff --git a/models/blender/mbb/prellbock.blend b/models/blender/mbb/prellbock.blend deleted file mode 100644 index 1c20ab2..0000000 Binary files a/models/blender/mbb/prellbock.blend and /dev/null differ diff --git a/models/blender/mbb/prellbock.blend1 b/models/blender/mbb/prellbock.blend1 deleted file mode 100644 index 981538e..0000000 Binary files a/models/blender/mbb/prellbock.blend1 and /dev/null differ diff --git a/models/blender/mbb/prellbock.uv.png b/models/blender/mbb/prellbock.uv.png deleted file mode 100644 index 7730753..0000000 Binary files a/models/blender/mbb/prellbock.uv.png and /dev/null differ diff --git a/models/blender/mbb/regio-lokomotive.blend b/models/blender/mbb/regio-lokomotive.blend deleted file mode 100644 index 210e60e..0000000 Binary files a/models/blender/mbb/regio-lokomotive.blend and /dev/null differ diff --git a/models/blender/mbb/regio-waron.blend b/models/blender/mbb/regio-waron.blend deleted file mode 100644 index 19b07ce..0000000 Binary files a/models/blender/mbb/regio-waron.blend and /dev/null differ diff --git a/models/blender/mbb/retrosignal.blend b/models/blender/mbb/retrosignal.blend deleted file mode 100644 index b795215..0000000 Binary files a/models/blender/mbb/retrosignal.blend and /dev/null differ diff --git a/models/blender/mbb/retrosignal.blend1 b/models/blender/mbb/retrosignal.blend1 deleted file mode 100644 index 94af470..0000000 Binary files a/models/blender/mbb/retrosignal.blend1 and /dev/null differ diff --git a/models/blender/mbb/signal(2)_hoch.blend b/models/blender/mbb/signal(2)_hoch.blend deleted file mode 100644 index 70391f6..0000000 Binary files a/models/blender/mbb/signal(2)_hoch.blend and /dev/null differ diff --git a/models/blender/mbb/signal(2)_unten.blend b/models/blender/mbb/signal(2)_unten.blend deleted file mode 100644 index 4e917bc..0000000 Binary files a/models/blender/mbb/signal(2)_unten.blend and /dev/null differ diff --git a/models/blender/mbb/signal.blend b/models/blender/mbb/signal.blend deleted file mode 100644 index 135c7b4..0000000 Binary files a/models/blender/mbb/signal.blend and /dev/null differ diff --git a/models/blender/mbb/signal.blend1 b/models/blender/mbb/signal.blend1 deleted file mode 100644 index 63a8c99..0000000 Binary files a/models/blender/mbb/signal.blend1 and /dev/null differ diff --git a/models/blender/mbb/signal.png b/models/blender/mbb/signal.png deleted file mode 100644 index 779cdda..0000000 Binary files a/models/blender/mbb/signal.png and /dev/null differ diff --git a/models/blender/mbb/signal.xcf b/models/blender/mbb/signal.xcf deleted file mode 100644 index f667739..0000000 Binary files a/models/blender/mbb/signal.xcf and /dev/null differ diff --git a/models/blender/mbb/signal2.png b/models/blender/mbb/signal2.png deleted file mode 100644 index 7af4e2d..0000000 Binary files a/models/blender/mbb/signal2.png and /dev/null differ diff --git a/models/blender/mbb/tr-logo.png b/models/blender/mbb/tr-logo.png deleted file mode 100644 index 9bc0f10..0000000 Binary files a/models/blender/mbb/tr-logo.png and /dev/null differ diff --git a/models/blender/mbb/weichenhebel1.blend b/models/blender/mbb/weichenhebel1.blend deleted file mode 100644 index 70b997d..0000000 Binary files a/models/blender/mbb/weichenhebel1.blend and /dev/null differ diff --git a/models/blender/mbb/weichenhebel2.blend b/models/blender/mbb/weichenhebel2.blend deleted file mode 100644 index c1c3aac..0000000 Binary files a/models/blender/mbb/weichenhebel2.blend and /dev/null differ diff --git a/models/blender/newlocomotive.blend b/models/blender/newlocomotive.blend deleted file mode 100644 index 858882b..0000000 Binary files a/models/blender/newlocomotive.blend and /dev/null differ diff --git a/models/blender/newlocomotive.blend1 b/models/blender/newlocomotive.blend1 deleted file mode 100644 index 4b8b24f..0000000 Binary files a/models/blender/newlocomotive.blend1 and /dev/null differ diff --git a/models/blender/newlocomotive_uvs.png b/models/blender/newlocomotive_uvs.png deleted file mode 100644 index 879be65..0000000 Binary files a/models/blender/newlocomotive_uvs.png and /dev/null differ diff --git a/models/blender/newwagon.blend b/models/blender/newwagon.blend deleted file mode 100644 index 1cedc55..0000000 Binary files a/models/blender/newwagon.blend and /dev/null differ diff --git a/models/blender/newwagon.blend1 b/models/blender/newwagon.blend1 deleted file mode 100644 index eb30fde..0000000 Binary files a/models/blender/newwagon.blend1 and /dev/null differ diff --git a/models/blender/newwagon.png b/models/blender/newwagon.png deleted file mode 100644 index 812bc32..0000000 Binary files a/models/blender/newwagon.png and /dev/null differ diff --git a/models/blender/subway-train.blend b/models/blender/subway-train.blend deleted file mode 100644 index 690d87b..0000000 Binary files a/models/blender/subway-train.blend and /dev/null differ diff --git a/models/blender/subway-train.blend1 b/models/blender/subway-train.blend1 deleted file mode 100644 index 86d1f92..0000000 Binary files a/models/blender/subway-train.blend1 and /dev/null differ diff --git a/models/blender/subway-train.png b/models/blender/subway-train.png deleted file mode 100644 index d0b9731..0000000 Binary files a/models/blender/subway-train.png and /dev/null differ diff --git a/models/blender/subway-train.xcf b/models/blender/subway-train.xcf deleted file mode 100644 index 775b87c..0000000 Binary files a/models/blender/subway-train.xcf and /dev/null differ diff --git a/models/blender/trackplane.blend b/models/blender/trackplane.blend deleted file mode 100644 index 79365f7..0000000 Binary files a/models/blender/trackplane.blend and /dev/null differ diff --git a/models/blender/trackvertical1.blend b/models/blender/trackvertical1.blend deleted file mode 100644 index fca6742..0000000 Binary files a/models/blender/trackvertical1.blend and /dev/null differ diff --git a/models/blender/trackvertical1.blend1 b/models/blender/trackvertical1.blend1 deleted file mode 100644 index b146b56..0000000 Binary files a/models/blender/trackvertical1.blend1 and /dev/null differ diff --git a/models/blender/trackvertical1.png b/models/blender/trackvertical1.png deleted file mode 100644 index a998dcb..0000000 Binary files a/models/blender/trackvertical1.png and /dev/null differ diff --git a/models/blender/trackvertical2.blend b/models/blender/trackvertical2.blend deleted file mode 100644 index a066b84..0000000 Binary files a/models/blender/trackvertical2.blend and /dev/null differ diff --git a/models/blender/trackvertical2.png b/models/blender/trackvertical2.png deleted file mode 100644 index 43142f9..0000000 Binary files a/models/blender/trackvertical2.png and /dev/null differ diff --git a/models/oldmodels/locomotive.b3d b/models/oldmodels/locomotive.b3d deleted file mode 100644 index 5e16be3..0000000 Binary files a/models/oldmodels/locomotive.b3d and /dev/null differ diff --git a/models/oldmodels/trackvertical1.b3d b/models/oldmodels/trackvertical1.b3d deleted file mode 100644 index 5620f60..0000000 Binary files a/models/oldmodels/trackvertical1.b3d and /dev/null differ diff --git a/models/oldmodels/trackvertical2.b3d b/models/oldmodels/trackvertical2.b3d deleted file mode 100644 index 22dbb20..0000000 Binary files a/models/oldmodels/trackvertical2.b3d and /dev/null differ diff --git a/models/trackplane.b3d b/models/trackplane.b3d deleted file mode 100644 index b4728c3..0000000 Binary files a/models/trackplane.b3d and /dev/null differ diff --git a/modpack.txt b/modpack.txt new file mode 100644 index 0000000..e69de29 diff --git a/pseudoload.lua b/pseudoload.lua deleted file mode 100644 index 8511811..0000000 --- a/pseudoload.lua +++ /dev/null @@ -1,180 +0,0 @@ -local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end - ---pseudoload.lua ---responsible for keeping up a database of all rail nodes existant in the world, regardless of whether the mapchunk is loaded. - -advtrains.trackdb={} ---trackdb[tt][y][x][z]={conn1, conn2, rely1, rely2, railheight} ---serialization format: ---(2byte x)(2byte y)(2byte z)(4bits conn1, 4bits conn2)[(plain rely1)|(plain rely2)|(plain railheight)]\n ---[] may be missing if 0,0,0 - ---load initially - ---[[ TODO temporary outcomment - ---delayed since all traintypes need to be registered -minetest.after(0, function() - -for tt, _ in pairs(advtrains.all_traintypes) do - local pl_fpath=minetest.get_worldpath().."/advtrains_trackdb_"..tt - advtrains.trackdb[tt]={} - local file, err = io.open(pl_fpath, "r") - if not file then - local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains trackdb save file "..er) - else - --custom format to save memory - while true do - local xbytes=file:read(2) - if not xbytes or #xbytes<2 then - break --eof reached - end - print(xbytes) - local ybytes=file:read(2) - local zbytes=file:read(2) - local x=(string.byte(xbytes[1])-128)*256+(string.byte(xbytes[2])) - local y=(string.byte(ybytes[1])-128)*256+(string.byte(ybytes[2])) - local z=(string.byte(zbytes[1])-128)*256+(string.byte(zbytes[2])) - - local conn1=string.byte(file:read(1)) - local conn1=string.byte(file:read(1)) - - if not advtrains.trackdb[tt][y] then advtrains.trackdb[tt][y]={} end - if not advtrains.trackdb[tt][y][x] then advtrains.trackdb[tt][y][x]={} end - - local rest=file.read("*l") - if rest~="" then - local rely1, rely2, railheight=string.match(rest, "([^|]+)|([^|]+)|([^|]+)") - if rely1 and rely2 and railheight then - advtrains.trackdb[tt][y][x][z]={ - conn1=conn1, conn2=conn2, - rely1=rely1, rely2=rely2, - railheight=railheight - } - else - advtrains.trackdb[tt][y][x][z]={ - conn1=conn1, conn2=conn2 - } - end - else - advtrains.trackdb[tt][y][x][z]={ - conn1=conn1, conn2=conn2 - } - end - end - file:close() - end -end - ---end minetest.after -end) - -function advtrains.save_trackdb() - for tt, _ in pairs(advtrains.all_traintypes) do - local pl_fpath=minetest.get_worldpath().."/advtrains_trackdb_"..tt - local file, err = io.open(pl_fpath, "w") - if not file then - local er=err or "Unknown Error" - print("[advtrains]Failed saving advtrains trackdb save file "..er) - else - --custom format to save memory - for y,tyl in pairs(advtrains.trackdb[tt]) do - for x,txl in pairs(tyl) do - for z,rail in pairs(txl) do - print("write "..x.." "..y.." "..z.." "..minetest.serialize(rail)) - file:write(string.char(math.floor(x/256)+128)..string.char((x%256))) - file:write(string.char(math.floor(y/256)+128)..string.char((y%256))) - file:write(string.char(math.floor(z/256)+128)..string.char((z%256))) - file:write(string.char(rail.conn1)) - file:write(string.char(rail.conn2)) - if (rail.rely1 and rail.rely1~=0) or (rail.rely2 and rail.rely2~=0) or (rail.railheight and rail.railheight~=0) then - file:write(rail.rely1.."|"..rail.rely2.."|"..rail.railheight) - end - file:write("\n") - end - end - end - file:close() - end - end -end -]]--end temp outcomment -advtrains.trackdb={} -advtrains.fpath_tdb=minetest.get_worldpath().."/advtrains_trackdb" -local file, err = io.open(advtrains.fpath_tdb, "r") -if not file then - local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains save file "..er) -else - local tbl = minetest.deserialize(file:read("*a")) - if type(tbl) == "table" then - advtrains.trackdb=tbl - end - file:close() -end -function advtrains.save_trackdb() - local datastr = minetest.serialize(advtrains.trackdb) - if not datastr then - minetest.log("error", "[advtrains] Failed to serialize trackdb data!") - return - end - local file, err = io.open(advtrains.fpath_tdb, "w") - if err then - return err - end - file:write(datastr) - file:close() -end - ---get_node with pseudoload. ---returns: ---true, conn1, conn2, rely1, rely2, railheight in case everything's right. ---false if it's not a rail or the train does not drive on this rail, but it is loaded or ---nil if the node is neither loaded nor in trackdb ---the distraction between false and nil will be needed only in special cases.(train initpos) -function advtrains.get_rail_info_at(pos, traintype) - local node=minetest.get_node_or_nil(pos) - if not node then - --try raildb - local rdp=vector.round(pos) - local dbe=(advtrains.trackdb[traintype] and advtrains.trackdb[traintype][rdp.y] and advtrains.trackdb[traintype][rdp.y][rdp.x] and advtrains.trackdb[traintype][rdp.y][rdp.x][rdp.z]) - if dbe then - return true, dbe.conn1, dbe.conn2, dbe.rely1 or 0, dbe.rely2 or 0, dbe.railheight or 0 - else - return nil - end - end - local nodename=node.name - if(not advtrains.is_track_and_drives_on(nodename, advtrains.all_traintypes[traintype].drives_on)) then - return false - end - local conn1, conn2, rely1, rely2, railheight=advtrains.get_track_connections(node.name, node.param2) - - --already in trackdb? - local rdp=vector.round(pos) - if not (advtrains.trackdb[traintype] and advtrains.trackdb[traintype][rdp.y] and advtrains.trackdb[traintype][rdp.y][rdp.x] and advtrains.trackdb[traintype][rdp.y][rdp.x][rdp.z]) then--TODO is this necessary? - if not advtrains.trackdb[traintype] then advtrains.trackdb[traintype]={} end - if not advtrains.trackdb[traintype][rdp.y] then advtrains.trackdb[traintype][rdp.y]={} end - if not advtrains.trackdb[traintype][rdp.y][rdp.x] then advtrains.trackdb[traintype][rdp.y][rdp.x]={} end - advtrains.trackdb[traintype][rdp.y][rdp.x][rdp.z]={ - conn1=conn1, conn2=conn2, - rely1=rely1, rely2=rely2, - railheight=railheight - } - end - - return true, conn1, conn2, rely1, rely2, railheight -end -function advtrains.reset_trackdb_position(pos) - local rdp=vector.round(pos) - for tt, _ in pairs(advtrains.all_traintypes) do - if not advtrains.trackdb[tt] then advtrains.trackdb[tt]={} end - if not advtrains.trackdb[tt][rdp.y] then advtrains.trackdb[tt][rdp.y]={} end - if not advtrains.trackdb[tt][rdp.y][rdp.x] then advtrains.trackdb[tt][rdp.y][rdp.x]={} end - advtrains.trackdb[tt][rdp.y][rdp.x][rdp.z]=nil - advtrains.get_rail_info_at(pos, tt)--to restore it. - end -end - - diff --git a/readme.txt b/readme.txt deleted file mode 100644 index ad093bd..0000000 --- a/readme.txt +++ /dev/null @@ -1,23 +0,0 @@ - -## ADVTRAINS ## realistic trains in Minetest! -by orwell96 and contributors(see below) - -For up-to-date information, visit https://forum.minetest.net/viewtopic.php?f=9&t=14726 - - -Manual: -If manual.pdf is not present (which is the case when you downloaded the zip file), see https://github.com/orwell96/advtrains/blob/master/manual.pdf - -License of code: LGPL 2.1 -License of media: CC-BY-NC-SA 3.0 - -Contributions: - -Gravel Texture : from Minetest Game -Initial rail model/texture : DS-minetest -Models for signals/bumpers : mbb -Steam engine / wagon texture: mbb -Industrial engine/wagons : mbb -Inventory images : mbb -Small code contributions : NaruTrey / gpcf -Mod Description : hajo \ No newline at end of file diff --git a/signals.lua b/signals.lua deleted file mode 100644 index 8be65e0..0000000 --- a/signals.lua +++ /dev/null @@ -1,76 +0,0 @@ ---advtrains by orwell96 ---signals.lua -for r,f in pairs({on="off", off="on"}) do - - advtrains.trackplacer.register_tracktype("advtrains:retrosignal", "") - advtrains.trackplacer.register_tracktype("advtrains:signal", "") - - for rotid, rotation in ipairs({"", "_30", "_45", "_60"}) do - local crea=1 - if rotid==1 and r=="off" then crea=0 end - - minetest.register_node("advtrains:retrosignal_"..r..rotation, { - drawtype = "mesh", - paramtype="light", - paramtype2="facedir", - walkable = false, - selection_box = { - type = "fixed", - fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4}, - }, - mesh = "advtrains_retrosignal_"..r..rotation..".b3d", - tiles = {"advtrains_retrosignal.png"}, - inventory_image="advtrains_retrosignal_inv.png", - drop="advtrains:retrosignal_off", - description="Lampless Signal ("..r..rotation..")", - on_rightclick=switchfunc, - sunlight_propagates=true, - groups = { - choppy=3, - not_blocking_trains=1, - not_in_creative_inventory=crea, - }, - mesecons = {effector = { - ["action_"..f] = function (pos, node) - minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2}) - end - }}, - on_rightclick=function(pos, node, clicker) - minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2}) - end, - }) - advtrains.trackplacer.add_worked("advtrains:retrosignal", r, rotation, nil) - minetest.register_node("advtrains:signal_"..r..rotation, { - drawtype = "mesh", - paramtype="light", - paramtype2="facedir", - walkable = false, - selection_box = { - type = "fixed", - fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4}, - }, - mesh = "advtrains_signal"..rotation..".b3d", - tiles = {"advtrains_signal_"..r..".png"}, - inventory_image="advtrains_signal_inv.png", - drop="advtrains:signal_off", - description="Signal ("..r..rotation..")", - on_rightclick=switchfunc, - groups = { - choppy=3, - not_blocking_trains=1, - not_in_creative_inventory=crea, - }, - light_source = 1, - sunlight_propagates=true, - mesecons = {effector = { - ["action_"..f] = function (pos, node) - minetest.swap_node(pos, {name = "advtrains:signal_"..f..rotation, param2 = node.param2}) - end - }}, - on_rightclick=function(pos, node, clicker) - minetest.swap_node(pos, {name = "advtrains:signal_"..f..rotation, param2 = node.param2}) - end, - }) - advtrains.trackplacer.add_worked("advtrains:signal", r, rotation, nil) - end -end diff --git a/textures/advtrains_couple.png b/textures/advtrains_couple.png deleted file mode 100644 index 9e997e4..0000000 Binary files a/textures/advtrains_couple.png and /dev/null differ diff --git a/textures/advtrains_discouple.png b/textures/advtrains_discouple.png deleted file mode 100644 index b27c4fb..0000000 Binary files a/textures/advtrains_discouple.png and /dev/null differ diff --git a/textures/advtrains_dtrack_bumper_placer.png b/textures/advtrains_dtrack_bumper_placer.png deleted file mode 100644 index 27191fe..0000000 Binary files a/textures/advtrains_dtrack_bumper_placer.png and /dev/null differ diff --git a/textures/advtrains_dtrack_detector_placer.png b/textures/advtrains_dtrack_detector_placer.png deleted file mode 100644 index e6c6ad6..0000000 Binary files a/textures/advtrains_dtrack_detector_placer.png and /dev/null differ diff --git a/textures/advtrains_dtrack_placer.png b/textures/advtrains_dtrack_placer.png deleted file mode 100644 index c49777c..0000000 Binary files a/textures/advtrains_dtrack_placer.png and /dev/null differ diff --git a/textures/advtrains_dtrack_rail.png b/textures/advtrains_dtrack_rail.png deleted file mode 100644 index 568e533..0000000 Binary files a/textures/advtrains_dtrack_rail.png and /dev/null differ diff --git a/textures/advtrains_dtrack_rail_detector_on.png b/textures/advtrains_dtrack_rail_detector_on.png deleted file mode 100644 index 3ae0dac..0000000 Binary files a/textures/advtrains_dtrack_rail_detector_on.png and /dev/null differ diff --git a/textures/advtrains_dtrack_slopeplacer.png b/textures/advtrains_dtrack_slopeplacer.png deleted file mode 100644 index 1d456b0..0000000 Binary files a/textures/advtrains_dtrack_slopeplacer.png and /dev/null differ diff --git a/textures/advtrains_engine_industrial.png b/textures/advtrains_engine_industrial.png deleted file mode 100644 index 38a872f..0000000 Binary files a/textures/advtrains_engine_industrial.png and /dev/null differ diff --git a/textures/advtrains_engine_industrial_inv.png b/textures/advtrains_engine_industrial_inv.png deleted file mode 100644 index be4e80f..0000000 Binary files a/textures/advtrains_engine_industrial_inv.png and /dev/null differ diff --git a/textures/advtrains_engine_japan.png b/textures/advtrains_engine_japan.png deleted file mode 100644 index b286b38..0000000 Binary files a/textures/advtrains_engine_japan.png and /dev/null differ diff --git a/textures/advtrains_engine_japan_inv.png b/textures/advtrains_engine_japan_inv.png deleted file mode 100644 index 6af0636..0000000 Binary files a/textures/advtrains_engine_japan_inv.png and /dev/null differ diff --git a/textures/advtrains_newlocomotive.png b/textures/advtrains_newlocomotive.png deleted file mode 100644 index e461bc7..0000000 Binary files a/textures/advtrains_newlocomotive.png and /dev/null differ diff --git a/textures/advtrains_newlocomotive.xcf b/textures/advtrains_newlocomotive.xcf deleted file mode 100644 index 9ad5187..0000000 Binary files a/textures/advtrains_newlocomotive.xcf and /dev/null differ diff --git a/textures/advtrains_newlocomotive_inv.png b/textures/advtrains_newlocomotive_inv.png deleted file mode 100755 index 8d3fafb..0000000 Binary files a/textures/advtrains_newlocomotive_inv.png and /dev/null differ diff --git a/textures/advtrains_platform.png b/textures/advtrains_platform.png deleted file mode 100644 index 5ba9663..0000000 Binary files a/textures/advtrains_platform.png and /dev/null differ diff --git a/textures/advtrains_retrosignal.png b/textures/advtrains_retrosignal.png deleted file mode 100644 index 141198d..0000000 Binary files a/textures/advtrains_retrosignal.png and /dev/null differ diff --git a/textures/advtrains_retrosignal_inv.png b/textures/advtrains_retrosignal_inv.png deleted file mode 100644 index 1036594..0000000 Binary files a/textures/advtrains_retrosignal_inv.png and /dev/null differ diff --git a/textures/advtrains_signal_inv.png b/textures/advtrains_signal_inv.png deleted file mode 100644 index ed64ed9..0000000 Binary files a/textures/advtrains_signal_inv.png and /dev/null differ diff --git a/textures/advtrains_signal_off.png b/textures/advtrains_signal_off.png deleted file mode 100644 index 8046e52..0000000 Binary files a/textures/advtrains_signal_off.png and /dev/null differ diff --git a/textures/advtrains_signal_on.png b/textures/advtrains_signal_on.png deleted file mode 100644 index 5228bb3..0000000 Binary files a/textures/advtrains_signal_on.png and /dev/null differ diff --git a/textures/advtrains_subway_train.png b/textures/advtrains_subway_train.png deleted file mode 100644 index 1d569f3..0000000 Binary files a/textures/advtrains_subway_train.png and /dev/null differ diff --git a/textures/advtrains_subway_train_inv.png b/textures/advtrains_subway_train_inv.png deleted file mode 100644 index 1d0e809..0000000 Binary files a/textures/advtrains_subway_train_inv.png and /dev/null differ diff --git a/textures/advtrains_track_cr.png b/textures/advtrains_track_cr.png deleted file mode 100644 index 40f0cc5..0000000 Binary files a/textures/advtrains_track_cr.png and /dev/null differ diff --git a/textures/advtrains_track_cr_45.png b/textures/advtrains_track_cr_45.png deleted file mode 100644 index 54966b3..0000000 Binary files a/textures/advtrains_track_cr_45.png and /dev/null differ diff --git a/textures/advtrains_track_placer.png b/textures/advtrains_track_placer.png deleted file mode 100644 index 03e17ed..0000000 Binary files a/textures/advtrains_track_placer.png and /dev/null differ diff --git a/textures/advtrains_track_st.png b/textures/advtrains_track_st.png deleted file mode 100644 index 5ad7e4f..0000000 Binary files a/textures/advtrains_track_st.png and /dev/null differ diff --git a/textures/advtrains_track_st_45.png b/textures/advtrains_track_st_45.png deleted file mode 100644 index 63b4c96..0000000 Binary files a/textures/advtrains_track_st_45.png and /dev/null differ diff --git a/textures/advtrains_track_swlcr.png b/textures/advtrains_track_swlcr.png deleted file mode 100644 index d9b5c0b..0000000 Binary files a/textures/advtrains_track_swlcr.png and /dev/null differ diff --git a/textures/advtrains_track_swlcr_45.png b/textures/advtrains_track_swlcr_45.png deleted file mode 100644 index f098fc9..0000000 Binary files a/textures/advtrains_track_swlcr_45.png and /dev/null differ diff --git a/textures/advtrains_track_swlst.png b/textures/advtrains_track_swlst.png deleted file mode 100644 index 314bd2d..0000000 Binary files a/textures/advtrains_track_swlst.png and /dev/null differ diff --git a/textures/advtrains_track_swlst_45.png b/textures/advtrains_track_swlst_45.png deleted file mode 100644 index 765d0ec..0000000 Binary files a/textures/advtrains_track_swlst_45.png and /dev/null differ diff --git a/textures/advtrains_track_swrcr.png b/textures/advtrains_track_swrcr.png deleted file mode 100644 index f74e1bc..0000000 Binary files a/textures/advtrains_track_swrcr.png and /dev/null differ diff --git a/textures/advtrains_track_swrcr_45.png b/textures/advtrains_track_swrcr_45.png deleted file mode 100644 index fa432aa..0000000 Binary files a/textures/advtrains_track_swrcr_45.png and /dev/null differ diff --git a/textures/advtrains_track_swrst.png b/textures/advtrains_track_swrst.png deleted file mode 100644 index 06ea29e..0000000 Binary files a/textures/advtrains_track_swrst.png and /dev/null differ diff --git a/textures/advtrains_track_swrst_45.png b/textures/advtrains_track_swrst_45.png deleted file mode 100644 index be477b7..0000000 Binary files a/textures/advtrains_track_swrst_45.png and /dev/null differ diff --git a/textures/advtrains_trackworker.png b/textures/advtrains_trackworker.png deleted file mode 100644 index b50bcae..0000000 Binary files a/textures/advtrains_trackworker.png and /dev/null differ diff --git a/textures/advtrains_wagon.png b/textures/advtrains_wagon.png deleted file mode 100644 index c37c979..0000000 Binary files a/textures/advtrains_wagon.png and /dev/null differ diff --git a/textures/advtrains_wagon_box.png b/textures/advtrains_wagon_box.png deleted file mode 100644 index 8bfbe06..0000000 Binary files a/textures/advtrains_wagon_box.png and /dev/null differ diff --git a/textures/advtrains_wagon_box_inv.png b/textures/advtrains_wagon_box_inv.png deleted file mode 100644 index 480f245..0000000 Binary files a/textures/advtrains_wagon_box_inv.png and /dev/null differ diff --git a/textures/advtrains_wagon_inv.png b/textures/advtrains_wagon_inv.png deleted file mode 100755 index 0b72ac3..0000000 Binary files a/textures/advtrains_wagon_inv.png and /dev/null differ diff --git a/textures/advtrains_wagon_japan.png b/textures/advtrains_wagon_japan.png deleted file mode 100644 index bee565e..0000000 Binary files a/textures/advtrains_wagon_japan.png and /dev/null differ diff --git a/textures/advtrains_wagon_japan_inv.png b/textures/advtrains_wagon_japan_inv.png deleted file mode 100644 index 3e6357c..0000000 Binary files a/textures/advtrains_wagon_japan_inv.png and /dev/null differ diff --git a/textures/advtrains_wagon_tank.png b/textures/advtrains_wagon_tank.png deleted file mode 100644 index 79b1316..0000000 Binary files a/textures/advtrains_wagon_tank.png and /dev/null differ diff --git a/textures/advtrains_wagon_tank_inv.png b/textures/advtrains_wagon_tank_inv.png deleted file mode 100644 index 03401be..0000000 Binary files a/textures/advtrains_wagon_tank_inv.png and /dev/null differ diff --git a/textures/advtrains_wagon_wood.png b/textures/advtrains_wagon_wood.png deleted file mode 100644 index acc6f72..0000000 Binary files a/textures/advtrains_wagon_wood.png and /dev/null differ diff --git a/textures/advtrains_wagon_wood_inv.png b/textures/advtrains_wagon_wood_inv.png deleted file mode 100644 index 87109dd..0000000 Binary files a/textures/advtrains_wagon_wood_inv.png and /dev/null differ diff --git a/textures/drwho_screwdriver.png b/textures/drwho_screwdriver.png deleted file mode 100644 index b50bcae..0000000 Binary files a/textures/drwho_screwdriver.png and /dev/null differ diff --git a/textures/larger rails.xcf b/textures/larger rails.xcf deleted file mode 100644 index 42ae592..0000000 Binary files a/textures/larger rails.xcf and /dev/null differ diff --git a/trackplacer.lua b/trackplacer.lua deleted file mode 100644 index eebf2ae..0000000 --- a/trackplacer.lua +++ /dev/null @@ -1,282 +0,0 @@ ---trackplacer.lua ---holds code for the track-placing system. the default 'track' item will be a craftitem that places rails as needed. this will neither place or change switches nor place vertical rails. - ---all new trackplacer code -local tp={ - tracks={} -} - -function tp.register_tracktype(nnprefix, n_suffix) - tp.tracks[nnprefix]={ - default=n_suffix, - single_conn={}, - double_conn={}, - --keys:conn1_conn2 (example:1_4) - --values:{name=x, param2=x} - twcycle={}, - twrotate={},--indexed by suffix, list, tells order of rotations - modify={} - } -end -function tp.add_double_conn(nnprefix, suffix, rotation, conns) - local nodename=nnprefix.."_"..suffix..rotation - for i=0,3 do - tp.tracks[nnprefix].double_conn[((conns.conn1+4*i)%16).."_"..((conns.conn2+4*i)%16)]={name=nodename, param2=i} - tp.tracks[nnprefix].double_conn[((conns.conn2+4*i)%16).."_"..((conns.conn1+4*i)%16)]={name=nodename, param2=i} - end - tp.tracks[nnprefix].modify[nodename]=true -end -function tp.add_single_conn(nnprefix, suffix, rotation, conns) - local nodename=nnprefix.."_"..suffix..rotation - for i=0,3 do - tp.tracks[nnprefix].single_conn[((conns.conn1+4*i)%16)]={name=nodename, param2=i} - tp.tracks[nnprefix].single_conn[((conns.conn2+4*i)%16)]={name=nodename, param2=i} - end - tp.tracks[nnprefix].modify[nodename]=true -end - -function tp.add_worked(nnprefix, suffix, rotation, cycle_follows) - tp.tracks[nnprefix].twcycle[suffix]=cycle_follows - if not tp.tracks[nnprefix].twrotate[suffix] then tp.tracks[nnprefix].twrotate[suffix]={} end - table.insert(tp.tracks[nnprefix].twrotate[suffix], rotation) -end - - ---[[ - rewrite algorithm. - selection criteria: these will never be changed or even selected: - - tracks being already connected on both sides - - tracks that are already connected on one side but are not bendable to the desired position - the following situations can occur: - 1. there are two more than two rails around - 1.1 there is one or more subset(s) that can be directly connected - -> choose the first possibility - 2.2 not - -> choose the first one and orient straight - 2. there's exactly 1 rail around - -> choose and orient straight - 3. there's no rail around - -> set straight -]] -function tp.find_already_connected(pos)--TODO vertical calculations(check node below) - local function istrackandbc(pos, conn) - local cnode=minetest.get_node(advtrains.dirCoordSet(pos, conn)) - local bconn=(conn+8)%16 - if advtrains.is_track_and_drives_on(cnode.name, advtrains.all_tracktypes) then - local cconn1, cconn2=advtrains.get_track_connections(cnode.name, cnode.param2) - return cconn1==bconn or cconn2==bconn - end - return false - end - local dnode=minetest.get_node(pos) - local dconn1, dconn2=advtrains.get_track_connections(dnode.name, dnode.param2) - local t={[true]="true", [false]="false"} - if istrackandbc(pos, dconn1) and istrackandbc(pos, dconn2) then return dconn1, dconn2 - elseif istrackandbc(pos, dconn1) then return dconn1 - elseif istrackandbc(pos, dconn2) then return dconn2 - end - return nil -end -function tp.rail_and_can_be_bent(originpos, conn, nnpref) - local pos=advtrains.dirCoordSet(originpos, conn) - local newdir=(conn+8)%16 - local node=minetest.get_node(pos) - local tr=tp.tracks[nnpref] - if not advtrains.is_track_and_drives_on(node.name, advtrains.all_tracktypes) then - return false - end - --rail at other end? - local adj1, adj2=tp.find_already_connected(pos) - if adj1 and adj2 then - return false--dont destroy existing track - elseif adj1 and not adj2 then - if tr.double_conn[adj1.."_"..newdir] then - return true--if exists, connect new rail and old end - end - return false - else - if tr.single_conn[newdir] then--just rotate old rail to right orientation - return true - end - return false - end -end -function tp.bend_rail(originpos, conn, nnpref) - local pos=advtrains.dirCoordSet(originpos, conn) - local newdir=(conn+8)%16 - local node=minetest.get_node(pos) - local tr=tp.tracks[nnpref] - --is rail already connected? no need to bend. - local conn1, conn2=advtrains.get_track_connections(node.name, node.param2) - if newdir==conn1 or newdir==conn2 then - return - end - --rail at other end? - local adj1, adj2=tp.find_already_connected(pos) - if adj1 and adj2 then - return false--dont destroy existing track - elseif adj1 and not adj2 then - if tr.double_conn[adj1.."_"..newdir] then - minetest.set_node(pos, tr.double_conn[adj1.."_"..newdir]) - return true--if exists, connect new rail and old end - end - return false - else - if tr.single_conn[newdir] then--just rotate old rail to right orientation - minetest.set_node(pos, tr.single_conn[newdir]) - return true - end - return false - end -end -function tp.placetrack(pos, nnpref) - --1. find all rails that are likely to be connected - local tr=tp.tracks[nnpref] - local p_rails={} - for i=0,15 do - if tp.rail_and_can_be_bent(pos, i, nnpref) then - p_rails[#p_rails+1]=i - end - end - if #p_rails==0 then - minetest.set_node(pos, {name=nnpref.."_"..tr.default}) - elseif #p_rails==1 then - tp.bend_rail(pos, p_rails[1], nnpref) - minetest.set_node(pos, tr.single_conn[p_rails[1]]) - else - --iterate subsets - for k1, conn1 in ipairs(p_rails) do - for k2, conn2 in ipairs(p_rails) do - if k1~=k2 then - if (tr.double_conn[conn1.."_"..conn2]) then - tp.bend_rail(pos, conn1, nnpref) - tp.bend_rail(pos, conn2, nnpref) - minetest.set_node(pos, tr.double_conn[conn1.."_"..conn2]) - return - end - end - end - end - --not found - tp.bend_rail(pos, p_rails[1], nnpref) - minetest.set_node(pos, tr.single_conn[p_rails[1]]) - end -end - - -function tp.register_track_placer(nnprefix, imgprefix, dispname) - minetest.register_craftitem(nnprefix.."_placer",{ - description = dispname, - inventory_image = imgprefix.."_placer.png", - wield_image = imgprefix.."_placer.png", - groups={}, - on_place = function(itemstack, placer, pointed_thing) - local name = placer:get_player_name() - if not name then - return itemstack - end - if pointed_thing.type=="node" then - local pos=pointed_thing.above - local upos=pointed_thing.under - if minetest.is_protected(pos,name) and minetest.is_protected(upos,name) then - return itemstack - end - if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to - and minetest.registered_nodes[minetest.get_node(upos).name] and minetest.registered_nodes[minetest.get_node(upos).name].walkable then - tp.placetrack(pos, nnprefix) - if not minetest.setting_getbool("creative_mode") then - itemstack:take_item() - end - end - end - return itemstack - end, - }) -end - - - -minetest.register_craftitem("advtrains:trackworker",{ - description = "Track Worker Tool\n\nLeft-click: change rail type (straight/curve/switch)\nRight-click: rotate rail/bumper/signal/etc.", - groups = {cracky=1}, -- key=name, value=rating; rating=1..3. - inventory_image = "advtrains_trackworker.png", - wield_image = "advtrains_trackworker.png", - stack_max = 1, - on_place = function(itemstack, placer, pointed_thing) - local name = placer:get_player_name() - if not name then - return - end - if pointed_thing.type=="node" then - local pos=pointed_thing.under - if minetest.is_protected(pos, name) then - return - end - local node=minetest.get_node(pos) - - --if not advtrains.is_track_and_drives_on(minetest.get_node(pos).name, advtrains.all_tracktypes) then return end - if advtrains.is_train_at_pos(pos) then return end - - local nnprefix, suffix, rotation=string.match(node.name, "^(.+)_([^_]+)(_[^_]+)$") - --print(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) - if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then - nnprefix, suffix=string.match(node.name, "^(.+)_([^_]+)$") - rotation = "" - if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then - minetest.chat_send_player(placer:get_player_name(), "This node can't be rotated using the trackworker!") - return - end - end - local modext=tp.tracks[nnprefix].twrotate[suffix] - - if rotation==modext[#modext] then --increase param2 - minetest.set_node(pos, {name=nnprefix.."_"..suffix..modext[1], param2=(node.param2+1)%4}) - return - else - local modpos - for k,v in pairs(modext) do if v==rotation then modpos=k end end - if not modpos then - minetest.chat_send_player(placer:get_player_name(), "This node can't be rotated using the trackworker!") - return - end - minetest.set_node(pos, {name=nnprefix.."_"..suffix..modext[modpos+1], param2=node.param2}) - end - advtrains.invalidate_all_paths() - end - end, - on_use=function(itemstack, user, pointed_thing) - local name = user:get_player_name() - if not name then - return - end - if pointed_thing.type=="node" then - local pos=pointed_thing.under - local node=minetest.get_node(pos) - if minetest.is_protected(pos, name) then - return - end - - --if not advtrains.is_track_and_drives_on(minetest.get_node(pos).name, advtrains.all_tracktypes) then return end - if advtrains.is_train_at_pos(pos) then return end - local nnprefix, suffix, rotation=string.match(node.name, "^(.+)_([^_]+)(_[^_]+)$") - --print(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) - if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twcycle[suffix] then - nnprefix, suffix=string.match(node.name, "^(.+)_([^_]+)$") - rotation = "" - if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twcycle[suffix] then - minetest.chat_send_player(user:get_player_name(), "This node can't be changed using the trackworker!") - return - end - end - local nextsuffix=tp.tracks[nnprefix].twcycle[suffix] - minetest.set_node(pos, {name=nnprefix.."_"..nextsuffix..rotation, param2=node.param2}) - --invalidate trains - advtrains.invalidate_all_paths() - else - print(name, dump(tp.tracks)) - end - end, -}) - ---putting into right place -advtrains.trackplacer=tp diff --git a/tracks.lua b/tracks.lua deleted file mode 100644 index 99dbb27..0000000 --- a/tracks.lua +++ /dev/null @@ -1,693 +0,0 @@ ---advtrains by orwell96, see readme.txt - ---dev-time settings: ---EDIT HERE ---If the old non-model rails on straight tracks should be replaced by the new... ---false: no ---true: yes -advtrains.register_replacement_lbms=false - ---[[TracksDefinition -nodename_prefix -texture_prefix -description -common={} -straight={} -straight45={} -curve={} -curve45={} -lswitchst={} -lswitchst45={} -rswitchst={} -rswitchst45={} -lswitchcr={} -lswitchcr45={} -rswitchcr={} -rswitchcr45={} -vert1={ - --you'll probably want to override mesh here -} -vert2={ - --you'll probably want to override mesh here -} -]]-- -advtrains.all_tracktypes={} - ---definition preparation -local function conns(c1, c2, r1, r2, rh, rots) return {conn1=c1, conn2=c2, rely1=r1, rely2=r2, railheight=rh} end - -local t_30deg={ - regstep=1, - variant={ - st=conns(0,8), - cr=conns(0,7), - swlst=conns(0,8), - swlcr=conns(0,7), - swrst=conns(0,8), - swrcr=conns(0,9), - vst1=conns(8,0,0,0.5,0.25), - vst2=conns(8,0,0.5,1,0.75), - vst31=conns(8,0,0,0.33,0.16), - vst32=conns(8,0,0.33,0.66,0.5), - vst33=conns(8,0,0.66,1,0.83), - }, - description={ - st="straight", - cr="curve", - swlst="left switch (straight)", - swlcr="left switch (curve)", - swrst="right switch (straight)", - swrcr="right switch (curve)", - vst1="steep uphill 1/2", - vst2="steep uphill 2/2", - vst31="uphill 1/3", - vst32="uphill 2/3", - vst33="uphill 3/3", - }, - switch={ - swlst="swlcr", - swlcr="swlst", - swrst="swrcr", - swrcr="swrst", - }, - switchmc={ - swlst="on", - swlcr="off", - swrst="on", - swrcr="off", - }, - regtp=true, - trackplacer={ - st=true, - cr=true, - }, - tpsingle={ - st=true, - }, - tpdefault="st", - trackworker={ - ["swrcr"]="st", - ["swrst"]="st", - ["st"]="cr", - ["cr"]="swlst", - ["swlcr"]="swrcr", - ["swlst"]="swrst", - }, - regsp=true, - slopenodes={ - vst1=true, vst2=true, - vst31=true, vst32=true, vst33=true, - }, - slopeplacer={ - [2]={"vst1", "vst2"}, - [3]={"vst31", "vst32", "vst33"}, - max=3,--highest entry - }, - slopeplacer_45={ - [2]={"vst1_45", "vst2_45"}, - max=2, - }, - rotation={"", "_30", "_45", "_60"}, - increativeinv={}, -} -local t_30deg_straightonly={ - regstep=1, - variant={ - st=conns(0,8), - }, - description={ - st="straight", - }, - switch={ - }, - switchmc={ - }, - regtp=true, - trackplacer={ - }, - tpsingle={ - }, - tpdefault="st", - trackworker={ - ["st"]="st", - }, - slopenodes={}, - 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={ - }, - tpdefault="st", - trackworker={ - ["st"]="st", - }, - slopenodes={}, - rotation={"", "_30", "_45", "_60"}, - increativeinv={st}, -} -local t_45deg={ - regstep=2, - variant={ - st=conns(0,8), - cr=conns(0,6), - swlst=conns(0,8), - swlcr=conns(0,6), - swrst=conns(0,8), - swrcr=conns(0,10), - vst1=conns(8,0,0,0.5,0.25), - vst2=conns(8,0,0.5,1,0.75), - }, - description={ - st="straight", - cr="curve", - swlst="left switch (straight)", - swlcr="left switch (curve)", - swrst="right switch (straight)", - swrcr="right switch (curve)", - vst1="vertical lower node", - vst2="vertical upper node", - }, - switch={ - swlst="swlcr", - swlcr="swlst", - swrst="swrcr", - swrcr="swrst", - }, - switchmc={ - swlst="on", - swlcr="off", - swrst="on", - swrcr="off", - }, - regtp=true, - trackplacer={ - st=true, - cr=true, - }, - tpsingle={ - st=true, - }, - tpdefault="st", - trackworker={ - ["swrcr"]="st", - ["swrst"]="st", - ["st"]="cr", - ["cr"]="swlst", - ["swlcr"]="swrcr", - ["swlst"]="swrst", - }, - slopenodes={}, - rotation={"", "_45"}, - increativeinv={vst1=true, vst2=true} -} - ---definition format: ([] optional) ---[[{ - nodename_prefix - texture_prefix - [shared_texture] - models_prefix - models_suffix (with dot) - [shared_model] - formats={ - st,cr,swlst,swlcr,swrst,swrcr,vst1,vst2 - (each a table with indices 0-3, for if to register a rail with this 'rotation' table entry. nil is assumed as 'all', set {} to not register at all) - } - common={} change something on common rail appearance -}]] -function advtrains.register_tracks(tracktype, def, preset) - local function make_switchfunc(suffix_target, mesecon_state) - local switchfunc=function(pos, node) - if advtrains.is_train_at_pos(pos) then return end - minetest.set_node(pos, {name=def.nodename_prefix.."_"..suffix_target, param2=node.param2}) - advtrains.invalidate_all_paths() - advtrains.reset_trackdb_position(pos) - end - return switchfunc, {effector = { - ["action_"..mesecon_state] = switchfunc, - rules=advtrains.meseconrules - }} - end - local function make_overdef(suffix, rotation, conns, switchfunc, mesecontbl, in_creative_inv, drop_slope) - local img_suffix=suffix..rotation - return { - mesh = def.shared_model or (def.models_prefix.."_"..img_suffix..def.models_suffix), - tiles = {def.shared_texture or (def.texture_prefix.."_"..img_suffix..".png")}, - --inventory_image = def.texture_prefix.."_"..img_suffix..".png", - --wield_image = def.texture_prefix.."_"..img_suffix..".png", - description=def.description.."("..preset.description[suffix]..rotation..")", - connect1=conns.conn1, - connect2=conns.conn2, - rely1=conns.rely1 or 0, - rely2=conns.rely2 or 0, - railheight=conns.railheight or 0, - on_rightclick=switchfunc, - groups = { - attached_node=1, - ["advtrains_track_"..tracktype]=1, - dig_immediate=2, - not_in_creative_inventory=(not in_creative_inv and 1 or nil), - not_blocking_trains=1, - }, - mesecons=mesecontbl, - drop = increativeinv and def.nodename_prefix.."_"..suffix..rotation or (drop_slope and def.nodename_prefix.."_slopeplacer" or def.nodename_prefix.."_placer"), - } - end - local function cycle_conns(conns, rotid) - local add=(rotid-1)*preset.regstep - return { - conn1=(conns.conn1+add)%16, - conn2=(conns.conn2+add)%16, - rely1=conns.rely1 or 0, - rely2=conns.rely2 or 0, - railheight=conns.railheight or 0, - } - end - local common_def=advtrains.merge_tables({ - description = def.description, - drawtype = "mesh", - paramtype="light", - paramtype2="facedir", - walkable = false, - selection_box = { - type = "fixed", - fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2}, - }, - rely1=0, - rely2=0, - railheight=0, - drop=def.nodename_prefix.."_placer", - can_dig=function(pos) - return not advtrains.is_train_at_pos(pos) - end, - after_dig_node=function(pos) - advtrains.invalidate_all_paths() - advtrains.reset_trackdb_position(pos) - end, - after_place_node=function(pos) - advtrains.reset_trackdb_position(pos) - end, - }, def.common or {}) - --make trackplacer base def - advtrains.trackplacer.register_tracktype(def.nodename_prefix, preset.tpdefault) - if preset.regtp then - advtrains.trackplacer.register_track_placer(def.nodename_prefix, def.texture_prefix, def.description) - end - if preset.regsp then - advtrains.slope.register_placer(def, preset) - 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 - local switchfunc, mesecontbl - 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], preset.slopenodes[suffix] - ), - adef - ) - ) - --trackplacer - 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 - end - end - table.insert(advtrains.all_tracktypes, tracktype) -end - - -function advtrains.is_track_and_drives_on(nodename, drives_on) - if not minetest.registered_nodes[nodename] then - return false - end - local nodedef=minetest.registered_nodes[nodename] - for k,v in ipairs(drives_on) do - if nodedef.groups["advtrains_track_"..v] then - return true - end - end - return false -end - -function advtrains.get_track_connections(name, param2) - local nodedef=minetest.registered_nodes[name] - if not nodedef then print("[advtrains] get_track_connections couldn't find nodedef for nodename "..(name or "nil")) return 0, 8, 0, 0, 0 end - local noderot=param2 - if not param2 then noderot=0 end - if noderot > 3 then print("[advtrains] get_track_connections: rail has invaild param2 of "..noderot) noderot=0 end - - return (nodedef.connect1 + 4 * noderot)%16, (nodedef.connect2 + 4 * noderot)%16, nodedef.rely1 or 0, nodedef.rely2 or 0, nodedef.railheight or 0 -end - ---detector code ---holds a table with nodes on which trains are on. - -advtrains.detector = {} -advtrains.detector.on_node = {} -advtrains.detector.on_node_restore = {} ---set if paths were invalidated before. tells trainlogic.lua to call advtrains.detector.finalize_restore() -advtrains.detector.clean_step_before = false - ---when train enters a node, call this ---The entry already being contained in advtrains.detector.on_node_restore will not trigger an on_train_enter event on the node. (when path is reset, this is saved). -function advtrains.detector.enter_node(pos, train_id) - local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - --print("enterNode "..pts.." "..train_id) - if not advtrains.detector.on_node[pts] then - advtrains.detector.on_node[pts]=train_id - if advtrains.detector.on_node_restore[pts] then - advtrains.detector.on_node_restore[pts]=nil - else - advtrains.detector.call_enter_callback(advtrains.round_vector_floor_y(pos), train_id) - end - end -end -function advtrains.detector.leave_node(pos, train_id) - local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - --print("leaveNode "..pts.." "..train_id) - if advtrains.detector.on_node[pts] then - advtrains.detector.call_leave_callback(advtrains.round_vector_floor_y(pos), train_id) - advtrains.detector.on_node[pts]=nil - end -end ---called immediately before invalidating paths -function advtrains.detector.setup_restore() - --print("setup_restore") - advtrains.detector.on_node_restore = advtrains.detector.on_node - advtrains.detector.on_node = {} -end ---called one step after invalidating paths, when all trains have restored their path and called enter_node for their contents. -function advtrains.detector.finalize_restore() - --print("finalize_restore") - for pts, train_id in pairs(advtrains.detector.on_node_restore) do - --print("called leave callback "..pts.." "..train_id) - advtrains.detector.call_leave_callback(minetest.string_to_pos(pts), train_id) - end - advtrains.detector.on_node_restore = {} -end -function advtrains.detector.call_enter_callback(pos, train_id) - --print("instructed to call enter calback") - - local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case - local mregnode=minetest.registered_nodes[node.name] - if mregnode and mregnode.advtrains and mregnode.advtrains.on_train_enter then - mregnode.advtrains.on_train_enter(pos, train_id) - end -end -function advtrains.detector.call_leave_callback(pos, train_id) - --print("instructed to call leave calback") - - local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case - local mregnode=minetest.registered_nodes[node.name] - if mregnode and mregnode.advtrains and mregnode.advtrains.on_train_leave then - mregnode.advtrains.on_train_leave(pos, train_id) - end -end - --- slope placer. Defined in register_tracks. ---crafted with rail and gravel -local sl={} -function sl.register_placer(def, preset) - minetest.register_craftitem(def.nodename_prefix.."_slopeplacer",{ - description = def.description.." Slope", - inventory_image = def.texture_prefix.."_slopeplacer.png", - wield_image = def.texture_prefix.."_slopeplacer.png", - groups={}, - on_place = sl.create_slopeplacer_on_place(def, preset) - }) -end ---(itemstack, placer, pointed_thing) -function sl.create_slopeplacer_on_place(def, preset) - return function(istack, player, pt) - if not pt.type=="node" then - minetest.chat_send_player(player:get_player_name(), "Can't place: not pointing at node") - return istack - end - local pos=pt.above - if not pos then - minetest.chat_send_player(player:get_player_name(), "Can't place: not pointing at node") - return istack - end - local node=minetest.get_node(pos) - if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].buildable_to then - minetest.chat_send_player(player:get_player_name(), "Can't place: space occupied!") - return istack - end - if minetest.is_protected(pos, player:get_player_name()) then - minetest.chat_send_player(player:get_player_name(), "Can't place: protected position!") - return istack - end - --determine player orientation (only horizontal component) - --get_look_horizontal may not be available - local yaw=player.get_look_horizontal and player:get_look_horizontal() or (player:get_look_yaw() - math.pi/2) - - --rounding unit vectors is a nice way for selecting 1 of 8 directions since sin(30°) is 0.5. - dirvec={x=math.floor(math.sin(-yaw)+0.5), y=0, z=math.floor(math.cos(-yaw)+0.5)} - --translate to direction to look up inside the preset table - local param2, rot45=({ - [-1]={ - [-1]=2, - [0]=3, - [1]=3, - }, - [0]={ - [-1]=2, - [1]=0, - }, - [1]={ - [-1]=1, - [0]=1, - [1]=0, - }, - })[dirvec.x][dirvec.z], dirvec.x~=0 and dirvec.z~=0 - local lookup=preset.slopeplacer - if rot45 then lookup=preset.slopeplacer_45 end - - --go unitvector forward and look how far the next node is - local step=1 - while step<=lookup.max do - local node=minetest.get_node(vector.add(pos, dirvec)) - --next node solid? - if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].buildable_to or minetest.is_protected(pos, player:get_player_name()) then - --do slopes of this distance exist? - if lookup[step] then - if minetest.setting_getbool("creative_mode") or istack:get_count()>=step then - --start placing - local placenodes=lookup[step] - while step>0 do - minetest.set_node(pos, {name=def.nodename_prefix.."_"..placenodes[step], param2=param2}) - if not minetest.setting_getbool("creative_mode") then - istack:take_item() - end - step=step-1 - pos=vector.subtract(pos, dirvec) - end - else - minetest.chat_send_player(player:get_player_name(), "Can't place: Not enough slope items left ("..step.." required)") - end - else - minetest.chat_send_player(player:get_player_name(), "Can't place: There's no slope of length "..step) - end - return istack - end - step=step+1 - pos=vector.add(pos, dirvec) - end - minetest.chat_send_player(player:get_player_name(), "Can't place: no supporting node at upper end.") - return itemstack - end -end - -advtrains.slope=sl - ---END code, BEGIN definition ---definition format: ([] optional) ---[[{ - nodename_prefix - texture_prefix - [shared_texture] - models_prefix - models_suffix (with dot) - [shared_model] - formats={ - st,cr,swlst,swlcr,swrst,swrcr,vst1,vst2 - (each a table with indices 0-3, for if to register a rail with this 'rotation' table entry. nil is assumed as 'all', set {} to not register at all) - } - common={} change something on common rail appearance -}]] - -advtrains.register_tracks("regular", { - nodename_prefix="advtrains:track", - texture_prefix="advtrains_track", - shared_model="trackplane.b3d", - description="Deprecated Track", - formats={vst1={}, vst2={}}, -}, t_45deg) - - -advtrains.register_tracks("default", { - nodename_prefix="advtrains:dtrack", - texture_prefix="advtrains_dtrack", - models_prefix="advtrains_dtrack", - models_suffix=".b3d", - shared_texture="advtrains_dtrack_rail.png", - description="Track", - formats={vst1={true, false, true}, vst2={true, false, true}, vst31={true}, vst32={true}, vst33={true}}, -}, t_30deg) - ---bumpers -advtrains.register_tracks("default", { - nodename_prefix="advtrains:dtrack_bumper", - texture_prefix="advtrains_dtrack_bumper", - models_prefix="advtrains_dtrack_bumper", - models_suffix=".b3d", - shared_texture="advtrains_dtrack_rail.png", - description="Bumper", - formats={}, -}, t_30deg_straightonly) ---legacy bumpers -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, param2=minetest.get_node(pos).param2}) - 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, param2=minetest.get_node(pos).param2}) - 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 - minetest.register_abm({ - -- In the following two fields, also group:groupname will work. - nodenames = {"advtrains:track_"..name}, - interval = 1.0, -- Operation interval in seconds - chance = 1, -- Chance of trigger per-node per-interval is 1.0 / this - action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:track_"..rep, param2=node.param2}) end, - }) - minetest.register_abm({ - -- In the following two fields, also group:groupname will work. - nodenames = {"advtrains:track_"..name.."_45"}, - interval = 1.0, -- Operation interval in seconds - chance = 1, -- Chance of trigger per-node per-interval is 1.0 / this - action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:track_"..rep.."_45", param2=node.param2}) end, - }) -end - -if advtrains.register_replacement_lbms then -minetest.register_lbm({ - name = "advtrains:ramp_replacement_1", --- In the following two fields, also group:groupname will work. - nodenames = {"advtrains:track_vert1"}, - action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_vst1", param2=(node.param2+2)%4}) end, -}) -minetest.register_lbm({ - name = "advtrains:ramp_replacement_1", --- -- In the following two fields, also group:groupname will work. - nodenames = {"advtrains:track_vert2"}, - action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_vst2", param2=(node.param2+2)%4}) end, -}) - minetest.register_abm({ - name = "advtrains:st_rep_1", - -- In the following two fields, also group:groupname will work. - nodenames = {"advtrains:track_st"}, - interval=1, - chance=1, - action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_st", param2=node.param2}) end, - }) - minetest.register_lbm({ - name = "advtrains:st_rep_1", - -- -- In the following two fields, also group:groupname will work. - nodenames = {"advtrains:track_st_45"}, - action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_st_45", param2=node.param2}) end, - }) -end - - - - - - - - diff --git a/trainhud.lua b/trainhud.lua deleted file mode 100644 index aead246..0000000 --- a/trainhud.lua +++ /dev/null @@ -1,109 +0,0 @@ ---trainhud.lua: holds all the code for train controlling - -advtrains.hud = {} - -minetest.register_on_leaveplayer(function(player) -advtrains.hud[player:get_player_name()] = nil -end) - -local mletter={[1]="F", [-1]="R", [0]="N"} - -function advtrains.on_control_change(pc, train, flip) - if pc.sneak then - if pc.up then - train.tarvelocity = advtrains.all_traintypes[train.traintype].max_speed or 10 - end - if pc.down then - train.tarvelocity = 0 - end - if pc.left then - train.tarvelocity = 4 - end - if pc.right then - train.tarvelocity = 8 - end - if pc.jump then - train.brake = true - --0: released, 1: brake and pressed, 2: released and brake, 3: pressed and brake - if not train.brake_hold_state or train.brake_hold_state==0 then - train.brake_hold_state = 1 - elseif train.brake_hold_state==2 then - train.brake_hold_state = 3 - end - elseif train.brake_hold_state==1 then - train.brake_hold_state = 2 - elseif train.brake_hold_state==3 then - train.brake = false - train.brake_hold_state = 0 - end - --shift+use:see wagons.lua - else - if pc.up then - train.tarvelocity = train.tarvelocity + 1 - end - if pc.down then - if train.velocity>0 then - train.tarvelocity = math.max(train.tarvelocity - 1, 0) - else - train.movedir = -train.movedir - end - end - if train.brake_hold_state~=2 then - train.brake = false - end - if pc.jump then - train.brake = true - end - if pc.aux1 then - --horn - end - end -end -function advtrains.update_driver_hud(pname, train, flip) - advtrains.set_trainhud(pname, advtrains.hud_train_format(train, flip)) -end -function advtrains.clear_driver_hud(pname) - advtrains.set_trainhud(pname, "") -end - -function advtrains.set_trainhud(name, text) - local hud = advtrains.hud[name] - local player=minetest.get_player_by_name(name) - if not player then - return - end - if not hud then - hud = {} - advtrains.hud[name] = hud - hud.id = player:hud_add({ - hud_elem_type = "text", - name = "ADVTRAINS", - number = 0xFFFFFF, - position = {x=0.5, y=0.7}, - offset = {x=0, y=0}, - text = text, - scale = {x=200, y=60}, - alignment = {x=0, y=0}, - }) - hud.oldText=text - return - elseif hud.oldText ~= text then - player:hud_change(hud.id, "text", text) - hud.oldText=text - end -end -function advtrains.hud_train_format(train, flip) - local fct=flip and -1 or 1 - if not train or not train.traintype then return "" end - - local max=advtrains.all_traintypes[train.traintype].max_speed or 10 - local vel=advtrains.abs_ceil(train.velocity) - local tvel=advtrains.abs_ceil(train.tarvelocity) - local topLine, firstLine, secondLine - - topLine=train.traintype.." ["..mletter[fct*train.movedir].."] "..(train.brake and "="..( train.brake_hold_state==2 and "^" or "" ).."B=" or "") - firstLine="Speed: |"..string.rep("+", vel)..string.rep("_", max-vel)..">" - secondLine="Target: |"..string.rep("+", tvel)..string.rep("_", max-tvel)..">" - - return topLine.."\n"..firstLine.."\n"..secondLine -end diff --git a/trainlogic.lua b/trainlogic.lua deleted file mode 100644 index 5e3936f..0000000 --- a/trainlogic.lua +++ /dev/null @@ -1,895 +0,0 @@ ---trainlogic.lua ---controls train entities stuff about connecting/disconnecting/colliding trains and other things - ---local print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end -local print=function() end - -local benchmark=false ---printbm=function(str, t) print("[advtrains]"..str.." "..((os.clock()-t)*1000).."ms") end -local bm={} -local bmlt=0 -local bmsteps=0 -local bmstepint=200 -printbm=function(action, ta) - if not benchmark then return end - local t=(os.clock()-ta)*1000 - if not bm[action] then - bm[action]=t - else - bm[action]=bm[action]+t - end - bmlt=bmlt+t -end -function endstep() - if not benchmark then return end - bmsteps=bmsteps-1 - if bmsteps<=0 then - bmsteps=bmstepint - for key, value in pairs(bm) do - minetest.chat_send_all(key.." "..(value/bmstepint).." ms avg.") - end - minetest.chat_send_all("Total time consumed by all advtrains actions per step: "..(bmlt/bmstepint).." ms avg.") - bm={} - bmlt=0 - end -end - ---TODO: these values need to be integrated when i remove traintypes. -advtrains.train_accel_force=2--per second and divided by number of wagons -advtrains.train_brake_force=3--per second, not divided by number of wagons -advtrains.train_roll_force=0.5--per second, not divided by number of wagons, acceleration when rolling without brake -advtrains.train_emerg_force=10--for emergency brakes(when going off track) - -advtrains.audit_interval=30 - -advtrains.all_traintypes={} -function advtrains.register_train_type(name, drives_on, max_speed) - advtrains.all_traintypes[name]={} - advtrains.all_traintypes[name].drives_on=drives_on - advtrains.all_traintypes[name].max_speed=max_speed or 10 -end - - -advtrains.trains={} -advtrains.wagon_save={} - ---load initially -advtrains.fpath=minetest.get_worldpath().."/advtrains" -local file, err = io.open(advtrains.fpath, "r") -if not file then - local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains save file "..er) -else - local tbl = minetest.deserialize(file:read("*a")) - if type(tbl) == "table" then - advtrains.trains=tbl - end - file:close() -end -advtrains.fpath_ws=minetest.get_worldpath().."/advtrains_wagon_save" -local file, err = io.open(advtrains.fpath_ws, "r") -if not file then - local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains save file "..er) -else - local tbl = minetest.deserialize(file:read("*a")) - if type(tbl) == "table" then - advtrains.wagon_save=tbl - end - file:close() -end - - -advtrains.save = function() - --print("[advtrains]saving") - advtrains.invalidate_all_paths() - local datastr = minetest.serialize(advtrains.trains) - if not datastr then - minetest.log("error", "[advtrains] Failed to serialize train data!") - return - end - local file, err = io.open(advtrains.fpath, "w") - if err then - return err - end - file:write(datastr) - file:close() - - -- update wagon saves - for _,wagon in pairs(minetest.luaentities) do - if wagon.is_wagon and wagon.initialized then - wagon:get_staticdata() - end - end - --cross out userdata - for w_id, data in pairs(advtrains.wagon_save) do - data.name=nil - data.object=nil - if data.driver then - data.driver_name=data.driver:get_player_name() - data.driver=nil - else - data.driver_name=nil - end - if data.discouple then - data.discouple.object:remove() - data.discouple=nil - end - end - --print(dump(advtrains.wagon_save)) - datastr = minetest.serialize(advtrains.wagon_save) - if not datastr then - minetest.log("error", "[advtrains] Failed to serialize train data!") - return - end - file, err = io.open(advtrains.fpath_ws, "w") - if err then - return err - end - file:write(datastr) - file:close() - - advtrains.save_trackdb() -end -minetest.register_on_shutdown(advtrains.save) - -advtrains.save_and_audit_timer=advtrains.audit_interval -minetest.register_globalstep(function(dtime) - advtrains.save_and_audit_timer=advtrains.save_and_audit_timer-dtime - if advtrains.save_and_audit_timer<=0 then - local t=os.clock() - --print("[advtrains] audit step") - --clean up orphaned trains - for k,v in pairs(advtrains.trains) do - --advtrains.update_trainpart_properties(k) - if #v.trainparts==0 then - print("[advtrains][train "..k.."] has empty trainparts, removing.") - advtrains.trains[k]=nil - end - end - --save - advtrains.save() - advtrains.save_and_audit_timer=advtrains.audit_interval - printbm("saving", t) - end - --regular train step - local t=os.clock() - for k,v in pairs(advtrains.trains) do - advtrains.train_step(k, v, dtime) - end - - --see tracks.lua - if advtrains.detector.clean_step_before then - advtrains.detector.finalize_restore() - end - - printbm("trainsteps", t) - endstep() -end) - -function advtrains.train_step(id, train, dtime) - - --TODO check for all vars to be present - if not train.velocity then - train.velocity=0 - end - if not train.movedir or (train.movedir~=1 and train.movedir~=-1) then - train.movedir=1 - end - --very unimportant thing: check if couple is here - if train.couple_eid_front and (not minetest.luaentities[train.couple_eid_front] or not minetest.luaentities[train.couple_eid_front].is_couple) then train.couple_eid_front=nil end - if train.couple_eid_back and (not minetest.luaentities[train.couple_eid_back] or not minetest.luaentities[train.couple_eid_back].is_couple) then train.couple_eid_back=nil end - - --skip certain things (esp. collision) when not moving - local train_moves=(train.velocity~=0) - - --if not train.last_pos then advtrains.trains[id]=nil return end - - if not advtrains.pathpredict(id, train) then - print("pathpredict failed(returned false)") - train.velocity=0 - train.tarvelocity=0 - return - end - - local path=advtrains.get_or_create_path(id, train) - if not path then - train.velocity=0 - train.tarvelocity=0 - print("train has no path for whatever reason") - return - end - - local train_end_index=advtrains.get_train_end_index(train) - --apply off-track handling: - local front_off_track=train.max_index_on_track and train.index>train.max_index_on_track - local back_off_track=train.min_index_on_track and train_end_index1 then train.tarvelocity=1 end - elseif front_off_track then--allow movement only backward - if train.movedir==1 and train.tarvelocity>0 then train.tarvelocity=0 end - if train.movedir==-1 and train.tarvelocity>1 then train.tarvelocity=1 end - elseif back_off_track then--allow movement only forward - if train.movedir==-1 and train.tarvelocity>0 then train.tarvelocity=0 end - if train.movedir==1 and train.tarvelocity>1 then train.tarvelocity=1 end - end - - --update advtrains.detector - if not train.detector_old_index then - train.detector_old_index = math.floor(train_end_index) - train.detector_old_end_index = math.floor(train_end_index) - end - local ifo, ifn, ibo, ibn = train.detector_old_index, math.floor(train.index), train.detector_old_end_index, math.floor(train_end_index) - if ifn>ifo then - for i=ifo, ifn do - if path[i] then - advtrains.detector.enter_node(path[i], id) - end - end - elseif ifnibo then - for i=ibo, ibn do - if path[i] then - advtrains.detector.leave_node(path[i], id) - end - end - end - train.detector_old_index = math.floor(train.index) - train.detector_old_end_index = math.floor(train_end_index) - - if train_moves then - --check for collisions by finding objects - --front - local search_radius=4 - - --coupling - local couple_outward=1 - local posfront=advtrains.get_real_index_position(path, train.index+couple_outward) - local posback=advtrains.get_real_index_position(path, train_end_index-couple_outward) - for _,pos in ipairs({posfront, posback}) do - if pos then - local objrefs=minetest.get_objects_inside_radius(pos, search_radius) - for _,v in pairs(objrefs) do - local le=v:get_luaentity() - if le and le.is_wagon and le.initialized and le.train_id~=id then - advtrains.try_connect_trains(id, le.train_id) - end - end - end - end - --heh, new collision again. - --this time, based on NODES and the advtrains.detector.on_node table. - local collpos - local coll_grace=1 - if train.movedir==1 then - collpos=advtrains.get_real_index_position(path, train.index-coll_grace) - else - collpos=advtrains.get_real_index_position(path, train_end_index+coll_grace) - end - if collpos then - local rcollpos=advtrains.round_vector_floor_y(collpos) - for x=-1,1 do - for z=-1,1 do - local testpts=minetest.pos_to_string(vector.add(rcollpos, {x=x, y=0, z=z})) - if advtrains.detector.on_node[testpts] and advtrains.detector.on_node[testpts]~=id then - --collides - train.recently_collided_with_env=true - train.velocity=0.5*train.velocity - train.movedir=train.movedir*-1 - train.tarvelocity=0 - end - end - end - end - end - --check for any trainpart entities if they have been unloaded. do this only if train is near a player, to not spawn entities into unloaded areas - train.check_trainpartload=(train.check_trainpartload or 0)-dtime - local node_range=(math.max((minetest.setting_get("active_block_range") or 0),1)*16) - if train.check_trainpartload<=0 then - local ori_pos=advtrains.get_real_index_position(path, train.index) --not much to calculate - print("[advtrains][train "..id.."] at "..minetest.pos_to_string(vector.round(ori_pos))) - - local should_check=false - for _,p in ipairs(minetest.get_connected_players()) do - should_check=should_check or ((vector.distance(ori_pos, p:getpos())0 then--accelerating, force will be brought on only by locomotives. - --print("accelerating with default force") - applydiff=(math.min((advtrains.train_accel_force*train.locomotives_in_train*dtime)/mass, math.abs(diff))) - else--decelerating - if front_off_track or back_off_track or train.recently_collided_with_env then --every wagon has a brake, so not divided by mass. - --print("braking with emergency force") - applydiff= -(math.min((advtrains.train_emerg_force*dtime), math.abs(diff))) - elseif train.brake then - --print("braking with default force") - --no math.min, because it can grow beyond tarvelocity, see up there - --dont worry, it will never fall below zero. - applydiff= -((advtrains.train_brake_force*dtime)) - else - --print("roll") - applydiff= -(math.min((advtrains.train_roll_force*dtime), math.abs(diff))) - end - end - train.last_accel=(applydiff*train.movedir) - train.velocity=math.min(math.max( train.velocity+applydiff , 0), advtrains.all_traintypes[train.traintype].max_speed) - else - train.last_accel=0 - end - - --move - --TODO 3,5 + 0.7 - train.index=train.index and train.index+(((train.velocity*train.movedir)/(train.path_dist[math.floor(train.index)] or 1))*dtime) or 0 - -end - - ---structure of train table: ---[[ -trains={ - [train_id]={ - trainparts={ - [n]=wagon_id - } - path={path} - velocity - tarvelocity - index - trainlen - path_inv_level - last_pos | - last_dir | for pathpredicting. - } -} ---a wagon itself has the following properties: -wagon={ - unique_id - train_id - pos_in_train (is index difference, including train_span stuff) - pos_in_trainparts (is index in trainparts tabel of trains) -} -inherited by metatable: -wagon_proto={ - wagon_span -} -]] - ---returns new id -function advtrains.create_new_train_at(pos, pos_prev, traintype) - local newtrain_id=os.time()..os.clock() - while advtrains.trains[newtrain_id] do newtrain_id=os.time()..os.clock() end--ensure uniqueness(will be unneccessary) - - advtrains.trains[newtrain_id]={} - advtrains.trains[newtrain_id].last_pos=pos - advtrains.trains[newtrain_id].last_pos_prev=pos_prev - advtrains.trains[newtrain_id].traintype=traintype - advtrains.trains[newtrain_id].tarvelocity=0 - advtrains.trains[newtrain_id].velocity=0 - advtrains.trains[newtrain_id].trainparts={} - return newtrain_id -end - ---returns false on failure. handle this case! -function advtrains.pathpredict(id, train) - - --print("pos ",x,y,z) - --::rerun:: - if not train.index then train.index=0 end - if not train.path or #train.path<2 then - if not train.last_pos then - --no chance to recover - print("[advtrains]train hasn't saved last-pos, removing train.") - advtrains.train[id]=nil - return false - end - - local node_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(train.last_pos), train.traintype) - - if node_ok==nil then - --block not loaded, do nothing - return nil - elseif node_ok==false then - print("[advtrains]no track here, (fail) removing train.") - advtrains.trains[id]=nil - return false - end - - if not train.last_pos_prev then - --no chance to recover - print("[advtrains]train hasn't saved last-pos_prev, removing train.") - advtrains.trains[id]=nil - return false - end - - local prevnode_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(train.last_pos_prev), train.traintype) - - if prevnode_ok==nil then - --block not loaded, do nothing - return nil - elseif prevnode_ok==false then - print("[advtrains]no track at prev, (fail) removing train.") - advtrains.trains[id]=nil - return false - end - - train.index=(train.restore_add_index or 0)+(train.savedpos_off_track_index_offset or 0) - --restore_add_index is set by save() to prevent trains hopping to next round index. should be between -0.5 and 0.5 - --savedpos_off_track_index_offset is set if train went off track. see below. - train.path={} - train.path_dist={} - train.path[0]=train.last_pos - train.path[-1]=train.last_pos_prev - train.path_dist[-1]=vector.distance(train.last_pos, train.last_pos_prev) - end - - local pregen_front=2 - local pregen_back=2 - if train.velocity>0 then - if train.movedir>0 then - pregen_front=2+math.ceil(train.velocity*0.15) --assumes server step of 0.1 seconds, +50% tolerance - else - pregen_back=2+math.ceil(train.velocity*0.15) - end - end - - - local maxn=advtrains.maxN(train.path) - while (maxn-train.index) < pregen_front do--pregenerate - --print("[advtrains]maxn conway for ",maxn,minetest.pos_to_string(path[maxn]),maxn-1,minetest.pos_to_string(path[maxn-1])) - local conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.traintype) - if conway then - train.path[maxn+1]=conway - train.max_index_on_track=maxn - else - --do as if nothing has happened and preceed with path - --but do not update max_index_on_track - --print("over-generating path max to index "..maxn+1) - train.path[maxn+1]=vector.add(train.path[maxn], vector.subtract(train.path[maxn], train.path[maxn-1])) - end - train.path_dist[maxn]=vector.distance(train.path[maxn+1], train.path[maxn]) - maxn=advtrains.maxN(train.path) - end - - local minn=advtrains.minN(train.path) - while (train.index-minn) < (train.trainlen or 0) + pregen_back do --post_generate. has to be at least trainlen. (we let go of the exact calculation here since this would be unuseful here) - --print("[advtrains]minn conway for ",minn,minetest.pos_to_string(path[minn]),minn+1,minetest.pos_to_string(path[minn+1])) - local conway=advtrains.conway(train.path[minn], train.path[minn+1], train.traintype) - if conway then - train.path[minn-1]=conway - train.min_index_on_track=minn - else - --do as if nothing has happened and preceed with path - --but do not update min_index_on_track - --print("over-generating path min to index "..minn-1) - train.path[minn-1]=vector.add(train.path[minn], vector.subtract(train.path[minn], train.path[minn+1])) - end - train.path_dist[minn-1]=vector.distance(train.path[minn], train.path[minn-1]) - minn=advtrains.minN(train.path) - end - if not train.min_index_on_track then train.min_index_on_track=0 end - if not train.max_index_on_track then train.max_index_on_track=0 end - - --make pos/yaw available for possible recover calls - if train.max_index_on_tracktrain.index then --whoops, train went even more far. same behavior - train.savedpos_off_track_index_offset=train.index-train.min_index_on_track - train.last_pos=train.path[train.min_index_on_track+1] - train.last_pos_prev=train.path[train.min_index_on_track] - --print("train is off-track (back), last positions kept at "..minetest.pos_to_string(train.last_pos).." / "..minetest.pos_to_string(train.last_pos_prev)) - else --regular case - train.savedpos_off_track_index_offset=nil - train.last_pos=train.path[math.floor(train.index+0.5)] - train.last_pos_prev=train.path[math.floor(train.index-0.5)] - end - return train.path -end -function advtrains.get_train_end_index(train) - return advtrains.get_real_path_index(train, train.trainlen or 2)--this function can be found inside wagons.lua since it's more related to wagons. we just set trainlen as pos_in_train -end - -function advtrains.get_or_create_path(id, train) - if not train.path then return advtrains.pathpredict(id, train) end - return train.path -end - -function advtrains.add_wagon_to_train(wagon, train_id, index) - local train=advtrains.trains[train_id] - if index then - table.insert(train.trainparts, index, wagon.unique_id) - else - table.insert(train.trainparts, wagon.unique_id) - end - --this is not the usual case!!! - --we may set initialized because the wagon has no chance to step() - wagon.initialized=true - --TODO is this art or can we throw it away? - advtrains.update_trainpart_properties(train_id) -end -function advtrains.update_trainpart_properties(train_id, invert_flipstate) - local train=advtrains.trains[train_id] - local rel_pos=0 - local count_l=0 - for i, w_id in ipairs(train.trainparts) do - local any_loaded=false - for _,wagon in pairs(minetest.luaentities) do - if wagon.is_wagon and wagon.initialized and wagon.unique_id==w_id then - rel_pos=rel_pos+wagon.wagon_span - wagon.train_id=train_id - wagon.pos_in_train=rel_pos - wagon.pos_in_trainparts=i - wagon.old_velocity_vector=nil - if wagon.is_locomotive then - count_l=count_l+1 - end - if invert_flipstate then - wagon.wagon_flipped = not wagon.wagon_flipped - end - rel_pos=rel_pos+wagon.wagon_span - any_loaded=true - end - end - if not any_loaded then - print("update_trainpart_properties wagon "..w_id.." not loaded, ignoring it.") - end - end - train.trainlen=rel_pos - train.locomotives_in_train=count_l -end - -function advtrains.split_train_at_wagon(wagon) - --get train - local train=advtrains.trains[wagon.train_id] - local real_pos_in_train=advtrains.get_real_path_index(train, wagon.pos_in_train) - local pos_for_new_train=advtrains.get_or_create_path(wagon.train_id, train)[math.floor(real_pos_in_train+wagon.wagon_span)] - local pos_for_new_train_prev=advtrains.get_or_create_path(wagon.train_id, train)[math.floor(real_pos_in_train-1+wagon.wagon_span)] - - --before doing anything, check if both are rails. else do not allow - if not pos_for_new_train then - print("split_train: pos_for_new_train not set") - return false - end - local node_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.traintype) - if not node_ok then - print("split_train: pos_for_new_train "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") - return false - end - - if not train.last_pos_prev then - print("split_train: pos_for_new_train_prev not set") - return false - end - - local prevnode_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.traintype) - if not prevnode_ok then - print("split_train: pos_for_new_train_prev "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") - return false - end - - --create subtrain - local newtrain_id=advtrains.create_new_train_at(pos_for_new_train, pos_for_new_train_prev, train.traintype) - local newtrain=advtrains.trains[newtrain_id] - --insert all wagons to new train - for k,v in ipairs(train.trainparts) do - if k>=wagon.pos_in_trainparts then - table.insert(newtrain.trainparts, v) - train.trainparts[k]=nil - end - end - --update train parts - advtrains.update_trainpart_properties(wagon.train_id)--atm it still is the desierd id. - advtrains.update_trainpart_properties(newtrain_id) - train.tarvelocity=0 - newtrain.velocity=train.velocity - newtrain.tarvelocity=0 -end - ---there are 4 cases: ---1/2. F<->R F<->R regular, put second train behind first ---->frontpos of first train will match backpos of second ---3. F<->R R<->F flip one of these trains, take the other as new train ---->backpos's will match ---4. R<->F F<->R flip one of these trains and take it as new parent ---->frontpos's will match -function advtrains.try_connect_trains(id1, id2) - local train1=advtrains.trains[id1] - local train2=advtrains.trains[id2] - if not train1 or not train2 then return end - if not train1.path or not train2.path then return end - if #train1.trainparts==0 or #train2.trainparts==0 then return end - - local frontpos1=advtrains.get_real_index_position(train1.path, train1.index) - local backpos1=advtrains.get_real_index_position(train1.path, advtrains.get_train_end_index(train1)) - --couple logic - if train1.traintype==train2.traintype then - local frontpos2=advtrains.get_real_index_position(train2.path, train2.index) - local backpos2=advtrains.get_real_index_position(train2.path, advtrains.get_train_end_index(train2)) - - if not frontpos1 or not frontpos2 or not backpos1 or not backpos2 then return end - - local couple_spawnradius=0.7 - --case 1 (first train is front) - if vector.distance(frontpos2, backpos1)1 then - if gp.velocity==0 then - if not self.discouple or not self.discouple.object:getyaw() then - local object=minetest.add_entity(pos, "advtrains:discouple") - if object then - local le=object:get_luaentity() - le.wagon=self - --box is hidden when attached, so unuseful. - --object:set_attach(self.object, "", {x=0, y=0, z=self.wagon_span*10}, {x=0, y=0, z=0}) - self.discouple=le - else - print("Couldn't spawn DisCouple") - end - end - else - if self.discouple and self.discouple.object:getyaw() then - self.discouple.object:remove() - end - end - end - --for path to be available. if not, skip step - if not advtrains.get_or_create_path(self.train_id, gp) then - self.object:setvelocity({x=0, y=0, z=0}) - return - end - if not self.pos_in_train then - --why ever. but better continue next step... - advtrains.update_trainpart_properties(self.train_id) - return - end - - local index=advtrains.get_real_path_index(self:train(), self.pos_in_train) - --print("trainindex "..gp.index.." wagonindex "..index) - - --position recalculation - local first_pos=gp.path[math.floor(index)] - local second_pos=gp.path[math.floor(index)+1] - if not first_pos or not second_pos then - --print("[advtrains] object "..self.unique_id.." path end reached!") - self.object:setvelocity({x=0,y=0,z=0}) - return - end - - --checking for environment collisions(a 3x3 cube around the center) - if not gp.recently_collided_with_env then - local collides=false - for x=-1,1 do - for y=0,2 do - for z=-1,1 do - local node=minetest.get_node_or_nil(vector.add(first_pos, {x=x, y=y, z=z})) - if (advtrains.train_collides(node)) then - collides=true - end - end - end - end - if collides then - gp.recently_collided_with_env=true - gp.velocity=-0.5*gp.velocity - gp.tarvelocity=0 - end - end - - --FIX: use index of the wagon, not of the train. - local velocity=(gp.velocity*gp.movedir)/(gp.path_dist[math.floor(index)] or 1) - local acceleration=(gp.last_accel or 0)/(gp.path_dist[math.floor(index)] or 1) - local factor=index-math.floor(index) - local actual_pos={x=first_pos.x-(first_pos.x-second_pos.x)*factor, y=first_pos.y-(first_pos.y-second_pos.y)*factor, z=first_pos.z-(first_pos.z-second_pos.z)*factor,} - local velocityvec={x=(first_pos.x-second_pos.x)*velocity*-1, z=(first_pos.z-second_pos.z)*velocity*-1, y=(first_pos.y-second_pos.y)*velocity*-1} - local accelerationvec={x=(first_pos.x-second_pos.x)*acceleration*-1, z=(first_pos.z-second_pos.z)*acceleration*-1, y=(first_pos.y-second_pos.y)*acceleration*-1} - - --some additional positions to determine orientation - local aposfwd=gp.path[math.floor(index+2)] - local aposbwd=gp.path[math.floor(index-1)] - - local yaw - if aposfwd and aposbwd then - yaw=advtrains.get_wagon_yaw(aposfwd, second_pos, first_pos, aposbwd, factor)+math.pi--TODO remove when cleaning up - else - yaw=math.atan2((first_pos.x-second_pos.x), (second_pos.z-first_pos.z)) - end - if self.wagon_flipped then - yaw=yaw+math.pi - end - - self.updatepct_timer=(self.updatepct_timer or 0)-dtime - if not self.old_velocity_vector - or not vector.equals(velocityvec, self.old_velocity_vector) - or not self.old_acceleration_vector - or not vector.equals(accelerationvec, self.old_acceleration_vector) - or self.old_yaw~=yaw - or self.updatepct_timer<=0 then--only send update packet if something changed - self.object:setpos(actual_pos) - self.object:setvelocity(velocityvec) - self.object:setacceleration(accelerationvec) - self.object:setyaw(yaw) - self.updatepct_timer=2 - if self.update_animation then - self:update_animation(gp.velocity) - end - end - - - self.old_velocity_vector=velocityvec - self.old_acceleration_vector=accelerationvec - self.old_yaw=yaw - printbm("wagon step", t) -end - -function advtrains.get_real_path_index(train, pit) - local pos_in_train_left=pit - local index=train.index - if pos_in_train_left>(index-math.floor(index))*(train.path_dist[math.floor(index)] or 1) then - pos_in_train_left=pos_in_train_left - (index-math.floor(index))*(train.path_dist[math.floor(index)] or 1) - index=math.floor(index) - while pos_in_train_left>(train.path_dist[index-1] or 1) do - pos_in_train_left=pos_in_train_left - (train.path_dist[index-1] or 1) - index=index-1 - end - index=index-(pos_in_train_left/(train.path_dist[index-1] or 1)) - else - index=index-(pos_in_train_left/(train.path_dist[math.floor(index-1)] or 1)) - end - return index -end - -function wagon:get_on(clicker, seatno) - if not self.seatp then - self.seatp={} - end - if not self.seats[seatno] then return end - if self.seatp[seatno] and self.seatp[seatno]~=clicker:get_player_name() then - self:get_off(seatno) - end - self.seatp[seatno] = clicker:get_player_name() - advtrains.player_to_train_mapping[clicker:get_player_name()]=self.train_id - clicker:set_attach(self.object, "", self.seats[seatno].attach_offset, {x=0,y=0,z=0}) - clicker:set_eye_offset(self.seats[seatno].view_offset, self.seats[seatno].view_offset) -end -function wagon:get_off_plr(pname) - local no=self:get_seatno(pname) - if no then - self:get_off(no) - end -end -function wagon:get_seatno(pname) - for no, cont in pairs(self.seatp) do - if cont==pname then - return no - end - end - return nil -end -function wagon:get_off(seatno) - if not self.seatp[seatno] then return end - local pname = self.seatp[seatno] - local clicker = minetest.get_player_by_name(pname) - advtrains.player_to_train_mapping[pname]=nil - advtrains.clear_driver_hud(pname) - if clicker then - clicker:set_detach() - clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0}) - local objpos=advtrains.round_vector_floor_y(self.object:getpos()) - local yaw=self.object:getyaw() - local isx=(yaw < math.pi/4) or (yaw > 3*math.pi/4 and yaw < 5*math.pi/4) or (yaw > 7*math.pi/4) - --abuse helper function - for _,r in ipairs({-1, 1}) do - local p=vector.add({x=isx and r or 0, y=0, z=not isx and r or 0}, objpos) - if minetest.get_item_group(minetest.get_node(p).name, "platform")>0 then - minetest.after(0.2, function() clicker:setpos({x=p.x, y=p.y+1, z=p.z}) end) - end - end - end - self.seatp[seatno]=nil -end -function wagon:show_get_on_form(pname) - if not self.initialized then return end - if #self.seats==0 then - if self.has_inventory and self.get_inventory_formspec then - minetest.show_formspec(pname, "advtrains_inv_"..self.unique_id, self:get_inventory_formspec()) - end - return - end - local form, comma="size[5,8]label[0.5,0.5;Select seat:]textlist[0.5,1;4,6;seat;", "" - for seatno, seattbl in ipairs(self.seats) do - local addtext, colorcode="", "" - if self.seatp and self.seatp[seatno] then - colorcode="#FF0000" - addtext=" ("..self.seatp[seatno]..")" - end - form=form..comma..colorcode..seattbl.name..addtext - comma="," - end - form=form..";0,false]" - if self.has_inventory and self.get_inventory_formspec then - form=form.."button_exit[1,7;3,1;inv;Show Inventory]" - end - minetest.show_formspec(pname, "advtrains_geton_"..self.unique_id, form) -end -minetest.register_on_player_receive_fields(function(player, formname, fields) - local uid=string.match(formname, "^advtrains_geton_(.+)$") - if uid then - for _,wagon in pairs(minetest.luaentities) do - if wagon.is_wagon and wagon.initialized and wagon.unique_id==uid then - if fields.inv then - if wagon.has_inventory and wagon.get_inventory_formspec then - minetest.show_formspec(player:get_player_name(), "advtrains_inv_"..uid, wagon:get_inventory_formspec()) - end - elseif fields.seat then - local val=minetest.explode_textlist_event(fields.seat) - if val and val.type~="INV" then - --get on - wagon:get_on(player, val.index) - --will work with the new close_formspec functionality. close exactly this formspec. - minetest.show_formspec(player:get_player_name(), formname, "") - end - end - end - end - end -end) -function wagon:reattach_all() - if not self.seatp then self.seatp={} end - for seatno, pname in pairs(self.seatp) do - local p=minetest.get_player_by_name(pname) - if p then - self:get_on(p ,seatno) - end - end -end -minetest.register_on_joinplayer(function(player) - for _,wagon in pairs(minetest.luaentities) do - if wagon.is_wagon and wagon.initialized then - wagon:reattach_all() - end - end -end) - -function advtrains.register_wagon(sysname, traintype, prototype, desc, inv_img) - setmetatable(prototype, {__index=wagon}) - minetest.register_entity("advtrains:"..sysname,prototype) - - minetest.register_craftitem("advtrains:"..sysname, { - description = desc, - inventory_image = inv_img, - wield_image = inv_img, - stack_max = 1, - - on_place = function(itemstack, placer, pointed_thing) - if not pointed_thing.type == "node" then - return - end - - local node=minetest.env:get_node_or_nil(pointed_thing.under) - if not node then print("[advtrains]Ignore at placer position") return itemstack end - local nodename=node.name - if(not advtrains.is_track_and_drives_on(nodename, advtrains.all_traintypes[traintype].drives_on)) then - print("[advtrains]no track here, not placing.") - return itemstack - end - local conn1=advtrains.get_track_connections(node.name, node.param2) - local id=advtrains.create_new_train_at(pointed_thing.under, advtrains.dirCoordSet(pointed_thing.under, conn1), traintype) - - local ob=minetest.env:add_entity(pointed_thing.under, "advtrains:"..sysname) - if not ob then - print("[advtrains]couldn't add_entity, aborting") - end - local le=ob:get_luaentity() - - le.owner=placer:get_player_name() - le.infotext=desc..", owned by "..placer:get_player_name() - - local wagon_uid=le:init_new_instance(id, {}) - - advtrains.add_wagon_to_train(le, id) - if not minetest.setting_getbool("creative_mode") then - itemstack:take_item() - end - return itemstack - - end, - }) -end -advtrains.register_train_type("steam", {"regular", "default"}) - ---[[advtrains.register_wagon("blackwagon", "steam",{textures = {"black.png"}}) -advtrains.register_wagon("bluewagon", "steam",{textures = {"blue.png"}}) -advtrains.register_wagon("greenwagon", "steam",{textures = {"green.png"}}) -advtrains.register_wagon("redwagon", "steam",{textures = {"red.png"}}) -advtrains.register_wagon("yellowwagon", "steam",{textures = {"yellow.png"}}) -]] - ---[[ - wagons can define update_animation(self, velocity) if they have a speed-dependent animation - this function will be called when the velocity vector changes or every 2 seconds. -]] -advtrains.register_wagon("newlocomotive", "steam",{ - mesh="advtrains_engine_steam.b3d", - textures = {"advtrains_newlocomotive.png"}, - is_locomotive=true, - seats = { - { - name="Driver Stand (left)", - attach_offset={x=-5, y=10, z=-10}, - view_offset={x=0, y=6, z=0}, - driving_ctrl_access=true, - }, - { - name="Driver Stand (right)", - attach_offset={x=5, y=10, z=-10}, - view_offset={x=0, y=6, z=0}, - driving_ctrl_access=true, - }, - }, - visual_size = {x=1, y=1}, - wagon_span=1.85, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - update_animation=function(self, velocity) - --if self.old_anim_velocity~=advtrains.abs_ceil(velocity) then - self.object:set_animation({x=1,y=60}, 100)--math.floor(velocity)) - --self.old_anim_velocity=advtrains.abs_ceil(velocity) - --end - end, - custom_on_activate = function(self, staticdata_table, dtime_s) - minetest.add_particlespawner({ - amount = 10, - time = 0, - -- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base - minpos = {x=0, y=2, z=1.2}, - maxpos = {x=0, y=2, z=1.2}, - minvel = {x=-0.2, y=1.8, z=-0.2}, - maxvel = {x=0.2, y=2, z=0.2}, - minacc = {x=0, y=-0.1, z=0}, - maxacc = {x=0, y=-0.3, z=0}, - minexptime = 2, - maxexptime = 4, - minsize = 1, - maxsize = 5, - -- ^ The particle's properties are random values in between the bounds: - -- ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration), - -- ^ minsize/maxsize, minexptime/maxexptime (expirationtime) - collisiondetection = true, - -- ^ collisiondetection: if true uses collision detection - vertical = false, - -- ^ vertical: if true faces player using y axis only - texture = "smoke_puff.png", - -- ^ Uses texture (string) - attached = self.object, - }) - end, - drops={"default:steelblock 4"}, -}, "Steam Engine", "advtrains_newlocomotive_inv.png") -advtrains.register_wagon("wagon_default", "steam",{ - mesh="advtrains_wagon.b3d", - textures = {"advtrains_wagon.png"}, - seats = { - { - name="Default Seat", - attach_offset={x=0, y=10, z=0}, - view_offset={x=0, y=6, z=0}, - }, - }, - visual_size = {x=1, y=1}, - wagon_span=1.8, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, -}, "Passenger Wagon", "advtrains_wagon_inv.png") -advtrains.register_wagon("wagon_box", "steam",{ - mesh="advtrains_wagon.b3d", - textures = {"advtrains_wagon_box.png"}, - seats = {}, - visual_size = {x=1, y=1}, - wagon_span=1.8, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, - has_inventory = true, - get_inventory_formspec = function(self) - return "size[8,11]".. - "list[detached:advtrains_wgn_"..self.unique_id..";box;0,0;8,6;]".. - "list[current_player;main;0,7;8,4;]".. - "listring[]" - end, - inventory_list_sizes = { - box=8*6, - }, -}, "Box Wagon", "advtrains_wagon_box_inv.png") - -advtrains.register_train_type("electric", {"regular", "default"}, 20) - -advtrains.register_wagon("engine_japan", "electric",{ - mesh="advtrains_engine_japan.b3d", - textures = {"advtrains_engine_japan.png"}, - seats = { - { - name="Default Seat (driver stand)", - attach_offset={x=0, y=10, z=0}, - view_offset={x=0, y=6, z=0}, - driving_ctrl_access=true, - }, - }, - visual_size = {x=1, y=1}, - wagon_span=2.5, - is_locomotive=true, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, -}, "Japanese Train Engine", "advtrains_engine_japan_inv.png") - -advtrains.register_wagon("wagon_japan", "electric",{ - mesh="advtrains_wagon_japan.b3d", - textures = {"advtrains_wagon_japan.png"}, - seats = { - { - name="Default Seat", - attach_offset={x=0, y=10, z=0}, - view_offset={x=0, y=6, z=0}, - }, - }, - visual_size = {x=1, y=1}, - wagon_span=2.3, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, -}, "Japanese Train Wagon", "advtrains_wagon_japan_inv.png") - -advtrains.register_wagon("engine_industrial", "electric",{ - mesh="advtrains_engine_industrial.b3d", - textures = {"advtrains_engine_industrial.png"}, - seats = { - { - name="Driver Stand (left)", - attach_offset={x=-5, y=10, z=-10}, - view_offset={x=0, y=10, z=0}, - driving_ctrl_access=true, - }, - { - name="Driver Stand (right)", - attach_offset={x=5, y=10, z=-10}, - view_offset={x=0, y=10, z=0}, - driving_ctrl_access=true, - }, - }, - visual_size = {x=1, y=1}, - wagon_span=2.6, - is_locomotive=true, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, -}, "Industrial Train Engine", "advtrains_engine_industrial_inv.png") -advtrains.register_wagon("wagon_tank", "electric",{ - mesh="advtrains_wagon_tank.b3d", - textures = {"advtrains_wagon_tank.png"}, - seats = {}, - visual_size = {x=1, y=1}, - wagon_span=2.2, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, - has_inventory = true, - get_inventory_formspec = function(self) - return "size[8,11]".. - "list[detached:advtrains_wgn_"..self.unique_id..";box;0,0;8,6;]".. - "list[current_player;main;0,7;8,4;]".. - "listring[]" - end, - inventory_list_sizes = { - box=8*6, - }, -}, "Industrial tank wagon", "advtrains_wagon_tank_inv.png") -advtrains.register_wagon("wagon_wood", "electric",{ - mesh="advtrains_wagon_wood.b3d", - textures = {"advtrains_wagon_wood.png"}, - seats = {}, - visual_size = {x=1, y=1}, - wagon_span=1.8, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, - has_inventory = true, - get_inventory_formspec = function(self) - return "size[8,11]".. - "list[detached:advtrains_wgn_"..self.unique_id..";box;0,0;8,6;]".. - "list[current_player;main;0,7;8,4;]".. - "listring[]" - end, - inventory_list_sizes = { - box=8*6, - }, -}, "Industrial wood wagon", "advtrains_wagon_wood_inv.png") - -advtrains.register_train_type("subway", {"default"}, 15) - -advtrains.register_wagon("subway_wagon", "subway",{ - mesh="advtrains_subway_train.b3d", - textures = {"advtrains_subway_train.png"}, - seats = { - { - name="Default Seat (driver stand)", - attach_offset={x=0, y=10, z=0}, - view_offset={x=0, y=6, z=0}, - driving_ctrl_access=true, - }, - }, - visual_size = {x=1, y=1}, - wagon_span=1.8, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - is_locomotive=true, - drops={"default:steelblock 4"}, -}, "Subway Passenger Wagon", "advtrains_subway_train_inv.png") - - - -- cgit v1.2.3 From d08e202346192c50072450a3eaa3b28cad852b84 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Thu, 22 Dec 2016 18:55:10 +0100 Subject: remove train type concept and calculate train's capabilities based on used wagons --- advtrains/helpers.lua | 13 +++++----- advtrains/pseudoload.lua | 38 ++++++++++++++------------- advtrains/tracks.lua | 8 +++--- advtrains/trainhud.lua | 6 ++--- advtrains/trainlogic.lua | 51 ++++++++++++++++++++----------------- advtrains/wagons.lua | 42 +++--------------------------- advtrains_train_industrial/init.lua | 12 ++++++--- advtrains_train_japan/init.lua | 8 ++++-- advtrains_train_steam/init.lua | 18 ++++++++----- advtrains_train_subway/init.lua | 4 ++- 10 files changed, 95 insertions(+), 105 deletions(-) diff --git a/advtrains/helpers.lua b/advtrains/helpers.lua index 6a8175f..1a02621 100644 --- a/advtrains/helpers.lua +++ b/advtrains/helpers.lua @@ -55,15 +55,14 @@ rely1, rely2 tell to which height the connections are pointed to. 1 means it wil ]] -function advtrains.conway(midreal, prev, traintype)--in order prev,mid,return +function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return local mid=advtrains.round_vector_floor_y(midreal) - local drives_on=advtrains.all_traintypes[traintype].drives_on - if not advtrains.get_rail_info_at(advtrains.round_vector_floor_y(prev), traintype) then + if not advtrains.get_rail_info_at(advtrains.round_vector_floor_y(prev), drives_on) then return nil end - local midnode_ok, middir1, middir2, midrely1, midrely2=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(mid), traintype) + local midnode_ok, middir1, middir2, midrely1, midrely2=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(mid), drives_on) if not midnode_ok then return nil end @@ -104,7 +103,7 @@ function advtrains.conway(midreal, prev, traintype)--in order prev,mid,return return nil end - local nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), traintype) + local nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) --is it a rail? if(not nextnode_ok) then @@ -112,7 +111,7 @@ function advtrains.conway(midreal, prev, traintype)--in order prev,mid,return next.y=next.y-1 y_offset=y_offset-1 - nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), traintype) + nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) if(not nextnode_ok) then --print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!") return nil @@ -125,7 +124,7 @@ function advtrains.conway(midreal, prev, traintype)--in order prev,mid,return next.y=next.y-1 y_offset=y_offset-1 - nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), traintype) + nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) if(not nextnode_ok) then --print("[advtrains]in conway: (at connecting if check again) one below "..minetest.pos_to_string(next).." is not a rail either, returning!") return nil diff --git a/advtrains/pseudoload.lua b/advtrains/pseudoload.lua index 8511811..3f4f321 100644 --- a/advtrains/pseudoload.lua +++ b/advtrains/pseudoload.lua @@ -101,7 +101,7 @@ function advtrains.save_trackdb() end ]]--end temp outcomment advtrains.trackdb={} -advtrains.fpath_tdb=minetest.get_worldpath().."/advtrains_trackdb" +advtrains.fpath_tdb=minetest.get_worldpath().."/advtrains_trackdb2" local file, err = io.open(advtrains.fpath_tdb, "r") if not file then local er=err or "Unknown Error" @@ -133,34 +133,38 @@ end --false if it's not a rail or the train does not drive on this rail, but it is loaded or --nil if the node is neither loaded nor in trackdb --the distraction between false and nil will be needed only in special cases.(train initpos) -function advtrains.get_rail_info_at(pos, traintype) +function advtrains.get_rail_info_at(pos, drives_on) local node=minetest.get_node_or_nil(pos) if not node then --try raildb local rdp=vector.round(pos) local dbe=(advtrains.trackdb[traintype] and advtrains.trackdb[traintype][rdp.y] and advtrains.trackdb[traintype][rdp.y][rdp.x] and advtrains.trackdb[traintype][rdp.y][rdp.x][rdp.z]) if dbe then - return true, dbe.conn1, dbe.conn2, dbe.rely1 or 0, dbe.rely2 or 0, dbe.railheight or 0 + for tt,_ in pairs(drives_on) do + if not dbe.tracktype or tt==dbe.tracktype then + return true, dbe.conn1, dbe.conn2, dbe.rely1 or 0, dbe.rely2 or 0, dbe.railheight or 0 + end + end else return nil end end local nodename=node.name - if(not advtrains.is_track_and_drives_on(nodename, advtrains.all_traintypes[traintype].drives_on)) then + if(not advtrains.is_track_and_drives_on(nodename, drives_on)) then return false end - local conn1, conn2, rely1, rely2, railheight=advtrains.get_track_connections(node.name, node.param2) + local conn1, conn2, rely1, rely2, railheight, tracktype=advtrains.get_track_connections(node.name, node.param2) --already in trackdb? local rdp=vector.round(pos) - if not (advtrains.trackdb[traintype] and advtrains.trackdb[traintype][rdp.y] and advtrains.trackdb[traintype][rdp.y][rdp.x] and advtrains.trackdb[traintype][rdp.y][rdp.x][rdp.z]) then--TODO is this necessary? - if not advtrains.trackdb[traintype] then advtrains.trackdb[traintype]={} end - if not advtrains.trackdb[traintype][rdp.y] then advtrains.trackdb[traintype][rdp.y]={} end - if not advtrains.trackdb[traintype][rdp.y][rdp.x] then advtrains.trackdb[traintype][rdp.y][rdp.x]={} end - advtrains.trackdb[traintype][rdp.y][rdp.x][rdp.z]={ + if not (advtrains.trackdb and advtrains.trackdb[rdp.y] and advtrains.trackdb[rdp.y][rdp.x] and advtrains.trackdb[rdp.y][rdp.x][rdp.z]) then--TODO is this necessary? + if not advtrains.trackdb then advtrains.trackdb={} end + if not advtrains.trackdb[rdp.y] then advtrains.trackdb[rdp.y]={} end + if not advtrains.trackdb[rdp.y][rdp.x] then advtrains.trackdb[rdp.y][rdp.x]={} end + advtrains.trackdb[rdp.y][rdp.x][rdp.z]={ conn1=conn1, conn2=conn2, rely1=rely1, rely2=rely2, - railheight=railheight + railheight=railheight, tracktype=tracktype } end @@ -168,13 +172,11 @@ function advtrains.get_rail_info_at(pos, traintype) end function advtrains.reset_trackdb_position(pos) local rdp=vector.round(pos) - for tt, _ in pairs(advtrains.all_traintypes) do - if not advtrains.trackdb[tt] then advtrains.trackdb[tt]={} end - if not advtrains.trackdb[tt][rdp.y] then advtrains.trackdb[tt][rdp.y]={} end - if not advtrains.trackdb[tt][rdp.y][rdp.x] then advtrains.trackdb[tt][rdp.y][rdp.x]={} end - advtrains.trackdb[tt][rdp.y][rdp.x][rdp.z]=nil - advtrains.get_rail_info_at(pos, tt)--to restore it. - end + if not advtrains.trackdb then advtrains.trackdb={} end + if not advtrains.trackdb[rdp.y] then advtrains.trackdb[rdp.y]={} end + if not advtrains.trackdb[rdp.y][rdp.x] then advtrains.trackdb[rdp.y][rdp.x]={} end + advtrains.trackdb[rdp.y][rdp.x][rdp.z]=nil + advtrains.get_rail_info_at(pos)--to restore it. end diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua index 99dbb27..8bd5666 100644 --- a/advtrains/tracks.lua +++ b/advtrains/tracks.lua @@ -346,17 +346,17 @@ function advtrains.register_tracks(tracktype, def, preset) end end end - table.insert(advtrains.all_tracktypes, tracktype) + advtrains.all_tracktypes[tracktype]=true end -function advtrains.is_track_and_drives_on(nodename, drives_on) +function advtrains.is_track_and_drives_on(nodename, drives_on_p) if not minetest.registered_nodes[nodename] then return false end local nodedef=minetest.registered_nodes[nodename] - for k,v in ipairs(drives_on) do - if nodedef.groups["advtrains_track_"..v] then + for k,v in pairs(drives_on_p) do + if nodedef.groups["advtrains_track_"..k] then return true end end diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua index aead246..19e4f6f 100644 --- a/advtrains/trainhud.lua +++ b/advtrains/trainhud.lua @@ -94,14 +94,14 @@ function advtrains.set_trainhud(name, text) end function advtrains.hud_train_format(train, flip) local fct=flip and -1 or 1 - if not train or not train.traintype then return "" end + if not train then return "" end - local max=advtrains.all_traintypes[train.traintype].max_speed or 10 + local max=train.max_speed or 10 local vel=advtrains.abs_ceil(train.velocity) local tvel=advtrains.abs_ceil(train.tarvelocity) local topLine, firstLine, secondLine - topLine=train.traintype.." ["..mletter[fct*train.movedir].."] "..(train.brake and "="..( train.brake_hold_state==2 and "^" or "" ).."B=" or "") + topLine="Train".." ["..mletter[fct*train.movedir].."] "..(train.brake and "="..( train.brake_hold_state==2 and "^" or "" ).."B=" or "") firstLine="Speed: |"..string.rep("+", vel)..string.rep("_", max-vel)..">" secondLine="Target: |"..string.rep("+", tvel)..string.rep("_", max-tvel)..">" diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index 5e3936f..bb38fce 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -1,8 +1,8 @@ --trainlogic.lua --controls train entities stuff about connecting/disconnecting/colliding trains and other things ---local print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end -local print=function() end +local print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end +--local print=function() end local benchmark=false --printbm=function(str, t) print("[advtrains]"..str.." "..((os.clock()-t)*1000).."ms") end @@ -34,7 +34,6 @@ function endstep() end end ---TODO: these values need to be integrated when i remove traintypes. advtrains.train_accel_force=2--per second and divided by number of wagons advtrains.train_brake_force=3--per second, not divided by number of wagons advtrains.train_roll_force=0.5--per second, not divided by number of wagons, acceleration when rolling without brake @@ -42,13 +41,6 @@ advtrains.train_emerg_force=10--for emergency brakes(when going off track) advtrains.audit_interval=30 -advtrains.all_traintypes={} -function advtrains.register_train_type(name, drives_on, max_speed) - advtrains.all_traintypes[name]={} - advtrains.all_traintypes[name].drives_on=drives_on - advtrains.all_traintypes[name].max_speed=max_speed or 10 -end - advtrains.trains={} advtrains.wagon_save={} @@ -168,7 +160,10 @@ minetest.register_globalstep(function(dtime) end) function advtrains.train_step(id, train, dtime) - + --Legacy: set drives_on and max_speed + if not train.drives_on or not train.max_speed then + advtrains.update_trainpart_properties(id) + end --TODO check for all vars to be present if not train.velocity then train.velocity=0 @@ -377,7 +372,7 @@ function advtrains.train_step(id, train, dtime) end end train.last_accel=(applydiff*train.movedir) - train.velocity=math.min(math.max( train.velocity+applydiff , 0), advtrains.all_traintypes[train.traintype].max_speed) + train.velocity=math.min(math.max( train.velocity+applydiff , 0), train.max_speed or 10) else train.last_accel=0 end @@ -420,14 +415,13 @@ wagon_proto={ ]] --returns new id -function advtrains.create_new_train_at(pos, pos_prev, traintype) +function advtrains.create_new_train_at(pos, pos_prev) local newtrain_id=os.time()..os.clock() while advtrains.trains[newtrain_id] do newtrain_id=os.time()..os.clock() end--ensure uniqueness(will be unneccessary) advtrains.trains[newtrain_id]={} advtrains.trains[newtrain_id].last_pos=pos advtrains.trains[newtrain_id].last_pos_prev=pos_prev - advtrains.trains[newtrain_id].traintype=traintype advtrains.trains[newtrain_id].tarvelocity=0 advtrains.trains[newtrain_id].velocity=0 advtrains.trains[newtrain_id].trainparts={} @@ -448,7 +442,7 @@ function advtrains.pathpredict(id, train) return false end - local node_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(train.last_pos), train.traintype) + local node_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(train.last_pos), train.drives_on) if node_ok==nil then --block not loaded, do nothing @@ -466,7 +460,7 @@ function advtrains.pathpredict(id, train) return false end - local prevnode_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(train.last_pos_prev), train.traintype) + local prevnode_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(train.last_pos_prev), train.drives_on) if prevnode_ok==nil then --block not loaded, do nothing @@ -501,7 +495,7 @@ function advtrains.pathpredict(id, train) local maxn=advtrains.maxN(train.path) while (maxn-train.index) < pregen_front do--pregenerate --print("[advtrains]maxn conway for ",maxn,minetest.pos_to_string(path[maxn]),maxn-1,minetest.pos_to_string(path[maxn-1])) - local conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.traintype) + local conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.drives_on) if conway then train.path[maxn+1]=conway train.max_index_on_track=maxn @@ -518,7 +512,7 @@ function advtrains.pathpredict(id, train) local minn=advtrains.minN(train.path) while (train.index-minn) < (train.trainlen or 0) + pregen_back do --post_generate. has to be at least trainlen. (we let go of the exact calculation here since this would be unuseful here) --print("[advtrains]minn conway for ",minn,minetest.pos_to_string(path[minn]),minn+1,minetest.pos_to_string(path[minn+1])) - local conway=advtrains.conway(train.path[minn], train.path[minn+1], train.traintype) + local conway=advtrains.conway(train.path[minn], train.path[minn+1], train.drives_on) if conway then train.path[minn-1]=conway train.min_index_on_track=minn @@ -576,6 +570,8 @@ function advtrains.add_wagon_to_train(wagon, train_id, index) end function advtrains.update_trainpart_properties(train_id, invert_flipstate) local train=advtrains.trains[train_id] + train.drives_on=advtrains.all_tracktypes + train.max_speed=100 local rel_pos=0 local count_l=0 for i, w_id in ipairs(train.trainparts) do @@ -595,6 +591,15 @@ function advtrains.update_trainpart_properties(train_id, invert_flipstate) end rel_pos=rel_pos+wagon.wagon_span any_loaded=true + + if wagon.drives_on then + for k,_ in pairs(train.drives_on) do + if not wagon.drives_on[k] then + train.drives_on[k]=nil + end + end + end + train.max_speed=math.min(train.max_speed, wagon.max_speed) end end if not any_loaded then @@ -617,7 +622,7 @@ function advtrains.split_train_at_wagon(wagon) print("split_train: pos_for_new_train not set") return false end - local node_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.traintype) + local node_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.drives_on) if not node_ok then print("split_train: pos_for_new_train "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") return false @@ -628,14 +633,14 @@ function advtrains.split_train_at_wagon(wagon) return false end - local prevnode_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.traintype) + local prevnode_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.drives_on) if not prevnode_ok then print("split_train: pos_for_new_train_prev "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") return false end --create subtrain - local newtrain_id=advtrains.create_new_train_at(pos_for_new_train, pos_for_new_train_prev, train.traintype) + local newtrain_id=advtrains.create_new_train_at(pos_for_new_train, pos_for_new_train_prev) local newtrain=advtrains.trains[newtrain_id] --insert all wagons to new train for k,v in ipairs(train.trainparts) do @@ -669,7 +674,7 @@ function advtrains.try_connect_trains(id1, id2) local frontpos1=advtrains.get_real_index_position(train1.path, train1.index) local backpos1=advtrains.get_real_index_position(train1.path, advtrains.get_train_end_index(train1)) --couple logic - if train1.traintype==train2.traintype then + --if train1.traintype==train2.traintype then local frontpos2=advtrains.get_real_index_position(train2.path, train2.index) local backpos2=advtrains.get_real_index_position(train2.path, advtrains.get_train_end_index(train2)) @@ -689,7 +694,7 @@ function advtrains.try_connect_trains(id1, id2) elseif vector.distance(frontpos2, frontpos1) Date: Sat, 31 Dec 2016 15:16:19 +0100 Subject: spawn couple on train collision also fix empty trains hanging around for too long --- advtrains/couple.lua | 2 +- advtrains/pseudoload.lua | 2 +- advtrains/trainlogic.lua | 190 ++++++++++++++++++++--------------------------- 3 files changed, 83 insertions(+), 111 deletions(-) diff --git a/advtrains/couple.lua b/advtrains/couple.lua index a846c8b..675bed5 100644 --- a/advtrains/couple.lua +++ b/advtrains/couple.lua @@ -140,7 +140,7 @@ minetest.register_entity("advtrains:couple", { else tp2=advtrains.get_real_index_position(train2.path, advtrains.get_train_end_index(train2)) end - if not tp1 or not tp2 or not (vector.distance(tp1,tp2)<0.5) then + if not tp1 or not tp2 or not (vector.distance(tp1,tp2)<1.5) then self.object:remove() return else diff --git a/advtrains/pseudoload.lua b/advtrains/pseudoload.lua index 3f4f321..677cd14 100644 --- a/advtrains/pseudoload.lua +++ b/advtrains/pseudoload.lua @@ -176,7 +176,7 @@ function advtrains.reset_trackdb_position(pos) if not advtrains.trackdb[rdp.y] then advtrains.trackdb[rdp.y]={} end if not advtrains.trackdb[rdp.y][rdp.x] then advtrains.trackdb[rdp.y][rdp.x]={} end advtrains.trackdb[rdp.y][rdp.x][rdp.z]=nil - advtrains.get_rail_info_at(pos)--to restore it. + advtrains.get_rail_info_at(pos, advtrains.all_tracktypes)--to restore it. end diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index bb38fce..1050d62 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -2,6 +2,7 @@ --controls train entities stuff about connecting/disconnecting/colliding trains and other things local print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end +local sid=function(id) return string.sub(id, -4) end --local print=function() end local benchmark=false @@ -130,15 +131,7 @@ minetest.register_globalstep(function(dtime) advtrains.save_and_audit_timer=advtrains.save_and_audit_timer-dtime if advtrains.save_and_audit_timer<=0 then local t=os.clock() - --print("[advtrains] audit step") - --clean up orphaned trains - for k,v in pairs(advtrains.trains) do - --advtrains.update_trainpart_properties(k) - if #v.trainparts==0 then - print("[advtrains][train "..k.."] has empty trainparts, removing.") - advtrains.trains[k]=nil - end - end + --save advtrains.save() advtrains.save_and_audit_timer=advtrains.audit_interval @@ -244,26 +237,17 @@ function advtrains.train_step(id, train, dtime) train.detector_old_index = math.floor(train.index) train.detector_old_end_index = math.floor(train_end_index) + --remove? + if #train.trainparts==0 then + print("[advtrains][train "..sid(id).."] has empty trainparts, removing.") + advtrains.detector.leave_node(path[train.detector_old_index], id) + advtrains.trains[id]=nil + return + end + if train_moves then --check for collisions by finding objects - --front - local search_radius=4 - --coupling - local couple_outward=1 - local posfront=advtrains.get_real_index_position(path, train.index+couple_outward) - local posback=advtrains.get_real_index_position(path, train_end_index-couple_outward) - for _,pos in ipairs({posfront, posback}) do - if pos then - local objrefs=minetest.get_objects_inside_radius(pos, search_radius) - for _,v in pairs(objrefs) do - local le=v:get_luaentity() - if le and le.is_wagon and le.initialized and le.train_id~=id then - advtrains.try_connect_trains(id, le.train_id) - end - end - end - end --heh, new collision again. --this time, based on NODES and the advtrains.detector.on_node table. local collpos @@ -277,24 +261,29 @@ function advtrains.train_step(id, train, dtime) local rcollpos=advtrains.round_vector_floor_y(collpos) for x=-1,1 do for z=-1,1 do - local testpts=minetest.pos_to_string(vector.add(rcollpos, {x=x, y=0, z=z})) + local testpos=vector.add(rcollpos, {x=x, y=0, z=z}) + local testpts=minetest.pos_to_string(testpos) if advtrains.detector.on_node[testpts] and advtrains.detector.on_node[testpts]~=id then --collides + advtrains.spawn_couple_on_collide(id, testpos, advtrains.detector.on_node[testpts], train.movedir==-1) + train.recently_collided_with_env=true train.velocity=0.5*train.velocity train.movedir=train.movedir*-1 train.tarvelocity=0 + end end end end end --check for any trainpart entities if they have been unloaded. do this only if train is near a player, to not spawn entities into unloaded areas + --todo function will be taken by update_trainpart_properties train.check_trainpartload=(train.check_trainpartload or 0)-dtime local node_range=(math.max((minetest.setting_get("active_block_range") or 0),1)*16) if train.check_trainpartload<=0 then local ori_pos=advtrains.get_real_index_position(path, train.index) --not much to calculate - print("[advtrains][train "..id.."] at "..minetest.pos_to_string(vector.round(ori_pos))) + --print("[advtrains][train "..id.."] at "..minetest.pos_to_string(vector.round(ori_pos))) local should_check=false for _,p in ipairs(minetest.get_connected_players()) do @@ -664,38 +653,7 @@ end --->backpos's will match --4. R<->F F<->R flip one of these trains and take it as new parent --->frontpos's will match -function advtrains.try_connect_trains(id1, id2) - local train1=advtrains.trains[id1] - local train2=advtrains.trains[id2] - if not train1 or not train2 then return end - if not train1.path or not train2.path then return end - if #train1.trainparts==0 or #train2.trainparts==0 then return end - - local frontpos1=advtrains.get_real_index_position(train1.path, train1.index) - local backpos1=advtrains.get_real_index_position(train1.path, advtrains.get_train_end_index(train1)) - --couple logic - --if train1.traintype==train2.traintype then - local frontpos2=advtrains.get_real_index_position(train2.path, train2.index) - local backpos2=advtrains.get_real_index_position(train2.path, advtrains.get_train_end_index(train2)) - - if not frontpos1 or not frontpos2 or not backpos1 or not backpos2 then return end - - local couple_spawnradius=0.7 - --case 1 (first train is front) - if vector.distance(frontpos2, backpos1) Date: Mon, 2 Jan 2017 13:49:20 +0100 Subject: Do not duplicate definitions of 'print' in every file --- advtrains/couple.lua | 1 - advtrains/init.lua | 6 ++---- advtrains/tracks.lua | 10 +++++++--- advtrains/trainlogic.lua | 4 ---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/advtrains/couple.lua b/advtrains/couple.lua index 675bed5..1cfe29c 100644 --- a/advtrains/couple.lua +++ b/advtrains/couple.lua @@ -9,7 +9,6 @@ wagon wagons keep their couple entity minetest-internal id inside the field discouple_id. if it refers to nowhere, they will spawn a new one if player is near ]] -local print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end minetest.register_entity("advtrains:discouple", { diff --git a/advtrains/init.lua b/advtrains/init.lua index 41b624e..33aa962 100644 --- a/advtrains/init.lua +++ b/advtrains/init.lua @@ -4,10 +4,8 @@ advtrains={} advtrains.modpath = minetest.get_modpath("advtrains") ---print=function(text) --- minetest.log("action", tostring(text) or "") ---end -print = function(t) minetest.log("action", t) minetest.chat_send_all(t) end +print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end +sid=function(id) return string.sub(id, -4) end dofile(advtrains.modpath.."/helpers.lua"); dofile(advtrains.modpath.."/debugitems.lua"); diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua index 8bd5666..87998e9 100644 --- a/advtrains/tracks.lua +++ b/advtrains/tracks.lua @@ -386,7 +386,7 @@ advtrains.detector.clean_step_before = false --The entry already being contained in advtrains.detector.on_node_restore will not trigger an on_train_enter event on the node. (when path is reset, this is saved). function advtrains.detector.enter_node(pos, train_id) local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - --print("enterNode "..pts.." "..train_id) + print("enterNode "..pts.." "..sid(train_id)) if not advtrains.detector.on_node[pts] then advtrains.detector.on_node[pts]=train_id if advtrains.detector.on_node_restore[pts] then @@ -394,14 +394,18 @@ function advtrains.detector.enter_node(pos, train_id) else advtrains.detector.call_enter_callback(advtrains.round_vector_floor_y(pos), train_id) end + else + print(""..pts.." already occupied") end end function advtrains.detector.leave_node(pos, train_id) local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - --print("leaveNode "..pts.." "..train_id) - if advtrains.detector.on_node[pts] then + print("leaveNode "..pts.." "..sid(train_id)) + if advtrains.detector.on_node[pts] and advtrains.detector.on_node[pts]==train_id then advtrains.detector.call_leave_callback(advtrains.round_vector_floor_y(pos), train_id) advtrains.detector.on_node[pts]=nil + else + print(""..pts.." occupied by another train") end end --called immediately before invalidating paths diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index 1050d62..9c93d96 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -1,12 +1,8 @@ --trainlogic.lua --controls train entities stuff about connecting/disconnecting/colliding trains and other things -local print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end -local sid=function(id) return string.sub(id, -4) end ---local print=function() end local benchmark=false ---printbm=function(str, t) print("[advtrains]"..str.." "..((os.clock()-t)*1000).."ms") end local bm={} local bmlt=0 local bmsteps=0 -- cgit v1.2.3 From 2a924d086a2bce6ce4030c81175d6f214d3be5d1 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Mon, 2 Jan 2017 13:55:25 +0100 Subject: fix discouple not disappearing and a logical mistake with owners --- advtrains/couple.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/advtrains/couple.lua b/advtrains/couple.lua index 1cfe29c..974f450 100644 --- a/advtrains/couple.lua +++ b/advtrains/couple.lua @@ -31,7 +31,7 @@ minetest.register_entity("advtrains:discouple", { on_punch=function(self, player) --only if player owns at least one wagon next to this local own=player:get_player_name() - if self.wagon.owner and self.wagon.owner~=own then + if self.wagon.owner and self.wagon.owner==own then local train=advtrains.trains[self.wagon.train_id] local nextwgn_id=train.trainparts[self.wagon.pos_in_trainparts-1] for aoi, le in pairs(minetest.luaentities) do @@ -44,8 +44,11 @@ minetest.register_entity("advtrains:discouple", { end end end + advtrains.split_train_at_wagon(self.wagon)--found in trainlogic.lua + self.object:remove() + else + minetest.chat_send_player(own, "You need to own at least one neighboring wagon to destroy this couple.") end - advtrains.split_train_at_wagon(self.wagon)--found in trainlogic.lua end, on_step=function(self, dtime) local t=os.clock() -- cgit v1.2.3 From 79d0549c8af7eaa6ba97b8beaab52fb1012350f3 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Mon, 2 Jan 2017 18:40:49 +0100 Subject: unify update_trainpart_properties and check_trainpartload --- advtrains/trainlogic.lua | 96 +++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 54 deletions(-) diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index 9c93d96..4ac4b29 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -286,35 +286,7 @@ function advtrains.train_step(id, train, dtime) should_check=should_check or ((vector.distance(ori_pos, p:getpos()) Date: Mon, 2 Jan 2017 18:54:24 +0100 Subject: make detector code clear entries of trains that do not exist --- advtrains/tracks.lua | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua index 87998e9..07883c5 100644 --- a/advtrains/tracks.lua +++ b/advtrains/tracks.lua @@ -387,26 +387,42 @@ advtrains.detector.clean_step_before = false function advtrains.detector.enter_node(pos, train_id) local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) print("enterNode "..pts.." "..sid(train_id)) - if not advtrains.detector.on_node[pts] then - advtrains.detector.on_node[pts]=train_id - if advtrains.detector.on_node_restore[pts] then - advtrains.detector.on_node_restore[pts]=nil + if advtrains.detector.on_node[pts] then + if advtrains.trains[advtrains.detector.on_node[pts]] then + print(""..pts.." already occupied") + return false else - advtrains.detector.call_enter_callback(advtrains.round_vector_floor_y(pos), train_id) + advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) end + end + advtrains.detector.on_node[pts]=train_id + if advtrains.detector.on_node_restore[pts] then + advtrains.detector.on_node_restore[pts]=nil else - print(""..pts.." already occupied") + advtrains.detector.call_enter_callback(advtrains.round_vector_floor_y(pos), train_id) end + return true end function advtrains.detector.leave_node(pos, train_id) local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) print("leaveNode "..pts.." "..sid(train_id)) - if advtrains.detector.on_node[pts] and advtrains.detector.on_node[pts]==train_id then + if not advtrains.detector.on_node[pts] then + print(""..pts.." leave: nothing here") + return false + end + if advtrains.detector.on_node[pts]==train_id then advtrains.detector.call_leave_callback(advtrains.round_vector_floor_y(pos), train_id) advtrains.detector.on_node[pts]=nil else - print(""..pts.." occupied by another train") + if advtrains.trains[advtrains.detector.on_node[pts]] then + print(""..pts.." occupied by another train") + return false + else + advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) + return false + end end + return true end --called immediately before invalidating paths function advtrains.detector.setup_restore() -- cgit v1.2.3 From a9d43ce2ca3bfd703428d248c0839e53ffd76f27 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 3 Jan 2017 18:48:00 +0100 Subject: add API documentation --- advtrains/api_doc.txt | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++ advtrains/wagons.lua | 6 +-- 2 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 advtrains/api_doc.txt diff --git a/advtrains/api_doc.txt b/advtrains/api_doc.txt new file mode 100644 index 0000000..22132c3 --- /dev/null +++ b/advtrains/api_doc.txt @@ -0,0 +1,114 @@ +Advanced Trains [advtrains] API documentation +-------- +To use the API, mods must depend on 'advtrains'. +All boolean values in definition tables default to 'false' and can be omitted. +### Wagons +Wagons are registered using the function + +advtrains.register_wagon(name, prototype, description, inventory_image) +- 'name' is the internal name of the wagon. It is registered inside the 'advtrains:' namespace. + Example: A wagon with name="engine_tgv" will be registered as "advtrains:engine_tgv". +- 'prototype' is the lua entity prototype. The regular definition keys for luaentites apply. Additional required and optional properties see below. DO NOT define 'on_step', 'on_activate', 'on_punch', 'on_rightclick' and 'get_staticdata' since these will be overridden. Use 'custom_*' instead. +- 'description' is the description of the inventory item that is used to place the wagon. +- 'inventory_image' is the inventory image of said item. + +# Wagon prototype properties +{ + ... all regular luaentity properties (mesh, textures, collisionbox a.s.o)... + drives_on = {default=true}, + ^- used to define the tracktypes (see below) that wagon can drive on. The tracktype identifiers are given as keys, similar to privileges) + max_speed = 10, + ^- optional, default 10: defines the maximum speed this wagon can drive. The maximum speed of a train is determined by the wagon with the lowest max_speed value. + seats = { + { + name="Left front window", + ^- display name of this seat + attach_offset={x=0, y=10, z=0}, + ^- this value is passed to 'set_attach' + view_offset={x=0, y=6, z=0}, + ^- player:set_eye_offset is called with this parameter. + driving_ctrl_access=false, + ^- If the seat is a driver stand, and players sitting here should get access to the train's driving control. + + }, + }, + ^- contains zero or more seat definitions. A seat is a place where a player can be attached when getting on a wagon. + wagon_span=2, + ^- How far this wagon extends from its base position. Is the half of the wagon length. + ^- Used to determine in which distance the other wagons have to be positioned. Will require tweaking. + drops = {"default:steelblock 3"} + ^- List of itemstrings what to drop when the wagon is destroyed + + has_inventory = false + ^- If this wagon has an inventory. The inventory is saved with the wagon. + ^- the following settings are ignored if not. + inventory_list_sizes = { + box=8*6, + }, + ^- List of assignments of type list_name=size. + ^- For every entry, an inventory list is created with the specified size. + get_inventory_formspec = function(self, player_name) + return "" + end, + ^- Function that should return the formspec to be displayed when requests to open the wagon's inventory + ^- Use "list[detached:advtrains_wgn_"..self.unique_id..";;,;,;]" to display a wagon's inventory list. + + custom_on_step = function(self, dtime) end + ^- optional: Execute custom code on every step + custom_on_activate = function(self, dtime_s) end + ^- optional: Execute custom code on activate. Staticdata does not need to be saved and restored since all properties written in 'self' are preserved over unloads. + update_animation = function(self, velocity) end + ^- optional: Function that is called whenever the train's velocity changes or every 2 seconds. Used to call 'self.object:update_animation()' if needed. + +} + +# Notes on wagons + +- Every wagon has the field 'unique_id' which assigns each wagon a random id. +- All properties written in the lua entity (self) are saved and restored automatically. Minetest's internal staticdata is only used to save the unique_id of the wagon, which serves as a key in an externally saved table. +- Assuming Z Axis as the axis parallel to the tracks and Y Axis as the one pointing into the sky, wagon models should be dimensioned in a way that: + - their origin is centered in X and Z direction + - their origin lies 0.5 units above the bottom of the model + - the overall extent in X and Y direction is <=3 units +- wagon_span is then the distance between the model origin and the Z axis extent. + +### Tracks +Most modders will be satisfied with the built-in tracks. If cog railways, maglev trains and mine trains are added, it is necessary to understand the definition of tracks. Although the tracks API is there, explaining it would require more effort than me creating the wanted definitions myself. Contact me if you need to register your own rails using my registration functions. + +However, it is still possible to register single rails by understanding the node properties of rails. +minetest.register_node(nodename, { + ... usual node definition ... + groups = { + advtrains_track_=1 + ^- this group tells that the node is a track + not_blocking_trains=1, + ^- this group tells that the node should not block trains although it's walkable. + }, + connect1 = 0, + connect2 = 8, + ^- These values tell the direction (horizontal) the rail ends are pointing to. 0 means +Z, then rotation values increase clockwise. For a translation of directions to positions see helpers.lua. + rely1=0, + rely2=0, + ^- the Y height of the rail end 1/2. A value of >=1 means that the rail end points to the next y layer at rely-1 + railheight=0, + ^- the height value of this rail that is saved in the path. usually the median of rely1 and rely2. + + can_dig=function(pos) + return not advtrains.is_train_at_pos(pos) + end, + after_dig_node=function(pos) + advtrains.invalidate_all_paths() + advtrains.reset_trackdb_position(pos) + end, + after_place_node=function(pos) + advtrains.reset_trackdb_position(pos) + end, + ^- the code in these 3 functions is required for advtrains to work. + + advtrains = { + on_train_enter=function(pos, train_id) end + ^- called when a train enters the rail + on_train_leave=function(pos, train_id) end + ^- called when a train leaves the rail + } +}) \ No newline at end of file diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua index fdd2b2e..495f914 100644 --- a/advtrains/wagons.lua +++ b/advtrains/wagons.lua @@ -73,7 +73,7 @@ function wagon:on_activate(sd_uid, dtime_s) end if self.custom_on_activate then - self:custom_on_activate(staticdata_table, dtime_s) + self:custom_on_activate(dtime_s) end end @@ -460,7 +460,7 @@ function wagon:show_get_on_form(pname) if not self.initialized then return end if #self.seats==0 then if self.has_inventory and self.get_inventory_formspec then - minetest.show_formspec(pname, "advtrains_inv_"..self.unique_id, self:get_inventory_formspec()) + minetest.show_formspec(pname, "advtrains_inv_"..self.unique_id, self:get_inventory_formspec(pname)) end return end @@ -487,7 +487,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) if wagon.is_wagon and wagon.initialized and wagon.unique_id==uid then if fields.inv then if wagon.has_inventory and wagon.get_inventory_formspec then - minetest.show_formspec(player:get_player_name(), "advtrains_inv_"..uid, wagon:get_inventory_formspec()) + minetest.show_formspec(player:get_player_name(), "advtrains_inv_"..uid, wagon:get_inventory_formspec(player:get_player_name())) end elseif fields.seat then local val=minetest.explode_textlist_event(fields.seat) -- cgit v1.2.3 From 853a9e690eeeb48aa1a13faa66db0a91d5b49390 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 4 Jan 2017 12:02:00 +0100 Subject: Add Automatic Train Control system --- advtrains/api_doc.txt | 2 +- advtrains/atc.lua | 292 ++++++++++++++++++++- advtrains/atc_command.txt | 68 +++++ advtrains/models/advtrains_dtrack_detector_st.b3d | Bin 17157 -> 17157 bytes .../models/advtrains_dtrack_detector_st_30.b3d | Bin 32779 -> 32779 bytes .../models/advtrains_dtrack_detector_st_45.b3d | Bin 17163 -> 17163 bytes .../models/advtrains_dtrack_detector_st_60.b3d | Bin 32779 -> 32779 bytes advtrains/models/blender/gleis/detectorpart.png | Bin 0 -> 857 bytes .../models/blender/gleis/rail_my_rt_final.blend | Bin 1094836 -> 1015668 bytes .../models/blender/gleis/rail_my_rt_final.blend1 | Bin 827052 -> 1106004 bytes advtrains/textures/advtrains_dtrack_atc_placer.png | Bin 0 -> 1259 bytes advtrains/textures/advtrains_dtrack_placer.png | Bin 5831 -> 1097 bytes advtrains/textures/advtrains_dtrack_rail.png | Bin 2810 -> 2814 bytes advtrains/textures/advtrains_dtrack_rail_atc.png | Bin 0 -> 2837 bytes .../textures/advtrains_dtrack_rail_detector_on.png | Bin 2844 -> 2818 bytes advtrains/trackplacer.lua | 25 +- advtrains/tracks.lua | 38 +-- advtrains/trainhud.lua | 2 +- advtrains/trainlogic.lua | 21 +- 19 files changed, 424 insertions(+), 24 deletions(-) create mode 100644 advtrains/atc_command.txt create mode 100644 advtrains/models/blender/gleis/detectorpart.png create mode 100644 advtrains/textures/advtrains_dtrack_atc_placer.png create mode 100644 advtrains/textures/advtrains_dtrack_rail_atc.png diff --git a/advtrains/api_doc.txt b/advtrains/api_doc.txt index 22132c3..6b1aa2e 100644 --- a/advtrains/api_doc.txt +++ b/advtrains/api_doc.txt @@ -103,7 +103,7 @@ minetest.register_node(nodename, { after_place_node=function(pos) advtrains.reset_trackdb_position(pos) end, - ^- the code in these 3 functions is required for advtrains to work. + ^- the code in these 3 default minetest API functions is required for advtrains to work, however you can add your own code advtrains = { on_train_enter=function(pos, train_id) end diff --git a/advtrains/atc.lua b/advtrains/atc.lua index 0afddb0..f070b20 100644 --- a/advtrains/atc.lua +++ b/advtrains/atc.lua @@ -1,4 +1,294 @@ --atc.lua --registers and controls the ATC system ---(simple)mesecon detector rails +local atc={} +-- ATC persistence table +atc.controllers = {} +--contents: {command="...", arrowconn=0-15 where arrow points} + +advtrains.fpath_atc=minetest.get_worldpath().."/advtrains_atc" +local file, err = io.open(advtrains.fpath_atc, "r") +if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed loading advtrains atc save file "..er) +else + local tbl = minetest.deserialize(file:read("*a")) + if type(tbl) == "table" then + atc.controllers=tbl.controllers + end + file:close() +end +function atc.save() + --leave space for more save data. + local datastr = minetest.serialize({controllers = atc.controllers}) + if not datastr then + minetest.log("error", "[advtrains] Failed to serialize trackdb data!") + return + end + local file, err = io.open(advtrains.fpath_atc, "w") + if err then + return err + end + file:write(datastr) + file:close() +end + +--call from advtrains.detector subprogram + +function atc.trigger_controller_train_enter(pos, train_id) + atc.send_command(pos) +end + +--general + +function atc.send_command(pos) + local pts=minetest.pos_to_string(pos) + if atc.controllers[pts] then + print("Called send_command at "..pts) + local train_id = advtrains.detector.on_node[pts] + if train_id then + if advtrains.trains[train_id] then + print("send_command inside if: "..sid(train_id)) + atc.train_reset_command(train_id) + local arrowconn=atc.controllers[pts].arrowconn + local train=advtrains.trains[train_id] + for index, ppos in pairs(train.path) do + if vector.equals(advtrains.round_vector_floor_y(ppos), pos) then + advtrains.trains[train_id].atc_arrow = + vector.equals( + advtrains.dirCoordSet(pos, arrowconn), + advtrains.round_vector_floor_y(train.path[index+train.movedir]) + ) + advtrains.trains[train_id].atc_command=atc.controllers[pts].command + print("Sending ATC Command: "..atc.controllers[pts].command) + end + end + end + end + end + return false +end + +function atc.train_reset_command(train_id) + advtrains.trains[train_id].atc_command=nil + advtrains.trains[train_id].atc_delay=0 + advtrains.trains[train_id].atc_brake_target=nil + advtrains.trains[train_id].atc_wait_finish=nil + advtrains.trains[train_id].atc_arrow=nil +end + +--nodes +local idxtrans={static=1, mesecon=2, digiline=3} +local apn_func=function(pos) + advtrains.reset_trackdb_position(pos) + local meta=minetest.get_meta(pos) + if meta then + meta:set_string("infotext", "ATC controller, unconfigured.") + meta:set_string("formspec", atc.get_atc_controller_formspec(pos, meta)) + end +end + +advtrains.register_tracks("default", { + nodename_prefix="advtrains:dtrack_atc", + texture_prefix="advtrains_dtrack_atc", + models_prefix="advtrains_dtrack_detector", + models_suffix=".b3d", + shared_texture="advtrains_dtrack_rail_atc.png", + description="ATC controller", + formats={}, + get_additional_definiton = function(def, preset, suffix, rotation) + return { + after_place_node=apn_func, + on_place_rail=apn_func, + after_dig_node=function(pos) + advtrains.invalidate_all_paths() + advtrains.reset_trackdb_position(pos) + local pts=minetest.pos_to_string(pos) + atc.controllers[pts]=nil + end, + on_receive_fields = function(pos, formname, fields, player) + if minetest.is_protected(pos, player:get_player_name()) then + minetest.chat_send_player(player:get_player_name(), "This position is protected!") + return + end + local meta=minetest.get_meta(pos) + if meta then + if not fields.save then + --maybe only the dropdown changed + if fields.mode then + meta:set_string("mode", idxtrans[fields.mode]) + meta:set_string("infotext", "ATC controller, mode "..fields.mode.."\n"..( fields.mode=="digiline" and "Channel: "..meta:get_string("channel") or "Command: "..meta:get_string("command") ) ) + meta:set_string("formspec", atc.get_atc_controller_formspec(pos, meta)) + end + return + end + meta:set_string("mode", idxtrans[fields.mode]) + meta:set_string("command", fields.command) + meta:set_string("command_on", fields.command_on) + meta:set_string("channel", fields.channel) + meta:set_string("infotext", "ATC controller, mode "..fields.mode.."\n"..( fields.mode=="digiline" and "Channel: "..meta:get_string("channel") or "Command: "..meta:get_string("command") ) ) + meta:set_string("formspec", atc.get_atc_controller_formspec(pos, meta)) + + local pts=minetest.pos_to_string(pos) + local _, conn1=advtrains.get_rail_info_at(pos, advtrains.all_tracktypes) + atc.controllers[pts]={command=fields.command, arrowconn=conn1} + atc.send_command(pos) + end + end, + } + end +}, advtrains.trackpresets.t_30deg_straightonly) + + +function atc.get_atc_controller_formspec(pos, meta) + local mode=tonumber(meta:get_string("mode")) or 1 + local command=meta:get_string("command") + local command_on=meta:get_string("command_on") + local channel=meta:get_string("channel") + local formspec="size[8,6]".. + "dropdown[0,0;3;mode;static,mesecon,digiline;"..mode.."]" + if mode<3 then + formspec=formspec.."field[0.5,1.5;7,1;command;Command;"..minetest.formspec_escape(command).."]" + if tonumber(mode)==2 then + formspec=formspec.."field[0.5,3;7,1;command_on;Command (on);"..minetest.formspec_escape(command_on).."]" + end + else + formspec=formspec.."field[0.5,1.5;7,1;channel;Digiline channel;"..minetest.formspec_escape(channel).."]" + end + return formspec.."button_exit[0.5,4.5;7,1;save;Save]" +end + +--from trainlogic.lua train step +local matchptn={ + ["SM"]=function(id, train) + train.tarvelocity=train.max_speed + return 2 + end, + ["S([0-9]+)"]=function(id, train, match) + train.tarvelocity=tonumber(match) + return #match+1 + end, + ["B([0-9]+)"]=function(id, train, match) + if train.velocity>tonumber(match) then + train.atc_brake_target=tonumber(match) + if train.tarvelocity>train.atc_brake_target then + train.tarvelocity=train.atc_brake_target + end + end + return #match+1 + end, + ["W"]=function(id, train) + train.atc_wait_finish=true + return 1 + end, + ["D([0-9]+)"]=function(id, train, match) + train.atc_delay=tonumber(match) + return #match+1 + end, + ["R"]=function(id, train) + if train.velocity<=0 then + train.movedir=train.movedir*-1 + train.atc_arrow = not train.atc_arrow + else + print("ATC Reverse command warning: didn't reverse train!") + end + return 1 + end, +} + +function atc.execute_atc_command(id, train) + --strip whitespaces + local command=string.match(train.atc_command, "^%s*(.*)$") + + + if string.match(command, "^%s*$") then + train.atc_command=nil + return + end + --conditional statement? + local is_cond, cond_applies + local cond, rest=string.match(command, "^I([%+%-])(.+)$") + if cond then + is_cond=true + if cond=="+" then + cond_applies=train.atc_arrow + end + if cond=="-" then + cond_applies=not train.atc_arrow + end + else + cond, compare, rest=string.match(command, "^I([<>]=?)([0-9]+)(.+)$") + if cond and compare then + is_cond=true + if cond=="<" then + cond_applies=train.velocity" then + cond_applies=train.velocity>tonumber(compare) + end + if cond=="<=" then + cond_applies=train.velocity<=tonumber(compare) + end + if cond==">=" then + cond_applies=train.velocity>=tonumber(compare) + end + end + end + if is_cond then + print("Evaluating if statement: "..command) + print("Cond: "..(cond or "nil")) + print("Applies: "..(cond_applies and "true" or "false")) + print("Rest: "..rest) + --find end of conditional statement + local nest, pos, elsepos=0, 1 + while nest>=0 do + if pos>#rest then + print("ATC command syntax error: I statement not closed: "..command) + atc.train_reset_command(id) + return + end + local char=string.sub(rest, pos, pos) + if char=="I" then + nest=nest+1 + end + if char==";" then + nest=nest-1 + end + if nest==0 and char=="E" then + elsepos=pos+0 + end + pos=pos+1 + end + if not elsepos then elsepos=pos-1 end + if cond_applies then + command=string.sub(rest, 1, elsepos-1)..string.sub(rest, pos) + else + command=string.sub(rest, elsepos+1, pos-2)..string.sub(rest, pos) + end + print("Result: "..command) + train.atc_command=command + atc.execute_atc_command(id, train) + return + else + for pattern, func in pairs(matchptn) do + local match=string.match(command, "^"..pattern) + if match then + local patlen=func(id, train, match) + + print("Executing: "..string.sub(command, 1, patlen)) + + train.atc_command=string.sub(command, patlen+1) + if train.atc_delay<=0 and not train.atc_wait_finish then + --continue (recursive, cmds shouldn't get too long, and it's a end-recursion.) + atc.execute_atc_command(id, train) + end + return + end + end + end + print("ATC command parse error: "..command) + atc.train_reset_command(id) +end + +--move table to desired place +advtrains.atc=atc diff --git a/advtrains/atc_command.txt b/advtrains/atc_command.txt new file mode 100644 index 0000000..fa846e3 --- /dev/null +++ b/advtrains/atc_command.txt @@ -0,0 +1,68 @@ +ATC Command Syntax + +A train runs the current ATC command once it receives it, including delayed instructions. If the train receives a new command, the current command is discarded. +Spaces can be inserted into commands as needed and are ignored. + +# simple commands: + +S<[0-9]+ speed or 'M'> +Set target speed of train to . Accelerates if slower, rolls if faster. 'M' means maximum speed. +Execution of command continues immediately. + +B<[0-9]+ speed> +Brake until speed is reached. If faster, apply brakes, if slower, do nothing. +Execution of command continues immediately. + +Examples: +SM : accelerate to maximum speed +S0 : roll to stand +B0 : brake to stand +S0B3 or B3S0: brake to 3, then roll to stand. + +W +Wait until S and/or B commands reached the desired speed before continuing execution. + +D<[0-9]+ time> +Delay: Wait for time seconds before continuing execution. + +R +Reverse: change movement direction of train. ONLY WORKS WHEN TRAIN STANDS, else no-op. +Use B0WR to definitely change direction. + +Examples: +B0 W R D10 SM +Subway train stopping in dead end station and returning in opposite direction + +# conditional statements: + +I; +Execute code only if condition applies +IE; +Execute code1 only if condition applies, else execute code2 + +Conditions: ++ / - +Tests the train's movement direction against the arrow on the ATC rail: M+ is true when train drives in direction of arrow. + +[/<=/>=][speed] +Test if train's speed is greater or smaller than the given value + +Examples: +I- B0 W R ; S8 +If the train drives in the 'wrong' direction, stop and reverse; independently accelerate to speed 8 afterwards. + +I<8 S8 ; +If the train is slower than 8, accelerate to 8. + +# ATC controller operation modes +static: Only give 1 static command. +mesecon: Give 2 different commands depending on if the controller is mesecon-powered or not +digiline: Don't give any commands by itself. When a train passes, a digiline message in the form of "[+/-][speed]" is sent on the set channel (where +/- means the same as with conditions). Any digiline message sent to the controller will be interpreted as ATC command and sent to the train. + +# Persistence +ATC controllers that are configured as 'static' or 'mesecon' are persistent over mapblock unloads and will even command the train when the mapblock is unloaded. This is not possible with digilines since these do not work in unloaded mapchunks. + +# LUA ATC controller (in development) +The LUA ATC Controller will operate by using LUA code. All operations shown above will have a function equivalent. Additionally all LUA ATC controllers share an environment and setting signal and switch status will be possible to allow for complicated railway systems/fully automated subways a.s.o. +Also planned: +- digicompute add-on to allow computer access to the ATC environment (railway maps... ... ... ... ...) diff --git a/advtrains/models/advtrains_dtrack_detector_st.b3d b/advtrains/models/advtrains_dtrack_detector_st.b3d index 893c8cd..6762bc3 100644 Binary files a/advtrains/models/advtrains_dtrack_detector_st.b3d and b/advtrains/models/advtrains_dtrack_detector_st.b3d differ diff --git a/advtrains/models/advtrains_dtrack_detector_st_30.b3d b/advtrains/models/advtrains_dtrack_detector_st_30.b3d index 2e59e93..f2d5991 100644 Binary files a/advtrains/models/advtrains_dtrack_detector_st_30.b3d and b/advtrains/models/advtrains_dtrack_detector_st_30.b3d differ diff --git a/advtrains/models/advtrains_dtrack_detector_st_45.b3d b/advtrains/models/advtrains_dtrack_detector_st_45.b3d index c73166f..9ecb4a6 100644 Binary files a/advtrains/models/advtrains_dtrack_detector_st_45.b3d and b/advtrains/models/advtrains_dtrack_detector_st_45.b3d differ diff --git a/advtrains/models/advtrains_dtrack_detector_st_60.b3d b/advtrains/models/advtrains_dtrack_detector_st_60.b3d index b6bc9af..bd102cb 100644 Binary files a/advtrains/models/advtrains_dtrack_detector_st_60.b3d and b/advtrains/models/advtrains_dtrack_detector_st_60.b3d differ diff --git a/advtrains/models/blender/gleis/detectorpart.png b/advtrains/models/blender/gleis/detectorpart.png new file mode 100644 index 0000000..fc24181 Binary files /dev/null and b/advtrains/models/blender/gleis/detectorpart.png differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_final.blend b/advtrains/models/blender/gleis/rail_my_rt_final.blend index 6a9a088..d07a65d 100644 Binary files a/advtrains/models/blender/gleis/rail_my_rt_final.blend and b/advtrains/models/blender/gleis/rail_my_rt_final.blend differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_final.blend1 b/advtrains/models/blender/gleis/rail_my_rt_final.blend1 index 1f346ae..8a2d213 100644 Binary files a/advtrains/models/blender/gleis/rail_my_rt_final.blend1 and b/advtrains/models/blender/gleis/rail_my_rt_final.blend1 differ diff --git a/advtrains/textures/advtrains_dtrack_atc_placer.png b/advtrains/textures/advtrains_dtrack_atc_placer.png new file mode 100644 index 0000000..31c2b30 Binary files /dev/null and b/advtrains/textures/advtrains_dtrack_atc_placer.png differ diff --git a/advtrains/textures/advtrains_dtrack_placer.png b/advtrains/textures/advtrains_dtrack_placer.png index c49777c..7bef8a9 100644 Binary files a/advtrains/textures/advtrains_dtrack_placer.png and b/advtrains/textures/advtrains_dtrack_placer.png differ diff --git a/advtrains/textures/advtrains_dtrack_rail.png b/advtrains/textures/advtrains_dtrack_rail.png index 568e533..1cf7f83 100644 Binary files a/advtrains/textures/advtrains_dtrack_rail.png and b/advtrains/textures/advtrains_dtrack_rail.png differ diff --git a/advtrains/textures/advtrains_dtrack_rail_atc.png b/advtrains/textures/advtrains_dtrack_rail_atc.png new file mode 100644 index 0000000..d171985 Binary files /dev/null and b/advtrains/textures/advtrains_dtrack_rail_atc.png differ diff --git a/advtrains/textures/advtrains_dtrack_rail_detector_on.png b/advtrains/textures/advtrains_dtrack_rail_detector_on.png index 3ae0dac..4f09b35 100644 Binary files a/advtrains/textures/advtrains_dtrack_rail_detector_on.png and b/advtrains/textures/advtrains_dtrack_rail_detector_on.png differ diff --git a/advtrains/trackplacer.lua b/advtrains/trackplacer.lua index eebf2ae..b24103a 100644 --- a/advtrains/trackplacer.lua +++ b/advtrains/trackplacer.lua @@ -129,7 +129,7 @@ function tp.bend_rail(originpos, conn, nnpref) return false end end -function tp.placetrack(pos, nnpref) +function tp.placetrack(pos, nnpref, placer, itemstack, pointed_thing) --1. find all rails that are likely to be connected local tr=tp.tracks[nnpref] local p_rails={} @@ -140,9 +140,16 @@ function tp.placetrack(pos, nnpref) end if #p_rails==0 then minetest.set_node(pos, {name=nnpref.."_"..tr.default}) + if minetest.registered_nodes[nnpref.."_"..tr.default] and minetest.registered_nodes[nnpref.."_"..tr.default].after_place_node then + minetest.registered_nodes[nnpref.."_"..tr.default].after_place_node(pos, placer, itemstack, pointed_thing) + end elseif #p_rails==1 then tp.bend_rail(pos, p_rails[1], nnpref) minetest.set_node(pos, tr.single_conn[p_rails[1]]) + local nname=tr.single_conn[p_rails[1]].name + if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then + minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) + end else --iterate subsets for k1, conn1 in ipairs(p_rails) do @@ -152,6 +159,10 @@ function tp.placetrack(pos, nnpref) tp.bend_rail(pos, conn1, nnpref) tp.bend_rail(pos, conn2, nnpref) minetest.set_node(pos, tr.double_conn[conn1.."_"..conn2]) + local nname=tr.double_conn[conn1.."_"..conn2].name + if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then + minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) + end return end end @@ -160,6 +171,10 @@ function tp.placetrack(pos, nnpref) --not found tp.bend_rail(pos, p_rails[1], nnpref) minetest.set_node(pos, tr.single_conn[p_rails[1]]) + local nname=tr.single_conn[p_rails[1]].name + if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then + minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) + end end end @@ -183,7 +198,7 @@ function tp.register_track_placer(nnprefix, imgprefix, dispname) end if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to and minetest.registered_nodes[minetest.get_node(upos).name] and minetest.registered_nodes[minetest.get_node(upos).name].walkable then - tp.placetrack(pos, nnprefix) + tp.placetrack(pos, nnprefix, placer, itemstack, pointed_thing) if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end @@ -230,7 +245,7 @@ minetest.register_craftitem("advtrains:trackworker",{ local modext=tp.tracks[nnprefix].twrotate[suffix] if rotation==modext[#modext] then --increase param2 - minetest.set_node(pos, {name=nnprefix.."_"..suffix..modext[1], param2=(node.param2+1)%4}) + minetest.swap_node(pos, {name=nnprefix.."_"..suffix..modext[1], param2=(node.param2+1)%4}) return else local modpos @@ -239,7 +254,7 @@ minetest.register_craftitem("advtrains:trackworker",{ minetest.chat_send_player(placer:get_player_name(), "This node can't be rotated using the trackworker!") return end - minetest.set_node(pos, {name=nnprefix.."_"..suffix..modext[modpos+1], param2=node.param2}) + minetest.swap_node(pos, {name=nnprefix.."_"..suffix..modext[modpos+1], param2=node.param2}) end advtrains.invalidate_all_paths() end @@ -269,7 +284,7 @@ minetest.register_craftitem("advtrains:trackworker",{ end end local nextsuffix=tp.tracks[nnprefix].twcycle[suffix] - minetest.set_node(pos, {name=nnprefix.."_"..nextsuffix..rotation, param2=node.param2}) + minetest.swap_node(pos, {name=nnprefix.."_"..nextsuffix..rotation, param2=node.param2}) --invalidate trains advtrains.invalidate_all_paths() else diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua index 07883c5..beb0bbc 100644 --- a/advtrains/tracks.lua +++ b/advtrains/tracks.lua @@ -36,7 +36,8 @@ advtrains.all_tracktypes={} --definition preparation local function conns(c1, c2, r1, r2, rh, rots) return {conn1=c1, conn2=c2, rely1=r1, rely2=r2, railheight=rh} end -local t_30deg={ +local ap={} +ap.t_30deg={ regstep=1, variant={ st=conns(0,8), @@ -110,7 +111,7 @@ local t_30deg={ rotation={"", "_30", "_45", "_60"}, increativeinv={}, } -local t_30deg_straightonly={ +ap.t_30deg_straightonly={ regstep=1, variant={ st=conns(0,8), @@ -135,7 +136,7 @@ local t_30deg_straightonly={ rotation={"", "_30", "_45", "_60"}, increativeinv={st}, } -local t_30deg_straightonly_noplacer={ +ap.t_30deg_straightonly_noplacer={ regstep=1, variant={ st=conns(0,8), @@ -160,7 +161,7 @@ local t_30deg_straightonly_noplacer={ rotation={"", "_30", "_45", "_60"}, increativeinv={st}, } -local t_45deg={ +ap.t_45deg={ regstep=2, variant={ st=conns(0,8), @@ -215,6 +216,7 @@ local t_45deg={ rotation={"", "_45"}, increativeinv={vst1=true, vst2=true} } +advtrains.trackpresets = ap --definition format: ([] optional) --[[{ @@ -302,6 +304,9 @@ function advtrains.register_tracks(tracktype, def, preset) after_place_node=function(pos) advtrains.reset_trackdb_position(pos) end, + on_place_rail=function(pos) + advtrains.reset_trackdb_position(pos) + end, }, def.common or {}) --make trackplacer base def advtrains.trackplacer.register_tracktype(def.nodename_prefix, preset.tpdefault) @@ -386,10 +391,10 @@ advtrains.detector.clean_step_before = false --The entry already being contained in advtrains.detector.on_node_restore will not trigger an on_train_enter event on the node. (when path is reset, this is saved). function advtrains.detector.enter_node(pos, train_id) local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - print("enterNode "..pts.." "..sid(train_id)) + --print("enterNode "..pts.." "..sid(train_id)) if advtrains.detector.on_node[pts] then if advtrains.trains[advtrains.detector.on_node[pts]] then - print(""..pts.." already occupied") + --print(""..pts.." already occupied") return false else advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) @@ -405,9 +410,9 @@ function advtrains.detector.enter_node(pos, train_id) end function advtrains.detector.leave_node(pos, train_id) local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - print("leaveNode "..pts.." "..sid(train_id)) + --print("leaveNode "..pts.." "..sid(train_id)) if not advtrains.detector.on_node[pts] then - print(""..pts.." leave: nothing here") + --print(""..pts.." leave: nothing here") return false end if advtrains.detector.on_node[pts]==train_id then @@ -415,7 +420,7 @@ function advtrains.detector.leave_node(pos, train_id) advtrains.detector.on_node[pts]=nil else if advtrains.trains[advtrains.detector.on_node[pts]] then - print(""..pts.." occupied by another train") + --print(""..pts.." occupied by another train") return false else advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) @@ -446,7 +451,10 @@ function advtrains.detector.call_enter_callback(pos, train_id) local mregnode=minetest.registered_nodes[node.name] if mregnode and mregnode.advtrains and mregnode.advtrains.on_train_enter then mregnode.advtrains.on_train_enter(pos, train_id) - end + end + + --atc code wants to be notified too + advtrains.atc.trigger_controller_train_enter(pos, train_id) end function advtrains.detector.call_leave_callback(pos, train_id) --print("instructed to call leave calback") @@ -576,7 +584,7 @@ advtrains.register_tracks("regular", { shared_model="trackplane.b3d", description="Deprecated Track", formats={vst1={}, vst2={}}, -}, t_45deg) +}, ap.t_45deg) advtrains.register_tracks("default", { @@ -587,7 +595,7 @@ advtrains.register_tracks("default", { shared_texture="advtrains_dtrack_rail.png", description="Track", formats={vst1={true, false, true}, vst2={true, false, true}, vst31={true}, vst32={true}, vst33={true}}, -}, t_30deg) +}, ap.t_30deg) --bumpers advtrains.register_tracks("default", { @@ -598,7 +606,7 @@ advtrains.register_tracks("default", { shared_texture="advtrains_dtrack_rail.png", description="Bumper", formats={}, -}, t_30deg_straightonly) +}, ap.t_30deg_straightonly) --legacy bumpers for _,rot in ipairs({"", "_30", "_45", "_60"}) do minetest.register_alias("advtrains:dtrack_bumper"..rot, "advtrains:dtrack_bumper_st"..rot) @@ -629,7 +637,7 @@ if mesecon then } } end - }, t_30deg_straightonly) + }, ap.t_30deg_straightonly) advtrains.register_tracks("default", { nodename_prefix="advtrains:dtrack_detector_on", texture_prefix="advtrains_dtrack_detector", @@ -654,7 +662,7 @@ if mesecon then } } end - }, t_30deg_straightonly_noplacer) + }, ap.t_30deg_straightonly_noplacer) end --TODO legacy --I know lbms are better for this purpose diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua index 19e4f6f..e69f04a 100644 --- a/advtrains/trainhud.lua +++ b/advtrains/trainhud.lua @@ -11,7 +11,7 @@ local mletter={[1]="F", [-1]="R", [0]="N"} function advtrains.on_control_change(pc, train, flip) if pc.sneak then if pc.up then - train.tarvelocity = advtrains.all_traintypes[train.traintype].max_speed or 10 + train.tarvelocity = train.max_speed or 10 end if pc.down then train.tarvelocity = 0 diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index 4ac4b29..eb45500 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -119,6 +119,7 @@ advtrains.save = function() file:close() advtrains.save_trackdb() + advtrains.atc.save() end minetest.register_on_shutdown(advtrains.save) @@ -302,6 +303,24 @@ function advtrains.train_step(id, train, dtime) if train.locomotives_in_train==0 then train.tarvelocity=0 end + + --interpret ATC command + if train.atc_brake_target and train.atc_brake_target>=train.velocity then + train.atc_brake_target=nil + end + if train.atc_wait_finish then + if not train.atc_brake_target and train.velocity==train.tarvelocity then + train.atc_wait_finish=nil + end + end + if train.atc_command then + if train.atc_delay<=0 and not train.atc_wait_finish then + advtrains.atc.execute_atc_command(id, train) + else + train.atc_delay=train.atc_delay-dtime + end + end + --make brake adjust the tarvelocity if necessary if train.brake and (math.ceil(train.velocity)-1) Date: Wed, 4 Jan 2017 19:10:03 +0100 Subject: Restructure mod directory --- Makefile | 5 - advtrains.zip | Bin 1488724 -> 0 bytes advtrains/Makefile | 5 + advtrains/advtrains.zip | Bin 0 -> 1488724 bytes advtrains/advtrains/api_doc.txt | 114 +++ advtrains/advtrains/atc.lua | 294 +++++++ advtrains/advtrains/atc_command.txt | 68 ++ advtrains/advtrains/couple.lua | 156 ++++ advtrains/advtrains/crafting.lua | 71 ++ advtrains/advtrains/damage.lua | 26 + advtrains/advtrains/debugitems.lua | 36 + advtrains/advtrains/depends.txt | 2 + advtrains/advtrains/description.txt | 8 + advtrains/advtrains/helpers.lua | 248 ++++++ advtrains/advtrains/init.lua | 40 + advtrains/advtrains/misc_nodes.lua | 67 ++ .../models/advtrains_dtrack_bumper_st.b3d | Bin 0 -> 32927 bytes .../models/advtrains_dtrack_bumper_st_30.b3d | Bin 0 -> 48546 bytes .../models/advtrains_dtrack_bumper_st_45.b3d | Bin 0 -> 32926 bytes .../models/advtrains_dtrack_bumper_st_60.b3d | Bin 0 -> 48546 bytes advtrains/advtrains/models/advtrains_dtrack_cr.b3d | Bin 0 -> 27540 bytes .../advtrains/models/advtrains_dtrack_cr_30.b3d | Bin 0 -> 27543 bytes .../advtrains/models/advtrains_dtrack_cr_45.b3d | Bin 0 -> 23037 bytes .../advtrains/models/advtrains_dtrack_cr_60.b3d | Bin 0 -> 23037 bytes .../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 advtrains/advtrains/models/advtrains_dtrack_st.b3d | Bin 0 -> 15828 bytes .../advtrains/models/advtrains_dtrack_st_30.b3d | Bin 0 -> 31447 bytes .../advtrains/models/advtrains_dtrack_st_45.b3d | Bin 0 -> 15831 bytes .../advtrains/models/advtrains_dtrack_st_60.b3d | Bin 0 -> 31447 bytes .../advtrains/models/advtrains_dtrack_swlcr.b3d | Bin 0 -> 36743 bytes .../advtrains/models/advtrains_dtrack_swlcr_30.b3d | Bin 0 -> 45922 bytes .../advtrains/models/advtrains_dtrack_swlcr_45.b3d | Bin 0 -> 32112 bytes .../advtrains/models/advtrains_dtrack_swlcr_60.b3d | Bin 0 -> 44864 bytes .../advtrains/models/advtrains_dtrack_swlst.b3d | Bin 0 -> 36743 bytes .../advtrains/models/advtrains_dtrack_swlst_30.b3d | Bin 0 -> 45922 bytes .../advtrains/models/advtrains_dtrack_swlst_45.b3d | Bin 0 -> 32112 bytes .../advtrains/models/advtrains_dtrack_swlst_60.b3d | Bin 0 -> 44864 bytes .../advtrains/models/advtrains_dtrack_swrcr.b3d | Bin 0 -> 36743 bytes .../advtrains/models/advtrains_dtrack_swrcr_30.b3d | Bin 0 -> 44864 bytes .../advtrains/models/advtrains_dtrack_swrcr_45.b3d | Bin 0 -> 32112 bytes .../advtrains/models/advtrains_dtrack_swrcr_60.b3d | Bin 0 -> 45922 bytes .../advtrains/models/advtrains_dtrack_swrst.b3d | Bin 0 -> 36743 bytes .../advtrains/models/advtrains_dtrack_swrst_30.b3d | Bin 0 -> 44864 bytes .../advtrains/models/advtrains_dtrack_swrst_45.b3d | Bin 0 -> 32112 bytes .../advtrains/models/advtrains_dtrack_swrst_60.b3d | Bin 0 -> 45922 bytes .../advtrains/models/advtrains_dtrack_vst1.b3d | Bin 0 -> 21495 bytes .../advtrains/models/advtrains_dtrack_vst1_45.b3d | Bin 0 -> 20739 bytes .../advtrains/models/advtrains_dtrack_vst2.b3d | Bin 0 -> 25143 bytes .../advtrains/models/advtrains_dtrack_vst2_45.b3d | Bin 0 -> 20919 bytes .../advtrains/models/advtrains_dtrack_vst31.b3d | Bin 0 -> 19051 bytes .../advtrains/models/advtrains_dtrack_vst32.b3d | Bin 0 -> 21635 bytes .../advtrains/models/advtrains_dtrack_vst33.b3d | Bin 0 -> 28795 bytes .../advtrains/models/advtrains_modernwagon.b3d | Bin 0 -> 172028 bytes .../advtrains/models/advtrains_retrosignal_off.b3d | Bin 0 -> 13093 bytes .../models/advtrains_retrosignal_off_30.b3d | Bin 0 -> 13093 bytes .../models/advtrains_retrosignal_off_45.b3d | Bin 0 -> 13093 bytes .../models/advtrains_retrosignal_off_60.b3d | Bin 0 -> 13093 bytes .../advtrains/models/advtrains_retrosignal_on.b3d | Bin 0 -> 13093 bytes .../models/advtrains_retrosignal_on_30.b3d | Bin 0 -> 13093 bytes .../models/advtrains_retrosignal_on_45.b3d | Bin 0 -> 13093 bytes .../models/advtrains_retrosignal_on_60.b3d | Bin 0 -> 13093 bytes advtrains/advtrains/models/advtrains_signal.b3d | Bin 0 -> 61544 bytes advtrains/advtrains/models/advtrains_signal_30.b3d | Bin 0 -> 61544 bytes advtrains/advtrains/models/advtrains_signal_45.b3d | Bin 0 -> 61544 bytes advtrains/advtrains/models/advtrains_signal_60.b3d | Bin 0 -> 61544 bytes advtrains/advtrains/models/advtrains_track_cr.b3d | Bin 0 -> 8023 bytes advtrains/advtrains/models/advtrains_track_st.b3d | Bin 0 -> 15831 bytes .../advtrains/models/advtrains_track_st_45.b3d | Bin 0 -> 8935 bytes advtrains/advtrains/models/trackplane.b3d | Bin 0 -> 262 bytes advtrains/advtrains/pseudoload.lua | 182 +++++ advtrains/advtrains/readme.txt | 23 + advtrains/advtrains/signals.lua | 76 ++ advtrains/advtrains/textures/advtrains_couple.png | Bin 0 -> 265 bytes .../advtrains/textures/advtrains_discouple.png | Bin 0 -> 307 bytes .../textures/advtrains_dtrack_atc_placer.png | Bin 0 -> 1259 bytes .../textures/advtrains_dtrack_bumper_placer.png | Bin 0 -> 2213 bytes .../textures/advtrains_dtrack_detector_placer.png | Bin 0 -> 1253 bytes .../advtrains/textures/advtrains_dtrack_placer.png | Bin 0 -> 1097 bytes .../advtrains/textures/advtrains_dtrack_rail.png | Bin 0 -> 2814 bytes .../textures/advtrains_dtrack_rail_atc.png | Bin 0 -> 2837 bytes .../textures/advtrains_dtrack_rail_detector_on.png | Bin 0 -> 2818 bytes .../textures/advtrains_dtrack_slopeplacer.png | Bin 0 -> 2415 bytes .../advtrains/textures/advtrains_platform.png | Bin 0 -> 193 bytes .../advtrains/textures/advtrains_retrosignal.png | Bin 0 -> 8496 bytes .../textures/advtrains_retrosignal_inv.png | Bin 0 -> 2242 bytes .../advtrains/textures/advtrains_signal_inv.png | Bin 0 -> 856 bytes .../advtrains/textures/advtrains_signal_off.png | Bin 0 -> 5882 bytes .../advtrains/textures/advtrains_signal_on.png | Bin 0 -> 5884 bytes .../advtrains/textures/advtrains_track_cr.png | Bin 0 -> 33370 bytes .../advtrains/textures/advtrains_track_cr_45.png | Bin 0 -> 33938 bytes .../advtrains/textures/advtrains_track_placer.png | Bin 0 -> 32349 bytes .../advtrains/textures/advtrains_track_st.png | Bin 0 -> 20405 bytes .../advtrains/textures/advtrains_track_st_45.png | Bin 0 -> 39977 bytes .../advtrains/textures/advtrains_track_swlcr.png | Bin 0 -> 33378 bytes .../textures/advtrains_track_swlcr_45.png | Bin 0 -> 45772 bytes .../advtrains/textures/advtrains_track_swlst.png | Bin 0 -> 32321 bytes .../textures/advtrains_track_swlst_45.png | Bin 0 -> 46408 bytes .../advtrains/textures/advtrains_track_swrcr.png | Bin 0 -> 33670 bytes .../textures/advtrains_track_swrcr_45.png | Bin 0 -> 46865 bytes .../advtrains/textures/advtrains_track_swrst.png | Bin 0 -> 32654 bytes .../textures/advtrains_track_swrst_45.png | Bin 0 -> 47636 bytes .../advtrains/textures/advtrains_trackworker.png | Bin 0 -> 328 bytes advtrains/advtrains/textures/drwho_screwdriver.png | Bin 0 -> 328 bytes advtrains/advtrains/trackplacer.lua | 297 +++++++ advtrains/advtrains/tracks.lua | 721 +++++++++++++++++ advtrains/advtrains/trainhud.lua | 109 +++ advtrains/advtrains/trainlogic.lua | 875 +++++++++++++++++++++ advtrains/advtrains/wagons.lua | 573 ++++++++++++++ advtrains/advtrains_train_industrial/depends.txt | 1 + advtrains/advtrains_train_industrial/init.lua | 67 ++ .../models/advtrains_engine_industrial.b3d | Bin 0 -> 143659 bytes .../models/advtrains_wagon_tank.b3d | Bin 0 -> 223975 bytes .../models/advtrains_wagon_wood.b3d | Bin 0 -> 193975 bytes .../textures/advtrains_engine_industrial.png | Bin 0 -> 59019 bytes .../textures/advtrains_engine_industrial_inv.png | Bin 0 -> 381 bytes .../textures/advtrains_wagon_tank.png | Bin 0 -> 8975 bytes .../textures/advtrains_wagon_tank_inv.png | Bin 0 -> 408 bytes .../textures/advtrains_wagon_wood.png | Bin 0 -> 5974 bytes .../textures/advtrains_wagon_wood_inv.png | Bin 0 -> 316 bytes advtrains/advtrains_train_japan/depends.txt | 1 + advtrains/advtrains_train_japan/init.lua | 38 + .../models/advtrains_engine_japan.b3d | Bin 0 -> 165287 bytes .../models/advtrains_wagon_japan.b3d | Bin 0 -> 171991 bytes .../textures/advtrains_engine_japan.png | Bin 0 -> 12664 bytes .../textures/advtrains_engine_japan_inv.png | Bin 0 -> 434 bytes .../textures/advtrains_wagon_japan.png | Bin 0 -> 11175 bytes .../textures/advtrains_wagon_japan_inv.png | Bin 0 -> 400 bytes advtrains/advtrains_train_steam/depends.txt | 1 + advtrains/advtrains_train_steam/init.lua | 121 +++ .../models/advtrains_engine_steam.b3d | Bin 0 -> 298687 bytes .../models/advtrains_wagon.b3d | Bin 0 -> 107352 bytes .../textures/advtrains_newlocomotive.png | Bin 0 -> 31800 bytes .../textures/advtrains_newlocomotive_inv.png | Bin 0 -> 469 bytes .../textures/advtrains_wagon.png | Bin 0 -> 35724 bytes .../textures/advtrains_wagon_box.png | Bin 0 -> 22503 bytes .../textures/advtrains_wagon_box_inv.png | Bin 0 -> 347 bytes .../textures/advtrains_wagon_inv.png | Bin 0 -> 709 bytes advtrains/advtrains_train_subway/depends.txt | 1 + advtrains/advtrains_train_subway/init.lua | 30 + .../models/advtrains_subway_train.b3d | Bin 0 -> 95856 bytes .../textures/advtrains_subway_train.png | Bin 0 -> 12002 bytes .../textures/advtrains_subway_train_inv.png | Bin 0 -> 900 bytes advtrains/api_doc.txt | 114 --- advtrains/atc.lua | 294 ------- advtrains/atc_command.txt | 68 -- advtrains/couple.lua | 156 ---- advtrains/crafting.lua | 71 -- advtrains/damage.lua | 26 - advtrains/debugitems.lua | 36 - advtrains/depends.txt | 2 - advtrains/description.txt | 8 - advtrains/helpers.lua | 248 ------ advtrains/init.lua | 40 - advtrains/license.txt | 142 ++++ advtrains/license_media.txt | 63 ++ advtrains/manual.pdf | Bin 0 -> 1037362 bytes advtrains/misc_nodes.lua | 67 -- advtrains/models/advtrains_dtrack_bumper_st.b3d | Bin 32927 -> 0 bytes advtrains/models/advtrains_dtrack_bumper_st_30.b3d | Bin 48546 -> 0 bytes advtrains/models/advtrains_dtrack_bumper_st_45.b3d | Bin 32926 -> 0 bytes advtrains/models/advtrains_dtrack_bumper_st_60.b3d | Bin 48546 -> 0 bytes advtrains/models/advtrains_dtrack_cr.b3d | Bin 27540 -> 0 bytes advtrains/models/advtrains_dtrack_cr_30.b3d | Bin 27543 -> 0 bytes advtrains/models/advtrains_dtrack_cr_45.b3d | Bin 23037 -> 0 bytes advtrains/models/advtrains_dtrack_cr_60.b3d | Bin 23037 -> 0 bytes advtrains/models/advtrains_dtrack_detector_st.b3d | Bin 17157 -> 0 bytes .../models/advtrains_dtrack_detector_st_30.b3d | Bin 32779 -> 0 bytes .../models/advtrains_dtrack_detector_st_45.b3d | Bin 17163 -> 0 bytes .../models/advtrains_dtrack_detector_st_60.b3d | Bin 32779 -> 0 bytes advtrains/models/advtrains_dtrack_st.b3d | Bin 15828 -> 0 bytes advtrains/models/advtrains_dtrack_st_30.b3d | Bin 31447 -> 0 bytes advtrains/models/advtrains_dtrack_st_45.b3d | Bin 15831 -> 0 bytes advtrains/models/advtrains_dtrack_st_60.b3d | Bin 31447 -> 0 bytes advtrains/models/advtrains_dtrack_swlcr.b3d | Bin 36743 -> 0 bytes advtrains/models/advtrains_dtrack_swlcr_30.b3d | Bin 45922 -> 0 bytes advtrains/models/advtrains_dtrack_swlcr_45.b3d | Bin 32112 -> 0 bytes advtrains/models/advtrains_dtrack_swlcr_60.b3d | Bin 44864 -> 0 bytes advtrains/models/advtrains_dtrack_swlst.b3d | Bin 36743 -> 0 bytes advtrains/models/advtrains_dtrack_swlst_30.b3d | Bin 45922 -> 0 bytes advtrains/models/advtrains_dtrack_swlst_45.b3d | Bin 32112 -> 0 bytes advtrains/models/advtrains_dtrack_swlst_60.b3d | Bin 44864 -> 0 bytes advtrains/models/advtrains_dtrack_swrcr.b3d | Bin 36743 -> 0 bytes advtrains/models/advtrains_dtrack_swrcr_30.b3d | Bin 44864 -> 0 bytes advtrains/models/advtrains_dtrack_swrcr_45.b3d | Bin 32112 -> 0 bytes advtrains/models/advtrains_dtrack_swrcr_60.b3d | Bin 45922 -> 0 bytes advtrains/models/advtrains_dtrack_swrst.b3d | Bin 36743 -> 0 bytes advtrains/models/advtrains_dtrack_swrst_30.b3d | Bin 44864 -> 0 bytes advtrains/models/advtrains_dtrack_swrst_45.b3d | Bin 32112 -> 0 bytes advtrains/models/advtrains_dtrack_swrst_60.b3d | Bin 45922 -> 0 bytes advtrains/models/advtrains_dtrack_vst1.b3d | Bin 21495 -> 0 bytes advtrains/models/advtrains_dtrack_vst1_45.b3d | Bin 20739 -> 0 bytes advtrains/models/advtrains_dtrack_vst2.b3d | Bin 25143 -> 0 bytes advtrains/models/advtrains_dtrack_vst2_45.b3d | Bin 20919 -> 0 bytes advtrains/models/advtrains_dtrack_vst31.b3d | Bin 19051 -> 0 bytes advtrains/models/advtrains_dtrack_vst32.b3d | Bin 21635 -> 0 bytes advtrains/models/advtrains_dtrack_vst33.b3d | Bin 28795 -> 0 bytes advtrains/models/advtrains_modernwagon.b3d | Bin 172028 -> 0 bytes advtrains/models/advtrains_retrosignal_off.b3d | Bin 13093 -> 0 bytes advtrains/models/advtrains_retrosignal_off_30.b3d | Bin 13093 -> 0 bytes advtrains/models/advtrains_retrosignal_off_45.b3d | Bin 13093 -> 0 bytes advtrains/models/advtrains_retrosignal_off_60.b3d | Bin 13093 -> 0 bytes advtrains/models/advtrains_retrosignal_on.b3d | Bin 13093 -> 0 bytes advtrains/models/advtrains_retrosignal_on_30.b3d | Bin 13093 -> 0 bytes advtrains/models/advtrains_retrosignal_on_45.b3d | Bin 13093 -> 0 bytes advtrains/models/advtrains_retrosignal_on_60.b3d | Bin 13093 -> 0 bytes advtrains/models/advtrains_signal.b3d | Bin 61544 -> 0 bytes advtrains/models/advtrains_signal_30.b3d | Bin 61544 -> 0 bytes advtrains/models/advtrains_signal_45.b3d | Bin 61544 -> 0 bytes advtrains/models/advtrains_signal_60.b3d | Bin 61544 -> 0 bytes advtrains/models/advtrains_track_cr.b3d | Bin 8023 -> 0 bytes advtrains/models/advtrains_track_st.b3d | Bin 15831 -> 0 bytes advtrains/models/advtrains_track_st_45.b3d | Bin 8935 -> 0 bytes .../models/blender/engine-with-animation.blend | Bin 599504 -> 0 bytes advtrains/models/blender/gleis/detectorpart.png | Bin 857 -> 0 bytes .../models/blender/gleis/infos/Grafik_weiche.png | Bin 361700 -> 0 bytes advtrains/models/blender/gleis/infos/breite | 1 - advtrains/models/blender/gleis/licence.txt~ | 0 advtrains/models/blender/gleis/rail_my.blend | Bin 654772 -> 0 bytes advtrains/models/blender/gleis/rail_my.blend1 | Bin 674164 -> 0 bytes advtrains/models/blender/gleis/rail_my_rt.blend | Bin 847060 -> 0 bytes advtrains/models/blender/gleis/rail_my_rt.blend1 | Bin 767780 -> 0 bytes .../models/blender/gleis/rail_my_rt_final.blend | Bin 1015668 -> 0 bytes .../models/blender/gleis/rail_my_rt_final.blend1 | Bin 1106004 -> 0 bytes .../models/blender/gleis/rail_my_rt_switches.blend | Bin 2184236 -> 0 bytes .../blender/gleis/rail_my_rt_switches.blend1 | Bin 1945588 -> 0 bytes .../blender/gleis/rail_my_rt_switches2.blend | Bin 2139340 -> 0 bytes .../blender/gleis/rail_my_rt_switches2.blend1 | Bin 2172972 -> 0 bytes advtrains/models/blender/gleis/rail_together.blend | Bin 1016920 -> 0 bytes advtrains/models/blender/gleis/rail_together.png | Bin 233544 -> 0 bytes advtrains/models/blender/gleis/rail_together2.png | Bin 312891 -> 0 bytes advtrains/models/blender/gleis/rail_together3.png | Bin 309398 -> 0 bytes .../models/blender/gleis/rail_verticals.blend | Bin 550748 -> 0 bytes .../models/blender/gleis/rail_verticals.blend1 | Bin 574100 -> 0 bytes .../models/blender/gleis/rail_verticals3.blend | Bin 591800 -> 0 bytes .../models/blender/gleis/rail_verticals3.blend1 | Bin 554196 -> 0 bytes .../models/blender/gleis/rail_verticals45.blend | Bin 547788 -> 0 bytes .../models/blender/gleis/rail_verticals45.blend1 | Bin 547300 -> 0 bytes .../models/blender/gleis/rail_verticals45.blend11 | Bin 547300 -> 0 bytes advtrains/models/blender/gleis/texturen/rail.png | Bin 2616 -> 0 bytes advtrains/models/blender/gleis/texturen/uv.png | Bin 2343 -> 0 bytes .../models/blender/industrial/industry_loc.blend | Bin 652640 -> 0 bytes .../models/blender/industrial/industry_loc.blend1 | Bin 652640 -> 0 bytes .../models/blender/industrial/industry_loc.blend11 | Bin 659096 -> 0 bytes .../blender/industrial/industry_oil_ wagong.blend | Bin 693488 -> 0 bytes .../blender/industrial/industry_oil_ wagong.blend1 | Bin 693488 -> 0 bytes .../blender/industrial/industry_tree_wagong.blend | Bin 640056 -> 0 bytes .../blender/industrial/industry_tree_wagong.blend1 | Bin 640056 -> 0 bytes .../blender/industrial/industry_tree_wagong.png | Bin 316 -> 0 bytes advtrains/models/blender/locomotive.blend | Bin 459600 -> 0 bytes advtrains/models/blender/magnet_track.blend | Bin 516836 -> 0 bytes .../models/blender/mbb/advtrains_wagon_japan.xcf | Bin 814467 -> 0 bytes .../blender/mbb/modern_japanlocomotive.blend | Bin 715116 -> 0 bytes .../blender/mbb/modern_japanlocomotive.blend1 | Bin 715116 -> 0 bytes .../models/blender/mbb/modern_japanlocomotive.png | Bin 204978 -> 0 bytes .../models/blender/mbb/modern_japanlocomotive.xcf | Bin 957175 -> 0 bytes .../models/blender/mbb/modern_locomotive.blend | Bin 732124 -> 0 bytes advtrains/models/blender/mbb/modern_wagong.blend | Bin 471140 -> 0 bytes advtrains/models/blender/mbb/modern_wagong.blend1 | Bin 518316 -> 0 bytes .../models/blender/mbb/modern_wagong_uv.blend | Bin 571364 -> 0 bytes .../models/blender/mbb/modern_wagong_uv.blend1 | Bin 575708 -> 0 bytes advtrains/models/blender/mbb/modern_wagong_uv.png | Bin 189564 -> 0 bytes advtrains/models/blender/mbb/prellbock.blend | Bin 745176 -> 0 bytes advtrains/models/blender/mbb/prellbock.blend1 | Bin 485416 -> 0 bytes advtrains/models/blender/mbb/prellbock.uv.png | Bin 4034 -> 0 bytes .../models/blender/mbb/regio-lokomotive.blend | Bin 704160 -> 0 bytes advtrains/models/blender/mbb/regio-waron.blend | Bin 545620 -> 0 bytes advtrains/models/blender/mbb/retrosignal.blend | Bin 488920 -> 0 bytes advtrains/models/blender/mbb/retrosignal.blend1 | Bin 507800 -> 0 bytes advtrains/models/blender/mbb/signal(2)_hoch.blend | Bin 472092 -> 0 bytes advtrains/models/blender/mbb/signal(2)_unten.blend | Bin 472092 -> 0 bytes advtrains/models/blender/mbb/signal.blend | Bin 570336 -> 0 bytes advtrains/models/blender/mbb/signal.blend1 | Bin 570336 -> 0 bytes advtrains/models/blender/mbb/signal.png | Bin 244314 -> 0 bytes advtrains/models/blender/mbb/signal.xcf | Bin 881142 -> 0 bytes advtrains/models/blender/mbb/signal2.png | Bin 39924 -> 0 bytes advtrains/models/blender/mbb/tr-logo.png | Bin 197 -> 0 bytes advtrains/models/blender/mbb/weichenhebel1.blend | Bin 493028 -> 0 bytes advtrains/models/blender/mbb/weichenhebel2.blend | Bin 492996 -> 0 bytes advtrains/models/blender/newlocomotive.blend | Bin 603376 -> 0 bytes advtrains/models/blender/newlocomotive.blend1 | Bin 603376 -> 0 bytes advtrains/models/blender/newlocomotive_uvs.png | Bin 175030 -> 0 bytes advtrains/models/blender/newwagon.blend | Bin 542188 -> 0 bytes advtrains/models/blender/newwagon.blend1 | Bin 550292 -> 0 bytes advtrains/models/blender/newwagon.png | Bin 108762 -> 0 bytes advtrains/models/blender/subway-train.blend | Bin 536268 -> 0 bytes advtrains/models/blender/subway-train.blend1 | Bin 538188 -> 0 bytes advtrains/models/blender/subway-train.png | Bin 96773 -> 0 bytes advtrains/models/blender/subway-train.xcf | Bin 92558 -> 0 bytes advtrains/models/blender/trackplane.blend | Bin 462200 -> 0 bytes advtrains/models/blender/trackvertical1.blend | Bin 453656 -> 0 bytes advtrains/models/blender/trackvertical1.blend1 | Bin 453344 -> 0 bytes advtrains/models/blender/trackvertical1.png | Bin 59146 -> 0 bytes advtrains/models/blender/trackvertical2.blend | Bin 459216 -> 0 bytes advtrains/models/blender/trackvertical2.png | Bin 66755 -> 0 bytes advtrains/models/oldmodels/locomotive.b3d | Bin 181112 -> 0 bytes advtrains/models/oldmodels/trackvertical1.b3d | Bin 629 -> 0 bytes advtrains/models/oldmodels/trackvertical2.b3d | Bin 869 -> 0 bytes advtrains/models/trackplane.b3d | Bin 262 -> 0 bytes advtrains/modpack.txt | 0 advtrains/pseudoload.lua | 182 ----- advtrains/readme.txt | 23 - advtrains/screenshot.png | Bin 0 -> 445014 bytes advtrains/signals.lua | 76 -- advtrains/textures/advtrains_couple.png | Bin 265 -> 0 bytes advtrains/textures/advtrains_discouple.png | Bin 307 -> 0 bytes advtrains/textures/advtrains_dtrack_atc_placer.png | Bin 1259 -> 0 bytes .../textures/advtrains_dtrack_bumper_placer.png | Bin 2213 -> 0 bytes .../textures/advtrains_dtrack_detector_placer.png | Bin 1253 -> 0 bytes advtrains/textures/advtrains_dtrack_placer.png | Bin 1097 -> 0 bytes advtrains/textures/advtrains_dtrack_rail.png | Bin 2814 -> 0 bytes advtrains/textures/advtrains_dtrack_rail_atc.png | Bin 2837 -> 0 bytes .../textures/advtrains_dtrack_rail_detector_on.png | Bin 2818 -> 0 bytes .../textures/advtrains_dtrack_slopeplacer.png | Bin 2415 -> 0 bytes advtrains/textures/advtrains_newlocomotive.xcf | Bin 7462378 -> 0 bytes advtrains/textures/advtrains_platform.png | Bin 193 -> 0 bytes advtrains/textures/advtrains_retrosignal.png | Bin 8496 -> 0 bytes advtrains/textures/advtrains_retrosignal_inv.png | Bin 2242 -> 0 bytes advtrains/textures/advtrains_signal_inv.png | Bin 856 -> 0 bytes advtrains/textures/advtrains_signal_off.png | Bin 5882 -> 0 bytes advtrains/textures/advtrains_signal_on.png | Bin 5884 -> 0 bytes advtrains/textures/advtrains_track_cr.png | Bin 33370 -> 0 bytes advtrains/textures/advtrains_track_cr_45.png | Bin 33938 -> 0 bytes advtrains/textures/advtrains_track_placer.png | Bin 32349 -> 0 bytes advtrains/textures/advtrains_track_st.png | Bin 20405 -> 0 bytes advtrains/textures/advtrains_track_st_45.png | Bin 39977 -> 0 bytes advtrains/textures/advtrains_track_swlcr.png | Bin 33378 -> 0 bytes advtrains/textures/advtrains_track_swlcr_45.png | Bin 45772 -> 0 bytes advtrains/textures/advtrains_track_swlst.png | Bin 32321 -> 0 bytes advtrains/textures/advtrains_track_swlst_45.png | Bin 46408 -> 0 bytes advtrains/textures/advtrains_track_swrcr.png | Bin 33670 -> 0 bytes advtrains/textures/advtrains_track_swrcr_45.png | Bin 46865 -> 0 bytes advtrains/textures/advtrains_track_swrst.png | Bin 32654 -> 0 bytes advtrains/textures/advtrains_track_swrst_45.png | Bin 47636 -> 0 bytes advtrains/textures/advtrains_trackworker.png | Bin 328 -> 0 bytes advtrains/textures/drwho_screwdriver.png | Bin 328 -> 0 bytes advtrains/textures/larger rails.xcf | Bin 1239132 -> 0 bytes advtrains/trackplacer.lua | 297 ------- advtrains/tracks.lua | 721 ----------------- advtrains/trainhud.lua | 109 --- advtrains/trainlogic.lua | 875 --------------------- advtrains/wagons.lua | 573 -------------- advtrains_train_industrial/depends.txt | 1 - advtrains_train_industrial/init.lua | 67 -- .../models/advtrains_engine_industrial.b3d | Bin 143659 -> 0 bytes .../models/advtrains_wagon_tank.b3d | Bin 223975 -> 0 bytes .../models/advtrains_wagon_wood.b3d | Bin 193975 -> 0 bytes .../textures/advtrains_engine_industrial.png | Bin 59019 -> 0 bytes .../textures/advtrains_engine_industrial_inv.png | Bin 381 -> 0 bytes .../textures/advtrains_wagon_tank.png | Bin 8975 -> 0 bytes .../textures/advtrains_wagon_tank_inv.png | Bin 408 -> 0 bytes .../textures/advtrains_wagon_wood.png | Bin 5974 -> 0 bytes .../textures/advtrains_wagon_wood_inv.png | Bin 316 -> 0 bytes advtrains_train_japan/depends.txt | 1 - advtrains_train_japan/init.lua | 38 - .../models/advtrains_engine_japan.b3d | Bin 165287 -> 0 bytes .../models/advtrains_wagon_japan.b3d | Bin 171991 -> 0 bytes .../textures/advtrains_engine_japan.png | Bin 12664 -> 0 bytes .../textures/advtrains_engine_japan_inv.png | Bin 434 -> 0 bytes .../textures/advtrains_wagon_japan.png | Bin 11175 -> 0 bytes .../textures/advtrains_wagon_japan_inv.png | Bin 400 -> 0 bytes advtrains_train_steam/depends.txt | 1 - advtrains_train_steam/init.lua | 121 --- .../models/advtrains_engine_steam.b3d | Bin 298687 -> 0 bytes advtrains_train_steam/models/advtrains_wagon.b3d | Bin 107352 -> 0 bytes .../textures/advtrains_newlocomotive.png | Bin 31800 -> 0 bytes .../textures/advtrains_newlocomotive_inv.png | Bin 469 -> 0 bytes advtrains_train_steam/textures/advtrains_wagon.png | Bin 35724 -> 0 bytes .../textures/advtrains_wagon_box.png | Bin 22503 -> 0 bytes .../textures/advtrains_wagon_box_inv.png | Bin 347 -> 0 bytes .../textures/advtrains_wagon_inv.png | Bin 709 -> 0 bytes advtrains_train_subway/depends.txt | 1 - advtrains_train_subway/init.lua | 30 - .../models/advtrains_subway_train.b3d | Bin 95856 -> 0 bytes .../textures/advtrains_subway_train.png | Bin 12002 -> 0 bytes .../textures/advtrains_subway_train_inv.png | Bin 900 -> 0 bytes assets/advtrains_newlocomotive.xcf | Bin 0 -> 7462378 bytes assets/blender/engine-with-animation.blend | Bin 0 -> 599504 bytes assets/blender/gleis/detectorpart.png | Bin 0 -> 857 bytes assets/blender/gleis/infos/Grafik_weiche.png | Bin 0 -> 361700 bytes assets/blender/gleis/infos/breite | 1 + assets/blender/gleis/licence.txt~ | 0 assets/blender/gleis/rail_my.blend | Bin 0 -> 654772 bytes assets/blender/gleis/rail_my.blend1 | Bin 0 -> 674164 bytes assets/blender/gleis/rail_my_rt.blend | Bin 0 -> 847060 bytes assets/blender/gleis/rail_my_rt.blend1 | Bin 0 -> 767780 bytes assets/blender/gleis/rail_my_rt_final.blend | Bin 0 -> 1015668 bytes assets/blender/gleis/rail_my_rt_final.blend1 | Bin 0 -> 1106004 bytes assets/blender/gleis/rail_my_rt_switches.blend | Bin 0 -> 2184236 bytes assets/blender/gleis/rail_my_rt_switches.blend1 | Bin 0 -> 1945588 bytes assets/blender/gleis/rail_my_rt_switches2.blend | Bin 0 -> 2139340 bytes assets/blender/gleis/rail_my_rt_switches2.blend1 | Bin 0 -> 2172972 bytes assets/blender/gleis/rail_together.blend | Bin 0 -> 1016920 bytes assets/blender/gleis/rail_together.png | Bin 0 -> 233544 bytes assets/blender/gleis/rail_together2.png | Bin 0 -> 312891 bytes assets/blender/gleis/rail_together3.png | Bin 0 -> 309398 bytes assets/blender/gleis/rail_verticals.blend | Bin 0 -> 550748 bytes assets/blender/gleis/rail_verticals.blend1 | Bin 0 -> 574100 bytes assets/blender/gleis/rail_verticals3.blend | Bin 0 -> 591800 bytes assets/blender/gleis/rail_verticals3.blend1 | Bin 0 -> 554196 bytes assets/blender/gleis/rail_verticals45.blend | Bin 0 -> 547788 bytes assets/blender/gleis/rail_verticals45.blend1 | Bin 0 -> 547300 bytes assets/blender/gleis/rail_verticals45.blend11 | Bin 0 -> 547300 bytes assets/blender/gleis/texturen/rail.png | Bin 0 -> 2616 bytes assets/blender/gleis/texturen/uv.png | Bin 0 -> 2343 bytes assets/blender/industrial/industry_loc.blend | Bin 0 -> 652640 bytes assets/blender/industrial/industry_loc.blend1 | Bin 0 -> 652640 bytes assets/blender/industrial/industry_loc.blend11 | Bin 0 -> 659096 bytes .../blender/industrial/industry_oil_ wagong.blend | Bin 0 -> 693488 bytes .../blender/industrial/industry_oil_ wagong.blend1 | Bin 0 -> 693488 bytes .../blender/industrial/industry_tree_wagong.blend | Bin 0 -> 640056 bytes .../blender/industrial/industry_tree_wagong.blend1 | Bin 0 -> 640056 bytes assets/blender/industrial/industry_tree_wagong.png | Bin 0 -> 316 bytes assets/blender/locomotive.blend | Bin 0 -> 459600 bytes assets/blender/magnet_track.blend | Bin 0 -> 516836 bytes assets/blender/mbb/advtrains_wagon_japan.xcf | Bin 0 -> 814467 bytes assets/blender/mbb/modern_japanlocomotive.blend | Bin 0 -> 715116 bytes assets/blender/mbb/modern_japanlocomotive.blend1 | Bin 0 -> 715116 bytes assets/blender/mbb/modern_japanlocomotive.png | Bin 0 -> 204978 bytes assets/blender/mbb/modern_japanlocomotive.xcf | Bin 0 -> 957175 bytes assets/blender/mbb/modern_locomotive.blend | Bin 0 -> 732124 bytes assets/blender/mbb/modern_wagong.blend | Bin 0 -> 471140 bytes assets/blender/mbb/modern_wagong.blend1 | Bin 0 -> 518316 bytes assets/blender/mbb/modern_wagong_uv.blend | Bin 0 -> 571364 bytes assets/blender/mbb/modern_wagong_uv.blend1 | Bin 0 -> 575708 bytes assets/blender/mbb/modern_wagong_uv.png | Bin 0 -> 189564 bytes assets/blender/mbb/prellbock.blend | Bin 0 -> 745176 bytes assets/blender/mbb/prellbock.blend1 | Bin 0 -> 485416 bytes assets/blender/mbb/prellbock.uv.png | Bin 0 -> 4034 bytes assets/blender/mbb/regio-lokomotive.blend | Bin 0 -> 704160 bytes assets/blender/mbb/regio-waron.blend | Bin 0 -> 545620 bytes assets/blender/mbb/retrosignal.blend | Bin 0 -> 488920 bytes assets/blender/mbb/retrosignal.blend1 | Bin 0 -> 507800 bytes assets/blender/mbb/signal(2)_hoch.blend | Bin 0 -> 472092 bytes assets/blender/mbb/signal(2)_unten.blend | Bin 0 -> 472092 bytes assets/blender/mbb/signal.blend | Bin 0 -> 570336 bytes assets/blender/mbb/signal.blend1 | Bin 0 -> 570336 bytes assets/blender/mbb/signal.png | Bin 0 -> 244314 bytes assets/blender/mbb/signal.xcf | Bin 0 -> 881142 bytes assets/blender/mbb/signal2.png | Bin 0 -> 39924 bytes assets/blender/mbb/tr-logo.png | Bin 0 -> 197 bytes assets/blender/mbb/weichenhebel1.blend | Bin 0 -> 493028 bytes assets/blender/mbb/weichenhebel2.blend | Bin 0 -> 492996 bytes assets/blender/newlocomotive.blend | Bin 0 -> 603376 bytes assets/blender/newlocomotive.blend1 | Bin 0 -> 603376 bytes assets/blender/newlocomotive_uvs.png | Bin 0 -> 175030 bytes assets/blender/newwagon.blend | Bin 0 -> 542188 bytes assets/blender/newwagon.blend1 | Bin 0 -> 550292 bytes assets/blender/newwagon.png | Bin 0 -> 108762 bytes assets/blender/subway-train.blend | Bin 0 -> 536268 bytes assets/blender/subway-train.blend1 | Bin 0 -> 538188 bytes assets/blender/subway-train.png | Bin 0 -> 96773 bytes assets/blender/subway-train.xcf | Bin 0 -> 92558 bytes assets/blender/trackplane.blend | Bin 0 -> 462200 bytes assets/blender/trackvertical1.blend | Bin 0 -> 453656 bytes assets/blender/trackvertical1.blend1 | Bin 0 -> 453344 bytes assets/blender/trackvertical1.png | Bin 0 -> 59146 bytes assets/blender/trackvertical2.blend | Bin 0 -> 459216 bytes assets/blender/trackvertical2.png | Bin 0 -> 66755 bytes assets/init.lua | 0 assets/larger rails.xcf | Bin 0 -> 1239132 bytes assets/oldmodels/locomotive.b3d | Bin 0 -> 181112 bytes assets/oldmodels/trackvertical1.b3d | Bin 0 -> 629 bytes assets/oldmodels/trackvertical2.b3d | Bin 0 -> 869 bytes license.txt | 142 ---- license_media.txt | 63 -- manual.pdf | Bin 1037362 -> 0 bytes screenshot.png | Bin 445014 -> 0 bytes 470 files changed, 4457 insertions(+), 4457 deletions(-) delete mode 100644 Makefile delete mode 100644 advtrains.zip create mode 100644 advtrains/Makefile create mode 100644 advtrains/advtrains.zip create mode 100644 advtrains/advtrains/api_doc.txt create mode 100644 advtrains/advtrains/atc.lua create mode 100644 advtrains/advtrains/atc_command.txt create mode 100644 advtrains/advtrains/couple.lua create mode 100644 advtrains/advtrains/crafting.lua create mode 100644 advtrains/advtrains/damage.lua create mode 100644 advtrains/advtrains/debugitems.lua create mode 100644 advtrains/advtrains/depends.txt create mode 100644 advtrains/advtrains/description.txt create mode 100644 advtrains/advtrains/helpers.lua create mode 100644 advtrains/advtrains/init.lua create mode 100644 advtrains/advtrains/misc_nodes.lua create mode 100644 advtrains/advtrains/models/advtrains_dtrack_bumper_st.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_bumper_st_30.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_bumper_st_45.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_bumper_st_60.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_cr.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_cr_30.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_cr_45.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_cr_60.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_detector_st.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_detector_st_30.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_detector_st_45.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_detector_st_60.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_st.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_st_30.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_st_45.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_st_60.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swlcr.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swlcr_30.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swlcr_45.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swlcr_60.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swlst.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swlst_30.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swlst_45.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swlst_60.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swrcr.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swrcr_30.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swrcr_45.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swrcr_60.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swrst.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swrst_30.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swrst_45.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_swrst_60.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_vst1.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_vst1_45.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_vst2.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_vst2_45.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_vst31.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_vst32.b3d create mode 100644 advtrains/advtrains/models/advtrains_dtrack_vst33.b3d create mode 100644 advtrains/advtrains/models/advtrains_modernwagon.b3d create mode 100644 advtrains/advtrains/models/advtrains_retrosignal_off.b3d create mode 100644 advtrains/advtrains/models/advtrains_retrosignal_off_30.b3d create mode 100644 advtrains/advtrains/models/advtrains_retrosignal_off_45.b3d create mode 100644 advtrains/advtrains/models/advtrains_retrosignal_off_60.b3d create mode 100644 advtrains/advtrains/models/advtrains_retrosignal_on.b3d create mode 100644 advtrains/advtrains/models/advtrains_retrosignal_on_30.b3d create mode 100644 advtrains/advtrains/models/advtrains_retrosignal_on_45.b3d create mode 100644 advtrains/advtrains/models/advtrains_retrosignal_on_60.b3d create mode 100644 advtrains/advtrains/models/advtrains_signal.b3d create mode 100644 advtrains/advtrains/models/advtrains_signal_30.b3d create mode 100644 advtrains/advtrains/models/advtrains_signal_45.b3d create mode 100644 advtrains/advtrains/models/advtrains_signal_60.b3d create mode 100644 advtrains/advtrains/models/advtrains_track_cr.b3d create mode 100644 advtrains/advtrains/models/advtrains_track_st.b3d create mode 100644 advtrains/advtrains/models/advtrains_track_st_45.b3d create mode 100644 advtrains/advtrains/models/trackplane.b3d create mode 100644 advtrains/advtrains/pseudoload.lua create mode 100644 advtrains/advtrains/readme.txt create mode 100644 advtrains/advtrains/signals.lua create mode 100644 advtrains/advtrains/textures/advtrains_couple.png create mode 100644 advtrains/advtrains/textures/advtrains_discouple.png create mode 100644 advtrains/advtrains/textures/advtrains_dtrack_atc_placer.png create mode 100644 advtrains/advtrains/textures/advtrains_dtrack_bumper_placer.png create mode 100644 advtrains/advtrains/textures/advtrains_dtrack_detector_placer.png create mode 100644 advtrains/advtrains/textures/advtrains_dtrack_placer.png create mode 100644 advtrains/advtrains/textures/advtrains_dtrack_rail.png create mode 100644 advtrains/advtrains/textures/advtrains_dtrack_rail_atc.png create mode 100644 advtrains/advtrains/textures/advtrains_dtrack_rail_detector_on.png create mode 100644 advtrains/advtrains/textures/advtrains_dtrack_slopeplacer.png create mode 100644 advtrains/advtrains/textures/advtrains_platform.png create mode 100644 advtrains/advtrains/textures/advtrains_retrosignal.png create mode 100644 advtrains/advtrains/textures/advtrains_retrosignal_inv.png create mode 100644 advtrains/advtrains/textures/advtrains_signal_inv.png create mode 100644 advtrains/advtrains/textures/advtrains_signal_off.png create mode 100644 advtrains/advtrains/textures/advtrains_signal_on.png create mode 100644 advtrains/advtrains/textures/advtrains_track_cr.png create mode 100644 advtrains/advtrains/textures/advtrains_track_cr_45.png create mode 100644 advtrains/advtrains/textures/advtrains_track_placer.png create mode 100644 advtrains/advtrains/textures/advtrains_track_st.png create mode 100644 advtrains/advtrains/textures/advtrains_track_st_45.png create mode 100644 advtrains/advtrains/textures/advtrains_track_swlcr.png create mode 100644 advtrains/advtrains/textures/advtrains_track_swlcr_45.png create mode 100644 advtrains/advtrains/textures/advtrains_track_swlst.png create mode 100644 advtrains/advtrains/textures/advtrains_track_swlst_45.png create mode 100644 advtrains/advtrains/textures/advtrains_track_swrcr.png create mode 100644 advtrains/advtrains/textures/advtrains_track_swrcr_45.png create mode 100644 advtrains/advtrains/textures/advtrains_track_swrst.png create mode 100644 advtrains/advtrains/textures/advtrains_track_swrst_45.png create mode 100644 advtrains/advtrains/textures/advtrains_trackworker.png create mode 100644 advtrains/advtrains/textures/drwho_screwdriver.png create mode 100644 advtrains/advtrains/trackplacer.lua create mode 100644 advtrains/advtrains/tracks.lua create mode 100644 advtrains/advtrains/trainhud.lua create mode 100644 advtrains/advtrains/trainlogic.lua create mode 100644 advtrains/advtrains/wagons.lua create mode 100644 advtrains/advtrains_train_industrial/depends.txt create mode 100644 advtrains/advtrains_train_industrial/init.lua create mode 100644 advtrains/advtrains_train_industrial/models/advtrains_engine_industrial.b3d create mode 100644 advtrains/advtrains_train_industrial/models/advtrains_wagon_tank.b3d create mode 100644 advtrains/advtrains_train_industrial/models/advtrains_wagon_wood.b3d create mode 100644 advtrains/advtrains_train_industrial/textures/advtrains_engine_industrial.png create mode 100644 advtrains/advtrains_train_industrial/textures/advtrains_engine_industrial_inv.png create mode 100644 advtrains/advtrains_train_industrial/textures/advtrains_wagon_tank.png create mode 100644 advtrains/advtrains_train_industrial/textures/advtrains_wagon_tank_inv.png create mode 100644 advtrains/advtrains_train_industrial/textures/advtrains_wagon_wood.png create mode 100644 advtrains/advtrains_train_industrial/textures/advtrains_wagon_wood_inv.png create mode 100644 advtrains/advtrains_train_japan/depends.txt create mode 100644 advtrains/advtrains_train_japan/init.lua create mode 100644 advtrains/advtrains_train_japan/models/advtrains_engine_japan.b3d create mode 100644 advtrains/advtrains_train_japan/models/advtrains_wagon_japan.b3d create mode 100644 advtrains/advtrains_train_japan/textures/advtrains_engine_japan.png create mode 100644 advtrains/advtrains_train_japan/textures/advtrains_engine_japan_inv.png create mode 100644 advtrains/advtrains_train_japan/textures/advtrains_wagon_japan.png create mode 100644 advtrains/advtrains_train_japan/textures/advtrains_wagon_japan_inv.png create mode 100644 advtrains/advtrains_train_steam/depends.txt create mode 100644 advtrains/advtrains_train_steam/init.lua create mode 100644 advtrains/advtrains_train_steam/models/advtrains_engine_steam.b3d create mode 100644 advtrains/advtrains_train_steam/models/advtrains_wagon.b3d create mode 100644 advtrains/advtrains_train_steam/textures/advtrains_newlocomotive.png create mode 100644 advtrains/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png create mode 100644 advtrains/advtrains_train_steam/textures/advtrains_wagon.png create mode 100644 advtrains/advtrains_train_steam/textures/advtrains_wagon_box.png create mode 100644 advtrains/advtrains_train_steam/textures/advtrains_wagon_box_inv.png create mode 100644 advtrains/advtrains_train_steam/textures/advtrains_wagon_inv.png create mode 100644 advtrains/advtrains_train_subway/depends.txt create mode 100644 advtrains/advtrains_train_subway/init.lua create mode 100644 advtrains/advtrains_train_subway/models/advtrains_subway_train.b3d create mode 100644 advtrains/advtrains_train_subway/textures/advtrains_subway_train.png create mode 100644 advtrains/advtrains_train_subway/textures/advtrains_subway_train_inv.png delete mode 100644 advtrains/api_doc.txt delete mode 100644 advtrains/atc.lua delete mode 100644 advtrains/atc_command.txt delete mode 100644 advtrains/couple.lua delete mode 100644 advtrains/crafting.lua delete mode 100644 advtrains/damage.lua delete mode 100644 advtrains/debugitems.lua delete mode 100644 advtrains/depends.txt delete mode 100644 advtrains/description.txt delete mode 100644 advtrains/helpers.lua delete mode 100644 advtrains/init.lua create mode 100644 advtrains/license.txt create mode 100644 advtrains/license_media.txt create mode 100644 advtrains/manual.pdf delete mode 100644 advtrains/misc_nodes.lua delete mode 100644 advtrains/models/advtrains_dtrack_bumper_st.b3d delete mode 100644 advtrains/models/advtrains_dtrack_bumper_st_30.b3d delete mode 100644 advtrains/models/advtrains_dtrack_bumper_st_45.b3d delete mode 100644 advtrains/models/advtrains_dtrack_bumper_st_60.b3d delete mode 100644 advtrains/models/advtrains_dtrack_cr.b3d delete mode 100644 advtrains/models/advtrains_dtrack_cr_30.b3d delete mode 100644 advtrains/models/advtrains_dtrack_cr_45.b3d delete mode 100644 advtrains/models/advtrains_dtrack_cr_60.b3d delete mode 100644 advtrains/models/advtrains_dtrack_detector_st.b3d delete mode 100644 advtrains/models/advtrains_dtrack_detector_st_30.b3d delete mode 100644 advtrains/models/advtrains_dtrack_detector_st_45.b3d delete mode 100644 advtrains/models/advtrains_dtrack_detector_st_60.b3d delete mode 100644 advtrains/models/advtrains_dtrack_st.b3d delete mode 100644 advtrains/models/advtrains_dtrack_st_30.b3d delete mode 100644 advtrains/models/advtrains_dtrack_st_45.b3d delete mode 100644 advtrains/models/advtrains_dtrack_st_60.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swlcr.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swlcr_30.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swlcr_45.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swlcr_60.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swlst.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swlst_30.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swlst_45.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swlst_60.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swrcr.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swrcr_30.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swrcr_45.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swrcr_60.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swrst.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swrst_30.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swrst_45.b3d delete mode 100644 advtrains/models/advtrains_dtrack_swrst_60.b3d delete mode 100644 advtrains/models/advtrains_dtrack_vst1.b3d delete mode 100644 advtrains/models/advtrains_dtrack_vst1_45.b3d delete mode 100644 advtrains/models/advtrains_dtrack_vst2.b3d delete mode 100644 advtrains/models/advtrains_dtrack_vst2_45.b3d delete mode 100644 advtrains/models/advtrains_dtrack_vst31.b3d delete mode 100644 advtrains/models/advtrains_dtrack_vst32.b3d delete mode 100644 advtrains/models/advtrains_dtrack_vst33.b3d delete mode 100644 advtrains/models/advtrains_modernwagon.b3d delete mode 100644 advtrains/models/advtrains_retrosignal_off.b3d delete mode 100644 advtrains/models/advtrains_retrosignal_off_30.b3d delete mode 100644 advtrains/models/advtrains_retrosignal_off_45.b3d delete mode 100644 advtrains/models/advtrains_retrosignal_off_60.b3d delete mode 100644 advtrains/models/advtrains_retrosignal_on.b3d delete mode 100644 advtrains/models/advtrains_retrosignal_on_30.b3d delete mode 100644 advtrains/models/advtrains_retrosignal_on_45.b3d delete mode 100644 advtrains/models/advtrains_retrosignal_on_60.b3d delete mode 100644 advtrains/models/advtrains_signal.b3d delete mode 100644 advtrains/models/advtrains_signal_30.b3d delete mode 100644 advtrains/models/advtrains_signal_45.b3d delete mode 100644 advtrains/models/advtrains_signal_60.b3d delete mode 100644 advtrains/models/advtrains_track_cr.b3d delete mode 100644 advtrains/models/advtrains_track_st.b3d delete mode 100644 advtrains/models/advtrains_track_st_45.b3d delete mode 100644 advtrains/models/blender/engine-with-animation.blend delete mode 100644 advtrains/models/blender/gleis/detectorpart.png delete mode 100644 advtrains/models/blender/gleis/infos/Grafik_weiche.png delete mode 100644 advtrains/models/blender/gleis/infos/breite delete mode 100644 advtrains/models/blender/gleis/licence.txt~ delete mode 100644 advtrains/models/blender/gleis/rail_my.blend delete mode 100644 advtrains/models/blender/gleis/rail_my.blend1 delete mode 100644 advtrains/models/blender/gleis/rail_my_rt.blend delete mode 100644 advtrains/models/blender/gleis/rail_my_rt.blend1 delete mode 100644 advtrains/models/blender/gleis/rail_my_rt_final.blend delete mode 100644 advtrains/models/blender/gleis/rail_my_rt_final.blend1 delete mode 100644 advtrains/models/blender/gleis/rail_my_rt_switches.blend delete mode 100644 advtrains/models/blender/gleis/rail_my_rt_switches.blend1 delete mode 100644 advtrains/models/blender/gleis/rail_my_rt_switches2.blend delete mode 100644 advtrains/models/blender/gleis/rail_my_rt_switches2.blend1 delete mode 100644 advtrains/models/blender/gleis/rail_together.blend delete mode 100644 advtrains/models/blender/gleis/rail_together.png delete mode 100644 advtrains/models/blender/gleis/rail_together2.png delete mode 100644 advtrains/models/blender/gleis/rail_together3.png delete mode 100644 advtrains/models/blender/gleis/rail_verticals.blend delete mode 100644 advtrains/models/blender/gleis/rail_verticals.blend1 delete mode 100644 advtrains/models/blender/gleis/rail_verticals3.blend delete mode 100644 advtrains/models/blender/gleis/rail_verticals3.blend1 delete mode 100644 advtrains/models/blender/gleis/rail_verticals45.blend delete mode 100644 advtrains/models/blender/gleis/rail_verticals45.blend1 delete mode 100644 advtrains/models/blender/gleis/rail_verticals45.blend11 delete mode 100644 advtrains/models/blender/gleis/texturen/rail.png delete mode 100644 advtrains/models/blender/gleis/texturen/uv.png delete mode 100644 advtrains/models/blender/industrial/industry_loc.blend delete mode 100644 advtrains/models/blender/industrial/industry_loc.blend1 delete mode 100644 advtrains/models/blender/industrial/industry_loc.blend11 delete mode 100644 advtrains/models/blender/industrial/industry_oil_ wagong.blend delete mode 100644 advtrains/models/blender/industrial/industry_oil_ wagong.blend1 delete mode 100644 advtrains/models/blender/industrial/industry_tree_wagong.blend delete mode 100644 advtrains/models/blender/industrial/industry_tree_wagong.blend1 delete mode 100644 advtrains/models/blender/industrial/industry_tree_wagong.png delete mode 100644 advtrains/models/blender/locomotive.blend delete mode 100644 advtrains/models/blender/magnet_track.blend delete mode 100644 advtrains/models/blender/mbb/advtrains_wagon_japan.xcf delete mode 100644 advtrains/models/blender/mbb/modern_japanlocomotive.blend delete mode 100644 advtrains/models/blender/mbb/modern_japanlocomotive.blend1 delete mode 100644 advtrains/models/blender/mbb/modern_japanlocomotive.png delete mode 100644 advtrains/models/blender/mbb/modern_japanlocomotive.xcf delete mode 100644 advtrains/models/blender/mbb/modern_locomotive.blend delete mode 100644 advtrains/models/blender/mbb/modern_wagong.blend delete mode 100644 advtrains/models/blender/mbb/modern_wagong.blend1 delete mode 100644 advtrains/models/blender/mbb/modern_wagong_uv.blend delete mode 100644 advtrains/models/blender/mbb/modern_wagong_uv.blend1 delete mode 100644 advtrains/models/blender/mbb/modern_wagong_uv.png delete mode 100644 advtrains/models/blender/mbb/prellbock.blend delete mode 100644 advtrains/models/blender/mbb/prellbock.blend1 delete mode 100644 advtrains/models/blender/mbb/prellbock.uv.png delete mode 100644 advtrains/models/blender/mbb/regio-lokomotive.blend delete mode 100644 advtrains/models/blender/mbb/regio-waron.blend delete mode 100644 advtrains/models/blender/mbb/retrosignal.blend delete mode 100644 advtrains/models/blender/mbb/retrosignal.blend1 delete mode 100644 advtrains/models/blender/mbb/signal(2)_hoch.blend delete mode 100644 advtrains/models/blender/mbb/signal(2)_unten.blend delete mode 100644 advtrains/models/blender/mbb/signal.blend delete mode 100644 advtrains/models/blender/mbb/signal.blend1 delete mode 100644 advtrains/models/blender/mbb/signal.png delete mode 100644 advtrains/models/blender/mbb/signal.xcf delete mode 100644 advtrains/models/blender/mbb/signal2.png delete mode 100644 advtrains/models/blender/mbb/tr-logo.png delete mode 100644 advtrains/models/blender/mbb/weichenhebel1.blend delete mode 100644 advtrains/models/blender/mbb/weichenhebel2.blend delete mode 100644 advtrains/models/blender/newlocomotive.blend delete mode 100644 advtrains/models/blender/newlocomotive.blend1 delete mode 100644 advtrains/models/blender/newlocomotive_uvs.png delete mode 100644 advtrains/models/blender/newwagon.blend delete mode 100644 advtrains/models/blender/newwagon.blend1 delete mode 100644 advtrains/models/blender/newwagon.png delete mode 100644 advtrains/models/blender/subway-train.blend delete mode 100644 advtrains/models/blender/subway-train.blend1 delete mode 100644 advtrains/models/blender/subway-train.png delete mode 100644 advtrains/models/blender/subway-train.xcf delete mode 100644 advtrains/models/blender/trackplane.blend delete mode 100644 advtrains/models/blender/trackvertical1.blend delete mode 100644 advtrains/models/blender/trackvertical1.blend1 delete mode 100644 advtrains/models/blender/trackvertical1.png delete mode 100644 advtrains/models/blender/trackvertical2.blend delete mode 100644 advtrains/models/blender/trackvertical2.png delete mode 100644 advtrains/models/oldmodels/locomotive.b3d delete mode 100644 advtrains/models/oldmodels/trackvertical1.b3d delete mode 100644 advtrains/models/oldmodels/trackvertical2.b3d delete mode 100644 advtrains/models/trackplane.b3d create mode 100644 advtrains/modpack.txt delete mode 100644 advtrains/pseudoload.lua delete mode 100644 advtrains/readme.txt create mode 100644 advtrains/screenshot.png delete mode 100644 advtrains/signals.lua delete mode 100644 advtrains/textures/advtrains_couple.png delete mode 100644 advtrains/textures/advtrains_discouple.png delete mode 100644 advtrains/textures/advtrains_dtrack_atc_placer.png delete mode 100644 advtrains/textures/advtrains_dtrack_bumper_placer.png delete mode 100644 advtrains/textures/advtrains_dtrack_detector_placer.png delete mode 100644 advtrains/textures/advtrains_dtrack_placer.png delete mode 100644 advtrains/textures/advtrains_dtrack_rail.png delete mode 100644 advtrains/textures/advtrains_dtrack_rail_atc.png delete mode 100644 advtrains/textures/advtrains_dtrack_rail_detector_on.png delete mode 100644 advtrains/textures/advtrains_dtrack_slopeplacer.png delete mode 100644 advtrains/textures/advtrains_newlocomotive.xcf delete mode 100644 advtrains/textures/advtrains_platform.png delete mode 100644 advtrains/textures/advtrains_retrosignal.png delete mode 100644 advtrains/textures/advtrains_retrosignal_inv.png delete mode 100644 advtrains/textures/advtrains_signal_inv.png delete mode 100644 advtrains/textures/advtrains_signal_off.png delete mode 100644 advtrains/textures/advtrains_signal_on.png delete mode 100644 advtrains/textures/advtrains_track_cr.png delete mode 100644 advtrains/textures/advtrains_track_cr_45.png delete mode 100644 advtrains/textures/advtrains_track_placer.png delete mode 100644 advtrains/textures/advtrains_track_st.png delete mode 100644 advtrains/textures/advtrains_track_st_45.png delete mode 100644 advtrains/textures/advtrains_track_swlcr.png delete mode 100644 advtrains/textures/advtrains_track_swlcr_45.png delete mode 100644 advtrains/textures/advtrains_track_swlst.png delete mode 100644 advtrains/textures/advtrains_track_swlst_45.png delete mode 100644 advtrains/textures/advtrains_track_swrcr.png delete mode 100644 advtrains/textures/advtrains_track_swrcr_45.png delete mode 100644 advtrains/textures/advtrains_track_swrst.png delete mode 100644 advtrains/textures/advtrains_track_swrst_45.png delete mode 100644 advtrains/textures/advtrains_trackworker.png delete mode 100644 advtrains/textures/drwho_screwdriver.png delete mode 100644 advtrains/textures/larger rails.xcf delete mode 100644 advtrains/trackplacer.lua delete mode 100644 advtrains/tracks.lua delete mode 100644 advtrains/trainhud.lua delete mode 100644 advtrains/trainlogic.lua delete mode 100644 advtrains/wagons.lua delete mode 100644 advtrains_train_industrial/depends.txt delete mode 100644 advtrains_train_industrial/init.lua delete mode 100644 advtrains_train_industrial/models/advtrains_engine_industrial.b3d delete mode 100644 advtrains_train_industrial/models/advtrains_wagon_tank.b3d delete mode 100644 advtrains_train_industrial/models/advtrains_wagon_wood.b3d delete mode 100644 advtrains_train_industrial/textures/advtrains_engine_industrial.png delete mode 100644 advtrains_train_industrial/textures/advtrains_engine_industrial_inv.png delete mode 100644 advtrains_train_industrial/textures/advtrains_wagon_tank.png delete mode 100644 advtrains_train_industrial/textures/advtrains_wagon_tank_inv.png delete mode 100644 advtrains_train_industrial/textures/advtrains_wagon_wood.png delete mode 100644 advtrains_train_industrial/textures/advtrains_wagon_wood_inv.png delete mode 100644 advtrains_train_japan/depends.txt delete mode 100644 advtrains_train_japan/init.lua delete mode 100644 advtrains_train_japan/models/advtrains_engine_japan.b3d delete mode 100644 advtrains_train_japan/models/advtrains_wagon_japan.b3d delete mode 100644 advtrains_train_japan/textures/advtrains_engine_japan.png delete mode 100644 advtrains_train_japan/textures/advtrains_engine_japan_inv.png delete mode 100644 advtrains_train_japan/textures/advtrains_wagon_japan.png delete mode 100644 advtrains_train_japan/textures/advtrains_wagon_japan_inv.png delete mode 100644 advtrains_train_steam/depends.txt delete mode 100644 advtrains_train_steam/init.lua delete mode 100644 advtrains_train_steam/models/advtrains_engine_steam.b3d delete mode 100644 advtrains_train_steam/models/advtrains_wagon.b3d delete mode 100644 advtrains_train_steam/textures/advtrains_newlocomotive.png delete mode 100644 advtrains_train_steam/textures/advtrains_newlocomotive_inv.png delete mode 100644 advtrains_train_steam/textures/advtrains_wagon.png delete mode 100644 advtrains_train_steam/textures/advtrains_wagon_box.png delete mode 100644 advtrains_train_steam/textures/advtrains_wagon_box_inv.png delete mode 100644 advtrains_train_steam/textures/advtrains_wagon_inv.png delete mode 100644 advtrains_train_subway/depends.txt delete mode 100644 advtrains_train_subway/init.lua delete mode 100644 advtrains_train_subway/models/advtrains_subway_train.b3d delete mode 100644 advtrains_train_subway/textures/advtrains_subway_train.png delete mode 100644 advtrains_train_subway/textures/advtrains_subway_train_inv.png create mode 100644 assets/advtrains_newlocomotive.xcf create mode 100644 assets/blender/engine-with-animation.blend create mode 100644 assets/blender/gleis/detectorpart.png create mode 100644 assets/blender/gleis/infos/Grafik_weiche.png create mode 100644 assets/blender/gleis/infos/breite create mode 100644 assets/blender/gleis/licence.txt~ create mode 100644 assets/blender/gleis/rail_my.blend create mode 100644 assets/blender/gleis/rail_my.blend1 create mode 100644 assets/blender/gleis/rail_my_rt.blend create mode 100644 assets/blender/gleis/rail_my_rt.blend1 create mode 100644 assets/blender/gleis/rail_my_rt_final.blend create mode 100644 assets/blender/gleis/rail_my_rt_final.blend1 create mode 100644 assets/blender/gleis/rail_my_rt_switches.blend create mode 100644 assets/blender/gleis/rail_my_rt_switches.blend1 create mode 100644 assets/blender/gleis/rail_my_rt_switches2.blend create mode 100644 assets/blender/gleis/rail_my_rt_switches2.blend1 create mode 100644 assets/blender/gleis/rail_together.blend create mode 100644 assets/blender/gleis/rail_together.png create mode 100644 assets/blender/gleis/rail_together2.png create mode 100644 assets/blender/gleis/rail_together3.png create mode 100644 assets/blender/gleis/rail_verticals.blend create mode 100644 assets/blender/gleis/rail_verticals.blend1 create mode 100644 assets/blender/gleis/rail_verticals3.blend create mode 100644 assets/blender/gleis/rail_verticals3.blend1 create mode 100644 assets/blender/gleis/rail_verticals45.blend create mode 100644 assets/blender/gleis/rail_verticals45.blend1 create mode 100644 assets/blender/gleis/rail_verticals45.blend11 create mode 100644 assets/blender/gleis/texturen/rail.png create mode 100644 assets/blender/gleis/texturen/uv.png create mode 100644 assets/blender/industrial/industry_loc.blend create mode 100644 assets/blender/industrial/industry_loc.blend1 create mode 100644 assets/blender/industrial/industry_loc.blend11 create mode 100644 assets/blender/industrial/industry_oil_ wagong.blend create mode 100644 assets/blender/industrial/industry_oil_ wagong.blend1 create mode 100644 assets/blender/industrial/industry_tree_wagong.blend create mode 100644 assets/blender/industrial/industry_tree_wagong.blend1 create mode 100644 assets/blender/industrial/industry_tree_wagong.png create mode 100644 assets/blender/locomotive.blend create mode 100644 assets/blender/magnet_track.blend create mode 100644 assets/blender/mbb/advtrains_wagon_japan.xcf create mode 100644 assets/blender/mbb/modern_japanlocomotive.blend create mode 100644 assets/blender/mbb/modern_japanlocomotive.blend1 create mode 100644 assets/blender/mbb/modern_japanlocomotive.png create mode 100644 assets/blender/mbb/modern_japanlocomotive.xcf create mode 100644 assets/blender/mbb/modern_locomotive.blend create mode 100644 assets/blender/mbb/modern_wagong.blend create mode 100644 assets/blender/mbb/modern_wagong.blend1 create mode 100644 assets/blender/mbb/modern_wagong_uv.blend create mode 100644 assets/blender/mbb/modern_wagong_uv.blend1 create mode 100644 assets/blender/mbb/modern_wagong_uv.png create mode 100644 assets/blender/mbb/prellbock.blend create mode 100644 assets/blender/mbb/prellbock.blend1 create mode 100644 assets/blender/mbb/prellbock.uv.png create mode 100644 assets/blender/mbb/regio-lokomotive.blend create mode 100644 assets/blender/mbb/regio-waron.blend create mode 100644 assets/blender/mbb/retrosignal.blend create mode 100644 assets/blender/mbb/retrosignal.blend1 create mode 100644 assets/blender/mbb/signal(2)_hoch.blend create mode 100644 assets/blender/mbb/signal(2)_unten.blend create mode 100644 assets/blender/mbb/signal.blend create mode 100644 assets/blender/mbb/signal.blend1 create mode 100644 assets/blender/mbb/signal.png create mode 100644 assets/blender/mbb/signal.xcf create mode 100644 assets/blender/mbb/signal2.png create mode 100644 assets/blender/mbb/tr-logo.png create mode 100644 assets/blender/mbb/weichenhebel1.blend create mode 100644 assets/blender/mbb/weichenhebel2.blend create mode 100644 assets/blender/newlocomotive.blend create mode 100644 assets/blender/newlocomotive.blend1 create mode 100644 assets/blender/newlocomotive_uvs.png create mode 100644 assets/blender/newwagon.blend create mode 100644 assets/blender/newwagon.blend1 create mode 100644 assets/blender/newwagon.png create mode 100644 assets/blender/subway-train.blend create mode 100644 assets/blender/subway-train.blend1 create mode 100644 assets/blender/subway-train.png create mode 100644 assets/blender/subway-train.xcf create mode 100644 assets/blender/trackplane.blend create mode 100644 assets/blender/trackvertical1.blend create mode 100644 assets/blender/trackvertical1.blend1 create mode 100644 assets/blender/trackvertical1.png create mode 100644 assets/blender/trackvertical2.blend create mode 100644 assets/blender/trackvertical2.png create mode 100644 assets/init.lua create mode 100644 assets/larger rails.xcf create mode 100644 assets/oldmodels/locomotive.b3d create mode 100644 assets/oldmodels/trackvertical1.b3d create mode 100644 assets/oldmodels/trackvertical2.b3d delete mode 100644 license.txt delete mode 100644 license_media.txt delete mode 100644 manual.pdf delete mode 100644 screenshot.png diff --git a/Makefile b/Makefile deleted file mode 100644 index 7300426..0000000 --- a/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -tarball: clean -# tar czf advtrains.tar.gz textures/*.png models/*.b3d *.lua *.txt - which zip && zip advtrains.zip textures/*.png models/*.b3d *.lua *.txt -clean: - rm -f advtrains.zip advtrains.tar.gz diff --git a/advtrains.zip b/advtrains.zip deleted file mode 100644 index a3dab82..0000000 Binary files a/advtrains.zip and /dev/null differ diff --git a/advtrains/Makefile b/advtrains/Makefile new file mode 100644 index 0000000..7300426 --- /dev/null +++ b/advtrains/Makefile @@ -0,0 +1,5 @@ +tarball: clean +# tar czf advtrains.tar.gz textures/*.png models/*.b3d *.lua *.txt + which zip && zip advtrains.zip textures/*.png models/*.b3d *.lua *.txt +clean: + rm -f advtrains.zip advtrains.tar.gz diff --git a/advtrains/advtrains.zip b/advtrains/advtrains.zip new file mode 100644 index 0000000..a3dab82 Binary files /dev/null and b/advtrains/advtrains.zip differ diff --git a/advtrains/advtrains/api_doc.txt b/advtrains/advtrains/api_doc.txt new file mode 100644 index 0000000..6b1aa2e --- /dev/null +++ b/advtrains/advtrains/api_doc.txt @@ -0,0 +1,114 @@ +Advanced Trains [advtrains] API documentation +-------- +To use the API, mods must depend on 'advtrains'. +All boolean values in definition tables default to 'false' and can be omitted. +### Wagons +Wagons are registered using the function + +advtrains.register_wagon(name, prototype, description, inventory_image) +- 'name' is the internal name of the wagon. It is registered inside the 'advtrains:' namespace. + Example: A wagon with name="engine_tgv" will be registered as "advtrains:engine_tgv". +- 'prototype' is the lua entity prototype. The regular definition keys for luaentites apply. Additional required and optional properties see below. DO NOT define 'on_step', 'on_activate', 'on_punch', 'on_rightclick' and 'get_staticdata' since these will be overridden. Use 'custom_*' instead. +- 'description' is the description of the inventory item that is used to place the wagon. +- 'inventory_image' is the inventory image of said item. + +# Wagon prototype properties +{ + ... all regular luaentity properties (mesh, textures, collisionbox a.s.o)... + drives_on = {default=true}, + ^- used to define the tracktypes (see below) that wagon can drive on. The tracktype identifiers are given as keys, similar to privileges) + max_speed = 10, + ^- optional, default 10: defines the maximum speed this wagon can drive. The maximum speed of a train is determined by the wagon with the lowest max_speed value. + seats = { + { + name="Left front window", + ^- display name of this seat + attach_offset={x=0, y=10, z=0}, + ^- this value is passed to 'set_attach' + view_offset={x=0, y=6, z=0}, + ^- player:set_eye_offset is called with this parameter. + driving_ctrl_access=false, + ^- If the seat is a driver stand, and players sitting here should get access to the train's driving control. + + }, + }, + ^- contains zero or more seat definitions. A seat is a place where a player can be attached when getting on a wagon. + wagon_span=2, + ^- How far this wagon extends from its base position. Is the half of the wagon length. + ^- Used to determine in which distance the other wagons have to be positioned. Will require tweaking. + drops = {"default:steelblock 3"} + ^- List of itemstrings what to drop when the wagon is destroyed + + has_inventory = false + ^- If this wagon has an inventory. The inventory is saved with the wagon. + ^- the following settings are ignored if not. + inventory_list_sizes = { + box=8*6, + }, + ^- List of assignments of type list_name=size. + ^- For every entry, an inventory list is created with the specified size. + get_inventory_formspec = function(self, player_name) + return "" + end, + ^- Function that should return the formspec to be displayed when requests to open the wagon's inventory + ^- Use "list[detached:advtrains_wgn_"..self.unique_id..";;,;,;]" to display a wagon's inventory list. + + custom_on_step = function(self, dtime) end + ^- optional: Execute custom code on every step + custom_on_activate = function(self, dtime_s) end + ^- optional: Execute custom code on activate. Staticdata does not need to be saved and restored since all properties written in 'self' are preserved over unloads. + update_animation = function(self, velocity) end + ^- optional: Function that is called whenever the train's velocity changes or every 2 seconds. Used to call 'self.object:update_animation()' if needed. + +} + +# Notes on wagons + +- Every wagon has the field 'unique_id' which assigns each wagon a random id. +- All properties written in the lua entity (self) are saved and restored automatically. Minetest's internal staticdata is only used to save the unique_id of the wagon, which serves as a key in an externally saved table. +- Assuming Z Axis as the axis parallel to the tracks and Y Axis as the one pointing into the sky, wagon models should be dimensioned in a way that: + - their origin is centered in X and Z direction + - their origin lies 0.5 units above the bottom of the model + - the overall extent in X and Y direction is <=3 units +- wagon_span is then the distance between the model origin and the Z axis extent. + +### Tracks +Most modders will be satisfied with the built-in tracks. If cog railways, maglev trains and mine trains are added, it is necessary to understand the definition of tracks. Although the tracks API is there, explaining it would require more effort than me creating the wanted definitions myself. Contact me if you need to register your own rails using my registration functions. + +However, it is still possible to register single rails by understanding the node properties of rails. +minetest.register_node(nodename, { + ... usual node definition ... + groups = { + advtrains_track_=1 + ^- this group tells that the node is a track + not_blocking_trains=1, + ^- this group tells that the node should not block trains although it's walkable. + }, + connect1 = 0, + connect2 = 8, + ^- These values tell the direction (horizontal) the rail ends are pointing to. 0 means +Z, then rotation values increase clockwise. For a translation of directions to positions see helpers.lua. + rely1=0, + rely2=0, + ^- the Y height of the rail end 1/2. A value of >=1 means that the rail end points to the next y layer at rely-1 + railheight=0, + ^- the height value of this rail that is saved in the path. usually the median of rely1 and rely2. + + can_dig=function(pos) + return not advtrains.is_train_at_pos(pos) + end, + after_dig_node=function(pos) + advtrains.invalidate_all_paths() + advtrains.reset_trackdb_position(pos) + end, + after_place_node=function(pos) + advtrains.reset_trackdb_position(pos) + end, + ^- the code in these 3 default minetest API functions is required for advtrains to work, however you can add your own code + + advtrains = { + on_train_enter=function(pos, train_id) end + ^- called when a train enters the rail + on_train_leave=function(pos, train_id) end + ^- called when a train leaves the rail + } +}) \ No newline at end of file diff --git a/advtrains/advtrains/atc.lua b/advtrains/advtrains/atc.lua new file mode 100644 index 0000000..f070b20 --- /dev/null +++ b/advtrains/advtrains/atc.lua @@ -0,0 +1,294 @@ +--atc.lua +--registers and controls the ATC system + +local atc={} +-- ATC persistence table +atc.controllers = {} +--contents: {command="...", arrowconn=0-15 where arrow points} + +advtrains.fpath_atc=minetest.get_worldpath().."/advtrains_atc" +local file, err = io.open(advtrains.fpath_atc, "r") +if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed loading advtrains atc save file "..er) +else + local tbl = minetest.deserialize(file:read("*a")) + if type(tbl) == "table" then + atc.controllers=tbl.controllers + end + file:close() +end +function atc.save() + --leave space for more save data. + local datastr = minetest.serialize({controllers = atc.controllers}) + if not datastr then + minetest.log("error", "[advtrains] Failed to serialize trackdb data!") + return + end + local file, err = io.open(advtrains.fpath_atc, "w") + if err then + return err + end + file:write(datastr) + file:close() +end + +--call from advtrains.detector subprogram + +function atc.trigger_controller_train_enter(pos, train_id) + atc.send_command(pos) +end + +--general + +function atc.send_command(pos) + local pts=minetest.pos_to_string(pos) + if atc.controllers[pts] then + print("Called send_command at "..pts) + local train_id = advtrains.detector.on_node[pts] + if train_id then + if advtrains.trains[train_id] then + print("send_command inside if: "..sid(train_id)) + atc.train_reset_command(train_id) + local arrowconn=atc.controllers[pts].arrowconn + local train=advtrains.trains[train_id] + for index, ppos in pairs(train.path) do + if vector.equals(advtrains.round_vector_floor_y(ppos), pos) then + advtrains.trains[train_id].atc_arrow = + vector.equals( + advtrains.dirCoordSet(pos, arrowconn), + advtrains.round_vector_floor_y(train.path[index+train.movedir]) + ) + advtrains.trains[train_id].atc_command=atc.controllers[pts].command + print("Sending ATC Command: "..atc.controllers[pts].command) + end + end + end + end + end + return false +end + +function atc.train_reset_command(train_id) + advtrains.trains[train_id].atc_command=nil + advtrains.trains[train_id].atc_delay=0 + advtrains.trains[train_id].atc_brake_target=nil + advtrains.trains[train_id].atc_wait_finish=nil + advtrains.trains[train_id].atc_arrow=nil +end + +--nodes +local idxtrans={static=1, mesecon=2, digiline=3} +local apn_func=function(pos) + advtrains.reset_trackdb_position(pos) + local meta=minetest.get_meta(pos) + if meta then + meta:set_string("infotext", "ATC controller, unconfigured.") + meta:set_string("formspec", atc.get_atc_controller_formspec(pos, meta)) + end +end + +advtrains.register_tracks("default", { + nodename_prefix="advtrains:dtrack_atc", + texture_prefix="advtrains_dtrack_atc", + models_prefix="advtrains_dtrack_detector", + models_suffix=".b3d", + shared_texture="advtrains_dtrack_rail_atc.png", + description="ATC controller", + formats={}, + get_additional_definiton = function(def, preset, suffix, rotation) + return { + after_place_node=apn_func, + on_place_rail=apn_func, + after_dig_node=function(pos) + advtrains.invalidate_all_paths() + advtrains.reset_trackdb_position(pos) + local pts=minetest.pos_to_string(pos) + atc.controllers[pts]=nil + end, + on_receive_fields = function(pos, formname, fields, player) + if minetest.is_protected(pos, player:get_player_name()) then + minetest.chat_send_player(player:get_player_name(), "This position is protected!") + return + end + local meta=minetest.get_meta(pos) + if meta then + if not fields.save then + --maybe only the dropdown changed + if fields.mode then + meta:set_string("mode", idxtrans[fields.mode]) + meta:set_string("infotext", "ATC controller, mode "..fields.mode.."\n"..( fields.mode=="digiline" and "Channel: "..meta:get_string("channel") or "Command: "..meta:get_string("command") ) ) + meta:set_string("formspec", atc.get_atc_controller_formspec(pos, meta)) + end + return + end + meta:set_string("mode", idxtrans[fields.mode]) + meta:set_string("command", fields.command) + meta:set_string("command_on", fields.command_on) + meta:set_string("channel", fields.channel) + meta:set_string("infotext", "ATC controller, mode "..fields.mode.."\n"..( fields.mode=="digiline" and "Channel: "..meta:get_string("channel") or "Command: "..meta:get_string("command") ) ) + meta:set_string("formspec", atc.get_atc_controller_formspec(pos, meta)) + + local pts=minetest.pos_to_string(pos) + local _, conn1=advtrains.get_rail_info_at(pos, advtrains.all_tracktypes) + atc.controllers[pts]={command=fields.command, arrowconn=conn1} + atc.send_command(pos) + end + end, + } + end +}, advtrains.trackpresets.t_30deg_straightonly) + + +function atc.get_atc_controller_formspec(pos, meta) + local mode=tonumber(meta:get_string("mode")) or 1 + local command=meta:get_string("command") + local command_on=meta:get_string("command_on") + local channel=meta:get_string("channel") + local formspec="size[8,6]".. + "dropdown[0,0;3;mode;static,mesecon,digiline;"..mode.."]" + if mode<3 then + formspec=formspec.."field[0.5,1.5;7,1;command;Command;"..minetest.formspec_escape(command).."]" + if tonumber(mode)==2 then + formspec=formspec.."field[0.5,3;7,1;command_on;Command (on);"..minetest.formspec_escape(command_on).."]" + end + else + formspec=formspec.."field[0.5,1.5;7,1;channel;Digiline channel;"..minetest.formspec_escape(channel).."]" + end + return formspec.."button_exit[0.5,4.5;7,1;save;Save]" +end + +--from trainlogic.lua train step +local matchptn={ + ["SM"]=function(id, train) + train.tarvelocity=train.max_speed + return 2 + end, + ["S([0-9]+)"]=function(id, train, match) + train.tarvelocity=tonumber(match) + return #match+1 + end, + ["B([0-9]+)"]=function(id, train, match) + if train.velocity>tonumber(match) then + train.atc_brake_target=tonumber(match) + if train.tarvelocity>train.atc_brake_target then + train.tarvelocity=train.atc_brake_target + end + end + return #match+1 + end, + ["W"]=function(id, train) + train.atc_wait_finish=true + return 1 + end, + ["D([0-9]+)"]=function(id, train, match) + train.atc_delay=tonumber(match) + return #match+1 + end, + ["R"]=function(id, train) + if train.velocity<=0 then + train.movedir=train.movedir*-1 + train.atc_arrow = not train.atc_arrow + else + print("ATC Reverse command warning: didn't reverse train!") + end + return 1 + end, +} + +function atc.execute_atc_command(id, train) + --strip whitespaces + local command=string.match(train.atc_command, "^%s*(.*)$") + + + if string.match(command, "^%s*$") then + train.atc_command=nil + return + end + --conditional statement? + local is_cond, cond_applies + local cond, rest=string.match(command, "^I([%+%-])(.+)$") + if cond then + is_cond=true + if cond=="+" then + cond_applies=train.atc_arrow + end + if cond=="-" then + cond_applies=not train.atc_arrow + end + else + cond, compare, rest=string.match(command, "^I([<>]=?)([0-9]+)(.+)$") + if cond and compare then + is_cond=true + if cond=="<" then + cond_applies=train.velocity" then + cond_applies=train.velocity>tonumber(compare) + end + if cond=="<=" then + cond_applies=train.velocity<=tonumber(compare) + end + if cond==">=" then + cond_applies=train.velocity>=tonumber(compare) + end + end + end + if is_cond then + print("Evaluating if statement: "..command) + print("Cond: "..(cond or "nil")) + print("Applies: "..(cond_applies and "true" or "false")) + print("Rest: "..rest) + --find end of conditional statement + local nest, pos, elsepos=0, 1 + while nest>=0 do + if pos>#rest then + print("ATC command syntax error: I statement not closed: "..command) + atc.train_reset_command(id) + return + end + local char=string.sub(rest, pos, pos) + if char=="I" then + nest=nest+1 + end + if char==";" then + nest=nest-1 + end + if nest==0 and char=="E" then + elsepos=pos+0 + end + pos=pos+1 + end + if not elsepos then elsepos=pos-1 end + if cond_applies then + command=string.sub(rest, 1, elsepos-1)..string.sub(rest, pos) + else + command=string.sub(rest, elsepos+1, pos-2)..string.sub(rest, pos) + end + print("Result: "..command) + train.atc_command=command + atc.execute_atc_command(id, train) + return + else + for pattern, func in pairs(matchptn) do + local match=string.match(command, "^"..pattern) + if match then + local patlen=func(id, train, match) + + print("Executing: "..string.sub(command, 1, patlen)) + + train.atc_command=string.sub(command, patlen+1) + if train.atc_delay<=0 and not train.atc_wait_finish then + --continue (recursive, cmds shouldn't get too long, and it's a end-recursion.) + atc.execute_atc_command(id, train) + end + return + end + end + end + print("ATC command parse error: "..command) + atc.train_reset_command(id) +end + +--move table to desired place +advtrains.atc=atc diff --git a/advtrains/advtrains/atc_command.txt b/advtrains/advtrains/atc_command.txt new file mode 100644 index 0000000..fa846e3 --- /dev/null +++ b/advtrains/advtrains/atc_command.txt @@ -0,0 +1,68 @@ +ATC Command Syntax + +A train runs the current ATC command once it receives it, including delayed instructions. If the train receives a new command, the current command is discarded. +Spaces can be inserted into commands as needed and are ignored. + +# simple commands: + +S<[0-9]+ speed or 'M'> +Set target speed of train to . Accelerates if slower, rolls if faster. 'M' means maximum speed. +Execution of command continues immediately. + +B<[0-9]+ speed> +Brake until speed is reached. If faster, apply brakes, if slower, do nothing. +Execution of command continues immediately. + +Examples: +SM : accelerate to maximum speed +S0 : roll to stand +B0 : brake to stand +S0B3 or B3S0: brake to 3, then roll to stand. + +W +Wait until S and/or B commands reached the desired speed before continuing execution. + +D<[0-9]+ time> +Delay: Wait for time seconds before continuing execution. + +R +Reverse: change movement direction of train. ONLY WORKS WHEN TRAIN STANDS, else no-op. +Use B0WR to definitely change direction. + +Examples: +B0 W R D10 SM +Subway train stopping in dead end station and returning in opposite direction + +# conditional statements: + +I; +Execute code only if condition applies +IE; +Execute code1 only if condition applies, else execute code2 + +Conditions: ++ / - +Tests the train's movement direction against the arrow on the ATC rail: M+ is true when train drives in direction of arrow. + +[/<=/>=][speed] +Test if train's speed is greater or smaller than the given value + +Examples: +I- B0 W R ; S8 +If the train drives in the 'wrong' direction, stop and reverse; independently accelerate to speed 8 afterwards. + +I<8 S8 ; +If the train is slower than 8, accelerate to 8. + +# ATC controller operation modes +static: Only give 1 static command. +mesecon: Give 2 different commands depending on if the controller is mesecon-powered or not +digiline: Don't give any commands by itself. When a train passes, a digiline message in the form of "[+/-][speed]" is sent on the set channel (where +/- means the same as with conditions). Any digiline message sent to the controller will be interpreted as ATC command and sent to the train. + +# Persistence +ATC controllers that are configured as 'static' or 'mesecon' are persistent over mapblock unloads and will even command the train when the mapblock is unloaded. This is not possible with digilines since these do not work in unloaded mapchunks. + +# LUA ATC controller (in development) +The LUA ATC Controller will operate by using LUA code. All operations shown above will have a function equivalent. Additionally all LUA ATC controllers share an environment and setting signal and switch status will be possible to allow for complicated railway systems/fully automated subways a.s.o. +Also planned: +- digicompute add-on to allow computer access to the ATC environment (railway maps... ... ... ... ...) diff --git a/advtrains/advtrains/couple.lua b/advtrains/advtrains/couple.lua new file mode 100644 index 0000000..974f450 --- /dev/null +++ b/advtrains/advtrains/couple.lua @@ -0,0 +1,156 @@ +--couple.lua +--defines couple entities. + +--advtrains:discouple +--set into existing trains to split them when punched. +--they are attached to the wagons. +--[[fields +wagon + +wagons keep their couple entity minetest-internal id inside the field discouple_id. if it refers to nowhere, they will spawn a new one if player is near +]] + + +minetest.register_entity("advtrains:discouple", { + visual="sprite", + textures = {"advtrains_discouple.png"}, + collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, + visual_size = {x=1, y=1}, + initial_sprite_basepos = {x=0, y=0}, + + is_discouple=true, + on_activate=function(self, staticdata) + if staticdata=="DISCOUPLE" then + --couple entities have no right to exist further... + self.object:remove() + return + end + self.object:set_armor_groups({immortal=1}) + end, + get_staticdata=function() return "DISCOUPLE" end, + on_punch=function(self, player) + --only if player owns at least one wagon next to this + local own=player:get_player_name() + if self.wagon.owner and self.wagon.owner==own then + local train=advtrains.trains[self.wagon.train_id] + local nextwgn_id=train.trainparts[self.wagon.pos_in_trainparts-1] + for aoi, le in pairs(minetest.luaentities) do + if le and le.is_wagon then + if le.unique_id==nextwgn_id then + if le.owner and le.owner~=own then + minetest.chat_send_player(own, "You need to own at least one neighboring wagon to destroy this couple.") + return + end + end + end + end + advtrains.split_train_at_wagon(self.wagon)--found in trainlogic.lua + self.object:remove() + else + minetest.chat_send_player(own, "You need to own at least one neighboring wagon to destroy this couple.") + end + end, + on_step=function(self, dtime) + local t=os.clock() + if not self.wagon then + self.object:remove() + return + end + --getyaw seems to be a reliable method to check if an object is loaded...if it returns nil, it is not. + if not self.wagon.object:getyaw() then + self.object:remove() + return + end + local velocityvec=self.wagon.object:getvelocity() + self.updatepct_timer=(self.updatepct_timer or 0)-dtime + if not self.old_velocity_vector or not vector.equals(velocityvec, self.old_velocity_vector) or self.updatepct_timer<=0 then--only send update packet if something changed + local flipsign=self.wagon.wagon_flipped and -1 or 1 + self.object:setpos(vector.add(self.wagon.object:getpos(), {y=0, x=-math.sin(self.wagon.object:getyaw())*self.wagon.wagon_span*flipsign, z=math.cos(self.wagon.object:getyaw())*self.wagon.wagon_span*flipsign})) + self.object:setvelocity(velocityvec) + self.updatepct_timer=2 + end + printbm("discouple_step", t) + end, +}) + +--advtrains:couple +--when two trains overlap with their end-positions, this entity will be spawned and both trains set its id into appropiate fields for them to know when to free them again. The entity will destroy automatically when it recognizes that any of the trains left the common position. +--[[fields +train_id_1 +train_id_2 +train1_is_backpos +train2_is_backpos +]] + + +minetest.register_entity("advtrains:couple", { + visual="sprite", + textures = {"advtrains_couple.png"}, + collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, + visual_size = {x=1, y=1}, + initial_sprite_basepos = {x=0, y=0}, + + is_couple=true, + on_activate=function(self, staticdata) + if staticdata=="COUPLE" then + --couple entities have no right to exist further... + self.object:remove() + return + end + end, + get_staticdata=function(self) return "COUPLE" end, + on_rightclick=function(self) + if not self.train_id_1 or not self.train_id_2 then return end + + local id1, id2=self.train_id_1, self.train_id_2 + + if self.train1_is_backpos and not self.train2_is_backpos then + advtrains.do_connect_trains(id1, id2) + --case 2 (second train is front) + elseif self.train2_is_backpos and not self.train1_is_backpos then + advtrains.do_connect_trains(id2, id1) + --case 3 + elseif self.train1_is_backpos and self.train2_is_backpos then + advtrains.invert_train(id2) + advtrains.do_connect_trains(id1, id2) + --case 4 + elseif not self.train1_is_backpos and not self.train2_is_backpos then + advtrains.invert_train(id1) + advtrains.do_connect_trains(id1, id2) + end + self.object:remove() + end, + on_step=function(self, dtime) + local t=os.clock() + if not self.train_id_1 or not self.train_id_2 then print("wtf no train ids?")return end + local train1=advtrains.trains[self.train_id_1] + local train2=advtrains.trains[self.train_id_2] + if not train1 or not train2 or not train1.path or not train2.path or not train1.index or not train2.index then + self.object:remove() + return + end + + local tp1 + if not self.train1_is_backpos then + tp1=advtrains.get_real_index_position(train1.path, train1.index) + else + tp1=advtrains.get_real_index_position(train1.path, advtrains.get_train_end_index(train1)) + end + local tp2 + if not self.train2_is_backpos then + tp2=advtrains.get_real_index_position(train2.path, train2.index) + else + tp2=advtrains.get_real_index_position(train2.path, advtrains.get_train_end_index(train2)) + end + if not tp1 or not tp2 or not (vector.distance(tp1,tp2)<1.5) then + self.object:remove() + return + else + local pos_median=advtrains.pos_median(tp1, tp2) + if not vector.equals(pos_median, self.object:getpos()) then + self.object:setpos(pos_median) + end + end + printbm("couple step", t) + end, +}) diff --git a/advtrains/advtrains/crafting.lua b/advtrains/advtrains/crafting.lua new file mode 100644 index 0000000..5ba12ce --- /dev/null +++ b/advtrains/advtrains/crafting.lua @@ -0,0 +1,71 @@ +--advtrains by orwell96, see readme.txt and license.txt +--crafting.lua +--registers crafting recipes + +--tracks +minetest.register_craft({ + output = 'advtrains:dtrack_placer 50', + recipe = { + {'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, + {'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, + {'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, + }, +}) +minetest.register_craft({ + type = "shapeless", + output = 'advtrains:dtrack_slopeplacer 2', + recipe = { + "advtrains:dtrack_placer", + "advtrains:dtrack_placer", + "default:gravel", + }, +}) + +minetest.register_craft({ + output = 'advtrains:dtrack_bumper_placer 2', + recipe = { + {'default:wood', 'dye:red'}, + {'default:steel_ingot', 'default:steel_ingot'}, + {'advtrains:dtrack_placer', 'advtrains:dtrack_placer'}, + }, +}) +minetest.register_craft({ + type="shapeless", + output = 'advtrains:dtrack_detector_off_placer', + recipe = { + "advtrains:dtrack_placer", + "mesecons:wire_00000000_off" + }, +}) +--signals +minetest.register_craft({ + output = 'advtrains:retrosignal_off 2', + recipe = { + {'dye:red', 'default:steel_ingot', 'default:steel_ingot'}, + {'', '', 'default:steel_ingot'}, + {'', '', 'default:steel_ingot'}, + }, +}) +minetest.register_craft({ + output = 'advtrains:signal_off 2', + recipe = { + {'', 'dye:red', 'default:steel_ingot'}, + {'', 'dye:dark_green', 'default:steel_ingot'}, + {'', '', 'default:steel_ingot'}, + }, +}) + +--trackworker +minetest.register_craft({ + output = 'advtrains:trackworker', + recipe = { + {'default:diamond'}, + {'screwdriver:screwdriver'}, + {'default:steel_ingot'}, + }, +}) + + + +--misc_nodes +--crafts for platforms see misc_nodes.lua diff --git a/advtrains/advtrains/damage.lua b/advtrains/advtrains/damage.lua new file mode 100644 index 0000000..b39fe67 --- /dev/null +++ b/advtrains/advtrains/damage.lua @@ -0,0 +1,26 @@ +--damage.lua +--a globalstep that damages players overrolled by trains. + +advtrains.player_to_train_mapping={} + +local tmr=0 +minetest.register_globalstep(function(dtime) + tmr=tmr-dtime + if tmr<=0 then + + for _, player in pairs(minetest.get_connected_players()) do + local pos=player:getpos() + for _, object in pairs(minetest.get_objects_inside_radius(pos, 1)) do + local le=object:get_luaentity() + if le and le.is_wagon and le.initialized and le:train() then + if (not advtrains.player_to_train_mapping[player:get_player_name()] or le.train_id~=advtrains.player_to_train_mapping[player:get_player_name()]) and math.abs(le:train().velocity)>2 then + --player:punch(object, 1000, {damage={fleshy=3*math.abs(le:train().velocity)}}) + player:set_hp(player:get_hp()-math.abs(le:train().velocity)-3) + end + end + end + end + + tmr=0.5 + end +end) diff --git a/advtrains/advtrains/debugitems.lua b/advtrains/advtrains/debugitems.lua new file mode 100644 index 0000000..b3164ff --- /dev/null +++ b/advtrains/advtrains/debugitems.lua @@ -0,0 +1,36 @@ +minetest.register_tool("advtrains:tunnelborer", +{ + description = "tunnelborer", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "drwho_screwdriver.png", + wield_image = "drwho_screwdriver.png", + stack_max = 1, + range = 7.0, + + on_place = function(itemstack, placer, pointed_thing) + + end, + --[[ + ^ Shall place item and return the leftover itemstack + ^ default: minetest.item_place ]] + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type=="node" then + for x=-1,1 do + for y=-1,1 do + for z=-1,1 do + minetest.remove_node(vector.add(pointed_thing.under, {x=x, y=y, z=z})) + end + end + end + end + end, +--[[ +^ default: nil +^ Function must return either nil if no item shall be removed from +inventory, or an itemstack to replace the original itemstack. +e.g. itemstack:take_item(); return itemstack +^ Otherwise, the function is free to do what it wants. +^ The default functions handle regular use cases. +]] +} +) diff --git a/advtrains/advtrains/depends.txt b/advtrains/advtrains/depends.txt new file mode 100644 index 0000000..20aa884 --- /dev/null +++ b/advtrains/advtrains/depends.txt @@ -0,0 +1,2 @@ +default +mesecons? \ No newline at end of file diff --git a/advtrains/advtrains/description.txt b/advtrains/advtrains/description.txt new file mode 100644 index 0000000..ecc5d58 --- /dev/null +++ b/advtrains/advtrains/description.txt @@ -0,0 +1,8 @@ +Advanced Trains v1.3.0, by orwell and contributors. Also see readme. +Good-looking, realistic trains for minetest. + +For crafting recipes, see manual.pdf + +Website: http://advtrains.bleipb.de/ +Manual: https://github.com/orwell96/advtrains/blob/master/manual.pdf +Forum : https://forum.minetest.net/viewtopic.php?f=11&t=14726 \ No newline at end of file diff --git a/advtrains/advtrains/helpers.lua b/advtrains/advtrains/helpers.lua new file mode 100644 index 0000000..1a02621 --- /dev/null +++ b/advtrains/advtrains/helpers.lua @@ -0,0 +1,248 @@ +--advtrains by orwell96, see readme.txt +local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end + +advtrains.dir_trans_tbl={ + [0]={x=0, z=1}, + [1]={x=1, z=2}, + [2]={x=1, z=1}, + [3]={x=2, z=1}, + [4]={x=1, z=0}, + [5]={x=2, z=-1}, + [6]={x=1, z=-1}, + [7]={x=1, z=-2}, + [8]={x=0, z=-1}, + [9]={x=-1, z=-2}, + [10]={x=-1, z=-1}, + [11]={x=-2, z=-1}, + [12]={x=-1, z=0}, + [13]={x=-2, z=1}, + [14]={x=-1, z=1}, + [15]={x=-1, z=2}, +} + +function advtrains.dirCoordSet(coord, dir) + local x,z + if advtrains.dir_trans_tbl[dir] then + x,z=advtrains.dir_trans_tbl[dir].x, advtrains.dir_trans_tbl[dir].z + else + error("advtrains: in helpers.lua/dirCoordSet() given dir="..(dir or "nil")) + end + return {x=coord.x+x, y=coord.y, z=coord.z+z} +end +function advtrains.dirToCoord(dir) + return advtrains.dirCoordSet({x=0, y=0, z=0}, dir) +end + +function advtrains.maxN(list, expectstart) + local n=expectstart or 0 + while list[n] do + n=n+1 + end + return n-1 +end + +function advtrains.minN(list, expectstart) + local n=expectstart or 0 + while list[n] do + n=n-1 + end + return n+1 +end + +--vertical_transmit: +--[[ +rely1, rely2 tell to which height the connections are pointed to. 1 means it will go up the next node + +]] + +function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return + local mid=advtrains.round_vector_floor_y(midreal) + + if not advtrains.get_rail_info_at(advtrains.round_vector_floor_y(prev), drives_on) then + return nil + end + + local midnode_ok, middir1, middir2, midrely1, midrely2=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(mid), drives_on) + if not midnode_ok then + return nil + end + + local next, chkdir, chkrely, y_offset + y_offset=0 + --print("[advtrains] in order mid1,mid2",middir1,middir2) + --try if it is dir1 + local cor1=advtrains.dirCoordSet(mid, middir2)--<<<< + if math.floor(cor1.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor1.z+0.5)==math.floor(prev.z+0.5) then--this was previous + next=advtrains.dirCoordSet(mid, middir1) + if midrely1>=1 then + next.y=next.y+1 + --print("[advtrains]found midrely1 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) + y_offset=1 + end + chkdir=middir1 + chkrely=midrely1 + --print("[advtrains]dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") + end + --dir2??? + local cor2=advtrains.dirCoordSet(mid, middir1)--<<<< + if math.floor(cor2.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor2.z+0.5)==math.floor(prev.z+0.5) then + next=advtrains.dirCoordSet(mid, middir2)--dir2 wird überprüft, alles gut. + if midrely2>=1 then + next.y=next.y+1 + --print("[advtrains]found midrely2 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) + y_offset=1 + end + chkdir=middir2 + chkrely=midrely2 + --print("[advtrains] dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") + end + --print("[advtrains]dir applied next pos: "..(next and minetest.pos_to_string(next) or "nil").."(chkdir is "..(chkdir or "nil")..", y-offset "..y_offset..")") + --is there a next + if not next then + --print("[advtrains]in conway: no next rail(nil), returning!") + return nil + end + + local nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) + + --is it a rail? + if(not nextnode_ok) then + --print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not a rail, trying one node below!") + next.y=next.y-1 + y_offset=y_offset-1 + + nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) + if(not nextnode_ok) then + --print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!") + return nil + end + end + + --is this next rail connecting to the mid? + if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely-y_offset) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely-y_offset) ) then + --print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not connecting, trying one node below!") + next.y=next.y-1 + y_offset=y_offset-1 + + nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) + if(not nextnode_ok) then + --print("[advtrains]in conway: (at connecting if check again) one below "..minetest.pos_to_string(next).." is not a rail either, returning!") + return nil + end + if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely) ) then + --print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." rail not connecting, returning!") + --print("[advtrains] in order mid1,2,next1,2,chkdir "..middir1.." "..middir2.." "..nextdir1.." "..nextdir2.." "..chkdir) + return nil + end + end + + --print("[advtrains]conway found rail.") + return vector.add(advtrains.round_vector_floor_y(next), {x=0, y=nextrailheight, z=0}), chkdir +end +--TODO use this +function advtrains.oppd(dir) + return ((dir+8)%16) +end + +function advtrains.round_vector_floor_y(vec) + return {x=math.floor(vec.x+0.5), y=math.floor(vec.y), z=math.floor(vec.z+0.5)} +end + +function advtrains.yawToDirection(yaw, conn1, conn2) + if not conn1 or not conn2 then + error("given nil to yawToDirection: conn1="..(conn1 or "nil").." conn2="..(conn1 or "nil")) + end + local yaw1=math.pi*(conn1/4) + local yaw2=math.pi*(conn2/4) + if advtrains.minAngleDiffRad(yaw, yaw1) if weird behavior + return conn2 + else + return conn1 + end +end + +function advtrains.minAngleDiffRad(r1, r2) + local try1=r2-r1 + local try2=(r2+2*math.pi)-r1 + local try3=r2-(r1+2*math.pi) + if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try1) then + return try1 + end + if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try2) then + return try2 + end + if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try3) then + return try3 + end +end +function advtrains.dumppath(path) + if not path then print("dumppath: no path(nil)") return end + local min=advtrains.minN(path) + local max=advtrains.maxN(path) + for i=min, max do print("["..i.."] "..(path[i] and minetest.pos_to_string(path[i]) or "nil")) end +end + +function advtrains.merge_tables(a, ...) + local new={} + for _,t in ipairs({a,...}) do + for k,v in pairs(t) do new[k]=v end + end + return new +end +function advtrains.yaw_from_3_positions(prev, curr, next) + local pts=minetest.pos_to_string + --print("p3 "..pts(prev)..pts(curr)..pts(next)) + local prev2curr=math.atan2((curr.x-prev.x), (prev.z-curr.z)) + local curr2next=math.atan2((next.x-curr.x), (curr.z-next.z)) + --print("y3 "..(prev2curr*360/(2*math.pi)).." "..(curr2next*360/(2*math.pi))) + return prev2curr+(advtrains.minAngleDiffRad(prev2curr, curr2next)/2) +end +function advtrains.get_wagon_yaw(front, first, second, back, pct) + local pts=minetest.pos_to_string + --print("p "..pts(front)..pts(first)..pts(second)..pts(back)) + local y2=advtrains.yaw_from_3_positions(second, first, front) + local y1=advtrains.yaw_from_3_positions(back, second, first) + --print("y "..(y1*360/(2*math.pi)).." "..(y2*360/(2*math.pi))) + return y1+advtrains.minAngleDiffRad(y1, y2)*pct +end +function advtrains.get_real_index_position(path, index) + if not path or not index then return end + + local first_pos=path[math.floor(index)] + local second_pos=path[math.floor(index)+1] + + if not first_pos or not second_pos then return nil end + + local factor=index-math.floor(index) + local actual_pos={x=first_pos.x-(first_pos.x-second_pos.x)*factor, y=first_pos.y-(first_pos.y-second_pos.y)*factor, z=first_pos.z-(first_pos.z-second_pos.z)*factor,} + return actual_pos +end +function advtrains.pos_median(pos1, pos2) + return {x=pos1.x-(pos1.x-pos2.x)*0.5, y=pos1.y-(pos1.y-pos2.y)*0.5, z=pos1.z-(pos1.z-pos2.z)*0.5} +end +function advtrains.abs_ceil(i) + return math.ceil(math.abs(i))*math.sign(i) +end + +function advtrains.serialize_inventory(inv) + local ser={} + local liszts=inv:get_lists() + for lisztname, liszt in pairs(liszts) do + ser[lisztname]={} + for idx, item in ipairs(liszt) do + local istring=item:to_string() + if istring~="" then + ser[lisztname][idx]=istring + end + end + end + return minetest.serialize(ser) +end +function advtrains.deserialize_inventory(sers, inv) + local ser=minetest.deserialize(sers) + if ser then + inv:set_lists(ser) + return true + end + return false +end diff --git a/advtrains/advtrains/init.lua b/advtrains/advtrains/init.lua new file mode 100644 index 0000000..33aa962 --- /dev/null +++ b/advtrains/advtrains/init.lua @@ -0,0 +1,40 @@ +--advtrains + +advtrains={} + +advtrains.modpath = minetest.get_modpath("advtrains") + +print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end +sid=function(id) return string.sub(id, -4) end + +dofile(advtrains.modpath.."/helpers.lua"); +dofile(advtrains.modpath.."/debugitems.lua"); + +advtrains.meseconrules = +{{x=0, y=0, z=-1}, + {x=1, y=0, z=0}, + {x=-1, y=0, z=0}, + {x=0, y=0, z=1}, + {x=1, y=1, z=0}, + {x=1, y=-1, z=0}, + {x=-1, y=1, z=0}, + {x=-1, y=-1, z=0}, + {x=0, y=1, z=1}, + {x=0, y=-1, z=1}, + {x=0, y=1, z=-1}, + {x=0, y=-1, z=-1}, + {x=0, y=-2, z=0}} +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") +dofile(advtrains.modpath.."/couple.lua") +dofile(advtrains.modpath.."/damage.lua") + +dofile(advtrains.modpath.."/signals.lua") +dofile(advtrains.modpath.."/misc_nodes.lua") +dofile(advtrains.modpath.."/crafting.lua") diff --git a/advtrains/advtrains/misc_nodes.lua b/advtrains/advtrains/misc_nodes.lua new file mode 100644 index 0000000..93829f0 --- /dev/null +++ b/advtrains/advtrains/misc_nodes.lua @@ -0,0 +1,67 @@ +--all nodes that do not fit in any other category + +function advtrains.register_platform(preset) + local ndef=minetest.registered_nodes[preset] + if not ndef then + minetest.log("warning", "[advtrains] register_platform couldn't find preset node "..preset) + return + end + local btex=ndef.tiles + if type(btex)=="table" then + btex=btex[1] + end + local desc=ndef.description or "" + local nodename=string.match(preset, ":(.+)$") + minetest.register_node("advtrains:platform_low_"..nodename, { + description = desc.." Platform (low)", + tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex}, + groups = {cracky = 1, not_blocking_trains = 1, platform=1}, + sounds = default.node_sound_stone_defaults(), + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.1, -0.1, 0.5, 0 , 0.5}, + {-0.5, -0.5, 0 , 0.5, -0.1, 0.5} + }, + }, + paramtype2="facedir", + paramtype = "light", + sunlight_propagates = true, + }) + minetest.register_node("advtrains:platform_high_"..nodename, { + description = desc.." Platform (high)", + tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex}, + groups = {cracky = 1, not_blocking_trains = 1, platform=2}, + sounds = default.node_sound_stone_defaults(), + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, 0.3, -0.1, 0.5, 0.5, 0.5}, + {-0.5, -0.5, 0 , 0.5, 0.3, 0.5} + }, + }, + paramtype2="facedir", + paramtype = "light", + sunlight_propagates = true, + }) + minetest.register_craft({ + type="shapeless", + output = "advtrains:platform_high_"..nodename.." 4", + recipe = { + "dye:yellow", preset, preset + }, + }) + minetest.register_craft({ + type="shapeless", + output = "advtrains:platform_low_"..nodename.." 4", + recipe = { + "dye:yellow", preset + }, + }) +end + + +advtrains.register_platform("default:stonebrick") +advtrains.register_platform("default:sandstonebrick") diff --git a/advtrains/advtrains/models/advtrains_dtrack_bumper_st.b3d b/advtrains/advtrains/models/advtrains_dtrack_bumper_st.b3d new file mode 100644 index 0000000..a6d9745 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_bumper_st.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_bumper_st_30.b3d b/advtrains/advtrains/models/advtrains_dtrack_bumper_st_30.b3d new file mode 100644 index 0000000..5f5b3f4 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_bumper_st_30.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_bumper_st_45.b3d b/advtrains/advtrains/models/advtrains_dtrack_bumper_st_45.b3d new file mode 100644 index 0000000..f13ae75 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_bumper_st_45.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_bumper_st_60.b3d b/advtrains/advtrains/models/advtrains_dtrack_bumper_st_60.b3d new file mode 100644 index 0000000..59a2285 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_bumper_st_60.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_cr.b3d b/advtrains/advtrains/models/advtrains_dtrack_cr.b3d new file mode 100644 index 0000000..159717e Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_cr.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_cr_30.b3d b/advtrains/advtrains/models/advtrains_dtrack_cr_30.b3d new file mode 100644 index 0000000..09cdb1f Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_cr_30.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_cr_45.b3d b/advtrains/advtrains/models/advtrains_dtrack_cr_45.b3d new file mode 100644 index 0000000..176da81 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_cr_45.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_cr_60.b3d b/advtrains/advtrains/models/advtrains_dtrack_cr_60.b3d new file mode 100644 index 0000000..00313c8 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_cr_60.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_detector_st.b3d b/advtrains/advtrains/models/advtrains_dtrack_detector_st.b3d new file mode 100644 index 0000000..6762bc3 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_detector_st.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_detector_st_30.b3d b/advtrains/advtrains/models/advtrains_dtrack_detector_st_30.b3d new file mode 100644 index 0000000..f2d5991 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_detector_st_30.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_detector_st_45.b3d b/advtrains/advtrains/models/advtrains_dtrack_detector_st_45.b3d new file mode 100644 index 0000000..9ecb4a6 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_detector_st_45.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_detector_st_60.b3d b/advtrains/advtrains/models/advtrains_dtrack_detector_st_60.b3d new file mode 100644 index 0000000..bd102cb Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_detector_st_60.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_st.b3d b/advtrains/advtrains/models/advtrains_dtrack_st.b3d new file mode 100644 index 0000000..f3e2753 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_st.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_st_30.b3d b/advtrains/advtrains/models/advtrains_dtrack_st_30.b3d new file mode 100644 index 0000000..7a35c8d Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_st_30.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_st_45.b3d b/advtrains/advtrains/models/advtrains_dtrack_st_45.b3d new file mode 100644 index 0000000..b2a1702 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_st_45.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_st_60.b3d b/advtrains/advtrains/models/advtrains_dtrack_st_60.b3d new file mode 100644 index 0000000..0a59f77 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_st_60.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swlcr.b3d b/advtrains/advtrains/models/advtrains_dtrack_swlcr.b3d new file mode 100644 index 0000000..1adc23f Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swlcr.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swlcr_30.b3d b/advtrains/advtrains/models/advtrains_dtrack_swlcr_30.b3d new file mode 100644 index 0000000..7d8373b Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swlcr_30.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swlcr_45.b3d b/advtrains/advtrains/models/advtrains_dtrack_swlcr_45.b3d new file mode 100644 index 0000000..9679b9e Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swlcr_45.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swlcr_60.b3d b/advtrains/advtrains/models/advtrains_dtrack_swlcr_60.b3d new file mode 100644 index 0000000..3efc924 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swlcr_60.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swlst.b3d b/advtrains/advtrains/models/advtrains_dtrack_swlst.b3d new file mode 100644 index 0000000..93841a4 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swlst.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swlst_30.b3d b/advtrains/advtrains/models/advtrains_dtrack_swlst_30.b3d new file mode 100644 index 0000000..e9a90c7 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swlst_30.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swlst_45.b3d b/advtrains/advtrains/models/advtrains_dtrack_swlst_45.b3d new file mode 100644 index 0000000..49c707c Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swlst_45.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swlst_60.b3d b/advtrains/advtrains/models/advtrains_dtrack_swlst_60.b3d new file mode 100644 index 0000000..c9a6ffe Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swlst_60.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swrcr.b3d b/advtrains/advtrains/models/advtrains_dtrack_swrcr.b3d new file mode 100644 index 0000000..ee29b62 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swrcr.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swrcr_30.b3d b/advtrains/advtrains/models/advtrains_dtrack_swrcr_30.b3d new file mode 100644 index 0000000..ba065e1 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swrcr_30.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swrcr_45.b3d b/advtrains/advtrains/models/advtrains_dtrack_swrcr_45.b3d new file mode 100644 index 0000000..7f9dc43 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swrcr_45.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swrcr_60.b3d b/advtrains/advtrains/models/advtrains_dtrack_swrcr_60.b3d new file mode 100644 index 0000000..b8ffa61 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swrcr_60.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swrst.b3d b/advtrains/advtrains/models/advtrains_dtrack_swrst.b3d new file mode 100644 index 0000000..0b3e7ad Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swrst.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swrst_30.b3d b/advtrains/advtrains/models/advtrains_dtrack_swrst_30.b3d new file mode 100644 index 0000000..4aea19b Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swrst_30.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swrst_45.b3d b/advtrains/advtrains/models/advtrains_dtrack_swrst_45.b3d new file mode 100644 index 0000000..4182fe5 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swrst_45.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_swrst_60.b3d b/advtrains/advtrains/models/advtrains_dtrack_swrst_60.b3d new file mode 100644 index 0000000..6d2c891 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_swrst_60.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_vst1.b3d b/advtrains/advtrains/models/advtrains_dtrack_vst1.b3d new file mode 100644 index 0000000..c9d7427 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_vst1.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_vst1_45.b3d b/advtrains/advtrains/models/advtrains_dtrack_vst1_45.b3d new file mode 100644 index 0000000..14d438c Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_vst1_45.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_vst2.b3d b/advtrains/advtrains/models/advtrains_dtrack_vst2.b3d new file mode 100644 index 0000000..c128650 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_vst2.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_vst2_45.b3d b/advtrains/advtrains/models/advtrains_dtrack_vst2_45.b3d new file mode 100644 index 0000000..263276d Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_vst2_45.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_vst31.b3d b/advtrains/advtrains/models/advtrains_dtrack_vst31.b3d new file mode 100644 index 0000000..df0f383 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_vst31.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_vst32.b3d b/advtrains/advtrains/models/advtrains_dtrack_vst32.b3d new file mode 100644 index 0000000..01d2978 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_vst32.b3d differ diff --git a/advtrains/advtrains/models/advtrains_dtrack_vst33.b3d b/advtrains/advtrains/models/advtrains_dtrack_vst33.b3d new file mode 100644 index 0000000..7fe418d Binary files /dev/null and b/advtrains/advtrains/models/advtrains_dtrack_vst33.b3d differ diff --git a/advtrains/advtrains/models/advtrains_modernwagon.b3d b/advtrains/advtrains/models/advtrains_modernwagon.b3d new file mode 100644 index 0000000..aacddca Binary files /dev/null and b/advtrains/advtrains/models/advtrains_modernwagon.b3d differ diff --git a/advtrains/advtrains/models/advtrains_retrosignal_off.b3d b/advtrains/advtrains/models/advtrains_retrosignal_off.b3d new file mode 100644 index 0000000..3d231dd Binary files /dev/null and b/advtrains/advtrains/models/advtrains_retrosignal_off.b3d differ diff --git a/advtrains/advtrains/models/advtrains_retrosignal_off_30.b3d b/advtrains/advtrains/models/advtrains_retrosignal_off_30.b3d new file mode 100644 index 0000000..da258e1 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_retrosignal_off_30.b3d differ diff --git a/advtrains/advtrains/models/advtrains_retrosignal_off_45.b3d b/advtrains/advtrains/models/advtrains_retrosignal_off_45.b3d new file mode 100644 index 0000000..338224a Binary files /dev/null and b/advtrains/advtrains/models/advtrains_retrosignal_off_45.b3d differ diff --git a/advtrains/advtrains/models/advtrains_retrosignal_off_60.b3d b/advtrains/advtrains/models/advtrains_retrosignal_off_60.b3d new file mode 100644 index 0000000..c560ca1 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_retrosignal_off_60.b3d differ diff --git a/advtrains/advtrains/models/advtrains_retrosignal_on.b3d b/advtrains/advtrains/models/advtrains_retrosignal_on.b3d new file mode 100644 index 0000000..3d19439 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_retrosignal_on.b3d differ diff --git a/advtrains/advtrains/models/advtrains_retrosignal_on_30.b3d b/advtrains/advtrains/models/advtrains_retrosignal_on_30.b3d new file mode 100644 index 0000000..98f8a92 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_retrosignal_on_30.b3d differ diff --git a/advtrains/advtrains/models/advtrains_retrosignal_on_45.b3d b/advtrains/advtrains/models/advtrains_retrosignal_on_45.b3d new file mode 100644 index 0000000..414e121 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_retrosignal_on_45.b3d differ diff --git a/advtrains/advtrains/models/advtrains_retrosignal_on_60.b3d b/advtrains/advtrains/models/advtrains_retrosignal_on_60.b3d new file mode 100644 index 0000000..a51529a Binary files /dev/null and b/advtrains/advtrains/models/advtrains_retrosignal_on_60.b3d differ diff --git a/advtrains/advtrains/models/advtrains_signal.b3d b/advtrains/advtrains/models/advtrains_signal.b3d new file mode 100644 index 0000000..7f69560 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_signal.b3d differ diff --git a/advtrains/advtrains/models/advtrains_signal_30.b3d b/advtrains/advtrains/models/advtrains_signal_30.b3d new file mode 100644 index 0000000..0b949a7 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_signal_30.b3d differ diff --git a/advtrains/advtrains/models/advtrains_signal_45.b3d b/advtrains/advtrains/models/advtrains_signal_45.b3d new file mode 100644 index 0000000..ccaebf4 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_signal_45.b3d differ diff --git a/advtrains/advtrains/models/advtrains_signal_60.b3d b/advtrains/advtrains/models/advtrains_signal_60.b3d new file mode 100644 index 0000000..cf41e6d Binary files /dev/null and b/advtrains/advtrains/models/advtrains_signal_60.b3d differ diff --git a/advtrains/advtrains/models/advtrains_track_cr.b3d b/advtrains/advtrains/models/advtrains_track_cr.b3d new file mode 100644 index 0000000..b0f5e4b Binary files /dev/null and b/advtrains/advtrains/models/advtrains_track_cr.b3d differ diff --git a/advtrains/advtrains/models/advtrains_track_st.b3d b/advtrains/advtrains/models/advtrains_track_st.b3d new file mode 100644 index 0000000..10b5d90 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_track_st.b3d differ diff --git a/advtrains/advtrains/models/advtrains_track_st_45.b3d b/advtrains/advtrains/models/advtrains_track_st_45.b3d new file mode 100644 index 0000000..32505a1 Binary files /dev/null and b/advtrains/advtrains/models/advtrains_track_st_45.b3d differ diff --git a/advtrains/advtrains/models/trackplane.b3d b/advtrains/advtrains/models/trackplane.b3d new file mode 100644 index 0000000..b4728c3 Binary files /dev/null and b/advtrains/advtrains/models/trackplane.b3d differ diff --git a/advtrains/advtrains/pseudoload.lua b/advtrains/advtrains/pseudoload.lua new file mode 100644 index 0000000..677cd14 --- /dev/null +++ b/advtrains/advtrains/pseudoload.lua @@ -0,0 +1,182 @@ +local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end + +--pseudoload.lua +--responsible for keeping up a database of all rail nodes existant in the world, regardless of whether the mapchunk is loaded. + +advtrains.trackdb={} +--trackdb[tt][y][x][z]={conn1, conn2, rely1, rely2, railheight} +--serialization format: +--(2byte x)(2byte y)(2byte z)(4bits conn1, 4bits conn2)[(plain rely1)|(plain rely2)|(plain railheight)]\n +--[] may be missing if 0,0,0 + +--load initially + +--[[ TODO temporary outcomment + +--delayed since all traintypes need to be registered +minetest.after(0, function() + +for tt, _ in pairs(advtrains.all_traintypes) do + local pl_fpath=minetest.get_worldpath().."/advtrains_trackdb_"..tt + advtrains.trackdb[tt]={} + local file, err = io.open(pl_fpath, "r") + if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed loading advtrains trackdb save file "..er) + else + --custom format to save memory + while true do + local xbytes=file:read(2) + if not xbytes or #xbytes<2 then + break --eof reached + end + print(xbytes) + local ybytes=file:read(2) + local zbytes=file:read(2) + local x=(string.byte(xbytes[1])-128)*256+(string.byte(xbytes[2])) + local y=(string.byte(ybytes[1])-128)*256+(string.byte(ybytes[2])) + local z=(string.byte(zbytes[1])-128)*256+(string.byte(zbytes[2])) + + local conn1=string.byte(file:read(1)) + local conn1=string.byte(file:read(1)) + + if not advtrains.trackdb[tt][y] then advtrains.trackdb[tt][y]={} end + if not advtrains.trackdb[tt][y][x] then advtrains.trackdb[tt][y][x]={} end + + local rest=file.read("*l") + if rest~="" then + local rely1, rely2, railheight=string.match(rest, "([^|]+)|([^|]+)|([^|]+)") + if rely1 and rely2 and railheight then + advtrains.trackdb[tt][y][x][z]={ + conn1=conn1, conn2=conn2, + rely1=rely1, rely2=rely2, + railheight=railheight + } + else + advtrains.trackdb[tt][y][x][z]={ + conn1=conn1, conn2=conn2 + } + end + else + advtrains.trackdb[tt][y][x][z]={ + conn1=conn1, conn2=conn2 + } + end + end + file:close() + end +end + +--end minetest.after +end) + +function advtrains.save_trackdb() + for tt, _ in pairs(advtrains.all_traintypes) do + local pl_fpath=minetest.get_worldpath().."/advtrains_trackdb_"..tt + local file, err = io.open(pl_fpath, "w") + if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed saving advtrains trackdb save file "..er) + else + --custom format to save memory + for y,tyl in pairs(advtrains.trackdb[tt]) do + for x,txl in pairs(tyl) do + for z,rail in pairs(txl) do + print("write "..x.." "..y.." "..z.." "..minetest.serialize(rail)) + file:write(string.char(math.floor(x/256)+128)..string.char((x%256))) + file:write(string.char(math.floor(y/256)+128)..string.char((y%256))) + file:write(string.char(math.floor(z/256)+128)..string.char((z%256))) + file:write(string.char(rail.conn1)) + file:write(string.char(rail.conn2)) + if (rail.rely1 and rail.rely1~=0) or (rail.rely2 and rail.rely2~=0) or (rail.railheight and rail.railheight~=0) then + file:write(rail.rely1.."|"..rail.rely2.."|"..rail.railheight) + end + file:write("\n") + end + end + end + file:close() + end + end +end +]]--end temp outcomment +advtrains.trackdb={} +advtrains.fpath_tdb=minetest.get_worldpath().."/advtrains_trackdb2" +local file, err = io.open(advtrains.fpath_tdb, "r") +if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed loading advtrains save file "..er) +else + local tbl = minetest.deserialize(file:read("*a")) + if type(tbl) == "table" then + advtrains.trackdb=tbl + end + file:close() +end +function advtrains.save_trackdb() + local datastr = minetest.serialize(advtrains.trackdb) + if not datastr then + minetest.log("error", "[advtrains] Failed to serialize trackdb data!") + return + end + local file, err = io.open(advtrains.fpath_tdb, "w") + if err then + return err + end + file:write(datastr) + file:close() +end + +--get_node with pseudoload. +--returns: +--true, conn1, conn2, rely1, rely2, railheight in case everything's right. +--false if it's not a rail or the train does not drive on this rail, but it is loaded or +--nil if the node is neither loaded nor in trackdb +--the distraction between false and nil will be needed only in special cases.(train initpos) +function advtrains.get_rail_info_at(pos, drives_on) + local node=minetest.get_node_or_nil(pos) + if not node then + --try raildb + local rdp=vector.round(pos) + local dbe=(advtrains.trackdb[traintype] and advtrains.trackdb[traintype][rdp.y] and advtrains.trackdb[traintype][rdp.y][rdp.x] and advtrains.trackdb[traintype][rdp.y][rdp.x][rdp.z]) + if dbe then + for tt,_ in pairs(drives_on) do + if not dbe.tracktype or tt==dbe.tracktype then + return true, dbe.conn1, dbe.conn2, dbe.rely1 or 0, dbe.rely2 or 0, dbe.railheight or 0 + end + end + else + return nil + end + end + local nodename=node.name + if(not advtrains.is_track_and_drives_on(nodename, drives_on)) then + return false + end + local conn1, conn2, rely1, rely2, railheight, tracktype=advtrains.get_track_connections(node.name, node.param2) + + --already in trackdb? + local rdp=vector.round(pos) + if not (advtrains.trackdb and advtrains.trackdb[rdp.y] and advtrains.trackdb[rdp.y][rdp.x] and advtrains.trackdb[rdp.y][rdp.x][rdp.z]) then--TODO is this necessary? + if not advtrains.trackdb then advtrains.trackdb={} end + if not advtrains.trackdb[rdp.y] then advtrains.trackdb[rdp.y]={} end + if not advtrains.trackdb[rdp.y][rdp.x] then advtrains.trackdb[rdp.y][rdp.x]={} end + advtrains.trackdb[rdp.y][rdp.x][rdp.z]={ + conn1=conn1, conn2=conn2, + rely1=rely1, rely2=rely2, + railheight=railheight, tracktype=tracktype + } + end + + return true, conn1, conn2, rely1, rely2, railheight +end +function advtrains.reset_trackdb_position(pos) + local rdp=vector.round(pos) + if not advtrains.trackdb then advtrains.trackdb={} end + if not advtrains.trackdb[rdp.y] then advtrains.trackdb[rdp.y]={} end + if not advtrains.trackdb[rdp.y][rdp.x] then advtrains.trackdb[rdp.y][rdp.x]={} end + advtrains.trackdb[rdp.y][rdp.x][rdp.z]=nil + advtrains.get_rail_info_at(pos, advtrains.all_tracktypes)--to restore it. +end + + diff --git a/advtrains/advtrains/readme.txt b/advtrains/advtrains/readme.txt new file mode 100644 index 0000000..ad093bd --- /dev/null +++ b/advtrains/advtrains/readme.txt @@ -0,0 +1,23 @@ + +## ADVTRAINS ## realistic trains in Minetest! +by orwell96 and contributors(see below) + +For up-to-date information, visit https://forum.minetest.net/viewtopic.php?f=9&t=14726 + + +Manual: +If manual.pdf is not present (which is the case when you downloaded the zip file), see https://github.com/orwell96/advtrains/blob/master/manual.pdf + +License of code: LGPL 2.1 +License of media: CC-BY-NC-SA 3.0 + +Contributions: + +Gravel Texture : from Minetest Game +Initial rail model/texture : DS-minetest +Models for signals/bumpers : mbb +Steam engine / wagon texture: mbb +Industrial engine/wagons : mbb +Inventory images : mbb +Small code contributions : NaruTrey / gpcf +Mod Description : hajo \ No newline at end of file diff --git a/advtrains/advtrains/signals.lua b/advtrains/advtrains/signals.lua new file mode 100644 index 0000000..8be65e0 --- /dev/null +++ b/advtrains/advtrains/signals.lua @@ -0,0 +1,76 @@ +--advtrains by orwell96 +--signals.lua +for r,f in pairs({on="off", off="on"}) do + + advtrains.trackplacer.register_tracktype("advtrains:retrosignal", "") + advtrains.trackplacer.register_tracktype("advtrains:signal", "") + + for rotid, rotation in ipairs({"", "_30", "_45", "_60"}) do + local crea=1 + if rotid==1 and r=="off" then crea=0 end + + minetest.register_node("advtrains:retrosignal_"..r..rotation, { + drawtype = "mesh", + paramtype="light", + paramtype2="facedir", + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4}, + }, + mesh = "advtrains_retrosignal_"..r..rotation..".b3d", + tiles = {"advtrains_retrosignal.png"}, + inventory_image="advtrains_retrosignal_inv.png", + drop="advtrains:retrosignal_off", + description="Lampless Signal ("..r..rotation..")", + on_rightclick=switchfunc, + sunlight_propagates=true, + groups = { + choppy=3, + not_blocking_trains=1, + not_in_creative_inventory=crea, + }, + mesecons = {effector = { + ["action_"..f] = function (pos, node) + minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2}) + end + }}, + on_rightclick=function(pos, node, clicker) + minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2}) + end, + }) + advtrains.trackplacer.add_worked("advtrains:retrosignal", r, rotation, nil) + minetest.register_node("advtrains:signal_"..r..rotation, { + drawtype = "mesh", + paramtype="light", + paramtype2="facedir", + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4}, + }, + mesh = "advtrains_signal"..rotation..".b3d", + tiles = {"advtrains_signal_"..r..".png"}, + inventory_image="advtrains_signal_inv.png", + drop="advtrains:signal_off", + description="Signal ("..r..rotation..")", + on_rightclick=switchfunc, + groups = { + choppy=3, + not_blocking_trains=1, + not_in_creative_inventory=crea, + }, + light_source = 1, + sunlight_propagates=true, + mesecons = {effector = { + ["action_"..f] = function (pos, node) + minetest.swap_node(pos, {name = "advtrains:signal_"..f..rotation, param2 = node.param2}) + end + }}, + on_rightclick=function(pos, node, clicker) + minetest.swap_node(pos, {name = "advtrains:signal_"..f..rotation, param2 = node.param2}) + end, + }) + advtrains.trackplacer.add_worked("advtrains:signal", r, rotation, nil) + end +end diff --git a/advtrains/advtrains/textures/advtrains_couple.png b/advtrains/advtrains/textures/advtrains_couple.png new file mode 100644 index 0000000..9e997e4 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_couple.png differ diff --git a/advtrains/advtrains/textures/advtrains_discouple.png b/advtrains/advtrains/textures/advtrains_discouple.png new file mode 100644 index 0000000..b27c4fb Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_discouple.png differ diff --git a/advtrains/advtrains/textures/advtrains_dtrack_atc_placer.png b/advtrains/advtrains/textures/advtrains_dtrack_atc_placer.png new file mode 100644 index 0000000..31c2b30 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_dtrack_atc_placer.png differ diff --git a/advtrains/advtrains/textures/advtrains_dtrack_bumper_placer.png b/advtrains/advtrains/textures/advtrains_dtrack_bumper_placer.png new file mode 100644 index 0000000..27191fe Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_dtrack_bumper_placer.png differ diff --git a/advtrains/advtrains/textures/advtrains_dtrack_detector_placer.png b/advtrains/advtrains/textures/advtrains_dtrack_detector_placer.png new file mode 100644 index 0000000..e6c6ad6 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_dtrack_detector_placer.png differ diff --git a/advtrains/advtrains/textures/advtrains_dtrack_placer.png b/advtrains/advtrains/textures/advtrains_dtrack_placer.png new file mode 100644 index 0000000..7bef8a9 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_dtrack_placer.png differ diff --git a/advtrains/advtrains/textures/advtrains_dtrack_rail.png b/advtrains/advtrains/textures/advtrains_dtrack_rail.png new file mode 100644 index 0000000..1cf7f83 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_dtrack_rail.png differ diff --git a/advtrains/advtrains/textures/advtrains_dtrack_rail_atc.png b/advtrains/advtrains/textures/advtrains_dtrack_rail_atc.png new file mode 100644 index 0000000..d171985 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_dtrack_rail_atc.png differ diff --git a/advtrains/advtrains/textures/advtrains_dtrack_rail_detector_on.png b/advtrains/advtrains/textures/advtrains_dtrack_rail_detector_on.png new file mode 100644 index 0000000..4f09b35 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_dtrack_rail_detector_on.png differ diff --git a/advtrains/advtrains/textures/advtrains_dtrack_slopeplacer.png b/advtrains/advtrains/textures/advtrains_dtrack_slopeplacer.png new file mode 100644 index 0000000..1d456b0 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_dtrack_slopeplacer.png differ diff --git a/advtrains/advtrains/textures/advtrains_platform.png b/advtrains/advtrains/textures/advtrains_platform.png new file mode 100644 index 0000000..5ba9663 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_platform.png differ diff --git a/advtrains/advtrains/textures/advtrains_retrosignal.png b/advtrains/advtrains/textures/advtrains_retrosignal.png new file mode 100644 index 0000000..141198d Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_retrosignal.png differ diff --git a/advtrains/advtrains/textures/advtrains_retrosignal_inv.png b/advtrains/advtrains/textures/advtrains_retrosignal_inv.png new file mode 100644 index 0000000..1036594 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_retrosignal_inv.png differ diff --git a/advtrains/advtrains/textures/advtrains_signal_inv.png b/advtrains/advtrains/textures/advtrains_signal_inv.png new file mode 100644 index 0000000..ed64ed9 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_signal_inv.png differ diff --git a/advtrains/advtrains/textures/advtrains_signal_off.png b/advtrains/advtrains/textures/advtrains_signal_off.png new file mode 100644 index 0000000..8046e52 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_signal_off.png differ diff --git a/advtrains/advtrains/textures/advtrains_signal_on.png b/advtrains/advtrains/textures/advtrains_signal_on.png new file mode 100644 index 0000000..5228bb3 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_signal_on.png differ diff --git a/advtrains/advtrains/textures/advtrains_track_cr.png b/advtrains/advtrains/textures/advtrains_track_cr.png new file mode 100644 index 0000000..40f0cc5 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_track_cr.png differ diff --git a/advtrains/advtrains/textures/advtrains_track_cr_45.png b/advtrains/advtrains/textures/advtrains_track_cr_45.png new file mode 100644 index 0000000..54966b3 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_track_cr_45.png differ diff --git a/advtrains/advtrains/textures/advtrains_track_placer.png b/advtrains/advtrains/textures/advtrains_track_placer.png new file mode 100644 index 0000000..03e17ed Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_track_placer.png differ diff --git a/advtrains/advtrains/textures/advtrains_track_st.png b/advtrains/advtrains/textures/advtrains_track_st.png new file mode 100644 index 0000000..5ad7e4f Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_track_st.png differ diff --git a/advtrains/advtrains/textures/advtrains_track_st_45.png b/advtrains/advtrains/textures/advtrains_track_st_45.png new file mode 100644 index 0000000..63b4c96 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_track_st_45.png differ diff --git a/advtrains/advtrains/textures/advtrains_track_swlcr.png b/advtrains/advtrains/textures/advtrains_track_swlcr.png new file mode 100644 index 0000000..d9b5c0b Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_track_swlcr.png differ diff --git a/advtrains/advtrains/textures/advtrains_track_swlcr_45.png b/advtrains/advtrains/textures/advtrains_track_swlcr_45.png new file mode 100644 index 0000000..f098fc9 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_track_swlcr_45.png differ diff --git a/advtrains/advtrains/textures/advtrains_track_swlst.png b/advtrains/advtrains/textures/advtrains_track_swlst.png new file mode 100644 index 0000000..314bd2d Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_track_swlst.png differ diff --git a/advtrains/advtrains/textures/advtrains_track_swlst_45.png b/advtrains/advtrains/textures/advtrains_track_swlst_45.png new file mode 100644 index 0000000..765d0ec Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_track_swlst_45.png differ diff --git a/advtrains/advtrains/textures/advtrains_track_swrcr.png b/advtrains/advtrains/textures/advtrains_track_swrcr.png new file mode 100644 index 0000000..f74e1bc Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_track_swrcr.png differ diff --git a/advtrains/advtrains/textures/advtrains_track_swrcr_45.png b/advtrains/advtrains/textures/advtrains_track_swrcr_45.png new file mode 100644 index 0000000..fa432aa Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_track_swrcr_45.png differ diff --git a/advtrains/advtrains/textures/advtrains_track_swrst.png b/advtrains/advtrains/textures/advtrains_track_swrst.png new file mode 100644 index 0000000..06ea29e Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_track_swrst.png differ diff --git a/advtrains/advtrains/textures/advtrains_track_swrst_45.png b/advtrains/advtrains/textures/advtrains_track_swrst_45.png new file mode 100644 index 0000000..be477b7 Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_track_swrst_45.png differ diff --git a/advtrains/advtrains/textures/advtrains_trackworker.png b/advtrains/advtrains/textures/advtrains_trackworker.png new file mode 100644 index 0000000..b50bcae Binary files /dev/null and b/advtrains/advtrains/textures/advtrains_trackworker.png differ diff --git a/advtrains/advtrains/textures/drwho_screwdriver.png b/advtrains/advtrains/textures/drwho_screwdriver.png new file mode 100644 index 0000000..b50bcae Binary files /dev/null and b/advtrains/advtrains/textures/drwho_screwdriver.png differ diff --git a/advtrains/advtrains/trackplacer.lua b/advtrains/advtrains/trackplacer.lua new file mode 100644 index 0000000..b24103a --- /dev/null +++ b/advtrains/advtrains/trackplacer.lua @@ -0,0 +1,297 @@ +--trackplacer.lua +--holds code for the track-placing system. the default 'track' item will be a craftitem that places rails as needed. this will neither place or change switches nor place vertical rails. + +--all new trackplacer code +local tp={ + tracks={} +} + +function tp.register_tracktype(nnprefix, n_suffix) + tp.tracks[nnprefix]={ + default=n_suffix, + single_conn={}, + double_conn={}, + --keys:conn1_conn2 (example:1_4) + --values:{name=x, param2=x} + twcycle={}, + twrotate={},--indexed by suffix, list, tells order of rotations + modify={} + } +end +function tp.add_double_conn(nnprefix, suffix, rotation, conns) + local nodename=nnprefix.."_"..suffix..rotation + for i=0,3 do + tp.tracks[nnprefix].double_conn[((conns.conn1+4*i)%16).."_"..((conns.conn2+4*i)%16)]={name=nodename, param2=i} + tp.tracks[nnprefix].double_conn[((conns.conn2+4*i)%16).."_"..((conns.conn1+4*i)%16)]={name=nodename, param2=i} + end + tp.tracks[nnprefix].modify[nodename]=true +end +function tp.add_single_conn(nnprefix, suffix, rotation, conns) + local nodename=nnprefix.."_"..suffix..rotation + for i=0,3 do + tp.tracks[nnprefix].single_conn[((conns.conn1+4*i)%16)]={name=nodename, param2=i} + tp.tracks[nnprefix].single_conn[((conns.conn2+4*i)%16)]={name=nodename, param2=i} + end + tp.tracks[nnprefix].modify[nodename]=true +end + +function tp.add_worked(nnprefix, suffix, rotation, cycle_follows) + tp.tracks[nnprefix].twcycle[suffix]=cycle_follows + if not tp.tracks[nnprefix].twrotate[suffix] then tp.tracks[nnprefix].twrotate[suffix]={} end + table.insert(tp.tracks[nnprefix].twrotate[suffix], rotation) +end + + +--[[ + rewrite algorithm. + selection criteria: these will never be changed or even selected: + - tracks being already connected on both sides + - tracks that are already connected on one side but are not bendable to the desired position + the following situations can occur: + 1. there are two more than two rails around + 1.1 there is one or more subset(s) that can be directly connected + -> choose the first possibility + 2.2 not + -> choose the first one and orient straight + 2. there's exactly 1 rail around + -> choose and orient straight + 3. there's no rail around + -> set straight +]] +function tp.find_already_connected(pos)--TODO vertical calculations(check node below) + local function istrackandbc(pos, conn) + local cnode=minetest.get_node(advtrains.dirCoordSet(pos, conn)) + local bconn=(conn+8)%16 + if advtrains.is_track_and_drives_on(cnode.name, advtrains.all_tracktypes) then + local cconn1, cconn2=advtrains.get_track_connections(cnode.name, cnode.param2) + return cconn1==bconn or cconn2==bconn + end + return false + end + local dnode=minetest.get_node(pos) + local dconn1, dconn2=advtrains.get_track_connections(dnode.name, dnode.param2) + local t={[true]="true", [false]="false"} + if istrackandbc(pos, dconn1) and istrackandbc(pos, dconn2) then return dconn1, dconn2 + elseif istrackandbc(pos, dconn1) then return dconn1 + elseif istrackandbc(pos, dconn2) then return dconn2 + end + return nil +end +function tp.rail_and_can_be_bent(originpos, conn, nnpref) + local pos=advtrains.dirCoordSet(originpos, conn) + local newdir=(conn+8)%16 + local node=minetest.get_node(pos) + local tr=tp.tracks[nnpref] + if not advtrains.is_track_and_drives_on(node.name, advtrains.all_tracktypes) then + return false + end + --rail at other end? + local adj1, adj2=tp.find_already_connected(pos) + if adj1 and adj2 then + return false--dont destroy existing track + elseif adj1 and not adj2 then + if tr.double_conn[adj1.."_"..newdir] then + return true--if exists, connect new rail and old end + end + return false + else + if tr.single_conn[newdir] then--just rotate old rail to right orientation + return true + end + return false + end +end +function tp.bend_rail(originpos, conn, nnpref) + local pos=advtrains.dirCoordSet(originpos, conn) + local newdir=(conn+8)%16 + local node=minetest.get_node(pos) + local tr=tp.tracks[nnpref] + --is rail already connected? no need to bend. + local conn1, conn2=advtrains.get_track_connections(node.name, node.param2) + if newdir==conn1 or newdir==conn2 then + return + end + --rail at other end? + local adj1, adj2=tp.find_already_connected(pos) + if adj1 and adj2 then + return false--dont destroy existing track + elseif adj1 and not adj2 then + if tr.double_conn[adj1.."_"..newdir] then + minetest.set_node(pos, tr.double_conn[adj1.."_"..newdir]) + return true--if exists, connect new rail and old end + end + return false + else + if tr.single_conn[newdir] then--just rotate old rail to right orientation + minetest.set_node(pos, tr.single_conn[newdir]) + return true + end + return false + end +end +function tp.placetrack(pos, nnpref, placer, itemstack, pointed_thing) + --1. find all rails that are likely to be connected + local tr=tp.tracks[nnpref] + local p_rails={} + for i=0,15 do + if tp.rail_and_can_be_bent(pos, i, nnpref) then + p_rails[#p_rails+1]=i + end + end + if #p_rails==0 then + minetest.set_node(pos, {name=nnpref.."_"..tr.default}) + if minetest.registered_nodes[nnpref.."_"..tr.default] and minetest.registered_nodes[nnpref.."_"..tr.default].after_place_node then + minetest.registered_nodes[nnpref.."_"..tr.default].after_place_node(pos, placer, itemstack, pointed_thing) + end + elseif #p_rails==1 then + tp.bend_rail(pos, p_rails[1], nnpref) + minetest.set_node(pos, tr.single_conn[p_rails[1]]) + local nname=tr.single_conn[p_rails[1]].name + if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then + minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) + end + else + --iterate subsets + for k1, conn1 in ipairs(p_rails) do + for k2, conn2 in ipairs(p_rails) do + if k1~=k2 then + if (tr.double_conn[conn1.."_"..conn2]) then + tp.bend_rail(pos, conn1, nnpref) + tp.bend_rail(pos, conn2, nnpref) + minetest.set_node(pos, tr.double_conn[conn1.."_"..conn2]) + local nname=tr.double_conn[conn1.."_"..conn2].name + if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then + minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) + end + return + end + end + end + end + --not found + tp.bend_rail(pos, p_rails[1], nnpref) + minetest.set_node(pos, tr.single_conn[p_rails[1]]) + local nname=tr.single_conn[p_rails[1]].name + if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then + minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) + end + end +end + + +function tp.register_track_placer(nnprefix, imgprefix, dispname) + minetest.register_craftitem(nnprefix.."_placer",{ + description = dispname, + inventory_image = imgprefix.."_placer.png", + wield_image = imgprefix.."_placer.png", + groups={}, + on_place = function(itemstack, placer, pointed_thing) + local name = placer:get_player_name() + if not name then + return itemstack + end + if pointed_thing.type=="node" then + local pos=pointed_thing.above + local upos=pointed_thing.under + if minetest.is_protected(pos,name) and minetest.is_protected(upos,name) then + return itemstack + end + if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to + and minetest.registered_nodes[minetest.get_node(upos).name] and minetest.registered_nodes[minetest.get_node(upos).name].walkable then + tp.placetrack(pos, nnprefix, placer, itemstack, pointed_thing) + if not minetest.setting_getbool("creative_mode") then + itemstack:take_item() + end + end + end + return itemstack + end, + }) +end + + + +minetest.register_craftitem("advtrains:trackworker",{ + description = "Track Worker Tool\n\nLeft-click: change rail type (straight/curve/switch)\nRight-click: rotate rail/bumper/signal/etc.", + groups = {cracky=1}, -- key=name, value=rating; rating=1..3. + inventory_image = "advtrains_trackworker.png", + wield_image = "advtrains_trackworker.png", + stack_max = 1, + on_place = function(itemstack, placer, pointed_thing) + local name = placer:get_player_name() + if not name then + return + end + if pointed_thing.type=="node" then + local pos=pointed_thing.under + if minetest.is_protected(pos, name) then + return + end + local node=minetest.get_node(pos) + + --if not advtrains.is_track_and_drives_on(minetest.get_node(pos).name, advtrains.all_tracktypes) then return end + if advtrains.is_train_at_pos(pos) then return end + + local nnprefix, suffix, rotation=string.match(node.name, "^(.+)_([^_]+)(_[^_]+)$") + --print(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) + if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then + nnprefix, suffix=string.match(node.name, "^(.+)_([^_]+)$") + rotation = "" + if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then + minetest.chat_send_player(placer:get_player_name(), "This node can't be rotated using the trackworker!") + return + end + end + local modext=tp.tracks[nnprefix].twrotate[suffix] + + if rotation==modext[#modext] then --increase param2 + minetest.swap_node(pos, {name=nnprefix.."_"..suffix..modext[1], param2=(node.param2+1)%4}) + return + else + local modpos + for k,v in pairs(modext) do if v==rotation then modpos=k end end + if not modpos then + minetest.chat_send_player(placer:get_player_name(), "This node can't be rotated using the trackworker!") + return + end + minetest.swap_node(pos, {name=nnprefix.."_"..suffix..modext[modpos+1], param2=node.param2}) + end + advtrains.invalidate_all_paths() + end + end, + on_use=function(itemstack, user, pointed_thing) + local name = user:get_player_name() + if not name then + return + end + if pointed_thing.type=="node" then + local pos=pointed_thing.under + local node=minetest.get_node(pos) + if minetest.is_protected(pos, name) then + return + end + + --if not advtrains.is_track_and_drives_on(minetest.get_node(pos).name, advtrains.all_tracktypes) then return end + if advtrains.is_train_at_pos(pos) then return end + local nnprefix, suffix, rotation=string.match(node.name, "^(.+)_([^_]+)(_[^_]+)$") + --print(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) + if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twcycle[suffix] then + nnprefix, suffix=string.match(node.name, "^(.+)_([^_]+)$") + rotation = "" + if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twcycle[suffix] then + minetest.chat_send_player(user:get_player_name(), "This node can't be changed using the trackworker!") + return + end + end + local nextsuffix=tp.tracks[nnprefix].twcycle[suffix] + minetest.swap_node(pos, {name=nnprefix.."_"..nextsuffix..rotation, param2=node.param2}) + --invalidate trains + advtrains.invalidate_all_paths() + else + print(name, dump(tp.tracks)) + end + end, +}) + +--putting into right place +advtrains.trackplacer=tp diff --git a/advtrains/advtrains/tracks.lua b/advtrains/advtrains/tracks.lua new file mode 100644 index 0000000..beb0bbc --- /dev/null +++ b/advtrains/advtrains/tracks.lua @@ -0,0 +1,721 @@ +--advtrains by orwell96, see readme.txt + +--dev-time settings: +--EDIT HERE +--If the old non-model rails on straight tracks should be replaced by the new... +--false: no +--true: yes +advtrains.register_replacement_lbms=false + +--[[TracksDefinition +nodename_prefix +texture_prefix +description +common={} +straight={} +straight45={} +curve={} +curve45={} +lswitchst={} +lswitchst45={} +rswitchst={} +rswitchst45={} +lswitchcr={} +lswitchcr45={} +rswitchcr={} +rswitchcr45={} +vert1={ + --you'll probably want to override mesh here +} +vert2={ + --you'll probably want to override mesh here +} +]]-- +advtrains.all_tracktypes={} + +--definition preparation +local function conns(c1, c2, r1, r2, rh, rots) return {conn1=c1, conn2=c2, rely1=r1, rely2=r2, railheight=rh} end + +local ap={} +ap.t_30deg={ + regstep=1, + variant={ + st=conns(0,8), + cr=conns(0,7), + swlst=conns(0,8), + swlcr=conns(0,7), + swrst=conns(0,8), + swrcr=conns(0,9), + vst1=conns(8,0,0,0.5,0.25), + vst2=conns(8,0,0.5,1,0.75), + vst31=conns(8,0,0,0.33,0.16), + vst32=conns(8,0,0.33,0.66,0.5), + vst33=conns(8,0,0.66,1,0.83), + }, + description={ + st="straight", + cr="curve", + swlst="left switch (straight)", + swlcr="left switch (curve)", + swrst="right switch (straight)", + swrcr="right switch (curve)", + vst1="steep uphill 1/2", + vst2="steep uphill 2/2", + vst31="uphill 1/3", + vst32="uphill 2/3", + vst33="uphill 3/3", + }, + switch={ + swlst="swlcr", + swlcr="swlst", + swrst="swrcr", + swrcr="swrst", + }, + switchmc={ + swlst="on", + swlcr="off", + swrst="on", + swrcr="off", + }, + regtp=true, + trackplacer={ + st=true, + cr=true, + }, + tpsingle={ + st=true, + }, + tpdefault="st", + trackworker={ + ["swrcr"]="st", + ["swrst"]="st", + ["st"]="cr", + ["cr"]="swlst", + ["swlcr"]="swrcr", + ["swlst"]="swrst", + }, + regsp=true, + slopenodes={ + vst1=true, vst2=true, + vst31=true, vst32=true, vst33=true, + }, + slopeplacer={ + [2]={"vst1", "vst2"}, + [3]={"vst31", "vst32", "vst33"}, + max=3,--highest entry + }, + slopeplacer_45={ + [2]={"vst1_45", "vst2_45"}, + max=2, + }, + rotation={"", "_30", "_45", "_60"}, + increativeinv={}, +} +ap.t_30deg_straightonly={ + regstep=1, + variant={ + st=conns(0,8), + }, + description={ + st="straight", + }, + switch={ + }, + switchmc={ + }, + regtp=true, + trackplacer={ + }, + tpsingle={ + }, + tpdefault="st", + trackworker={ + ["st"]="st", + }, + slopenodes={}, + rotation={"", "_30", "_45", "_60"}, + increativeinv={st}, +} +ap.t_30deg_straightonly_noplacer={ + regstep=1, + variant={ + st=conns(0,8), + }, + description={ + st="straight", + }, + switch={ + }, + switchmc={ + }, + regtp=false, + trackplacer={ + }, + tpsingle={ + }, + tpdefault="st", + trackworker={ + ["st"]="st", + }, + slopenodes={}, + rotation={"", "_30", "_45", "_60"}, + increativeinv={st}, +} +ap.t_45deg={ + regstep=2, + variant={ + st=conns(0,8), + cr=conns(0,6), + swlst=conns(0,8), + swlcr=conns(0,6), + swrst=conns(0,8), + swrcr=conns(0,10), + vst1=conns(8,0,0,0.5,0.25), + vst2=conns(8,0,0.5,1,0.75), + }, + description={ + st="straight", + cr="curve", + swlst="left switch (straight)", + swlcr="left switch (curve)", + swrst="right switch (straight)", + swrcr="right switch (curve)", + vst1="vertical lower node", + vst2="vertical upper node", + }, + switch={ + swlst="swlcr", + swlcr="swlst", + swrst="swrcr", + swrcr="swrst", + }, + switchmc={ + swlst="on", + swlcr="off", + swrst="on", + swrcr="off", + }, + regtp=true, + trackplacer={ + st=true, + cr=true, + }, + tpsingle={ + st=true, + }, + tpdefault="st", + trackworker={ + ["swrcr"]="st", + ["swrst"]="st", + ["st"]="cr", + ["cr"]="swlst", + ["swlcr"]="swrcr", + ["swlst"]="swrst", + }, + slopenodes={}, + rotation={"", "_45"}, + increativeinv={vst1=true, vst2=true} +} +advtrains.trackpresets = ap + +--definition format: ([] optional) +--[[{ + nodename_prefix + texture_prefix + [shared_texture] + models_prefix + models_suffix (with dot) + [shared_model] + formats={ + st,cr,swlst,swlcr,swrst,swrcr,vst1,vst2 + (each a table with indices 0-3, for if to register a rail with this 'rotation' table entry. nil is assumed as 'all', set {} to not register at all) + } + common={} change something on common rail appearance +}]] +function advtrains.register_tracks(tracktype, def, preset) + local function make_switchfunc(suffix_target, mesecon_state) + local switchfunc=function(pos, node) + if advtrains.is_train_at_pos(pos) then return end + minetest.set_node(pos, {name=def.nodename_prefix.."_"..suffix_target, param2=node.param2}) + advtrains.invalidate_all_paths() + advtrains.reset_trackdb_position(pos) + end + return switchfunc, {effector = { + ["action_"..mesecon_state] = switchfunc, + rules=advtrains.meseconrules + }} + end + local function make_overdef(suffix, rotation, conns, switchfunc, mesecontbl, in_creative_inv, drop_slope) + local img_suffix=suffix..rotation + return { + mesh = def.shared_model or (def.models_prefix.."_"..img_suffix..def.models_suffix), + tiles = {def.shared_texture or (def.texture_prefix.."_"..img_suffix..".png")}, + --inventory_image = def.texture_prefix.."_"..img_suffix..".png", + --wield_image = def.texture_prefix.."_"..img_suffix..".png", + description=def.description.."("..preset.description[suffix]..rotation..")", + connect1=conns.conn1, + connect2=conns.conn2, + rely1=conns.rely1 or 0, + rely2=conns.rely2 or 0, + railheight=conns.railheight or 0, + on_rightclick=switchfunc, + groups = { + attached_node=1, + ["advtrains_track_"..tracktype]=1, + dig_immediate=2, + not_in_creative_inventory=(not in_creative_inv and 1 or nil), + not_blocking_trains=1, + }, + mesecons=mesecontbl, + drop = increativeinv and def.nodename_prefix.."_"..suffix..rotation or (drop_slope and def.nodename_prefix.."_slopeplacer" or def.nodename_prefix.."_placer"), + } + end + local function cycle_conns(conns, rotid) + local add=(rotid-1)*preset.regstep + return { + conn1=(conns.conn1+add)%16, + conn2=(conns.conn2+add)%16, + rely1=conns.rely1 or 0, + rely2=conns.rely2 or 0, + railheight=conns.railheight or 0, + } + end + local common_def=advtrains.merge_tables({ + description = def.description, + drawtype = "mesh", + paramtype="light", + paramtype2="facedir", + walkable = false, + selection_box = { + type = "fixed", + fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2}, + }, + rely1=0, + rely2=0, + railheight=0, + drop=def.nodename_prefix.."_placer", + can_dig=function(pos) + return not advtrains.is_train_at_pos(pos) + end, + after_dig_node=function(pos) + advtrains.invalidate_all_paths() + advtrains.reset_trackdb_position(pos) + end, + after_place_node=function(pos) + advtrains.reset_trackdb_position(pos) + end, + on_place_rail=function(pos) + advtrains.reset_trackdb_position(pos) + end, + }, def.common or {}) + --make trackplacer base def + advtrains.trackplacer.register_tracktype(def.nodename_prefix, preset.tpdefault) + if preset.regtp then + advtrains.trackplacer.register_track_placer(def.nodename_prefix, def.texture_prefix, def.description) + end + if preset.regsp then + advtrains.slope.register_placer(def, preset) + 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 + local switchfunc, mesecontbl + 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], preset.slopenodes[suffix] + ), + adef + ) + ) + --trackplacer + 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 + end + end + advtrains.all_tracktypes[tracktype]=true +end + + +function advtrains.is_track_and_drives_on(nodename, drives_on_p) + if not minetest.registered_nodes[nodename] then + return false + end + local nodedef=minetest.registered_nodes[nodename] + for k,v in pairs(drives_on_p) do + if nodedef.groups["advtrains_track_"..k] then + return true + end + end + return false +end + +function advtrains.get_track_connections(name, param2) + local nodedef=minetest.registered_nodes[name] + if not nodedef then print("[advtrains] get_track_connections couldn't find nodedef for nodename "..(name or "nil")) return 0, 8, 0, 0, 0 end + local noderot=param2 + if not param2 then noderot=0 end + if noderot > 3 then print("[advtrains] get_track_connections: rail has invaild param2 of "..noderot) noderot=0 end + + return (nodedef.connect1 + 4 * noderot)%16, (nodedef.connect2 + 4 * noderot)%16, nodedef.rely1 or 0, nodedef.rely2 or 0, nodedef.railheight or 0 +end + +--detector code +--holds a table with nodes on which trains are on. + +advtrains.detector = {} +advtrains.detector.on_node = {} +advtrains.detector.on_node_restore = {} +--set if paths were invalidated before. tells trainlogic.lua to call advtrains.detector.finalize_restore() +advtrains.detector.clean_step_before = false + +--when train enters a node, call this +--The entry already being contained in advtrains.detector.on_node_restore will not trigger an on_train_enter event on the node. (when path is reset, this is saved). +function advtrains.detector.enter_node(pos, train_id) + local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) + --print("enterNode "..pts.." "..sid(train_id)) + if advtrains.detector.on_node[pts] then + if advtrains.trains[advtrains.detector.on_node[pts]] then + --print(""..pts.." already occupied") + return false + else + advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) + end + end + advtrains.detector.on_node[pts]=train_id + if advtrains.detector.on_node_restore[pts] then + advtrains.detector.on_node_restore[pts]=nil + else + advtrains.detector.call_enter_callback(advtrains.round_vector_floor_y(pos), train_id) + end + return true +end +function advtrains.detector.leave_node(pos, train_id) + local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) + --print("leaveNode "..pts.." "..sid(train_id)) + if not advtrains.detector.on_node[pts] then + --print(""..pts.." leave: nothing here") + return false + end + if advtrains.detector.on_node[pts]==train_id then + advtrains.detector.call_leave_callback(advtrains.round_vector_floor_y(pos), train_id) + advtrains.detector.on_node[pts]=nil + else + if advtrains.trains[advtrains.detector.on_node[pts]] then + --print(""..pts.." occupied by another train") + return false + else + advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) + return false + end + end + return true +end +--called immediately before invalidating paths +function advtrains.detector.setup_restore() + --print("setup_restore") + advtrains.detector.on_node_restore = advtrains.detector.on_node + advtrains.detector.on_node = {} +end +--called one step after invalidating paths, when all trains have restored their path and called enter_node for their contents. +function advtrains.detector.finalize_restore() + --print("finalize_restore") + for pts, train_id in pairs(advtrains.detector.on_node_restore) do + --print("called leave callback "..pts.." "..train_id) + advtrains.detector.call_leave_callback(minetest.string_to_pos(pts), train_id) + end + advtrains.detector.on_node_restore = {} +end +function advtrains.detector.call_enter_callback(pos, train_id) + --print("instructed to call enter calback") + + local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case + local mregnode=minetest.registered_nodes[node.name] + if mregnode and mregnode.advtrains and mregnode.advtrains.on_train_enter then + mregnode.advtrains.on_train_enter(pos, train_id) + end + + --atc code wants to be notified too + advtrains.atc.trigger_controller_train_enter(pos, train_id) +end +function advtrains.detector.call_leave_callback(pos, train_id) + --print("instructed to call leave calback") + + local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case + local mregnode=minetest.registered_nodes[node.name] + if mregnode and mregnode.advtrains and mregnode.advtrains.on_train_leave then + mregnode.advtrains.on_train_leave(pos, train_id) + end +end + +-- slope placer. Defined in register_tracks. +--crafted with rail and gravel +local sl={} +function sl.register_placer(def, preset) + minetest.register_craftitem(def.nodename_prefix.."_slopeplacer",{ + description = def.description.." Slope", + inventory_image = def.texture_prefix.."_slopeplacer.png", + wield_image = def.texture_prefix.."_slopeplacer.png", + groups={}, + on_place = sl.create_slopeplacer_on_place(def, preset) + }) +end +--(itemstack, placer, pointed_thing) +function sl.create_slopeplacer_on_place(def, preset) + return function(istack, player, pt) + if not pt.type=="node" then + minetest.chat_send_player(player:get_player_name(), "Can't place: not pointing at node") + return istack + end + local pos=pt.above + if not pos then + minetest.chat_send_player(player:get_player_name(), "Can't place: not pointing at node") + return istack + end + local node=minetest.get_node(pos) + if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].buildable_to then + minetest.chat_send_player(player:get_player_name(), "Can't place: space occupied!") + return istack + end + if minetest.is_protected(pos, player:get_player_name()) then + minetest.chat_send_player(player:get_player_name(), "Can't place: protected position!") + return istack + end + --determine player orientation (only horizontal component) + --get_look_horizontal may not be available + local yaw=player.get_look_horizontal and player:get_look_horizontal() or (player:get_look_yaw() - math.pi/2) + + --rounding unit vectors is a nice way for selecting 1 of 8 directions since sin(30°) is 0.5. + dirvec={x=math.floor(math.sin(-yaw)+0.5), y=0, z=math.floor(math.cos(-yaw)+0.5)} + --translate to direction to look up inside the preset table + local param2, rot45=({ + [-1]={ + [-1]=2, + [0]=3, + [1]=3, + }, + [0]={ + [-1]=2, + [1]=0, + }, + [1]={ + [-1]=1, + [0]=1, + [1]=0, + }, + })[dirvec.x][dirvec.z], dirvec.x~=0 and dirvec.z~=0 + local lookup=preset.slopeplacer + if rot45 then lookup=preset.slopeplacer_45 end + + --go unitvector forward and look how far the next node is + local step=1 + while step<=lookup.max do + local node=minetest.get_node(vector.add(pos, dirvec)) + --next node solid? + if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].buildable_to or minetest.is_protected(pos, player:get_player_name()) then + --do slopes of this distance exist? + if lookup[step] then + if minetest.setting_getbool("creative_mode") or istack:get_count()>=step then + --start placing + local placenodes=lookup[step] + while step>0 do + minetest.set_node(pos, {name=def.nodename_prefix.."_"..placenodes[step], param2=param2}) + if not minetest.setting_getbool("creative_mode") then + istack:take_item() + end + step=step-1 + pos=vector.subtract(pos, dirvec) + end + else + minetest.chat_send_player(player:get_player_name(), "Can't place: Not enough slope items left ("..step.." required)") + end + else + minetest.chat_send_player(player:get_player_name(), "Can't place: There's no slope of length "..step) + end + return istack + end + step=step+1 + pos=vector.add(pos, dirvec) + end + minetest.chat_send_player(player:get_player_name(), "Can't place: no supporting node at upper end.") + return itemstack + end +end + +advtrains.slope=sl + +--END code, BEGIN definition +--definition format: ([] optional) +--[[{ + nodename_prefix + texture_prefix + [shared_texture] + models_prefix + models_suffix (with dot) + [shared_model] + formats={ + st,cr,swlst,swlcr,swrst,swrcr,vst1,vst2 + (each a table with indices 0-3, for if to register a rail with this 'rotation' table entry. nil is assumed as 'all', set {} to not register at all) + } + common={} change something on common rail appearance +}]] + +advtrains.register_tracks("regular", { + nodename_prefix="advtrains:track", + texture_prefix="advtrains_track", + shared_model="trackplane.b3d", + description="Deprecated Track", + formats={vst1={}, vst2={}}, +}, ap.t_45deg) + + +advtrains.register_tracks("default", { + nodename_prefix="advtrains:dtrack", + texture_prefix="advtrains_dtrack", + models_prefix="advtrains_dtrack", + models_suffix=".b3d", + shared_texture="advtrains_dtrack_rail.png", + description="Track", + formats={vst1={true, false, true}, vst2={true, false, true}, vst31={true}, vst32={true}, vst33={true}}, +}, ap.t_30deg) + +--bumpers +advtrains.register_tracks("default", { + nodename_prefix="advtrains:dtrack_bumper", + texture_prefix="advtrains_dtrack_bumper", + models_prefix="advtrains_dtrack_bumper", + models_suffix=".b3d", + shared_texture="advtrains_dtrack_rail.png", + description="Bumper", + formats={}, +}, ap.t_30deg_straightonly) +--legacy bumpers +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, param2=minetest.get_node(pos).param2}) + mesecon.receptor_on(pos, advtrains.meseconrules) + end + } + } + end + }, ap.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, param2=minetest.get_node(pos).param2}) + mesecon.receptor_off(pos, advtrains.meseconrules) + end + } + } + end + }, ap.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 + minetest.register_abm({ + -- In the following two fields, also group:groupname will work. + nodenames = {"advtrains:track_"..name}, + interval = 1.0, -- Operation interval in seconds + chance = 1, -- Chance of trigger per-node per-interval is 1.0 / this + action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:track_"..rep, param2=node.param2}) end, + }) + minetest.register_abm({ + -- In the following two fields, also group:groupname will work. + nodenames = {"advtrains:track_"..name.."_45"}, + interval = 1.0, -- Operation interval in seconds + chance = 1, -- Chance of trigger per-node per-interval is 1.0 / this + action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:track_"..rep.."_45", param2=node.param2}) end, + }) +end + +if advtrains.register_replacement_lbms then +minetest.register_lbm({ + name = "advtrains:ramp_replacement_1", +-- In the following two fields, also group:groupname will work. + nodenames = {"advtrains:track_vert1"}, + action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_vst1", param2=(node.param2+2)%4}) end, +}) +minetest.register_lbm({ + name = "advtrains:ramp_replacement_1", +-- -- In the following two fields, also group:groupname will work. + nodenames = {"advtrains:track_vert2"}, + action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_vst2", param2=(node.param2+2)%4}) end, +}) + minetest.register_abm({ + name = "advtrains:st_rep_1", + -- In the following two fields, also group:groupname will work. + nodenames = {"advtrains:track_st"}, + interval=1, + chance=1, + action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_st", param2=node.param2}) end, + }) + minetest.register_lbm({ + name = "advtrains:st_rep_1", + -- -- In the following two fields, also group:groupname will work. + nodenames = {"advtrains:track_st_45"}, + action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_st_45", param2=node.param2}) end, + }) +end + + + + + + + + diff --git a/advtrains/advtrains/trainhud.lua b/advtrains/advtrains/trainhud.lua new file mode 100644 index 0000000..e69f04a --- /dev/null +++ b/advtrains/advtrains/trainhud.lua @@ -0,0 +1,109 @@ +--trainhud.lua: holds all the code for train controlling + +advtrains.hud = {} + +minetest.register_on_leaveplayer(function(player) +advtrains.hud[player:get_player_name()] = nil +end) + +local mletter={[1]="F", [-1]="R", [0]="N"} + +function advtrains.on_control_change(pc, train, flip) + if pc.sneak then + if pc.up then + train.tarvelocity = train.max_speed or 10 + end + if pc.down then + train.tarvelocity = 0 + end + if pc.left then + train.tarvelocity = 4 + end + if pc.right then + train.tarvelocity = 8 + end + if pc.jump then + train.brake = true + --0: released, 1: brake and pressed, 2: released and brake, 3: pressed and brake + if not train.brake_hold_state or train.brake_hold_state==0 then + train.brake_hold_state = 1 + elseif train.brake_hold_state==2 then + train.brake_hold_state = 3 + end + elseif train.brake_hold_state==1 then + train.brake_hold_state = 2 + elseif train.brake_hold_state==3 then + train.brake = false + train.brake_hold_state = 0 + end + --shift+use:see wagons.lua + else + if pc.up then + train.tarvelocity = train.tarvelocity + 1 + end + if pc.down then + if train.velocity>0 then + train.tarvelocity = math.max(train.tarvelocity - 1, 0) + else + train.movedir = -train.movedir + end + end + if train.brake_hold_state~=2 then + train.brake = false + end + if pc.jump then + train.brake = true + end + if pc.aux1 then + --horn + end + end +end +function advtrains.update_driver_hud(pname, train, flip) + advtrains.set_trainhud(pname, advtrains.hud_train_format(train, flip)) +end +function advtrains.clear_driver_hud(pname) + advtrains.set_trainhud(pname, "") +end + +function advtrains.set_trainhud(name, text) + local hud = advtrains.hud[name] + local player=minetest.get_player_by_name(name) + if not player then + return + end + if not hud then + hud = {} + advtrains.hud[name] = hud + hud.id = player:hud_add({ + hud_elem_type = "text", + name = "ADVTRAINS", + number = 0xFFFFFF, + position = {x=0.5, y=0.7}, + offset = {x=0, y=0}, + text = text, + scale = {x=200, y=60}, + alignment = {x=0, y=0}, + }) + hud.oldText=text + return + elseif hud.oldText ~= text then + player:hud_change(hud.id, "text", text) + hud.oldText=text + end +end +function advtrains.hud_train_format(train, flip) + local fct=flip and -1 or 1 + if not train then return "" end + + local max=train.max_speed or 10 + local vel=advtrains.abs_ceil(train.velocity) + local tvel=advtrains.abs_ceil(train.tarvelocity) + local topLine, firstLine, secondLine + + topLine="Train".." ["..mletter[fct*train.movedir].."] "..(train.brake and "="..( train.brake_hold_state==2 and "^" or "" ).."B=" or "") + firstLine="Speed: |"..string.rep("+", vel)..string.rep("_", max-vel)..">" + secondLine="Target: |"..string.rep("+", tvel)..string.rep("_", max-tvel)..">" + + return topLine.."\n"..firstLine.."\n"..secondLine +end diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua new file mode 100644 index 0000000..eb45500 --- /dev/null +++ b/advtrains/advtrains/trainlogic.lua @@ -0,0 +1,875 @@ +--trainlogic.lua +--controls train entities stuff about connecting/disconnecting/colliding trains and other things + + +local benchmark=false +local bm={} +local bmlt=0 +local bmsteps=0 +local bmstepint=200 +printbm=function(action, ta) + if not benchmark then return end + local t=(os.clock()-ta)*1000 + if not bm[action] then + bm[action]=t + else + bm[action]=bm[action]+t + end + bmlt=bmlt+t +end +function endstep() + if not benchmark then return end + bmsteps=bmsteps-1 + if bmsteps<=0 then + bmsteps=bmstepint + for key, value in pairs(bm) do + minetest.chat_send_all(key.." "..(value/bmstepint).." ms avg.") + end + minetest.chat_send_all("Total time consumed by all advtrains actions per step: "..(bmlt/bmstepint).." ms avg.") + bm={} + bmlt=0 + end +end + +advtrains.train_accel_force=2--per second and divided by number of wagons +advtrains.train_brake_force=3--per second, not divided by number of wagons +advtrains.train_roll_force=0.5--per second, not divided by number of wagons, acceleration when rolling without brake +advtrains.train_emerg_force=10--for emergency brakes(when going off track) + +advtrains.audit_interval=30 + + +advtrains.trains={} +advtrains.wagon_save={} + +--load initially +advtrains.fpath=minetest.get_worldpath().."/advtrains" +local file, err = io.open(advtrains.fpath, "r") +if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed loading advtrains save file "..er) +else + local tbl = minetest.deserialize(file:read("*a")) + if type(tbl) == "table" then + advtrains.trains=tbl + end + file:close() +end +advtrains.fpath_ws=minetest.get_worldpath().."/advtrains_wagon_save" +local file, err = io.open(advtrains.fpath_ws, "r") +if not file then + local er=err or "Unknown Error" + print("[advtrains]Failed loading advtrains save file "..er) +else + local tbl = minetest.deserialize(file:read("*a")) + if type(tbl) == "table" then + advtrains.wagon_save=tbl + end + file:close() +end + + +advtrains.save = function() + --print("[advtrains]saving") + advtrains.invalidate_all_paths() + local datastr = minetest.serialize(advtrains.trains) + if not datastr then + minetest.log("error", "[advtrains] Failed to serialize train data!") + return + end + local file, err = io.open(advtrains.fpath, "w") + if err then + return err + end + file:write(datastr) + file:close() + + -- update wagon saves + for _,wagon in pairs(minetest.luaentities) do + if wagon.is_wagon and wagon.initialized then + wagon:get_staticdata() + end + end + --cross out userdata + for w_id, data in pairs(advtrains.wagon_save) do + data.name=nil + data.object=nil + if data.driver then + data.driver_name=data.driver:get_player_name() + data.driver=nil + else + data.driver_name=nil + end + if data.discouple then + data.discouple.object:remove() + data.discouple=nil + end + end + --print(dump(advtrains.wagon_save)) + datastr = minetest.serialize(advtrains.wagon_save) + if not datastr then + minetest.log("error", "[advtrains] Failed to serialize train data!") + return + end + file, err = io.open(advtrains.fpath_ws, "w") + if err then + return err + end + file:write(datastr) + file:close() + + advtrains.save_trackdb() + advtrains.atc.save() +end +minetest.register_on_shutdown(advtrains.save) + +advtrains.save_and_audit_timer=advtrains.audit_interval +minetest.register_globalstep(function(dtime) + advtrains.save_and_audit_timer=advtrains.save_and_audit_timer-dtime + if advtrains.save_and_audit_timer<=0 then + local t=os.clock() + + --save + advtrains.save() + advtrains.save_and_audit_timer=advtrains.audit_interval + printbm("saving", t) + end + --regular train step + local t=os.clock() + for k,v in pairs(advtrains.trains) do + advtrains.train_step(k, v, dtime) + end + + --see tracks.lua + if advtrains.detector.clean_step_before then + advtrains.detector.finalize_restore() + end + + printbm("trainsteps", t) + endstep() +end) + +function advtrains.train_step(id, train, dtime) + --Legacy: set drives_on and max_speed + if not train.drives_on or not train.max_speed then + advtrains.update_trainpart_properties(id) + end + --TODO check for all vars to be present + if not train.velocity then + train.velocity=0 + end + if not train.movedir or (train.movedir~=1 and train.movedir~=-1) then + train.movedir=1 + end + --very unimportant thing: check if couple is here + if train.couple_eid_front and (not minetest.luaentities[train.couple_eid_front] or not minetest.luaentities[train.couple_eid_front].is_couple) then train.couple_eid_front=nil end + if train.couple_eid_back and (not minetest.luaentities[train.couple_eid_back] or not minetest.luaentities[train.couple_eid_back].is_couple) then train.couple_eid_back=nil end + + --skip certain things (esp. collision) when not moving + local train_moves=(train.velocity~=0) + + --if not train.last_pos then advtrains.trains[id]=nil return end + + if not advtrains.pathpredict(id, train) then + print("pathpredict failed(returned false)") + train.velocity=0 + train.tarvelocity=0 + return + end + + local path=advtrains.get_or_create_path(id, train) + if not path then + train.velocity=0 + train.tarvelocity=0 + print("train has no path for whatever reason") + return + end + + local train_end_index=advtrains.get_train_end_index(train) + --apply off-track handling: + local front_off_track=train.max_index_on_track and train.index>train.max_index_on_track + local back_off_track=train.min_index_on_track and train_end_index1 then train.tarvelocity=1 end + elseif front_off_track then--allow movement only backward + if train.movedir==1 and train.tarvelocity>0 then train.tarvelocity=0 end + if train.movedir==-1 and train.tarvelocity>1 then train.tarvelocity=1 end + elseif back_off_track then--allow movement only forward + if train.movedir==-1 and train.tarvelocity>0 then train.tarvelocity=0 end + if train.movedir==1 and train.tarvelocity>1 then train.tarvelocity=1 end + end + + --update advtrains.detector + if not train.detector_old_index then + train.detector_old_index = math.floor(train_end_index) + train.detector_old_end_index = math.floor(train_end_index) + end + local ifo, ifn, ibo, ibn = train.detector_old_index, math.floor(train.index), train.detector_old_end_index, math.floor(train_end_index) + if ifn>ifo then + for i=ifo, ifn do + if path[i] then + advtrains.detector.enter_node(path[i], id) + end + end + elseif ifnibo then + for i=ibo, ibn do + if path[i] then + advtrains.detector.leave_node(path[i], id) + end + end + end + train.detector_old_index = math.floor(train.index) + train.detector_old_end_index = math.floor(train_end_index) + + --remove? + if #train.trainparts==0 then + print("[advtrains][train "..sid(id).."] has empty trainparts, removing.") + advtrains.detector.leave_node(path[train.detector_old_index], id) + advtrains.trains[id]=nil + return + end + + if train_moves then + --check for collisions by finding objects + + --heh, new collision again. + --this time, based on NODES and the advtrains.detector.on_node table. + local collpos + local coll_grace=1 + if train.movedir==1 then + collpos=advtrains.get_real_index_position(path, train.index-coll_grace) + else + collpos=advtrains.get_real_index_position(path, train_end_index+coll_grace) + end + if collpos then + local rcollpos=advtrains.round_vector_floor_y(collpos) + for x=-1,1 do + for z=-1,1 do + local testpos=vector.add(rcollpos, {x=x, y=0, z=z}) + local testpts=minetest.pos_to_string(testpos) + if advtrains.detector.on_node[testpts] and advtrains.detector.on_node[testpts]~=id then + --collides + advtrains.spawn_couple_on_collide(id, testpos, advtrains.detector.on_node[testpts], train.movedir==-1) + + train.recently_collided_with_env=true + train.velocity=0.5*train.velocity + train.movedir=train.movedir*-1 + train.tarvelocity=0 + + end + end + end + end + end + --check for any trainpart entities if they have been unloaded. do this only if train is near a player, to not spawn entities into unloaded areas + --todo function will be taken by update_trainpart_properties + train.check_trainpartload=(train.check_trainpartload or 0)-dtime + local node_range=(math.max((minetest.setting_get("active_block_range") or 0),1)*16) + if train.check_trainpartload<=0 then + local ori_pos=advtrains.get_real_index_position(path, train.index) --not much to calculate + --print("[advtrains][train "..id.."] at "..minetest.pos_to_string(vector.round(ori_pos))) + + local should_check=false + for _,p in ipairs(minetest.get_connected_players()) do + should_check=should_check or ((vector.distance(ori_pos, p:getpos())=train.velocity then + train.atc_brake_target=nil + end + if train.atc_wait_finish then + if not train.atc_brake_target and train.velocity==train.tarvelocity then + train.atc_wait_finish=nil + end + end + if train.atc_command then + if train.atc_delay<=0 and not train.atc_wait_finish then + advtrains.atc.execute_atc_command(id, train) + else + train.atc_delay=train.atc_delay-dtime + end + end + + --make brake adjust the tarvelocity if necessary + if train.brake and (math.ceil(train.velocity)-1)0 then--accelerating, force will be brought on only by locomotives. + --print("accelerating with default force") + applydiff=(math.min((advtrains.train_accel_force*train.locomotives_in_train*dtime)/mass, math.abs(diff))) + else--decelerating + if front_off_track or back_off_track or train.recently_collided_with_env then --every wagon has a brake, so not divided by mass. + --print("braking with emergency force") + applydiff= -(math.min((advtrains.train_emerg_force*dtime), math.abs(diff))) + elseif train.brake or (train.atc_brake_target and train.atc_brake_target0 then + if train.movedir>0 then + pregen_front=2+math.ceil(train.velocity*0.15) --assumes server step of 0.1 seconds, +50% tolerance + else + pregen_back=2+math.ceil(train.velocity*0.15) + end + end + + + local maxn=advtrains.maxN(train.path) + while (maxn-train.index) < pregen_front do--pregenerate + --print("[advtrains]maxn conway for ",maxn,minetest.pos_to_string(path[maxn]),maxn-1,minetest.pos_to_string(path[maxn-1])) + local conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.drives_on) + if conway then + train.path[maxn+1]=conway + train.max_index_on_track=maxn + else + --do as if nothing has happened and preceed with path + --but do not update max_index_on_track + --print("over-generating path max to index "..maxn+1) + train.path[maxn+1]=vector.add(train.path[maxn], vector.subtract(train.path[maxn], train.path[maxn-1])) + end + train.path_dist[maxn]=vector.distance(train.path[maxn+1], train.path[maxn]) + maxn=advtrains.maxN(train.path) + end + + local minn=advtrains.minN(train.path) + while (train.index-minn) < (train.trainlen or 0) + pregen_back do --post_generate. has to be at least trainlen. (we let go of the exact calculation here since this would be unuseful here) + --print("[advtrains]minn conway for ",minn,minetest.pos_to_string(path[minn]),minn+1,minetest.pos_to_string(path[minn+1])) + local conway=advtrains.conway(train.path[minn], train.path[minn+1], train.drives_on) + if conway then + train.path[minn-1]=conway + train.min_index_on_track=minn + else + --do as if nothing has happened and preceed with path + --but do not update min_index_on_track + --print("over-generating path min to index "..minn-1) + train.path[minn-1]=vector.add(train.path[minn], vector.subtract(train.path[minn], train.path[minn+1])) + end + train.path_dist[minn-1]=vector.distance(train.path[minn], train.path[minn-1]) + minn=advtrains.minN(train.path) + end + if not train.min_index_on_track then train.min_index_on_track=0 end + if not train.max_index_on_track then train.max_index_on_track=0 end + + --make pos/yaw available for possible recover calls + if train.max_index_on_tracktrain.index then --whoops, train went even more far. same behavior + train.savedpos_off_track_index_offset=train.index-train.min_index_on_track + train.last_pos=train.path[train.min_index_on_track+1] + train.last_pos_prev=train.path[train.min_index_on_track] + --print("train is off-track (back), last positions kept at "..minetest.pos_to_string(train.last_pos).." / "..minetest.pos_to_string(train.last_pos_prev)) + else --regular case + train.savedpos_off_track_index_offset=nil + train.last_pos=train.path[math.floor(train.index+0.5)] + train.last_pos_prev=train.path[math.floor(train.index-0.5)] + end + return train.path +end +function advtrains.get_train_end_index(train) + return advtrains.get_real_path_index(train, train.trainlen or 2)--this function can be found inside wagons.lua since it's more related to wagons. we just set trainlen as pos_in_train +end + +function advtrains.get_or_create_path(id, train) + if not train.path then return advtrains.pathpredict(id, train) end + return train.path +end + +function advtrains.add_wagon_to_train(wagon, train_id, index) + local train=advtrains.trains[train_id] + if index then + table.insert(train.trainparts, index, wagon.unique_id) + else + table.insert(train.trainparts, wagon.unique_id) + end + --this is not the usual case!!! + --we may set initialized because the wagon has no chance to step() + wagon.initialized=true + --TODO is this art or can we throw it away? + advtrains.update_trainpart_properties(train_id) +end +function advtrains.update_trainpart_properties(train_id, invert_flipstate) + local train=advtrains.trains[train_id] + train.drives_on=advtrains.all_tracktypes + train.max_speed=100 + local rel_pos=0 + local count_l=0 + for i, w_id in ipairs(train.trainparts) do + local wagon=nil + for _,iwagon in pairs(minetest.luaentities) do + if iwagon.is_wagon and iwagon.initialized and iwagon.unique_id==w_id then + if wagon then + --duplicate + iwagon.object:remove() + else + wagon=iwagon + end + end + end + if not wagon then + if advtrains.wagon_save[w_id] then + --spawn a new and initialize it with the properties from wagon_save + wagon=minetest.env:add_entity(train.last_pos, advtrains.wagon_save[w_id].entity_name):get_luaentity() + wagon:init_from_wagon_save(w_id) + end + end + if wagon then + rel_pos=rel_pos+wagon.wagon_span + wagon.train_id=train_id + wagon.pos_in_train=rel_pos + wagon.pos_in_trainparts=i + wagon.old_velocity_vector=nil + if wagon.is_locomotive then + count_l=count_l+1 + end + if invert_flipstate then + wagon.wagon_flipped = not wagon.wagon_flipped + end + rel_pos=rel_pos+wagon.wagon_span + any_loaded=true + + if wagon.drives_on then + for k,_ in pairs(train.drives_on) do + if not wagon.drives_on[k] then + train.drives_on[k]=nil + end + end + end + train.max_speed=math.min(train.max_speed, wagon.max_speed) + else + print(w_id.." not loaded and no save available") + --what the hell... + table.remove(train.trainparts, pit) + end + end + train.trainlen=rel_pos + train.locomotives_in_train=count_l +end + +function advtrains.split_train_at_wagon(wagon) + --get train + local train=advtrains.trains[wagon.train_id] + local real_pos_in_train=advtrains.get_real_path_index(train, wagon.pos_in_train) + local pos_for_new_train=advtrains.get_or_create_path(wagon.train_id, train)[math.floor(real_pos_in_train+wagon.wagon_span)] + local pos_for_new_train_prev=advtrains.get_or_create_path(wagon.train_id, train)[math.floor(real_pos_in_train-1+wagon.wagon_span)] + + --before doing anything, check if both are rails. else do not allow + if not pos_for_new_train then + print("split_train: pos_for_new_train not set") + return false + end + local node_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.drives_on) + if not node_ok then + print("split_train: pos_for_new_train "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") + return false + end + + if not train.last_pos_prev then + print("split_train: pos_for_new_train_prev not set") + return false + end + + local prevnode_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.drives_on) + if not prevnode_ok then + print("split_train: pos_for_new_train_prev "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") + return false + end + + --create subtrain + local newtrain_id=advtrains.create_new_train_at(pos_for_new_train, pos_for_new_train_prev) + local newtrain=advtrains.trains[newtrain_id] + --insert all wagons to new train + for k,v in ipairs(train.trainparts) do + if k>=wagon.pos_in_trainparts then + table.insert(newtrain.trainparts, v) + train.trainparts[k]=nil + end + end + --update train parts + advtrains.update_trainpart_properties(wagon.train_id)--atm it still is the desierd id. + advtrains.update_trainpart_properties(newtrain_id) + train.tarvelocity=0 + newtrain.velocity=train.velocity + newtrain.tarvelocity=0 +end + +--there are 4 cases: +--1/2. F<->R F<->R regular, put second train behind first +--->frontpos of first train will match backpos of second +--3. F<->R R<->F flip one of these trains, take the other as new train +--->backpos's will match +--4. R<->F F<->R flip one of these trains and take it as new parent +--->frontpos's will match + +--true when trains are facing each other. needed on colliding. +-- check done by iterating paths and checking their direction +--returns nil when not on the same track at all OR when required path items are not generated. this distinction may not always be needed. +function advtrains.trains_facing(train1, train2) + local sr_pos=train1.path[math.floor(train1.index)] + local sr_pos_p=train1.path[math.floor(train1.index)-1] + + for i=advtrains.minN(train2.path), advtrains.maxN(train2.path) do + if vector.equals(sr_pos, train2.path[i]) then + if train2.path[i+1] and vector.equals(sr_pos_p, train2.path[i+1]) then return true end + if train2.path[i-1] and vector.equals(sr_pos_p, train2.path[i-1]) then return false end + return nil + end + end + return nil +end + +function advtrains.spawn_couple_on_collide(id1, pos, id2, t1_is_backpos) + print("COLLISION: "..sid(id1).." and "..sid(id2).." at "..minetest.pos_to_string(pos)..", t1_is_backpos="..(t1_is_backpos and "true" or "false")) + --TODO: + local train1=advtrains.trains[id1] + local train2=advtrains.trains[id2] + + local found + for i=advtrains.minN(train1.path), advtrains.maxN(train1.path) do + if vector.equals(train1.path[i], pos) then + found=true + end + end + if not found then + print("Err: pos not in path") + return + end + + local frontpos2=train2.path[math.floor(train2.detector_old_index)] + local backpos2=train2.path[math.floor(train2.detector_old_end_index)] + local t2_is_backpos + print("End positions: "..minetest.pos_to_string(frontpos2)..minetest.pos_to_string(backpos2)) + + if vector.equals(frontpos2, pos) then + t2_is_backpos=false + elseif vector.equals(backpos2, pos) then + t2_is_backpos=true + else + print("Err: not a endpos") + return --the collision position is not the end position. + end + print("t2_is_backpos="..(t2_is_backpos and "true" or "false")) + + local t1_has_couple + if t1_is_backpos then + t1_has_couple=train1.couple_eid_back + else + t1_has_couple=train1.couple_eid_front + end + local t2_has_couple + if t2_is_backpos then + t2_has_couple=train2.couple_eid_back + else + t2_has_couple=train2.couple_eid_front + end + + if t1_has_couple then + if minetest.object_refs[t1_has_couple] then minetest.object_refs[t1_has_couple]:remove() end + end + if t2_has_couple then + if minetest.object_refs[t2_has_couple] then minetest.object_refs[t2_has_couple]:remove() end + end + local obj=minetest.add_entity(pos, "advtrains:couple") + if not obj then print("failed creating object") return end + local le=obj:get_luaentity() + le.train_id_1=id1 + le.train_id_2=id2 + le.train1_is_backpos=t1_is_backpos + le.train2_is_backpos=t2_is_backpos + --find in object_refs + for aoi, compare in pairs(minetest.object_refs) do + if compare==obj then + if t1_is_backpos then + train1.couple_eid_back=aoi + else + train1.couple_eid_front=aoi + end + if t2_is_backpos then + train2.couple_eid_back=aoi + else + train2.couple_eid_front=aoi + end + end + end + print("Couple entity:"..dump(le)) + + --also TODO: integrate check_trainpartload into update_trainpart_properties. +end +--order of trains may be irrelevant in some cases. check opposite cases. TODO does this work? +--pos1 and pos2 are just needed to form a median. + + +function advtrains.do_connect_trains(first_id, second_id) + local first_wagoncnt=#advtrains.trains[first_id].trainparts + local second_wagoncnt=#advtrains.trains[second_id].trainparts + + for _,v in ipairs(advtrains.trains[second_id].trainparts) do + table.insert(advtrains.trains[first_id].trainparts, v) + end + --kick it like physics (with mass being #wagons) + local new_velocity=((advtrains.trains[first_id].velocity*first_wagoncnt)+(advtrains.trains[second_id].velocity*second_wagoncnt))/(first_wagoncnt+second_wagoncnt) + advtrains.trains[second_id]=nil + advtrains.update_trainpart_properties(first_id) + advtrains.trains[first_id].velocity=new_velocity + advtrains.trains[first_id].tarvelocity=0 +end + +function advtrains.invert_train(train_id) + local train=advtrains.trains[train_id] + + local old_path=advtrains.get_or_create_path(train_id, train) + train.path={} + train.index= - advtrains.get_train_end_index(train) + train.velocity=-train.velocity + train.tarvelocity=-train.tarvelocity + for k,v in pairs(old_path) do + train.path[-k]=v + end + local old_trainparts=train.trainparts + train.trainparts={} + for k,v in ipairs(old_trainparts) do + table.insert(train.trainparts, 1, v)--notice insertion at first place + end + advtrains.update_trainpart_properties(train_id, true) +end + +function advtrains.is_train_at_pos(pos) + --print("istrainat: pos "..minetest.pos_to_string(pos)) + local checked_trains={} + local objrefs=minetest.get_objects_inside_radius(pos, 2) + for _,v in pairs(objrefs) do + local le=v:get_luaentity() + if le and le.is_wagon and le.initialized and le.train_id and not checked_trains[le.train_id] then + --print("istrainat: checking "..le.train_id) + checked_trains[le.train_id]=true + local path=advtrains.get_or_create_path(le.train_id, le:train()) + if path then + --print("has path") + for i=math.floor(advtrains.get_train_end_index(le:train())+0.5),math.floor(le:train().index+0.5) do + if path[i] then + --print("has pathitem "..i.." "..minetest.pos_to_string(path[i])) + if vector.equals(advtrains.round_vector_floor_y(path[i]), pos) then + return true + end + end + end + end + end + end + return false +end +function advtrains.invalidate_all_paths() + --print("invalidating all paths") + for k,v in pairs(advtrains.trains) do + if v.index then + v.restore_add_index=v.index-math.floor(v.index+0.5) + end + v.path=nil + v.path_dist=nil + v.index=nil + v.min_index_on_track=nil + v.max_index_on_track=nil + + advtrains.detector.setup_restore() + v.detector_old_index=nil + v.detector_old_end_index=nil + end +end + +--not blocking trains group +function advtrains.train_collides(node) + if node and minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].walkable then + if not minetest.registered_nodes[node.name].groups.not_blocking_trains then + return true + end + end + return false +end + +local nonblocknodes={ + "default:fence_wood", + "default:fence_acacia_wood", + "default:fence_aspen_wood", + "default:fence_pine_wood", + "default:fence_junglewood", + "default:torch", + + "default:sign_wall", + "signs:sign_wall", + "signs:sign_wall_blue", + "signs:sign_wall_brown", + "signs:sign_wall_orange", + "signs:sign_wall_green", + "signs:sign_yard", + "signs:sign_wall_white_black", + "signs:sign_wall_red", + "signs:sign_wall_white_red", + "signs:sign_wall_yellow", + "signs:sign_post", + "signs:sign_hanging", + + +} +minetest.after(0, function() + for _,name in ipairs(nonblocknodes) do + if minetest.registered_nodes[name] then + minetest.registered_nodes[name].groups.not_blocking_trains=1 + end + end +end) diff --git a/advtrains/advtrains/wagons.lua b/advtrains/advtrains/wagons.lua new file mode 100644 index 0000000..495f914 --- /dev/null +++ b/advtrains/advtrains/wagons.lua @@ -0,0 +1,573 @@ +--atan2 counts angles clockwise, minetest does counterclockwise +--local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end +local print=function() end + +local wagon={ + collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, + --physical = true, + visual = "mesh", + mesh = "wagon.b3d", + visual_size = {x=3, y=3}, + textures = {"black.png"}, + is_wagon=true, + wagon_span=1,--how many index units of space does this wagon consume + has_inventory=false, +} + + + +function wagon:on_rightclick(clicker) + if not self:ensure_init() then return end + if not clicker or not clicker:is_player() then + return + end + if clicker:get_player_control().aux1 then + --advtrains.dumppath(self:train().path) + --minetest.chat_send_all("at index "..(self:train().index or "nil")) + --advtrains.invert_train(self.train_id) + minetest.chat_send_all(dump(self:train())) + return + end + local no=self:get_seatno(clicker:get_player_name()) + if no then + self:get_off(no) + else + self:show_get_on_form(clicker:get_player_name()) + end +end + +function wagon:train() + return advtrains.trains[self.train_id] +end + +--[[about 'initalized': + when initialized is false, the entity hasn't got any data yet and should wait for these to be set before doing anything + when loading an existing object (with staticdata), it will be set + when instanciating a new object via add_entity, it is not set at the time on_activate is called. + then, wagon:initialize() will be called + + wagon will save only uid in staticdata, no serialized table +]] +function wagon:on_activate(sd_uid, dtime_s) + print("[advtrains][wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] activated") + self.object:set_armor_groups({immortal=1}) + if sd_uid and sd_uid~="" then + --legacy + --expect this to be a serialized table and handle + if minetest.deserialize(sd_uid) then + self:init_from_wagon_save(minetest.deserialize(sd_uid).unique_id) + else + self:init_from_wagon_save(sd_uid) + end + end + self.entity_name=self.name + + --duplicates? + for ao_id,wagon in pairs(minetest.luaentities) do + if wagon.is_wagon and wagon.initialized and wagon.unique_id==self.unique_id and wagon~=self then--i am a duplicate! + print("[advtrains][wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] duplicate found(ao_id:"..ao_id.."), removing") + self.object:remove() + minetest.after(0.5, function() advtrains.update_trainpart_properties(self.train_id) end) + return + end + end + + if self.custom_on_activate then + self:custom_on_activate(dtime_s) + end +end + +function wagon:get_staticdata() + if not self:ensure_init() then return end + print("[advtrains][wagon "..((self.unique_id and self.unique_id~="" and self.unique_id) or "no-id").."]: saving to wagon_save") + --serialize inventory, if it has one + if self.has_inventory then + local inv=minetest.get_inventory({type="detached", name="advtrains_wgn_"..self.unique_id}) + self.ser_inv=advtrains.serialize_inventory(inv) + end + --save to table before being unloaded + advtrains.wagon_save[self.unique_id]=advtrains.merge_tables(self) + advtrains.wagon_save[self.unique_id].entity_name=self.name + advtrains.wagon_save[self.unique_id].name=nil + advtrains.wagon_save[self.unique_id].object=nil + return self.unique_id +end +--returns: uid of wagon +function wagon:init_new_instance(train_id, properties) + self.unique_id=os.time()..os.clock() + self.train_id=train_id + for k,v in pairs(properties) do + if k~="name" and k~="object" then + self[k]=v + end + end + self:init_shared() + self.initialized=true + print("init_new_instance "..self.unique_id.." ("..self.train_id..")") + return self.unique_id +end +function wagon:init_from_wagon_save(uid) + if not advtrains.wagon_save[uid] then + self.object:remove() + return + end + self.unique_id=uid + for k,v in pairs(advtrains.wagon_save[uid]) do + if k~="name" and k~="object" then + self[k]=v + end + end + if not self.train_id or not self:train() then + self.object:remove() + return + end + self:init_shared() + self.initialized=true + minetest.after(1, function() self:reattach_all() end) + print("init_from_wagon_save "..self.unique_id.." ("..self.train_id..")") + advtrains.update_trainpart_properties(self.train_id) +end +function wagon:init_shared() + if self.has_inventory then + local uid_noptr=self.unique_id.."" + --to be used later + local inv=minetest.create_detached_inventory("advtrains_wgn_"..self.unique_id, { + allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) + return count + end, + allow_put = function(inv, listname, index, stack, player) + return stack:get_count() + end, + allow_take = function(inv, listname, index, stack, player) + return stack:get_count() + end + }) + if self.ser_inv then + advtrains.deserialize_inventory(self.ser_inv, inv) + end + if self.inventory_list_sizes then + for lst, siz in pairs(self.inventory_list_sizes) do + inv:set_size(lst, siz) + end + end + end +end +function wagon:ensure_init() + if self.initialized then return true end + self.object:setvelocity({x=0,y=0,z=0}) + return false +end + +-- Remove the wagon +function wagon:on_punch(puncher, time_from_last_punch, tool_capabilities, direction) + if not self:ensure_init() then return end + if not puncher or not puncher:is_player() then + return + end + if self.owner and puncher:get_player_name()~=self.owner then + minetest.chat_send_player(puncher:get_player_name(), "This wagon is owned by "..self.owner..", you can't destroy it.") + return + end + + if minetest.setting_getbool("creative_mode") then + if not self:destroy() then return end + + local inv = puncher:get_inventory() + if not inv:contains_item("main", self.name) then + inv:add_item("main", self.name) + end + else + local pc=puncher:get_player_control() + if not pc.sneak then + minetest.chat_send_player(puncher:get_player_name(), "Warning: If you destroy this wagon, you only get some steel back! If you are sure, shift-leftclick the wagon.") + return + end + + if not self:destroy() then return end + + local inv = puncher:get_inventory() + for _,item in ipairs(self.drops or {self.name}) do + inv:add_item("main", item) + end + end +end +function wagon:destroy() + --some rules: + -- you get only some items back + -- single left-click shows warning + -- shift leftclick destroys + -- not when a driver is inside + + for _,_ in pairs(self.seatp) do + return + end + + if self.custom_may_destroy then + if not self.custom_may_destroy(self, puncher, time_from_last_punch, tool_capabilities, direction) then + return + end + end + if self.custom_on_destroy then + self.custom_on_destroy(self, puncher, time_from_last_punch, tool_capabilities, direction) + end + + print("[advtrains][wagon "..((self.unique_id and self.unique_id~="" and self.unique_id) or "no-id").."]: destroying") + + self.object:remove() + + table.remove(self:train().trainparts, self.pos_in_trainparts) + advtrains.update_trainpart_properties(self.train_id) + advtrains.wagon_save[self.unique_id]=nil + if self.discouple then self.discouple.object:remove() end--will have no effect on unloaded objects + return true +end + + +function wagon:on_step(dtime) + if not self:ensure_init() then return end + + local t=os.clock() + local pos = self.object:getpos() + + if not pos then + print("["..self.unique_id.."][fatal] missing position (object:getpos() returned nil)") + return + end + + self.entity_name=self.name + + --is my train still here + if not self.train_id or not self:train() then + print("[advtrains][wagon "..self.unique_id.."] missing train_id, destroying") + self.object:remove() + return + elseif not self.initialized then + self.initialized=true + end + if not self.seatp then + self.seatp={} + end + + --custom on_step function + if self.custom_on_step then + self:custom_on_step(self, dtime) + end + + --driver control + for seatno, seat in ipairs(self.seats) do + if seat.driving_ctrl_access then + local driver=self.seatp[seatno] and minetest.get_player_by_name(self.seatp[seatno]) + local get_off_pressed=false + if driver and driver:get_player_control_bits()~=self.old_player_control_bits then + local pc=driver:get_player_control() + + advtrains.on_control_change(pc, self:train(), self.wagon_flipped) + if pc.aux1 and pc.sneak then + get_off_pressed=true + end + + self.old_player_control_bits=driver:get_player_control_bits() + end + if driver then + if get_off_pressed then + self:get_off(seatno) + else + advtrains.update_driver_hud(driver:get_player_name(), self:train(), self.wagon_flipped) + end + end + end + end + + local gp=self:train() + + --DisCouple + if self.pos_in_trainparts and self.pos_in_trainparts>1 then + if gp.velocity==0 then + if not self.discouple or not self.discouple.object:getyaw() then + local object=minetest.add_entity(pos, "advtrains:discouple") + if object then + local le=object:get_luaentity() + le.wagon=self + --box is hidden when attached, so unuseful. + --object:set_attach(self.object, "", {x=0, y=0, z=self.wagon_span*10}, {x=0, y=0, z=0}) + self.discouple=le + else + print("Couldn't spawn DisCouple") + end + end + else + if self.discouple and self.discouple.object:getyaw() then + self.discouple.object:remove() + end + end + end + --for path to be available. if not, skip step + if not advtrains.get_or_create_path(self.train_id, gp) then + self.object:setvelocity({x=0, y=0, z=0}) + return + end + if not self.pos_in_train then + --why ever. but better continue next step... + advtrains.update_trainpart_properties(self.train_id) + return + end + + local index=advtrains.get_real_path_index(self:train(), self.pos_in_train) + --print("trainindex "..gp.index.." wagonindex "..index) + + --position recalculation + local first_pos=gp.path[math.floor(index)] + local second_pos=gp.path[math.floor(index)+1] + if not first_pos or not second_pos then + --print("[advtrains] object "..self.unique_id.." path end reached!") + self.object:setvelocity({x=0,y=0,z=0}) + return + end + + --checking for environment collisions(a 3x3 cube around the center) + if not gp.recently_collided_with_env then + local collides=false + for x=-1,1 do + for y=0,2 do + for z=-1,1 do + local node=minetest.get_node_or_nil(vector.add(first_pos, {x=x, y=y, z=z})) + if (advtrains.train_collides(node)) then + collides=true + end + end + end + end + if collides then + gp.recently_collided_with_env=true + gp.velocity=-0.5*gp.velocity + gp.tarvelocity=0 + end + end + + --FIX: use index of the wagon, not of the train. + local velocity=(gp.velocity*gp.movedir)/(gp.path_dist[math.floor(index)] or 1) + local acceleration=(gp.last_accel or 0)/(gp.path_dist[math.floor(index)] or 1) + local factor=index-math.floor(index) + local actual_pos={x=first_pos.x-(first_pos.x-second_pos.x)*factor, y=first_pos.y-(first_pos.y-second_pos.y)*factor, z=first_pos.z-(first_pos.z-second_pos.z)*factor,} + local velocityvec={x=(first_pos.x-second_pos.x)*velocity*-1, z=(first_pos.z-second_pos.z)*velocity*-1, y=(first_pos.y-second_pos.y)*velocity*-1} + local accelerationvec={x=(first_pos.x-second_pos.x)*acceleration*-1, z=(first_pos.z-second_pos.z)*acceleration*-1, y=(first_pos.y-second_pos.y)*acceleration*-1} + + --some additional positions to determine orientation + local aposfwd=gp.path[math.floor(index+2)] + local aposbwd=gp.path[math.floor(index-1)] + + local yaw + if aposfwd and aposbwd then + yaw=advtrains.get_wagon_yaw(aposfwd, second_pos, first_pos, aposbwd, factor)+math.pi--TODO remove when cleaning up + else + yaw=math.atan2((first_pos.x-second_pos.x), (second_pos.z-first_pos.z)) + end + if self.wagon_flipped then + yaw=yaw+math.pi + end + + self.updatepct_timer=(self.updatepct_timer or 0)-dtime + if not self.old_velocity_vector + or not vector.equals(velocityvec, self.old_velocity_vector) + or not self.old_acceleration_vector + or not vector.equals(accelerationvec, self.old_acceleration_vector) + or self.old_yaw~=yaw + or self.updatepct_timer<=0 then--only send update packet if something changed + self.object:setpos(actual_pos) + self.object:setvelocity(velocityvec) + self.object:setacceleration(accelerationvec) + self.object:setyaw(yaw) + self.updatepct_timer=2 + if self.update_animation then + self:update_animation(gp.velocity) + end + end + + + self.old_velocity_vector=velocityvec + self.old_acceleration_vector=accelerationvec + self.old_yaw=yaw + printbm("wagon step", t) +end + +function advtrains.get_real_path_index(train, pit) + local pos_in_train_left=pit + local index=train.index + if pos_in_train_left>(index-math.floor(index))*(train.path_dist[math.floor(index)] or 1) then + pos_in_train_left=pos_in_train_left - (index-math.floor(index))*(train.path_dist[math.floor(index)] or 1) + index=math.floor(index) + while pos_in_train_left>(train.path_dist[index-1] or 1) do + pos_in_train_left=pos_in_train_left - (train.path_dist[index-1] or 1) + index=index-1 + end + index=index-(pos_in_train_left/(train.path_dist[index-1] or 1)) + else + index=index-(pos_in_train_left/(train.path_dist[math.floor(index-1)] or 1)) + end + return index +end + +function wagon:get_on(clicker, seatno) + if not self.seatp then + self.seatp={} + end + if not self.seats[seatno] then return end + if self.seatp[seatno] and self.seatp[seatno]~=clicker:get_player_name() then + self:get_off(seatno) + end + self.seatp[seatno] = clicker:get_player_name() + advtrains.player_to_train_mapping[clicker:get_player_name()]=self.train_id + clicker:set_attach(self.object, "", self.seats[seatno].attach_offset, {x=0,y=0,z=0}) + clicker:set_eye_offset(self.seats[seatno].view_offset, self.seats[seatno].view_offset) +end +function wagon:get_off_plr(pname) + local no=self:get_seatno(pname) + if no then + self:get_off(no) + end +end +function wagon:get_seatno(pname) + for no, cont in pairs(self.seatp) do + if cont==pname then + return no + end + end + return nil +end +function wagon:get_off(seatno) + if not self.seatp[seatno] then return end + local pname = self.seatp[seatno] + local clicker = minetest.get_player_by_name(pname) + advtrains.player_to_train_mapping[pname]=nil + advtrains.clear_driver_hud(pname) + if clicker then + clicker:set_detach() + clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0}) + local objpos=advtrains.round_vector_floor_y(self.object:getpos()) + local yaw=self.object:getyaw() + local isx=(yaw < math.pi/4) or (yaw > 3*math.pi/4 and yaw < 5*math.pi/4) or (yaw > 7*math.pi/4) + --abuse helper function + for _,r in ipairs({-1, 1}) do + local p=vector.add({x=isx and r or 0, y=0, z=not isx and r or 0}, objpos) + if minetest.get_item_group(minetest.get_node(p).name, "platform")>0 then + minetest.after(0.2, function() clicker:setpos({x=p.x, y=p.y+1, z=p.z}) end) + end + end + end + self.seatp[seatno]=nil +end +function wagon:show_get_on_form(pname) + if not self.initialized then return end + if #self.seats==0 then + if self.has_inventory and self.get_inventory_formspec then + minetest.show_formspec(pname, "advtrains_inv_"..self.unique_id, self:get_inventory_formspec(pname)) + end + return + end + local form, comma="size[5,8]label[0.5,0.5;Select seat:]textlist[0.5,1;4,6;seat;", "" + for seatno, seattbl in ipairs(self.seats) do + local addtext, colorcode="", "" + if self.seatp and self.seatp[seatno] then + colorcode="#FF0000" + addtext=" ("..self.seatp[seatno]..")" + end + form=form..comma..colorcode..seattbl.name..addtext + comma="," + end + form=form..";0,false]" + if self.has_inventory and self.get_inventory_formspec then + form=form.."button_exit[1,7;3,1;inv;Show Inventory]" + end + minetest.show_formspec(pname, "advtrains_geton_"..self.unique_id, form) +end +minetest.register_on_player_receive_fields(function(player, formname, fields) + local uid=string.match(formname, "^advtrains_geton_(.+)$") + if uid then + for _,wagon in pairs(minetest.luaentities) do + if wagon.is_wagon and wagon.initialized and wagon.unique_id==uid then + if fields.inv then + if wagon.has_inventory and wagon.get_inventory_formspec then + minetest.show_formspec(player:get_player_name(), "advtrains_inv_"..uid, wagon:get_inventory_formspec(player:get_player_name())) + end + elseif fields.seat then + local val=minetest.explode_textlist_event(fields.seat) + if val and val.type~="INV" and not wagon.seatp[player:get_player_name()] then + --get on + wagon:get_on(player, val.index) + --will work with the new close_formspec functionality. close exactly this formspec. + minetest.show_formspec(player:get_player_name(), formname, "") + end + end + end + end + end +end) +function wagon:reattach_all() + if not self.seatp then self.seatp={} end + for seatno, pname in pairs(self.seatp) do + local p=minetest.get_player_by_name(pname) + if p then + self:get_on(p ,seatno) + end + end +end +minetest.register_on_joinplayer(function(player) + for _,wagon in pairs(minetest.luaentities) do + if wagon.is_wagon and wagon.initialized then + wagon:reattach_all() + end + end +end) + +function advtrains.register_wagon(sysname, prototype, desc, inv_img) + setmetatable(prototype, {__index=wagon}) + minetest.register_entity(":advtrains:"..sysname,prototype) + + minetest.register_craftitem(":advtrains:"..sysname, { + description = desc, + inventory_image = inv_img, + wield_image = inv_img, + stack_max = 1, + + on_place = function(itemstack, placer, pointed_thing) + if not pointed_thing.type == "node" then + return + end + + local node=minetest.env:get_node_or_nil(pointed_thing.under) + if not node then print("[advtrains]Ignore at placer position") return itemstack end + local nodename=node.name + if(not advtrains.is_track_and_drives_on(nodename, prototype.drives_on)) then + print("[advtrains]no track here, not placing.") + return itemstack + end + local conn1=advtrains.get_track_connections(node.name, node.param2) + local id=advtrains.create_new_train_at(pointed_thing.under, advtrains.dirCoordSet(pointed_thing.under, conn1)) + + local ob=minetest.env:add_entity(pointed_thing.under, "advtrains:"..sysname) + if not ob then + print("[advtrains]couldn't add_entity, aborting") + end + local le=ob:get_luaentity() + + le.owner=placer:get_player_name() + le.infotext=desc..", owned by "..placer:get_player_name() + + local wagon_uid=le:init_new_instance(id, {}) + + advtrains.add_wagon_to_train(le, id) + if not minetest.setting_getbool("creative_mode") then + itemstack:take_item() + end + return itemstack + + end, + }) +end + +--[[ + wagons can define update_animation(self, velocity) if they have a speed-dependent animation + this function will be called when the velocity vector changes or every 2 seconds. +]] + + diff --git a/advtrains/advtrains_train_industrial/depends.txt b/advtrains/advtrains_train_industrial/depends.txt new file mode 100644 index 0000000..6f00bf6 --- /dev/null +++ b/advtrains/advtrains_train_industrial/depends.txt @@ -0,0 +1 @@ +advtrains \ No newline at end of file diff --git a/advtrains/advtrains_train_industrial/init.lua b/advtrains/advtrains_train_industrial/init.lua new file mode 100644 index 0000000..379832c --- /dev/null +++ b/advtrains/advtrains_train_industrial/init.lua @@ -0,0 +1,67 @@ +advtrains.register_wagon("engine_industrial", { + mesh="advtrains_engine_industrial.b3d", + textures = {"advtrains_engine_industrial.png"}, + drives_on={default=true}, + max_speed=20, + seats = { + { + name="Driver Stand (left)", + attach_offset={x=-5, y=10, z=-10}, + view_offset={x=0, y=10, z=0}, + driving_ctrl_access=true, + }, + { + name="Driver Stand (right)", + attach_offset={x=5, y=10, z=-10}, + view_offset={x=0, y=10, z=0}, + driving_ctrl_access=true, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=2.6, + is_locomotive=true, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, +}, "Industrial Train Engine", "advtrains_engine_industrial_inv.png") +advtrains.register_wagon("wagon_tank", { + mesh="advtrains_wagon_tank.b3d", + textures = {"advtrains_wagon_tank.png"}, + seats = {}, + drives_on={default=true}, + max_speed=20, + visual_size = {x=1, y=1}, + wagon_span=2.2, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, + has_inventory = true, + get_inventory_formspec = function(self) + return "size[8,11]".. + "list[detached:advtrains_wgn_"..self.unique_id..";box;0,0;8,6;]".. + "list[current_player;main;0,7;8,4;]".. + "listring[]" + end, + inventory_list_sizes = { + box=8*6, + }, +}, "Industrial tank wagon", "advtrains_wagon_tank_inv.png") +advtrains.register_wagon("wagon_wood", { + mesh="advtrains_wagon_wood.b3d", + textures = {"advtrains_wagon_wood.png"}, + seats = {}, + drives_on={default=true}, + max_speed=20, + visual_size = {x=1, y=1}, + wagon_span=1.8, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, + has_inventory = true, + get_inventory_formspec = function(self) + return "size[8,11]".. + "list[detached:advtrains_wgn_"..self.unique_id..";box;0,0;8,6;]".. + "list[current_player;main;0,7;8,4;]".. + "listring[]" + end, + inventory_list_sizes = { + box=8*6, + }, +}, "Industrial wood wagon", "advtrains_wagon_wood_inv.png") diff --git a/advtrains/advtrains_train_industrial/models/advtrains_engine_industrial.b3d b/advtrains/advtrains_train_industrial/models/advtrains_engine_industrial.b3d new file mode 100644 index 0000000..f1ea485 Binary files /dev/null and b/advtrains/advtrains_train_industrial/models/advtrains_engine_industrial.b3d differ diff --git a/advtrains/advtrains_train_industrial/models/advtrains_wagon_tank.b3d b/advtrains/advtrains_train_industrial/models/advtrains_wagon_tank.b3d new file mode 100644 index 0000000..af2604b Binary files /dev/null and b/advtrains/advtrains_train_industrial/models/advtrains_wagon_tank.b3d differ diff --git a/advtrains/advtrains_train_industrial/models/advtrains_wagon_wood.b3d b/advtrains/advtrains_train_industrial/models/advtrains_wagon_wood.b3d new file mode 100644 index 0000000..0e7fb4b Binary files /dev/null and b/advtrains/advtrains_train_industrial/models/advtrains_wagon_wood.b3d differ diff --git a/advtrains/advtrains_train_industrial/textures/advtrains_engine_industrial.png b/advtrains/advtrains_train_industrial/textures/advtrains_engine_industrial.png new file mode 100644 index 0000000..38a872f Binary files /dev/null and b/advtrains/advtrains_train_industrial/textures/advtrains_engine_industrial.png differ diff --git a/advtrains/advtrains_train_industrial/textures/advtrains_engine_industrial_inv.png b/advtrains/advtrains_train_industrial/textures/advtrains_engine_industrial_inv.png new file mode 100644 index 0000000..be4e80f Binary files /dev/null and b/advtrains/advtrains_train_industrial/textures/advtrains_engine_industrial_inv.png differ diff --git a/advtrains/advtrains_train_industrial/textures/advtrains_wagon_tank.png b/advtrains/advtrains_train_industrial/textures/advtrains_wagon_tank.png new file mode 100644 index 0000000..79b1316 Binary files /dev/null and b/advtrains/advtrains_train_industrial/textures/advtrains_wagon_tank.png differ diff --git a/advtrains/advtrains_train_industrial/textures/advtrains_wagon_tank_inv.png b/advtrains/advtrains_train_industrial/textures/advtrains_wagon_tank_inv.png new file mode 100644 index 0000000..03401be Binary files /dev/null and b/advtrains/advtrains_train_industrial/textures/advtrains_wagon_tank_inv.png differ diff --git a/advtrains/advtrains_train_industrial/textures/advtrains_wagon_wood.png b/advtrains/advtrains_train_industrial/textures/advtrains_wagon_wood.png new file mode 100644 index 0000000..acc6f72 Binary files /dev/null and b/advtrains/advtrains_train_industrial/textures/advtrains_wagon_wood.png differ diff --git a/advtrains/advtrains_train_industrial/textures/advtrains_wagon_wood_inv.png b/advtrains/advtrains_train_industrial/textures/advtrains_wagon_wood_inv.png new file mode 100644 index 0000000..87109dd Binary files /dev/null and b/advtrains/advtrains_train_industrial/textures/advtrains_wagon_wood_inv.png differ diff --git a/advtrains/advtrains_train_japan/depends.txt b/advtrains/advtrains_train_japan/depends.txt new file mode 100644 index 0000000..6f00bf6 --- /dev/null +++ b/advtrains/advtrains_train_japan/depends.txt @@ -0,0 +1 @@ +advtrains \ No newline at end of file diff --git a/advtrains/advtrains_train_japan/init.lua b/advtrains/advtrains_train_japan/init.lua new file mode 100644 index 0000000..47f50cf --- /dev/null +++ b/advtrains/advtrains_train_japan/init.lua @@ -0,0 +1,38 @@ +advtrains.register_wagon("engine_japan", { + mesh="advtrains_engine_japan.b3d", + textures = {"advtrains_engine_japan.png"}, + drives_on={default=true}, + max_speed=20, + seats = { + { + name="Default Seat (driver stand)", + attach_offset={x=0, y=10, z=0}, + view_offset={x=0, y=6, z=0}, + driving_ctrl_access=true, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=2.5, + is_locomotive=true, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, +}, "Japanese Train Engine", "advtrains_engine_japan_inv.png") + +advtrains.register_wagon("wagon_japan", { + mesh="advtrains_wagon_japan.b3d", + textures = {"advtrains_wagon_japan.png"}, + drives_on={default=true}, + max_speed=20, + seats = { + { + name="Default Seat", + attach_offset={x=0, y=10, z=0}, + view_offset={x=0, y=6, z=0}, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=2.3, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, +}, "Japanese Train Wagon", "advtrains_wagon_japan_inv.png") + diff --git a/advtrains/advtrains_train_japan/models/advtrains_engine_japan.b3d b/advtrains/advtrains_train_japan/models/advtrains_engine_japan.b3d new file mode 100644 index 0000000..f82c33e Binary files /dev/null and b/advtrains/advtrains_train_japan/models/advtrains_engine_japan.b3d differ diff --git a/advtrains/advtrains_train_japan/models/advtrains_wagon_japan.b3d b/advtrains/advtrains_train_japan/models/advtrains_wagon_japan.b3d new file mode 100644 index 0000000..7970438 Binary files /dev/null and b/advtrains/advtrains_train_japan/models/advtrains_wagon_japan.b3d differ diff --git a/advtrains/advtrains_train_japan/textures/advtrains_engine_japan.png b/advtrains/advtrains_train_japan/textures/advtrains_engine_japan.png new file mode 100644 index 0000000..b286b38 Binary files /dev/null and b/advtrains/advtrains_train_japan/textures/advtrains_engine_japan.png differ diff --git a/advtrains/advtrains_train_japan/textures/advtrains_engine_japan_inv.png b/advtrains/advtrains_train_japan/textures/advtrains_engine_japan_inv.png new file mode 100644 index 0000000..6af0636 Binary files /dev/null and b/advtrains/advtrains_train_japan/textures/advtrains_engine_japan_inv.png differ diff --git a/advtrains/advtrains_train_japan/textures/advtrains_wagon_japan.png b/advtrains/advtrains_train_japan/textures/advtrains_wagon_japan.png new file mode 100644 index 0000000..bee565e Binary files /dev/null and b/advtrains/advtrains_train_japan/textures/advtrains_wagon_japan.png differ diff --git a/advtrains/advtrains_train_japan/textures/advtrains_wagon_japan_inv.png b/advtrains/advtrains_train_japan/textures/advtrains_wagon_japan_inv.png new file mode 100644 index 0000000..3e6357c Binary files /dev/null and b/advtrains/advtrains_train_japan/textures/advtrains_wagon_japan_inv.png differ diff --git a/advtrains/advtrains_train_steam/depends.txt b/advtrains/advtrains_train_steam/depends.txt new file mode 100644 index 0000000..6f00bf6 --- /dev/null +++ b/advtrains/advtrains_train_steam/depends.txt @@ -0,0 +1 @@ +advtrains \ No newline at end of file diff --git a/advtrains/advtrains_train_steam/init.lua b/advtrains/advtrains_train_steam/init.lua new file mode 100644 index 0000000..ca52516 --- /dev/null +++ b/advtrains/advtrains_train_steam/init.lua @@ -0,0 +1,121 @@ +advtrains.register_wagon("newlocomotive", { + mesh="advtrains_engine_steam.b3d", + textures = {"advtrains_newlocomotive.png"}, + is_locomotive=true, + drives_on={default=true}, + max_speed=10, + seats = { + { + name="Driver Stand (left)", + attach_offset={x=-5, y=10, z=-10}, + view_offset={x=0, y=6, z=0}, + driving_ctrl_access=true, + }, + { + name="Driver Stand (right)", + attach_offset={x=5, y=10, z=-10}, + view_offset={x=0, y=6, z=0}, + driving_ctrl_access=true, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=1.85, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + --update_animation=function(self, velocity) + --if self.old_anim_velocity~=advtrains.abs_ceil(velocity) then + -- self.object:set_animation({x=1,y=60}, 100)--math.floor(velocity)) + --self.old_anim_velocity=advtrains.abs_ceil(velocity) + --end + --end, + custom_on_activate = function(self, staticdata_table, dtime_s) + minetest.add_particlespawner({ + amount = 10, + time = 0, + -- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base + minpos = {x=0, y=2, z=1.2}, + maxpos = {x=0, y=2, z=1.2}, + minvel = {x=-0.2, y=1.8, z=-0.2}, + maxvel = {x=0.2, y=2, z=0.2}, + minacc = {x=0, y=-0.1, z=0}, + maxacc = {x=0, y=-0.3, z=0}, + minexptime = 2, + maxexptime = 4, + minsize = 1, + maxsize = 5, + -- ^ The particle's properties are random values in between the bounds: + -- ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration), + -- ^ minsize/maxsize, minexptime/maxexptime (expirationtime) + collisiondetection = true, + -- ^ collisiondetection: if true uses collision detection + vertical = false, + -- ^ vertical: if true faces player using y axis only + texture = "smoke_puff.png", + -- ^ Uses texture (string) + attached = self.object, + }) + end, + drops={"default:steelblock 4"}, +}, "Steam Engine", "advtrains_newlocomotive_inv.png") +advtrains.register_wagon("wagon_default", { + mesh="advtrains_wagon.b3d", + textures = {"advtrains_wagon.png"}, + drives_on={default=true}, + max_speed=10, + seats = { + { + name="Default Seat", + attach_offset={x=0, y=10, z=0}, + view_offset={x=0, y=6, z=0}, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=1.8, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, +}, "Passenger Wagon", "advtrains_wagon_inv.png") +advtrains.register_wagon("wagon_box", { + mesh="advtrains_wagon.b3d", + textures = {"advtrains_wagon_box.png"}, + drives_on={default=true}, + max_speed=10, + seats = {}, + visual_size = {x=1, y=1}, + wagon_span=1.8, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + drops={"default:steelblock 4"}, + has_inventory = true, + get_inventory_formspec = function(self) + return "size[8,11]".. + "list[detached:advtrains_wgn_"..self.unique_id..";box;0,0;8,6;]".. + "list[current_player;main;0,7;8,4;]".. + "listring[]" + end, + inventory_list_sizes = { + box=8*6, + }, +}, "Box Wagon", "advtrains_wagon_box_inv.png") + +minetest.register_craft({ + output = 'advtrains:newlocomotive', + recipe = { + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + {'default:steelblock', 'dye:black', 'default:steelblock'}, + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + }, +}) +minetest.register_craft({ + output = 'advtrains:wagon_default', + recipe = { + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + {'default:steelblock', 'dye:dark_green', 'default:steelblock'}, + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + }, +}) +minetest.register_craft({ + output = 'advtrains:wagon_box', + recipe = { + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + {'default:steelblock', 'default:chest', 'default:steelblock'}, + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + }, +}) diff --git a/advtrains/advtrains_train_steam/models/advtrains_engine_steam.b3d b/advtrains/advtrains_train_steam/models/advtrains_engine_steam.b3d new file mode 100644 index 0000000..36bdd15 Binary files /dev/null and b/advtrains/advtrains_train_steam/models/advtrains_engine_steam.b3d differ diff --git a/advtrains/advtrains_train_steam/models/advtrains_wagon.b3d b/advtrains/advtrains_train_steam/models/advtrains_wagon.b3d new file mode 100644 index 0000000..5c8214c Binary files /dev/null and b/advtrains/advtrains_train_steam/models/advtrains_wagon.b3d differ diff --git a/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive.png b/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive.png new file mode 100644 index 0000000..e461bc7 Binary files /dev/null and b/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive.png differ diff --git a/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png b/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png new file mode 100644 index 0000000..8d3fafb Binary files /dev/null and b/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png differ diff --git a/advtrains/advtrains_train_steam/textures/advtrains_wagon.png b/advtrains/advtrains_train_steam/textures/advtrains_wagon.png new file mode 100644 index 0000000..c37c979 Binary files /dev/null and b/advtrains/advtrains_train_steam/textures/advtrains_wagon.png differ diff --git a/advtrains/advtrains_train_steam/textures/advtrains_wagon_box.png b/advtrains/advtrains_train_steam/textures/advtrains_wagon_box.png new file mode 100644 index 0000000..8bfbe06 Binary files /dev/null and b/advtrains/advtrains_train_steam/textures/advtrains_wagon_box.png differ diff --git a/advtrains/advtrains_train_steam/textures/advtrains_wagon_box_inv.png b/advtrains/advtrains_train_steam/textures/advtrains_wagon_box_inv.png new file mode 100644 index 0000000..480f245 Binary files /dev/null and b/advtrains/advtrains_train_steam/textures/advtrains_wagon_box_inv.png differ diff --git a/advtrains/advtrains_train_steam/textures/advtrains_wagon_inv.png b/advtrains/advtrains_train_steam/textures/advtrains_wagon_inv.png new file mode 100644 index 0000000..0b72ac3 Binary files /dev/null and b/advtrains/advtrains_train_steam/textures/advtrains_wagon_inv.png differ diff --git a/advtrains/advtrains_train_subway/depends.txt b/advtrains/advtrains_train_subway/depends.txt new file mode 100644 index 0000000..6f00bf6 --- /dev/null +++ b/advtrains/advtrains_train_subway/depends.txt @@ -0,0 +1 @@ +advtrains \ No newline at end of file diff --git a/advtrains/advtrains_train_subway/init.lua b/advtrains/advtrains_train_subway/init.lua new file mode 100644 index 0000000..b5bdb18 --- /dev/null +++ b/advtrains/advtrains_train_subway/init.lua @@ -0,0 +1,30 @@ + +advtrains.register_wagon("subway_wagon", { + mesh="advtrains_subway_train.b3d", + textures = {"advtrains_subway_train.png"}, + drives_on={default=true}, + max_speed=15, + seats = { + { + name="Default Seat (driver stand)", + attach_offset={x=0, y=10, z=0}, + view_offset={x=0, y=6, z=0}, + driving_ctrl_access=true, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=1.8, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + is_locomotive=true, + drops={"default:steelblock 4"}, +}, "Subway Passenger Wagon", "advtrains_subway_train_inv.png") + +--wagons +minetest.register_craft({ + output = 'advtrains:subway_wagon', + recipe = { + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + {'default:steelblock', 'dye:yellow', 'default:steelblock'}, + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + }, +}) diff --git a/advtrains/advtrains_train_subway/models/advtrains_subway_train.b3d b/advtrains/advtrains_train_subway/models/advtrains_subway_train.b3d new file mode 100644 index 0000000..a824d33 Binary files /dev/null and b/advtrains/advtrains_train_subway/models/advtrains_subway_train.b3d differ diff --git a/advtrains/advtrains_train_subway/textures/advtrains_subway_train.png b/advtrains/advtrains_train_subway/textures/advtrains_subway_train.png new file mode 100644 index 0000000..1d569f3 Binary files /dev/null and b/advtrains/advtrains_train_subway/textures/advtrains_subway_train.png differ diff --git a/advtrains/advtrains_train_subway/textures/advtrains_subway_train_inv.png b/advtrains/advtrains_train_subway/textures/advtrains_subway_train_inv.png new file mode 100644 index 0000000..1d0e809 Binary files /dev/null and b/advtrains/advtrains_train_subway/textures/advtrains_subway_train_inv.png differ diff --git a/advtrains/api_doc.txt b/advtrains/api_doc.txt deleted file mode 100644 index 6b1aa2e..0000000 --- a/advtrains/api_doc.txt +++ /dev/null @@ -1,114 +0,0 @@ -Advanced Trains [advtrains] API documentation --------- -To use the API, mods must depend on 'advtrains'. -All boolean values in definition tables default to 'false' and can be omitted. -### Wagons -Wagons are registered using the function - -advtrains.register_wagon(name, prototype, description, inventory_image) -- 'name' is the internal name of the wagon. It is registered inside the 'advtrains:' namespace. - Example: A wagon with name="engine_tgv" will be registered as "advtrains:engine_tgv". -- 'prototype' is the lua entity prototype. The regular definition keys for luaentites apply. Additional required and optional properties see below. DO NOT define 'on_step', 'on_activate', 'on_punch', 'on_rightclick' and 'get_staticdata' since these will be overridden. Use 'custom_*' instead. -- 'description' is the description of the inventory item that is used to place the wagon. -- 'inventory_image' is the inventory image of said item. - -# Wagon prototype properties -{ - ... all regular luaentity properties (mesh, textures, collisionbox a.s.o)... - drives_on = {default=true}, - ^- used to define the tracktypes (see below) that wagon can drive on. The tracktype identifiers are given as keys, similar to privileges) - max_speed = 10, - ^- optional, default 10: defines the maximum speed this wagon can drive. The maximum speed of a train is determined by the wagon with the lowest max_speed value. - seats = { - { - name="Left front window", - ^- display name of this seat - attach_offset={x=0, y=10, z=0}, - ^- this value is passed to 'set_attach' - view_offset={x=0, y=6, z=0}, - ^- player:set_eye_offset is called with this parameter. - driving_ctrl_access=false, - ^- If the seat is a driver stand, and players sitting here should get access to the train's driving control. - - }, - }, - ^- contains zero or more seat definitions. A seat is a place where a player can be attached when getting on a wagon. - wagon_span=2, - ^- How far this wagon extends from its base position. Is the half of the wagon length. - ^- Used to determine in which distance the other wagons have to be positioned. Will require tweaking. - drops = {"default:steelblock 3"} - ^- List of itemstrings what to drop when the wagon is destroyed - - has_inventory = false - ^- If this wagon has an inventory. The inventory is saved with the wagon. - ^- the following settings are ignored if not. - inventory_list_sizes = { - box=8*6, - }, - ^- List of assignments of type list_name=size. - ^- For every entry, an inventory list is created with the specified size. - get_inventory_formspec = function(self, player_name) - return "" - end, - ^- Function that should return the formspec to be displayed when requests to open the wagon's inventory - ^- Use "list[detached:advtrains_wgn_"..self.unique_id..";;,;,;]" to display a wagon's inventory list. - - custom_on_step = function(self, dtime) end - ^- optional: Execute custom code on every step - custom_on_activate = function(self, dtime_s) end - ^- optional: Execute custom code on activate. Staticdata does not need to be saved and restored since all properties written in 'self' are preserved over unloads. - update_animation = function(self, velocity) end - ^- optional: Function that is called whenever the train's velocity changes or every 2 seconds. Used to call 'self.object:update_animation()' if needed. - -} - -# Notes on wagons - -- Every wagon has the field 'unique_id' which assigns each wagon a random id. -- All properties written in the lua entity (self) are saved and restored automatically. Minetest's internal staticdata is only used to save the unique_id of the wagon, which serves as a key in an externally saved table. -- Assuming Z Axis as the axis parallel to the tracks and Y Axis as the one pointing into the sky, wagon models should be dimensioned in a way that: - - their origin is centered in X and Z direction - - their origin lies 0.5 units above the bottom of the model - - the overall extent in X and Y direction is <=3 units -- wagon_span is then the distance between the model origin and the Z axis extent. - -### Tracks -Most modders will be satisfied with the built-in tracks. If cog railways, maglev trains and mine trains are added, it is necessary to understand the definition of tracks. Although the tracks API is there, explaining it would require more effort than me creating the wanted definitions myself. Contact me if you need to register your own rails using my registration functions. - -However, it is still possible to register single rails by understanding the node properties of rails. -minetest.register_node(nodename, { - ... usual node definition ... - groups = { - advtrains_track_=1 - ^- this group tells that the node is a track - not_blocking_trains=1, - ^- this group tells that the node should not block trains although it's walkable. - }, - connect1 = 0, - connect2 = 8, - ^- These values tell the direction (horizontal) the rail ends are pointing to. 0 means +Z, then rotation values increase clockwise. For a translation of directions to positions see helpers.lua. - rely1=0, - rely2=0, - ^- the Y height of the rail end 1/2. A value of >=1 means that the rail end points to the next y layer at rely-1 - railheight=0, - ^- the height value of this rail that is saved in the path. usually the median of rely1 and rely2. - - can_dig=function(pos) - return not advtrains.is_train_at_pos(pos) - end, - after_dig_node=function(pos) - advtrains.invalidate_all_paths() - advtrains.reset_trackdb_position(pos) - end, - after_place_node=function(pos) - advtrains.reset_trackdb_position(pos) - end, - ^- the code in these 3 default minetest API functions is required for advtrains to work, however you can add your own code - - advtrains = { - on_train_enter=function(pos, train_id) end - ^- called when a train enters the rail - on_train_leave=function(pos, train_id) end - ^- called when a train leaves the rail - } -}) \ No newline at end of file diff --git a/advtrains/atc.lua b/advtrains/atc.lua deleted file mode 100644 index f070b20..0000000 --- a/advtrains/atc.lua +++ /dev/null @@ -1,294 +0,0 @@ ---atc.lua ---registers and controls the ATC system - -local atc={} --- ATC persistence table -atc.controllers = {} ---contents: {command="...", arrowconn=0-15 where arrow points} - -advtrains.fpath_atc=minetest.get_worldpath().."/advtrains_atc" -local file, err = io.open(advtrains.fpath_atc, "r") -if not file then - local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains atc save file "..er) -else - local tbl = minetest.deserialize(file:read("*a")) - if type(tbl) == "table" then - atc.controllers=tbl.controllers - end - file:close() -end -function atc.save() - --leave space for more save data. - local datastr = minetest.serialize({controllers = atc.controllers}) - if not datastr then - minetest.log("error", "[advtrains] Failed to serialize trackdb data!") - return - end - local file, err = io.open(advtrains.fpath_atc, "w") - if err then - return err - end - file:write(datastr) - file:close() -end - ---call from advtrains.detector subprogram - -function atc.trigger_controller_train_enter(pos, train_id) - atc.send_command(pos) -end - ---general - -function atc.send_command(pos) - local pts=minetest.pos_to_string(pos) - if atc.controllers[pts] then - print("Called send_command at "..pts) - local train_id = advtrains.detector.on_node[pts] - if train_id then - if advtrains.trains[train_id] then - print("send_command inside if: "..sid(train_id)) - atc.train_reset_command(train_id) - local arrowconn=atc.controllers[pts].arrowconn - local train=advtrains.trains[train_id] - for index, ppos in pairs(train.path) do - if vector.equals(advtrains.round_vector_floor_y(ppos), pos) then - advtrains.trains[train_id].atc_arrow = - vector.equals( - advtrains.dirCoordSet(pos, arrowconn), - advtrains.round_vector_floor_y(train.path[index+train.movedir]) - ) - advtrains.trains[train_id].atc_command=atc.controllers[pts].command - print("Sending ATC Command: "..atc.controllers[pts].command) - end - end - end - end - end - return false -end - -function atc.train_reset_command(train_id) - advtrains.trains[train_id].atc_command=nil - advtrains.trains[train_id].atc_delay=0 - advtrains.trains[train_id].atc_brake_target=nil - advtrains.trains[train_id].atc_wait_finish=nil - advtrains.trains[train_id].atc_arrow=nil -end - ---nodes -local idxtrans={static=1, mesecon=2, digiline=3} -local apn_func=function(pos) - advtrains.reset_trackdb_position(pos) - local meta=minetest.get_meta(pos) - if meta then - meta:set_string("infotext", "ATC controller, unconfigured.") - meta:set_string("formspec", atc.get_atc_controller_formspec(pos, meta)) - end -end - -advtrains.register_tracks("default", { - nodename_prefix="advtrains:dtrack_atc", - texture_prefix="advtrains_dtrack_atc", - models_prefix="advtrains_dtrack_detector", - models_suffix=".b3d", - shared_texture="advtrains_dtrack_rail_atc.png", - description="ATC controller", - formats={}, - get_additional_definiton = function(def, preset, suffix, rotation) - return { - after_place_node=apn_func, - on_place_rail=apn_func, - after_dig_node=function(pos) - advtrains.invalidate_all_paths() - advtrains.reset_trackdb_position(pos) - local pts=minetest.pos_to_string(pos) - atc.controllers[pts]=nil - end, - on_receive_fields = function(pos, formname, fields, player) - if minetest.is_protected(pos, player:get_player_name()) then - minetest.chat_send_player(player:get_player_name(), "This position is protected!") - return - end - local meta=minetest.get_meta(pos) - if meta then - if not fields.save then - --maybe only the dropdown changed - if fields.mode then - meta:set_string("mode", idxtrans[fields.mode]) - meta:set_string("infotext", "ATC controller, mode "..fields.mode.."\n"..( fields.mode=="digiline" and "Channel: "..meta:get_string("channel") or "Command: "..meta:get_string("command") ) ) - meta:set_string("formspec", atc.get_atc_controller_formspec(pos, meta)) - end - return - end - meta:set_string("mode", idxtrans[fields.mode]) - meta:set_string("command", fields.command) - meta:set_string("command_on", fields.command_on) - meta:set_string("channel", fields.channel) - meta:set_string("infotext", "ATC controller, mode "..fields.mode.."\n"..( fields.mode=="digiline" and "Channel: "..meta:get_string("channel") or "Command: "..meta:get_string("command") ) ) - meta:set_string("formspec", atc.get_atc_controller_formspec(pos, meta)) - - local pts=minetest.pos_to_string(pos) - local _, conn1=advtrains.get_rail_info_at(pos, advtrains.all_tracktypes) - atc.controllers[pts]={command=fields.command, arrowconn=conn1} - atc.send_command(pos) - end - end, - } - end -}, advtrains.trackpresets.t_30deg_straightonly) - - -function atc.get_atc_controller_formspec(pos, meta) - local mode=tonumber(meta:get_string("mode")) or 1 - local command=meta:get_string("command") - local command_on=meta:get_string("command_on") - local channel=meta:get_string("channel") - local formspec="size[8,6]".. - "dropdown[0,0;3;mode;static,mesecon,digiline;"..mode.."]" - if mode<3 then - formspec=formspec.."field[0.5,1.5;7,1;command;Command;"..minetest.formspec_escape(command).."]" - if tonumber(mode)==2 then - formspec=formspec.."field[0.5,3;7,1;command_on;Command (on);"..minetest.formspec_escape(command_on).."]" - end - else - formspec=formspec.."field[0.5,1.5;7,1;channel;Digiline channel;"..minetest.formspec_escape(channel).."]" - end - return formspec.."button_exit[0.5,4.5;7,1;save;Save]" -end - ---from trainlogic.lua train step -local matchptn={ - ["SM"]=function(id, train) - train.tarvelocity=train.max_speed - return 2 - end, - ["S([0-9]+)"]=function(id, train, match) - train.tarvelocity=tonumber(match) - return #match+1 - end, - ["B([0-9]+)"]=function(id, train, match) - if train.velocity>tonumber(match) then - train.atc_brake_target=tonumber(match) - if train.tarvelocity>train.atc_brake_target then - train.tarvelocity=train.atc_brake_target - end - end - return #match+1 - end, - ["W"]=function(id, train) - train.atc_wait_finish=true - return 1 - end, - ["D([0-9]+)"]=function(id, train, match) - train.atc_delay=tonumber(match) - return #match+1 - end, - ["R"]=function(id, train) - if train.velocity<=0 then - train.movedir=train.movedir*-1 - train.atc_arrow = not train.atc_arrow - else - print("ATC Reverse command warning: didn't reverse train!") - end - return 1 - end, -} - -function atc.execute_atc_command(id, train) - --strip whitespaces - local command=string.match(train.atc_command, "^%s*(.*)$") - - - if string.match(command, "^%s*$") then - train.atc_command=nil - return - end - --conditional statement? - local is_cond, cond_applies - local cond, rest=string.match(command, "^I([%+%-])(.+)$") - if cond then - is_cond=true - if cond=="+" then - cond_applies=train.atc_arrow - end - if cond=="-" then - cond_applies=not train.atc_arrow - end - else - cond, compare, rest=string.match(command, "^I([<>]=?)([0-9]+)(.+)$") - if cond and compare then - is_cond=true - if cond=="<" then - cond_applies=train.velocity" then - cond_applies=train.velocity>tonumber(compare) - end - if cond=="<=" then - cond_applies=train.velocity<=tonumber(compare) - end - if cond==">=" then - cond_applies=train.velocity>=tonumber(compare) - end - end - end - if is_cond then - print("Evaluating if statement: "..command) - print("Cond: "..(cond or "nil")) - print("Applies: "..(cond_applies and "true" or "false")) - print("Rest: "..rest) - --find end of conditional statement - local nest, pos, elsepos=0, 1 - while nest>=0 do - if pos>#rest then - print("ATC command syntax error: I statement not closed: "..command) - atc.train_reset_command(id) - return - end - local char=string.sub(rest, pos, pos) - if char=="I" then - nest=nest+1 - end - if char==";" then - nest=nest-1 - end - if nest==0 and char=="E" then - elsepos=pos+0 - end - pos=pos+1 - end - if not elsepos then elsepos=pos-1 end - if cond_applies then - command=string.sub(rest, 1, elsepos-1)..string.sub(rest, pos) - else - command=string.sub(rest, elsepos+1, pos-2)..string.sub(rest, pos) - end - print("Result: "..command) - train.atc_command=command - atc.execute_atc_command(id, train) - return - else - for pattern, func in pairs(matchptn) do - local match=string.match(command, "^"..pattern) - if match then - local patlen=func(id, train, match) - - print("Executing: "..string.sub(command, 1, patlen)) - - train.atc_command=string.sub(command, patlen+1) - if train.atc_delay<=0 and not train.atc_wait_finish then - --continue (recursive, cmds shouldn't get too long, and it's a end-recursion.) - atc.execute_atc_command(id, train) - end - return - end - end - end - print("ATC command parse error: "..command) - atc.train_reset_command(id) -end - ---move table to desired place -advtrains.atc=atc diff --git a/advtrains/atc_command.txt b/advtrains/atc_command.txt deleted file mode 100644 index fa846e3..0000000 --- a/advtrains/atc_command.txt +++ /dev/null @@ -1,68 +0,0 @@ -ATC Command Syntax - -A train runs the current ATC command once it receives it, including delayed instructions. If the train receives a new command, the current command is discarded. -Spaces can be inserted into commands as needed and are ignored. - -# simple commands: - -S<[0-9]+ speed or 'M'> -Set target speed of train to . Accelerates if slower, rolls if faster. 'M' means maximum speed. -Execution of command continues immediately. - -B<[0-9]+ speed> -Brake until speed is reached. If faster, apply brakes, if slower, do nothing. -Execution of command continues immediately. - -Examples: -SM : accelerate to maximum speed -S0 : roll to stand -B0 : brake to stand -S0B3 or B3S0: brake to 3, then roll to stand. - -W -Wait until S and/or B commands reached the desired speed before continuing execution. - -D<[0-9]+ time> -Delay: Wait for time seconds before continuing execution. - -R -Reverse: change movement direction of train. ONLY WORKS WHEN TRAIN STANDS, else no-op. -Use B0WR to definitely change direction. - -Examples: -B0 W R D10 SM -Subway train stopping in dead end station and returning in opposite direction - -# conditional statements: - -I; -Execute code only if condition applies -IE; -Execute code1 only if condition applies, else execute code2 - -Conditions: -+ / - -Tests the train's movement direction against the arrow on the ATC rail: M+ is true when train drives in direction of arrow. - -[/<=/>=][speed] -Test if train's speed is greater or smaller than the given value - -Examples: -I- B0 W R ; S8 -If the train drives in the 'wrong' direction, stop and reverse; independently accelerate to speed 8 afterwards. - -I<8 S8 ; -If the train is slower than 8, accelerate to 8. - -# ATC controller operation modes -static: Only give 1 static command. -mesecon: Give 2 different commands depending on if the controller is mesecon-powered or not -digiline: Don't give any commands by itself. When a train passes, a digiline message in the form of "[+/-][speed]" is sent on the set channel (where +/- means the same as with conditions). Any digiline message sent to the controller will be interpreted as ATC command and sent to the train. - -# Persistence -ATC controllers that are configured as 'static' or 'mesecon' are persistent over mapblock unloads and will even command the train when the mapblock is unloaded. This is not possible with digilines since these do not work in unloaded mapchunks. - -# LUA ATC controller (in development) -The LUA ATC Controller will operate by using LUA code. All operations shown above will have a function equivalent. Additionally all LUA ATC controllers share an environment and setting signal and switch status will be possible to allow for complicated railway systems/fully automated subways a.s.o. -Also planned: -- digicompute add-on to allow computer access to the ATC environment (railway maps... ... ... ... ...) diff --git a/advtrains/couple.lua b/advtrains/couple.lua deleted file mode 100644 index 974f450..0000000 --- a/advtrains/couple.lua +++ /dev/null @@ -1,156 +0,0 @@ ---couple.lua ---defines couple entities. - ---advtrains:discouple ---set into existing trains to split them when punched. ---they are attached to the wagons. ---[[fields -wagon - -wagons keep their couple entity minetest-internal id inside the field discouple_id. if it refers to nowhere, they will spawn a new one if player is near -]] - - -minetest.register_entity("advtrains:discouple", { - visual="sprite", - textures = {"advtrains_discouple.png"}, - collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, - visual_size = {x=1, y=1}, - initial_sprite_basepos = {x=0, y=0}, - - is_discouple=true, - on_activate=function(self, staticdata) - if staticdata=="DISCOUPLE" then - --couple entities have no right to exist further... - self.object:remove() - return - end - self.object:set_armor_groups({immortal=1}) - end, - get_staticdata=function() return "DISCOUPLE" end, - on_punch=function(self, player) - --only if player owns at least one wagon next to this - local own=player:get_player_name() - if self.wagon.owner and self.wagon.owner==own then - local train=advtrains.trains[self.wagon.train_id] - local nextwgn_id=train.trainparts[self.wagon.pos_in_trainparts-1] - for aoi, le in pairs(minetest.luaentities) do - if le and le.is_wagon then - if le.unique_id==nextwgn_id then - if le.owner and le.owner~=own then - minetest.chat_send_player(own, "You need to own at least one neighboring wagon to destroy this couple.") - return - end - end - end - end - advtrains.split_train_at_wagon(self.wagon)--found in trainlogic.lua - self.object:remove() - else - minetest.chat_send_player(own, "You need to own at least one neighboring wagon to destroy this couple.") - end - end, - on_step=function(self, dtime) - local t=os.clock() - if not self.wagon then - self.object:remove() - return - end - --getyaw seems to be a reliable method to check if an object is loaded...if it returns nil, it is not. - if not self.wagon.object:getyaw() then - self.object:remove() - return - end - local velocityvec=self.wagon.object:getvelocity() - self.updatepct_timer=(self.updatepct_timer or 0)-dtime - if not self.old_velocity_vector or not vector.equals(velocityvec, self.old_velocity_vector) or self.updatepct_timer<=0 then--only send update packet if something changed - local flipsign=self.wagon.wagon_flipped and -1 or 1 - self.object:setpos(vector.add(self.wagon.object:getpos(), {y=0, x=-math.sin(self.wagon.object:getyaw())*self.wagon.wagon_span*flipsign, z=math.cos(self.wagon.object:getyaw())*self.wagon.wagon_span*flipsign})) - self.object:setvelocity(velocityvec) - self.updatepct_timer=2 - end - printbm("discouple_step", t) - end, -}) - ---advtrains:couple ---when two trains overlap with their end-positions, this entity will be spawned and both trains set its id into appropiate fields for them to know when to free them again. The entity will destroy automatically when it recognizes that any of the trains left the common position. ---[[fields -train_id_1 -train_id_2 -train1_is_backpos -train2_is_backpos -]] - - -minetest.register_entity("advtrains:couple", { - visual="sprite", - textures = {"advtrains_couple.png"}, - collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, - visual_size = {x=1, y=1}, - initial_sprite_basepos = {x=0, y=0}, - - is_couple=true, - on_activate=function(self, staticdata) - if staticdata=="COUPLE" then - --couple entities have no right to exist further... - self.object:remove() - return - end - end, - get_staticdata=function(self) return "COUPLE" end, - on_rightclick=function(self) - if not self.train_id_1 or not self.train_id_2 then return end - - local id1, id2=self.train_id_1, self.train_id_2 - - if self.train1_is_backpos and not self.train2_is_backpos then - advtrains.do_connect_trains(id1, id2) - --case 2 (second train is front) - elseif self.train2_is_backpos and not self.train1_is_backpos then - advtrains.do_connect_trains(id2, id1) - --case 3 - elseif self.train1_is_backpos and self.train2_is_backpos then - advtrains.invert_train(id2) - advtrains.do_connect_trains(id1, id2) - --case 4 - elseif not self.train1_is_backpos and not self.train2_is_backpos then - advtrains.invert_train(id1) - advtrains.do_connect_trains(id1, id2) - end - self.object:remove() - end, - on_step=function(self, dtime) - local t=os.clock() - if not self.train_id_1 or not self.train_id_2 then print("wtf no train ids?")return end - local train1=advtrains.trains[self.train_id_1] - local train2=advtrains.trains[self.train_id_2] - if not train1 or not train2 or not train1.path or not train2.path or not train1.index or not train2.index then - self.object:remove() - return - end - - local tp1 - if not self.train1_is_backpos then - tp1=advtrains.get_real_index_position(train1.path, train1.index) - else - tp1=advtrains.get_real_index_position(train1.path, advtrains.get_train_end_index(train1)) - end - local tp2 - if not self.train2_is_backpos then - tp2=advtrains.get_real_index_position(train2.path, train2.index) - else - tp2=advtrains.get_real_index_position(train2.path, advtrains.get_train_end_index(train2)) - end - if not tp1 or not tp2 or not (vector.distance(tp1,tp2)<1.5) then - self.object:remove() - return - else - local pos_median=advtrains.pos_median(tp1, tp2) - if not vector.equals(pos_median, self.object:getpos()) then - self.object:setpos(pos_median) - end - end - printbm("couple step", t) - end, -}) diff --git a/advtrains/crafting.lua b/advtrains/crafting.lua deleted file mode 100644 index 5ba12ce..0000000 --- a/advtrains/crafting.lua +++ /dev/null @@ -1,71 +0,0 @@ ---advtrains by orwell96, see readme.txt and license.txt ---crafting.lua ---registers crafting recipes - ---tracks -minetest.register_craft({ - output = 'advtrains:dtrack_placer 50', - recipe = { - {'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, - {'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, - {'default:steel_ingot', 'group:stick', 'default:steel_ingot'}, - }, -}) -minetest.register_craft({ - type = "shapeless", - output = 'advtrains:dtrack_slopeplacer 2', - recipe = { - "advtrains:dtrack_placer", - "advtrains:dtrack_placer", - "default:gravel", - }, -}) - -minetest.register_craft({ - output = 'advtrains:dtrack_bumper_placer 2', - recipe = { - {'default:wood', 'dye:red'}, - {'default:steel_ingot', 'default:steel_ingot'}, - {'advtrains:dtrack_placer', 'advtrains:dtrack_placer'}, - }, -}) -minetest.register_craft({ - type="shapeless", - output = 'advtrains:dtrack_detector_off_placer', - recipe = { - "advtrains:dtrack_placer", - "mesecons:wire_00000000_off" - }, -}) ---signals -minetest.register_craft({ - output = 'advtrains:retrosignal_off 2', - recipe = { - {'dye:red', 'default:steel_ingot', 'default:steel_ingot'}, - {'', '', 'default:steel_ingot'}, - {'', '', 'default:steel_ingot'}, - }, -}) -minetest.register_craft({ - output = 'advtrains:signal_off 2', - recipe = { - {'', 'dye:red', 'default:steel_ingot'}, - {'', 'dye:dark_green', 'default:steel_ingot'}, - {'', '', 'default:steel_ingot'}, - }, -}) - ---trackworker -minetest.register_craft({ - output = 'advtrains:trackworker', - recipe = { - {'default:diamond'}, - {'screwdriver:screwdriver'}, - {'default:steel_ingot'}, - }, -}) - - - ---misc_nodes ---crafts for platforms see misc_nodes.lua diff --git a/advtrains/damage.lua b/advtrains/damage.lua deleted file mode 100644 index b39fe67..0000000 --- a/advtrains/damage.lua +++ /dev/null @@ -1,26 +0,0 @@ ---damage.lua ---a globalstep that damages players overrolled by trains. - -advtrains.player_to_train_mapping={} - -local tmr=0 -minetest.register_globalstep(function(dtime) - tmr=tmr-dtime - if tmr<=0 then - - for _, player in pairs(minetest.get_connected_players()) do - local pos=player:getpos() - for _, object in pairs(minetest.get_objects_inside_radius(pos, 1)) do - local le=object:get_luaentity() - if le and le.is_wagon and le.initialized and le:train() then - if (not advtrains.player_to_train_mapping[player:get_player_name()] or le.train_id~=advtrains.player_to_train_mapping[player:get_player_name()]) and math.abs(le:train().velocity)>2 then - --player:punch(object, 1000, {damage={fleshy=3*math.abs(le:train().velocity)}}) - player:set_hp(player:get_hp()-math.abs(le:train().velocity)-3) - end - end - end - end - - tmr=0.5 - end -end) diff --git a/advtrains/debugitems.lua b/advtrains/debugitems.lua deleted file mode 100644 index b3164ff..0000000 --- a/advtrains/debugitems.lua +++ /dev/null @@ -1,36 +0,0 @@ -minetest.register_tool("advtrains:tunnelborer", -{ - description = "tunnelborer", - groups = {cracky=1}, -- key=name, value=rating; rating=1..3. - inventory_image = "drwho_screwdriver.png", - wield_image = "drwho_screwdriver.png", - stack_max = 1, - range = 7.0, - - on_place = function(itemstack, placer, pointed_thing) - - end, - --[[ - ^ Shall place item and return the leftover itemstack - ^ default: minetest.item_place ]] - on_use = function(itemstack, user, pointed_thing) - if pointed_thing.type=="node" then - for x=-1,1 do - for y=-1,1 do - for z=-1,1 do - minetest.remove_node(vector.add(pointed_thing.under, {x=x, y=y, z=z})) - end - end - end - end - end, ---[[ -^ default: nil -^ Function must return either nil if no item shall be removed from -inventory, or an itemstack to replace the original itemstack. -e.g. itemstack:take_item(); return itemstack -^ Otherwise, the function is free to do what it wants. -^ The default functions handle regular use cases. -]] -} -) diff --git a/advtrains/depends.txt b/advtrains/depends.txt deleted file mode 100644 index 20aa884..0000000 --- a/advtrains/depends.txt +++ /dev/null @@ -1,2 +0,0 @@ -default -mesecons? \ No newline at end of file diff --git a/advtrains/description.txt b/advtrains/description.txt deleted file mode 100644 index ecc5d58..0000000 --- a/advtrains/description.txt +++ /dev/null @@ -1,8 +0,0 @@ -Advanced Trains v1.3.0, by orwell and contributors. Also see readme. -Good-looking, realistic trains for minetest. - -For crafting recipes, see manual.pdf - -Website: http://advtrains.bleipb.de/ -Manual: https://github.com/orwell96/advtrains/blob/master/manual.pdf -Forum : https://forum.minetest.net/viewtopic.php?f=11&t=14726 \ No newline at end of file diff --git a/advtrains/helpers.lua b/advtrains/helpers.lua deleted file mode 100644 index 1a02621..0000000 --- a/advtrains/helpers.lua +++ /dev/null @@ -1,248 +0,0 @@ ---advtrains by orwell96, see readme.txt -local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end - -advtrains.dir_trans_tbl={ - [0]={x=0, z=1}, - [1]={x=1, z=2}, - [2]={x=1, z=1}, - [3]={x=2, z=1}, - [4]={x=1, z=0}, - [5]={x=2, z=-1}, - [6]={x=1, z=-1}, - [7]={x=1, z=-2}, - [8]={x=0, z=-1}, - [9]={x=-1, z=-2}, - [10]={x=-1, z=-1}, - [11]={x=-2, z=-1}, - [12]={x=-1, z=0}, - [13]={x=-2, z=1}, - [14]={x=-1, z=1}, - [15]={x=-1, z=2}, -} - -function advtrains.dirCoordSet(coord, dir) - local x,z - if advtrains.dir_trans_tbl[dir] then - x,z=advtrains.dir_trans_tbl[dir].x, advtrains.dir_trans_tbl[dir].z - else - error("advtrains: in helpers.lua/dirCoordSet() given dir="..(dir or "nil")) - end - return {x=coord.x+x, y=coord.y, z=coord.z+z} -end -function advtrains.dirToCoord(dir) - return advtrains.dirCoordSet({x=0, y=0, z=0}, dir) -end - -function advtrains.maxN(list, expectstart) - local n=expectstart or 0 - while list[n] do - n=n+1 - end - return n-1 -end - -function advtrains.minN(list, expectstart) - local n=expectstart or 0 - while list[n] do - n=n-1 - end - return n+1 -end - ---vertical_transmit: ---[[ -rely1, rely2 tell to which height the connections are pointed to. 1 means it will go up the next node - -]] - -function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return - local mid=advtrains.round_vector_floor_y(midreal) - - if not advtrains.get_rail_info_at(advtrains.round_vector_floor_y(prev), drives_on) then - return nil - end - - local midnode_ok, middir1, middir2, midrely1, midrely2=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(mid), drives_on) - if not midnode_ok then - return nil - end - - local next, chkdir, chkrely, y_offset - y_offset=0 - --print("[advtrains] in order mid1,mid2",middir1,middir2) - --try if it is dir1 - local cor1=advtrains.dirCoordSet(mid, middir2)--<<<< - if math.floor(cor1.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor1.z+0.5)==math.floor(prev.z+0.5) then--this was previous - next=advtrains.dirCoordSet(mid, middir1) - if midrely1>=1 then - next.y=next.y+1 - --print("[advtrains]found midrely1 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) - y_offset=1 - end - chkdir=middir1 - chkrely=midrely1 - --print("[advtrains]dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") - end - --dir2??? - local cor2=advtrains.dirCoordSet(mid, middir1)--<<<< - if math.floor(cor2.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor2.z+0.5)==math.floor(prev.z+0.5) then - next=advtrains.dirCoordSet(mid, middir2)--dir2 wird überprüft, alles gut. - if midrely2>=1 then - next.y=next.y+1 - --print("[advtrains]found midrely2 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) - y_offset=1 - end - chkdir=middir2 - chkrely=midrely2 - --print("[advtrains] dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") - end - --print("[advtrains]dir applied next pos: "..(next and minetest.pos_to_string(next) or "nil").."(chkdir is "..(chkdir or "nil")..", y-offset "..y_offset..")") - --is there a next - if not next then - --print("[advtrains]in conway: no next rail(nil), returning!") - return nil - end - - local nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) - - --is it a rail? - if(not nextnode_ok) then - --print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not a rail, trying one node below!") - next.y=next.y-1 - y_offset=y_offset-1 - - nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) - if(not nextnode_ok) then - --print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!") - return nil - end - end - - --is this next rail connecting to the mid? - if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely-y_offset) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely-y_offset) ) then - --print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not connecting, trying one node below!") - next.y=next.y-1 - y_offset=y_offset-1 - - nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) - if(not nextnode_ok) then - --print("[advtrains]in conway: (at connecting if check again) one below "..minetest.pos_to_string(next).." is not a rail either, returning!") - return nil - end - if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely) ) then - --print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." rail not connecting, returning!") - --print("[advtrains] in order mid1,2,next1,2,chkdir "..middir1.." "..middir2.." "..nextdir1.." "..nextdir2.." "..chkdir) - return nil - end - end - - --print("[advtrains]conway found rail.") - return vector.add(advtrains.round_vector_floor_y(next), {x=0, y=nextrailheight, z=0}), chkdir -end ---TODO use this -function advtrains.oppd(dir) - return ((dir+8)%16) -end - -function advtrains.round_vector_floor_y(vec) - return {x=math.floor(vec.x+0.5), y=math.floor(vec.y), z=math.floor(vec.z+0.5)} -end - -function advtrains.yawToDirection(yaw, conn1, conn2) - if not conn1 or not conn2 then - error("given nil to yawToDirection: conn1="..(conn1 or "nil").." conn2="..(conn1 or "nil")) - end - local yaw1=math.pi*(conn1/4) - local yaw2=math.pi*(conn2/4) - if advtrains.minAngleDiffRad(yaw, yaw1) if weird behavior - return conn2 - else - return conn1 - end -end - -function advtrains.minAngleDiffRad(r1, r2) - local try1=r2-r1 - local try2=(r2+2*math.pi)-r1 - local try3=r2-(r1+2*math.pi) - if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try1) then - return try1 - end - if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try2) then - return try2 - end - if math.min(math.abs(try1), math.abs(try2), math.abs(try3))==math.abs(try3) then - return try3 - end -end -function advtrains.dumppath(path) - if not path then print("dumppath: no path(nil)") return end - local min=advtrains.minN(path) - local max=advtrains.maxN(path) - for i=min, max do print("["..i.."] "..(path[i] and minetest.pos_to_string(path[i]) or "nil")) end -end - -function advtrains.merge_tables(a, ...) - local new={} - for _,t in ipairs({a,...}) do - for k,v in pairs(t) do new[k]=v end - end - return new -end -function advtrains.yaw_from_3_positions(prev, curr, next) - local pts=minetest.pos_to_string - --print("p3 "..pts(prev)..pts(curr)..pts(next)) - local prev2curr=math.atan2((curr.x-prev.x), (prev.z-curr.z)) - local curr2next=math.atan2((next.x-curr.x), (curr.z-next.z)) - --print("y3 "..(prev2curr*360/(2*math.pi)).." "..(curr2next*360/(2*math.pi))) - return prev2curr+(advtrains.minAngleDiffRad(prev2curr, curr2next)/2) -end -function advtrains.get_wagon_yaw(front, first, second, back, pct) - local pts=minetest.pos_to_string - --print("p "..pts(front)..pts(first)..pts(second)..pts(back)) - local y2=advtrains.yaw_from_3_positions(second, first, front) - local y1=advtrains.yaw_from_3_positions(back, second, first) - --print("y "..(y1*360/(2*math.pi)).." "..(y2*360/(2*math.pi))) - return y1+advtrains.minAngleDiffRad(y1, y2)*pct -end -function advtrains.get_real_index_position(path, index) - if not path or not index then return end - - local first_pos=path[math.floor(index)] - local second_pos=path[math.floor(index)+1] - - if not first_pos or not second_pos then return nil end - - local factor=index-math.floor(index) - local actual_pos={x=first_pos.x-(first_pos.x-second_pos.x)*factor, y=first_pos.y-(first_pos.y-second_pos.y)*factor, z=first_pos.z-(first_pos.z-second_pos.z)*factor,} - return actual_pos -end -function advtrains.pos_median(pos1, pos2) - return {x=pos1.x-(pos1.x-pos2.x)*0.5, y=pos1.y-(pos1.y-pos2.y)*0.5, z=pos1.z-(pos1.z-pos2.z)*0.5} -end -function advtrains.abs_ceil(i) - return math.ceil(math.abs(i))*math.sign(i) -end - -function advtrains.serialize_inventory(inv) - local ser={} - local liszts=inv:get_lists() - for lisztname, liszt in pairs(liszts) do - ser[lisztname]={} - for idx, item in ipairs(liszt) do - local istring=item:to_string() - if istring~="" then - ser[lisztname][idx]=istring - end - end - end - return minetest.serialize(ser) -end -function advtrains.deserialize_inventory(sers, inv) - local ser=minetest.deserialize(sers) - if ser then - inv:set_lists(ser) - return true - end - return false -end diff --git a/advtrains/init.lua b/advtrains/init.lua deleted file mode 100644 index 33aa962..0000000 --- a/advtrains/init.lua +++ /dev/null @@ -1,40 +0,0 @@ ---advtrains - -advtrains={} - -advtrains.modpath = minetest.get_modpath("advtrains") - -print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end -sid=function(id) return string.sub(id, -4) end - -dofile(advtrains.modpath.."/helpers.lua"); -dofile(advtrains.modpath.."/debugitems.lua"); - -advtrains.meseconrules = -{{x=0, y=0, z=-1}, - {x=1, y=0, z=0}, - {x=-1, y=0, z=0}, - {x=0, y=0, z=1}, - {x=1, y=1, z=0}, - {x=1, y=-1, z=0}, - {x=-1, y=1, z=0}, - {x=-1, y=-1, z=0}, - {x=0, y=1, z=1}, - {x=0, y=-1, z=1}, - {x=0, y=1, z=-1}, - {x=0, y=-1, z=-1}, - {x=0, y=-2, z=0}} -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") -dofile(advtrains.modpath.."/couple.lua") -dofile(advtrains.modpath.."/damage.lua") - -dofile(advtrains.modpath.."/signals.lua") -dofile(advtrains.modpath.."/misc_nodes.lua") -dofile(advtrains.modpath.."/crafting.lua") diff --git a/advtrains/license.txt b/advtrains/license.txt new file mode 100644 index 0000000..68a4b60 --- /dev/null +++ b/advtrains/license.txt @@ -0,0 +1,142 @@ +GNU LESSER GENERAL PUBLIC LICENSE + +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. + +This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. + +To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. + +Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. + +Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. + +When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. + +We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. + +For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. + +In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. + +The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". + +A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. + c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. + d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. + + (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Library into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. + +However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. + +When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. + +If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: + + a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) + b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. + c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. + d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. + e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. + b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +END OF TERMS AND CONDITIONS diff --git a/advtrains/license_media.txt b/advtrains/license_media.txt new file mode 100644 index 0000000..c0da560 --- /dev/null +++ b/advtrains/license_media.txt @@ -0,0 +1,63 @@ +License + +THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. + +BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. + +1. Definitions + + "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. + "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(g) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License. + "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership. + "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, Noncommercial, ShareAlike. + "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. + "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. + "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. + "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. + "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. + "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. + +2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. + +3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: + + to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; + to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified."; + to Distribute and Publicly Perform the Work including as incorporated in Collections; and, + to Distribute and Publicly Perform Adaptations. + +The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved, including but not limited to the rights described in Section 4(e). + +4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: + + You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(d), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(d), as requested. + You may Distribute or Publicly Perform an Adaptation only under: (i) the terms of this License; (ii) a later version of this License with the same License Elements as this License; (iii) a Creative Commons jurisdiction license (either this or a later license version) that contains the same License Elements as this License (e.g., Attribution-NonCommercial-ShareAlike 3.0 US) ("Applicable License"). You must include a copy of, or the URI, for Applicable License with every copy of each Adaptation You Distribute or Publicly Perform. You may not offer or impose any terms on the Adaptation that restrict the terms of the Applicable License or the ability of the recipient of the Adaptation to exercise the rights granted to that recipient under the terms of the Applicable License. You must keep intact all notices that refer to the Applicable License and to the disclaimer of warranties with every copy of the Work as included in the Adaptation You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Adaptation, You may not impose any effective technological measures on the Adaptation that restrict the ability of a recipient of the Adaptation from You to exercise the rights granted to that recipient under the terms of the Applicable License. This Section 4(b) applies to the Adaptation as incorporated in a Collection, but this does not require the Collection apart from the Adaptation itself to be made subject to the terms of the Applicable License. + You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation. The exchange of the Work for other copyrighted works by means of digital file-sharing or otherwise shall not be considered to be intended for or directed toward commercial advantage or private monetary compensation, provided there is no payment of any monetary compensation in con-nection with the exchange of copyrighted works. + If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and, (iv) consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4(d) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. + + For the avoidance of doubt: + Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; + Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License if Your exercise of such rights is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(c) and otherwise waives the right to collect royalties through any statutory or compulsory licensing scheme; and, + Voluntary License Schemes. The Licensor reserves the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License that is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(c). + Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise. + +5. Representations, Warranties and Disclaimer + +UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING AND TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THIS EXCLUSION MAY NOT APPLY TO YOU. + +6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. Termination + + This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. + Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. + +8. Miscellaneous + + Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. + Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. + If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. + No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. + This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. + The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. + diff --git a/advtrains/manual.pdf b/advtrains/manual.pdf new file mode 100644 index 0000000..e8c6380 Binary files /dev/null and b/advtrains/manual.pdf differ diff --git a/advtrains/misc_nodes.lua b/advtrains/misc_nodes.lua deleted file mode 100644 index 93829f0..0000000 --- a/advtrains/misc_nodes.lua +++ /dev/null @@ -1,67 +0,0 @@ ---all nodes that do not fit in any other category - -function advtrains.register_platform(preset) - local ndef=minetest.registered_nodes[preset] - if not ndef then - minetest.log("warning", "[advtrains] register_platform couldn't find preset node "..preset) - return - end - local btex=ndef.tiles - if type(btex)=="table" then - btex=btex[1] - end - local desc=ndef.description or "" - local nodename=string.match(preset, ":(.+)$") - minetest.register_node("advtrains:platform_low_"..nodename, { - description = desc.." Platform (low)", - tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex}, - groups = {cracky = 1, not_blocking_trains = 1, platform=1}, - sounds = default.node_sound_stone_defaults(), - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = { - {-0.5, -0.1, -0.1, 0.5, 0 , 0.5}, - {-0.5, -0.5, 0 , 0.5, -0.1, 0.5} - }, - }, - paramtype2="facedir", - paramtype = "light", - sunlight_propagates = true, - }) - minetest.register_node("advtrains:platform_high_"..nodename, { - description = desc.." Platform (high)", - tiles = {btex.."^advtrains_platform.png", btex, btex, btex, btex, btex}, - groups = {cracky = 1, not_blocking_trains = 1, platform=2}, - sounds = default.node_sound_stone_defaults(), - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = { - {-0.5, 0.3, -0.1, 0.5, 0.5, 0.5}, - {-0.5, -0.5, 0 , 0.5, 0.3, 0.5} - }, - }, - paramtype2="facedir", - paramtype = "light", - sunlight_propagates = true, - }) - minetest.register_craft({ - type="shapeless", - output = "advtrains:platform_high_"..nodename.." 4", - recipe = { - "dye:yellow", preset, preset - }, - }) - minetest.register_craft({ - type="shapeless", - output = "advtrains:platform_low_"..nodename.." 4", - recipe = { - "dye:yellow", preset - }, - }) -end - - -advtrains.register_platform("default:stonebrick") -advtrains.register_platform("default:sandstonebrick") diff --git a/advtrains/models/advtrains_dtrack_bumper_st.b3d b/advtrains/models/advtrains_dtrack_bumper_st.b3d deleted file mode 100644 index a6d9745..0000000 Binary files a/advtrains/models/advtrains_dtrack_bumper_st.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_bumper_st_30.b3d b/advtrains/models/advtrains_dtrack_bumper_st_30.b3d deleted file mode 100644 index 5f5b3f4..0000000 Binary files a/advtrains/models/advtrains_dtrack_bumper_st_30.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_bumper_st_45.b3d b/advtrains/models/advtrains_dtrack_bumper_st_45.b3d deleted file mode 100644 index f13ae75..0000000 Binary files a/advtrains/models/advtrains_dtrack_bumper_st_45.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_bumper_st_60.b3d b/advtrains/models/advtrains_dtrack_bumper_st_60.b3d deleted file mode 100644 index 59a2285..0000000 Binary files a/advtrains/models/advtrains_dtrack_bumper_st_60.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_cr.b3d b/advtrains/models/advtrains_dtrack_cr.b3d deleted file mode 100644 index 159717e..0000000 Binary files a/advtrains/models/advtrains_dtrack_cr.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_cr_30.b3d b/advtrains/models/advtrains_dtrack_cr_30.b3d deleted file mode 100644 index 09cdb1f..0000000 Binary files a/advtrains/models/advtrains_dtrack_cr_30.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_cr_45.b3d b/advtrains/models/advtrains_dtrack_cr_45.b3d deleted file mode 100644 index 176da81..0000000 Binary files a/advtrains/models/advtrains_dtrack_cr_45.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_cr_60.b3d b/advtrains/models/advtrains_dtrack_cr_60.b3d deleted file mode 100644 index 00313c8..0000000 Binary files a/advtrains/models/advtrains_dtrack_cr_60.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_detector_st.b3d b/advtrains/models/advtrains_dtrack_detector_st.b3d deleted file mode 100644 index 6762bc3..0000000 Binary files a/advtrains/models/advtrains_dtrack_detector_st.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_detector_st_30.b3d b/advtrains/models/advtrains_dtrack_detector_st_30.b3d deleted file mode 100644 index f2d5991..0000000 Binary files a/advtrains/models/advtrains_dtrack_detector_st_30.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_detector_st_45.b3d b/advtrains/models/advtrains_dtrack_detector_st_45.b3d deleted file mode 100644 index 9ecb4a6..0000000 Binary files a/advtrains/models/advtrains_dtrack_detector_st_45.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_detector_st_60.b3d b/advtrains/models/advtrains_dtrack_detector_st_60.b3d deleted file mode 100644 index bd102cb..0000000 Binary files a/advtrains/models/advtrains_dtrack_detector_st_60.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_st.b3d b/advtrains/models/advtrains_dtrack_st.b3d deleted file mode 100644 index f3e2753..0000000 Binary files a/advtrains/models/advtrains_dtrack_st.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_st_30.b3d b/advtrains/models/advtrains_dtrack_st_30.b3d deleted file mode 100644 index 7a35c8d..0000000 Binary files a/advtrains/models/advtrains_dtrack_st_30.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_st_45.b3d b/advtrains/models/advtrains_dtrack_st_45.b3d deleted file mode 100644 index b2a1702..0000000 Binary files a/advtrains/models/advtrains_dtrack_st_45.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_st_60.b3d b/advtrains/models/advtrains_dtrack_st_60.b3d deleted file mode 100644 index 0a59f77..0000000 Binary files a/advtrains/models/advtrains_dtrack_st_60.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swlcr.b3d b/advtrains/models/advtrains_dtrack_swlcr.b3d deleted file mode 100644 index 1adc23f..0000000 Binary files a/advtrains/models/advtrains_dtrack_swlcr.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swlcr_30.b3d b/advtrains/models/advtrains_dtrack_swlcr_30.b3d deleted file mode 100644 index 7d8373b..0000000 Binary files a/advtrains/models/advtrains_dtrack_swlcr_30.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swlcr_45.b3d b/advtrains/models/advtrains_dtrack_swlcr_45.b3d deleted file mode 100644 index 9679b9e..0000000 Binary files a/advtrains/models/advtrains_dtrack_swlcr_45.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swlcr_60.b3d b/advtrains/models/advtrains_dtrack_swlcr_60.b3d deleted file mode 100644 index 3efc924..0000000 Binary files a/advtrains/models/advtrains_dtrack_swlcr_60.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swlst.b3d b/advtrains/models/advtrains_dtrack_swlst.b3d deleted file mode 100644 index 93841a4..0000000 Binary files a/advtrains/models/advtrains_dtrack_swlst.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swlst_30.b3d b/advtrains/models/advtrains_dtrack_swlst_30.b3d deleted file mode 100644 index e9a90c7..0000000 Binary files a/advtrains/models/advtrains_dtrack_swlst_30.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swlst_45.b3d b/advtrains/models/advtrains_dtrack_swlst_45.b3d deleted file mode 100644 index 49c707c..0000000 Binary files a/advtrains/models/advtrains_dtrack_swlst_45.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swlst_60.b3d b/advtrains/models/advtrains_dtrack_swlst_60.b3d deleted file mode 100644 index c9a6ffe..0000000 Binary files a/advtrains/models/advtrains_dtrack_swlst_60.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swrcr.b3d b/advtrains/models/advtrains_dtrack_swrcr.b3d deleted file mode 100644 index ee29b62..0000000 Binary files a/advtrains/models/advtrains_dtrack_swrcr.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swrcr_30.b3d b/advtrains/models/advtrains_dtrack_swrcr_30.b3d deleted file mode 100644 index ba065e1..0000000 Binary files a/advtrains/models/advtrains_dtrack_swrcr_30.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swrcr_45.b3d b/advtrains/models/advtrains_dtrack_swrcr_45.b3d deleted file mode 100644 index 7f9dc43..0000000 Binary files a/advtrains/models/advtrains_dtrack_swrcr_45.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swrcr_60.b3d b/advtrains/models/advtrains_dtrack_swrcr_60.b3d deleted file mode 100644 index b8ffa61..0000000 Binary files a/advtrains/models/advtrains_dtrack_swrcr_60.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swrst.b3d b/advtrains/models/advtrains_dtrack_swrst.b3d deleted file mode 100644 index 0b3e7ad..0000000 Binary files a/advtrains/models/advtrains_dtrack_swrst.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swrst_30.b3d b/advtrains/models/advtrains_dtrack_swrst_30.b3d deleted file mode 100644 index 4aea19b..0000000 Binary files a/advtrains/models/advtrains_dtrack_swrst_30.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swrst_45.b3d b/advtrains/models/advtrains_dtrack_swrst_45.b3d deleted file mode 100644 index 4182fe5..0000000 Binary files a/advtrains/models/advtrains_dtrack_swrst_45.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_swrst_60.b3d b/advtrains/models/advtrains_dtrack_swrst_60.b3d deleted file mode 100644 index 6d2c891..0000000 Binary files a/advtrains/models/advtrains_dtrack_swrst_60.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_vst1.b3d b/advtrains/models/advtrains_dtrack_vst1.b3d deleted file mode 100644 index c9d7427..0000000 Binary files a/advtrains/models/advtrains_dtrack_vst1.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_vst1_45.b3d b/advtrains/models/advtrains_dtrack_vst1_45.b3d deleted file mode 100644 index 14d438c..0000000 Binary files a/advtrains/models/advtrains_dtrack_vst1_45.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_vst2.b3d b/advtrains/models/advtrains_dtrack_vst2.b3d deleted file mode 100644 index c128650..0000000 Binary files a/advtrains/models/advtrains_dtrack_vst2.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_vst2_45.b3d b/advtrains/models/advtrains_dtrack_vst2_45.b3d deleted file mode 100644 index 263276d..0000000 Binary files a/advtrains/models/advtrains_dtrack_vst2_45.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_vst31.b3d b/advtrains/models/advtrains_dtrack_vst31.b3d deleted file mode 100644 index df0f383..0000000 Binary files a/advtrains/models/advtrains_dtrack_vst31.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_vst32.b3d b/advtrains/models/advtrains_dtrack_vst32.b3d deleted file mode 100644 index 01d2978..0000000 Binary files a/advtrains/models/advtrains_dtrack_vst32.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_dtrack_vst33.b3d b/advtrains/models/advtrains_dtrack_vst33.b3d deleted file mode 100644 index 7fe418d..0000000 Binary files a/advtrains/models/advtrains_dtrack_vst33.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_modernwagon.b3d b/advtrains/models/advtrains_modernwagon.b3d deleted file mode 100644 index aacddca..0000000 Binary files a/advtrains/models/advtrains_modernwagon.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_retrosignal_off.b3d b/advtrains/models/advtrains_retrosignal_off.b3d deleted file mode 100644 index 3d231dd..0000000 Binary files a/advtrains/models/advtrains_retrosignal_off.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_retrosignal_off_30.b3d b/advtrains/models/advtrains_retrosignal_off_30.b3d deleted file mode 100644 index da258e1..0000000 Binary files a/advtrains/models/advtrains_retrosignal_off_30.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_retrosignal_off_45.b3d b/advtrains/models/advtrains_retrosignal_off_45.b3d deleted file mode 100644 index 338224a..0000000 Binary files a/advtrains/models/advtrains_retrosignal_off_45.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_retrosignal_off_60.b3d b/advtrains/models/advtrains_retrosignal_off_60.b3d deleted file mode 100644 index c560ca1..0000000 Binary files a/advtrains/models/advtrains_retrosignal_off_60.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_retrosignal_on.b3d b/advtrains/models/advtrains_retrosignal_on.b3d deleted file mode 100644 index 3d19439..0000000 Binary files a/advtrains/models/advtrains_retrosignal_on.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_retrosignal_on_30.b3d b/advtrains/models/advtrains_retrosignal_on_30.b3d deleted file mode 100644 index 98f8a92..0000000 Binary files a/advtrains/models/advtrains_retrosignal_on_30.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_retrosignal_on_45.b3d b/advtrains/models/advtrains_retrosignal_on_45.b3d deleted file mode 100644 index 414e121..0000000 Binary files a/advtrains/models/advtrains_retrosignal_on_45.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_retrosignal_on_60.b3d b/advtrains/models/advtrains_retrosignal_on_60.b3d deleted file mode 100644 index a51529a..0000000 Binary files a/advtrains/models/advtrains_retrosignal_on_60.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_signal.b3d b/advtrains/models/advtrains_signal.b3d deleted file mode 100644 index 7f69560..0000000 Binary files a/advtrains/models/advtrains_signal.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_signal_30.b3d b/advtrains/models/advtrains_signal_30.b3d deleted file mode 100644 index 0b949a7..0000000 Binary files a/advtrains/models/advtrains_signal_30.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_signal_45.b3d b/advtrains/models/advtrains_signal_45.b3d deleted file mode 100644 index ccaebf4..0000000 Binary files a/advtrains/models/advtrains_signal_45.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_signal_60.b3d b/advtrains/models/advtrains_signal_60.b3d deleted file mode 100644 index cf41e6d..0000000 Binary files a/advtrains/models/advtrains_signal_60.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_track_cr.b3d b/advtrains/models/advtrains_track_cr.b3d deleted file mode 100644 index b0f5e4b..0000000 Binary files a/advtrains/models/advtrains_track_cr.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_track_st.b3d b/advtrains/models/advtrains_track_st.b3d deleted file mode 100644 index 10b5d90..0000000 Binary files a/advtrains/models/advtrains_track_st.b3d and /dev/null differ diff --git a/advtrains/models/advtrains_track_st_45.b3d b/advtrains/models/advtrains_track_st_45.b3d deleted file mode 100644 index 32505a1..0000000 Binary files a/advtrains/models/advtrains_track_st_45.b3d and /dev/null differ diff --git a/advtrains/models/blender/engine-with-animation.blend b/advtrains/models/blender/engine-with-animation.blend deleted file mode 100644 index 2649587..0000000 Binary files a/advtrains/models/blender/engine-with-animation.blend and /dev/null differ diff --git a/advtrains/models/blender/gleis/detectorpart.png b/advtrains/models/blender/gleis/detectorpart.png deleted file mode 100644 index fc24181..0000000 Binary files a/advtrains/models/blender/gleis/detectorpart.png and /dev/null differ diff --git a/advtrains/models/blender/gleis/infos/Grafik_weiche.png b/advtrains/models/blender/gleis/infos/Grafik_weiche.png deleted file mode 100644 index 6674eb3..0000000 Binary files a/advtrains/models/blender/gleis/infos/Grafik_weiche.png and /dev/null differ diff --git a/advtrains/models/blender/gleis/infos/breite b/advtrains/models/blender/gleis/infos/breite deleted file mode 100644 index b2862c6..0000000 --- a/advtrains/models/blender/gleis/infos/breite +++ /dev/null @@ -1 +0,0 @@ -1435mm diff --git a/advtrains/models/blender/gleis/licence.txt~ b/advtrains/models/blender/gleis/licence.txt~ deleted file mode 100644 index e69de29..0000000 diff --git a/advtrains/models/blender/gleis/rail_my.blend b/advtrains/models/blender/gleis/rail_my.blend deleted file mode 100644 index 3c741bc..0000000 Binary files a/advtrains/models/blender/gleis/rail_my.blend and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_my.blend1 b/advtrains/models/blender/gleis/rail_my.blend1 deleted file mode 100644 index 6322856..0000000 Binary files a/advtrains/models/blender/gleis/rail_my.blend1 and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_my_rt.blend b/advtrains/models/blender/gleis/rail_my_rt.blend deleted file mode 100644 index 8372a0c..0000000 Binary files a/advtrains/models/blender/gleis/rail_my_rt.blend and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_my_rt.blend1 b/advtrains/models/blender/gleis/rail_my_rt.blend1 deleted file mode 100644 index 7d0978e..0000000 Binary files a/advtrains/models/blender/gleis/rail_my_rt.blend1 and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_final.blend b/advtrains/models/blender/gleis/rail_my_rt_final.blend deleted file mode 100644 index d07a65d..0000000 Binary files a/advtrains/models/blender/gleis/rail_my_rt_final.blend and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_final.blend1 b/advtrains/models/blender/gleis/rail_my_rt_final.blend1 deleted file mode 100644 index 8a2d213..0000000 Binary files a/advtrains/models/blender/gleis/rail_my_rt_final.blend1 and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_switches.blend b/advtrains/models/blender/gleis/rail_my_rt_switches.blend deleted file mode 100644 index fdce427..0000000 Binary files a/advtrains/models/blender/gleis/rail_my_rt_switches.blend and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_switches.blend1 b/advtrains/models/blender/gleis/rail_my_rt_switches.blend1 deleted file mode 100644 index 04370ba..0000000 Binary files a/advtrains/models/blender/gleis/rail_my_rt_switches.blend1 and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_switches2.blend b/advtrains/models/blender/gleis/rail_my_rt_switches2.blend deleted file mode 100644 index 9562e4d..0000000 Binary files a/advtrains/models/blender/gleis/rail_my_rt_switches2.blend and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_my_rt_switches2.blend1 b/advtrains/models/blender/gleis/rail_my_rt_switches2.blend1 deleted file mode 100644 index 07a155f..0000000 Binary files a/advtrains/models/blender/gleis/rail_my_rt_switches2.blend1 and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_together.blend b/advtrains/models/blender/gleis/rail_together.blend deleted file mode 100644 index cff51ea..0000000 Binary files a/advtrains/models/blender/gleis/rail_together.blend and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_together.png b/advtrains/models/blender/gleis/rail_together.png deleted file mode 100644 index 386cd5c..0000000 Binary files a/advtrains/models/blender/gleis/rail_together.png and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_together2.png b/advtrains/models/blender/gleis/rail_together2.png deleted file mode 100644 index 3effe34..0000000 Binary files a/advtrains/models/blender/gleis/rail_together2.png and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_together3.png b/advtrains/models/blender/gleis/rail_together3.png deleted file mode 100644 index 4a183c1..0000000 Binary files a/advtrains/models/blender/gleis/rail_together3.png and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_verticals.blend b/advtrains/models/blender/gleis/rail_verticals.blend deleted file mode 100644 index 45c37e1..0000000 Binary files a/advtrains/models/blender/gleis/rail_verticals.blend and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_verticals.blend1 b/advtrains/models/blender/gleis/rail_verticals.blend1 deleted file mode 100644 index 320f30b..0000000 Binary files a/advtrains/models/blender/gleis/rail_verticals.blend1 and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_verticals3.blend b/advtrains/models/blender/gleis/rail_verticals3.blend deleted file mode 100644 index 5d62959..0000000 Binary files a/advtrains/models/blender/gleis/rail_verticals3.blend and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_verticals3.blend1 b/advtrains/models/blender/gleis/rail_verticals3.blend1 deleted file mode 100644 index 893f2ea..0000000 Binary files a/advtrains/models/blender/gleis/rail_verticals3.blend1 and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_verticals45.blend b/advtrains/models/blender/gleis/rail_verticals45.blend deleted file mode 100644 index a1589e3..0000000 Binary files a/advtrains/models/blender/gleis/rail_verticals45.blend and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_verticals45.blend1 b/advtrains/models/blender/gleis/rail_verticals45.blend1 deleted file mode 100644 index 6b44d1c..0000000 Binary files a/advtrains/models/blender/gleis/rail_verticals45.blend1 and /dev/null differ diff --git a/advtrains/models/blender/gleis/rail_verticals45.blend11 b/advtrains/models/blender/gleis/rail_verticals45.blend11 deleted file mode 100644 index 48316e8..0000000 Binary files a/advtrains/models/blender/gleis/rail_verticals45.blend11 and /dev/null differ diff --git a/advtrains/models/blender/gleis/texturen/rail.png b/advtrains/models/blender/gleis/texturen/rail.png deleted file mode 100644 index 8478cf6..0000000 Binary files a/advtrains/models/blender/gleis/texturen/rail.png and /dev/null differ diff --git a/advtrains/models/blender/gleis/texturen/uv.png b/advtrains/models/blender/gleis/texturen/uv.png deleted file mode 100644 index fb0af3e..0000000 Binary files a/advtrains/models/blender/gleis/texturen/uv.png and /dev/null differ diff --git a/advtrains/models/blender/industrial/industry_loc.blend b/advtrains/models/blender/industrial/industry_loc.blend deleted file mode 100644 index 1a6cb2b..0000000 Binary files a/advtrains/models/blender/industrial/industry_loc.blend and /dev/null differ diff --git a/advtrains/models/blender/industrial/industry_loc.blend1 b/advtrains/models/blender/industrial/industry_loc.blend1 deleted file mode 100644 index af54c3f..0000000 Binary files a/advtrains/models/blender/industrial/industry_loc.blend1 and /dev/null differ diff --git a/advtrains/models/blender/industrial/industry_loc.blend11 b/advtrains/models/blender/industrial/industry_loc.blend11 deleted file mode 100644 index a089a65..0000000 Binary files a/advtrains/models/blender/industrial/industry_loc.blend11 and /dev/null differ diff --git a/advtrains/models/blender/industrial/industry_oil_ wagong.blend b/advtrains/models/blender/industrial/industry_oil_ wagong.blend deleted file mode 100644 index 30bde51..0000000 Binary files a/advtrains/models/blender/industrial/industry_oil_ wagong.blend and /dev/null differ diff --git a/advtrains/models/blender/industrial/industry_oil_ wagong.blend1 b/advtrains/models/blender/industrial/industry_oil_ wagong.blend1 deleted file mode 100644 index 849971d..0000000 Binary files a/advtrains/models/blender/industrial/industry_oil_ wagong.blend1 and /dev/null differ diff --git a/advtrains/models/blender/industrial/industry_tree_wagong.blend b/advtrains/models/blender/industrial/industry_tree_wagong.blend deleted file mode 100644 index 23de208..0000000 Binary files a/advtrains/models/blender/industrial/industry_tree_wagong.blend and /dev/null differ diff --git a/advtrains/models/blender/industrial/industry_tree_wagong.blend1 b/advtrains/models/blender/industrial/industry_tree_wagong.blend1 deleted file mode 100644 index bf2c9ed..0000000 Binary files a/advtrains/models/blender/industrial/industry_tree_wagong.blend1 and /dev/null differ diff --git a/advtrains/models/blender/industrial/industry_tree_wagong.png b/advtrains/models/blender/industrial/industry_tree_wagong.png deleted file mode 100644 index 87109dd..0000000 Binary files a/advtrains/models/blender/industrial/industry_tree_wagong.png and /dev/null differ diff --git a/advtrains/models/blender/locomotive.blend b/advtrains/models/blender/locomotive.blend deleted file mode 100644 index 8fd6059..0000000 Binary files a/advtrains/models/blender/locomotive.blend and /dev/null differ diff --git a/advtrains/models/blender/magnet_track.blend b/advtrains/models/blender/magnet_track.blend deleted file mode 100644 index 0ab14e7..0000000 Binary files a/advtrains/models/blender/magnet_track.blend and /dev/null differ diff --git a/advtrains/models/blender/mbb/advtrains_wagon_japan.xcf b/advtrains/models/blender/mbb/advtrains_wagon_japan.xcf deleted file mode 100644 index 4fc88c0..0000000 Binary files a/advtrains/models/blender/mbb/advtrains_wagon_japan.xcf and /dev/null differ diff --git a/advtrains/models/blender/mbb/modern_japanlocomotive.blend b/advtrains/models/blender/mbb/modern_japanlocomotive.blend deleted file mode 100644 index 6eb8f3d..0000000 Binary files a/advtrains/models/blender/mbb/modern_japanlocomotive.blend and /dev/null differ diff --git a/advtrains/models/blender/mbb/modern_japanlocomotive.blend1 b/advtrains/models/blender/mbb/modern_japanlocomotive.blend1 deleted file mode 100644 index a2e745d..0000000 Binary files a/advtrains/models/blender/mbb/modern_japanlocomotive.blend1 and /dev/null differ diff --git a/advtrains/models/blender/mbb/modern_japanlocomotive.png b/advtrains/models/blender/mbb/modern_japanlocomotive.png deleted file mode 100644 index b80d16f..0000000 Binary files a/advtrains/models/blender/mbb/modern_japanlocomotive.png and /dev/null differ diff --git a/advtrains/models/blender/mbb/modern_japanlocomotive.xcf b/advtrains/models/blender/mbb/modern_japanlocomotive.xcf deleted file mode 100644 index bb28534..0000000 Binary files a/advtrains/models/blender/mbb/modern_japanlocomotive.xcf and /dev/null differ diff --git a/advtrains/models/blender/mbb/modern_locomotive.blend b/advtrains/models/blender/mbb/modern_locomotive.blend deleted file mode 100644 index 8e72233..0000000 Binary files a/advtrains/models/blender/mbb/modern_locomotive.blend and /dev/null differ diff --git a/advtrains/models/blender/mbb/modern_wagong.blend b/advtrains/models/blender/mbb/modern_wagong.blend deleted file mode 100644 index f32710a..0000000 Binary files a/advtrains/models/blender/mbb/modern_wagong.blend and /dev/null differ diff --git a/advtrains/models/blender/mbb/modern_wagong.blend1 b/advtrains/models/blender/mbb/modern_wagong.blend1 deleted file mode 100644 index 376831c..0000000 Binary files a/advtrains/models/blender/mbb/modern_wagong.blend1 and /dev/null differ diff --git a/advtrains/models/blender/mbb/modern_wagong_uv.blend b/advtrains/models/blender/mbb/modern_wagong_uv.blend deleted file mode 100644 index 4c10fb3..0000000 Binary files a/advtrains/models/blender/mbb/modern_wagong_uv.blend and /dev/null differ diff --git a/advtrains/models/blender/mbb/modern_wagong_uv.blend1 b/advtrains/models/blender/mbb/modern_wagong_uv.blend1 deleted file mode 100644 index ce77416..0000000 Binary files a/advtrains/models/blender/mbb/modern_wagong_uv.blend1 and /dev/null differ diff --git a/advtrains/models/blender/mbb/modern_wagong_uv.png b/advtrains/models/blender/mbb/modern_wagong_uv.png deleted file mode 100644 index 68018ea..0000000 Binary files a/advtrains/models/blender/mbb/modern_wagong_uv.png and /dev/null differ diff --git a/advtrains/models/blender/mbb/prellbock.blend b/advtrains/models/blender/mbb/prellbock.blend deleted file mode 100644 index 1c20ab2..0000000 Binary files a/advtrains/models/blender/mbb/prellbock.blend and /dev/null differ diff --git a/advtrains/models/blender/mbb/prellbock.blend1 b/advtrains/models/blender/mbb/prellbock.blend1 deleted file mode 100644 index 981538e..0000000 Binary files a/advtrains/models/blender/mbb/prellbock.blend1 and /dev/null differ diff --git a/advtrains/models/blender/mbb/prellbock.uv.png b/advtrains/models/blender/mbb/prellbock.uv.png deleted file mode 100644 index 7730753..0000000 Binary files a/advtrains/models/blender/mbb/prellbock.uv.png and /dev/null differ diff --git a/advtrains/models/blender/mbb/regio-lokomotive.blend b/advtrains/models/blender/mbb/regio-lokomotive.blend deleted file mode 100644 index 210e60e..0000000 Binary files a/advtrains/models/blender/mbb/regio-lokomotive.blend and /dev/null differ diff --git a/advtrains/models/blender/mbb/regio-waron.blend b/advtrains/models/blender/mbb/regio-waron.blend deleted file mode 100644 index 19b07ce..0000000 Binary files a/advtrains/models/blender/mbb/regio-waron.blend and /dev/null differ diff --git a/advtrains/models/blender/mbb/retrosignal.blend b/advtrains/models/blender/mbb/retrosignal.blend deleted file mode 100644 index b795215..0000000 Binary files a/advtrains/models/blender/mbb/retrosignal.blend and /dev/null differ diff --git a/advtrains/models/blender/mbb/retrosignal.blend1 b/advtrains/models/blender/mbb/retrosignal.blend1 deleted file mode 100644 index 94af470..0000000 Binary files a/advtrains/models/blender/mbb/retrosignal.blend1 and /dev/null differ diff --git a/advtrains/models/blender/mbb/signal(2)_hoch.blend b/advtrains/models/blender/mbb/signal(2)_hoch.blend deleted file mode 100644 index 70391f6..0000000 Binary files a/advtrains/models/blender/mbb/signal(2)_hoch.blend and /dev/null differ diff --git a/advtrains/models/blender/mbb/signal(2)_unten.blend b/advtrains/models/blender/mbb/signal(2)_unten.blend deleted file mode 100644 index 4e917bc..0000000 Binary files a/advtrains/models/blender/mbb/signal(2)_unten.blend and /dev/null differ diff --git a/advtrains/models/blender/mbb/signal.blend b/advtrains/models/blender/mbb/signal.blend deleted file mode 100644 index 135c7b4..0000000 Binary files a/advtrains/models/blender/mbb/signal.blend and /dev/null differ diff --git a/advtrains/models/blender/mbb/signal.blend1 b/advtrains/models/blender/mbb/signal.blend1 deleted file mode 100644 index 63a8c99..0000000 Binary files a/advtrains/models/blender/mbb/signal.blend1 and /dev/null differ diff --git a/advtrains/models/blender/mbb/signal.png b/advtrains/models/blender/mbb/signal.png deleted file mode 100644 index 779cdda..0000000 Binary files a/advtrains/models/blender/mbb/signal.png and /dev/null differ diff --git a/advtrains/models/blender/mbb/signal.xcf b/advtrains/models/blender/mbb/signal.xcf deleted file mode 100644 index f667739..0000000 Binary files a/advtrains/models/blender/mbb/signal.xcf and /dev/null differ diff --git a/advtrains/models/blender/mbb/signal2.png b/advtrains/models/blender/mbb/signal2.png deleted file mode 100644 index 7af4e2d..0000000 Binary files a/advtrains/models/blender/mbb/signal2.png and /dev/null differ diff --git a/advtrains/models/blender/mbb/tr-logo.png b/advtrains/models/blender/mbb/tr-logo.png deleted file mode 100644 index 9bc0f10..0000000 Binary files a/advtrains/models/blender/mbb/tr-logo.png and /dev/null differ diff --git a/advtrains/models/blender/mbb/weichenhebel1.blend b/advtrains/models/blender/mbb/weichenhebel1.blend deleted file mode 100644 index 70b997d..0000000 Binary files a/advtrains/models/blender/mbb/weichenhebel1.blend and /dev/null differ diff --git a/advtrains/models/blender/mbb/weichenhebel2.blend b/advtrains/models/blender/mbb/weichenhebel2.blend deleted file mode 100644 index c1c3aac..0000000 Binary files a/advtrains/models/blender/mbb/weichenhebel2.blend and /dev/null differ diff --git a/advtrains/models/blender/newlocomotive.blend b/advtrains/models/blender/newlocomotive.blend deleted file mode 100644 index 858882b..0000000 Binary files a/advtrains/models/blender/newlocomotive.blend and /dev/null differ diff --git a/advtrains/models/blender/newlocomotive.blend1 b/advtrains/models/blender/newlocomotive.blend1 deleted file mode 100644 index 4b8b24f..0000000 Binary files a/advtrains/models/blender/newlocomotive.blend1 and /dev/null differ diff --git a/advtrains/models/blender/newlocomotive_uvs.png b/advtrains/models/blender/newlocomotive_uvs.png deleted file mode 100644 index 879be65..0000000 Binary files a/advtrains/models/blender/newlocomotive_uvs.png and /dev/null differ diff --git a/advtrains/models/blender/newwagon.blend b/advtrains/models/blender/newwagon.blend deleted file mode 100644 index 1cedc55..0000000 Binary files a/advtrains/models/blender/newwagon.blend and /dev/null differ diff --git a/advtrains/models/blender/newwagon.blend1 b/advtrains/models/blender/newwagon.blend1 deleted file mode 100644 index eb30fde..0000000 Binary files a/advtrains/models/blender/newwagon.blend1 and /dev/null differ diff --git a/advtrains/models/blender/newwagon.png b/advtrains/models/blender/newwagon.png deleted file mode 100644 index 812bc32..0000000 Binary files a/advtrains/models/blender/newwagon.png and /dev/null differ diff --git a/advtrains/models/blender/subway-train.blend b/advtrains/models/blender/subway-train.blend deleted file mode 100644 index 690d87b..0000000 Binary files a/advtrains/models/blender/subway-train.blend and /dev/null differ diff --git a/advtrains/models/blender/subway-train.blend1 b/advtrains/models/blender/subway-train.blend1 deleted file mode 100644 index 86d1f92..0000000 Binary files a/advtrains/models/blender/subway-train.blend1 and /dev/null differ diff --git a/advtrains/models/blender/subway-train.png b/advtrains/models/blender/subway-train.png deleted file mode 100644 index d0b9731..0000000 Binary files a/advtrains/models/blender/subway-train.png and /dev/null differ diff --git a/advtrains/models/blender/subway-train.xcf b/advtrains/models/blender/subway-train.xcf deleted file mode 100644 index 775b87c..0000000 Binary files a/advtrains/models/blender/subway-train.xcf and /dev/null differ diff --git a/advtrains/models/blender/trackplane.blend b/advtrains/models/blender/trackplane.blend deleted file mode 100644 index 79365f7..0000000 Binary files a/advtrains/models/blender/trackplane.blend and /dev/null differ diff --git a/advtrains/models/blender/trackvertical1.blend b/advtrains/models/blender/trackvertical1.blend deleted file mode 100644 index fca6742..0000000 Binary files a/advtrains/models/blender/trackvertical1.blend and /dev/null differ diff --git a/advtrains/models/blender/trackvertical1.blend1 b/advtrains/models/blender/trackvertical1.blend1 deleted file mode 100644 index b146b56..0000000 Binary files a/advtrains/models/blender/trackvertical1.blend1 and /dev/null differ diff --git a/advtrains/models/blender/trackvertical1.png b/advtrains/models/blender/trackvertical1.png deleted file mode 100644 index a998dcb..0000000 Binary files a/advtrains/models/blender/trackvertical1.png and /dev/null differ diff --git a/advtrains/models/blender/trackvertical2.blend b/advtrains/models/blender/trackvertical2.blend deleted file mode 100644 index a066b84..0000000 Binary files a/advtrains/models/blender/trackvertical2.blend and /dev/null differ diff --git a/advtrains/models/blender/trackvertical2.png b/advtrains/models/blender/trackvertical2.png deleted file mode 100644 index 43142f9..0000000 Binary files a/advtrains/models/blender/trackvertical2.png and /dev/null differ diff --git a/advtrains/models/oldmodels/locomotive.b3d b/advtrains/models/oldmodels/locomotive.b3d deleted file mode 100644 index 5e16be3..0000000 Binary files a/advtrains/models/oldmodels/locomotive.b3d and /dev/null differ diff --git a/advtrains/models/oldmodels/trackvertical1.b3d b/advtrains/models/oldmodels/trackvertical1.b3d deleted file mode 100644 index 5620f60..0000000 Binary files a/advtrains/models/oldmodels/trackvertical1.b3d and /dev/null differ diff --git a/advtrains/models/oldmodels/trackvertical2.b3d b/advtrains/models/oldmodels/trackvertical2.b3d deleted file mode 100644 index 22dbb20..0000000 Binary files a/advtrains/models/oldmodels/trackvertical2.b3d and /dev/null differ diff --git a/advtrains/models/trackplane.b3d b/advtrains/models/trackplane.b3d deleted file mode 100644 index b4728c3..0000000 Binary files a/advtrains/models/trackplane.b3d and /dev/null differ diff --git a/advtrains/modpack.txt b/advtrains/modpack.txt new file mode 100644 index 0000000..e69de29 diff --git a/advtrains/pseudoload.lua b/advtrains/pseudoload.lua deleted file mode 100644 index 677cd14..0000000 --- a/advtrains/pseudoload.lua +++ /dev/null @@ -1,182 +0,0 @@ -local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end - ---pseudoload.lua ---responsible for keeping up a database of all rail nodes existant in the world, regardless of whether the mapchunk is loaded. - -advtrains.trackdb={} ---trackdb[tt][y][x][z]={conn1, conn2, rely1, rely2, railheight} ---serialization format: ---(2byte x)(2byte y)(2byte z)(4bits conn1, 4bits conn2)[(plain rely1)|(plain rely2)|(plain railheight)]\n ---[] may be missing if 0,0,0 - ---load initially - ---[[ TODO temporary outcomment - ---delayed since all traintypes need to be registered -minetest.after(0, function() - -for tt, _ in pairs(advtrains.all_traintypes) do - local pl_fpath=minetest.get_worldpath().."/advtrains_trackdb_"..tt - advtrains.trackdb[tt]={} - local file, err = io.open(pl_fpath, "r") - if not file then - local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains trackdb save file "..er) - else - --custom format to save memory - while true do - local xbytes=file:read(2) - if not xbytes or #xbytes<2 then - break --eof reached - end - print(xbytes) - local ybytes=file:read(2) - local zbytes=file:read(2) - local x=(string.byte(xbytes[1])-128)*256+(string.byte(xbytes[2])) - local y=(string.byte(ybytes[1])-128)*256+(string.byte(ybytes[2])) - local z=(string.byte(zbytes[1])-128)*256+(string.byte(zbytes[2])) - - local conn1=string.byte(file:read(1)) - local conn1=string.byte(file:read(1)) - - if not advtrains.trackdb[tt][y] then advtrains.trackdb[tt][y]={} end - if not advtrains.trackdb[tt][y][x] then advtrains.trackdb[tt][y][x]={} end - - local rest=file.read("*l") - if rest~="" then - local rely1, rely2, railheight=string.match(rest, "([^|]+)|([^|]+)|([^|]+)") - if rely1 and rely2 and railheight then - advtrains.trackdb[tt][y][x][z]={ - conn1=conn1, conn2=conn2, - rely1=rely1, rely2=rely2, - railheight=railheight - } - else - advtrains.trackdb[tt][y][x][z]={ - conn1=conn1, conn2=conn2 - } - end - else - advtrains.trackdb[tt][y][x][z]={ - conn1=conn1, conn2=conn2 - } - end - end - file:close() - end -end - ---end minetest.after -end) - -function advtrains.save_trackdb() - for tt, _ in pairs(advtrains.all_traintypes) do - local pl_fpath=minetest.get_worldpath().."/advtrains_trackdb_"..tt - local file, err = io.open(pl_fpath, "w") - if not file then - local er=err or "Unknown Error" - print("[advtrains]Failed saving advtrains trackdb save file "..er) - else - --custom format to save memory - for y,tyl in pairs(advtrains.trackdb[tt]) do - for x,txl in pairs(tyl) do - for z,rail in pairs(txl) do - print("write "..x.." "..y.." "..z.." "..minetest.serialize(rail)) - file:write(string.char(math.floor(x/256)+128)..string.char((x%256))) - file:write(string.char(math.floor(y/256)+128)..string.char((y%256))) - file:write(string.char(math.floor(z/256)+128)..string.char((z%256))) - file:write(string.char(rail.conn1)) - file:write(string.char(rail.conn2)) - if (rail.rely1 and rail.rely1~=0) or (rail.rely2 and rail.rely2~=0) or (rail.railheight and rail.railheight~=0) then - file:write(rail.rely1.."|"..rail.rely2.."|"..rail.railheight) - end - file:write("\n") - end - end - end - file:close() - end - end -end -]]--end temp outcomment -advtrains.trackdb={} -advtrains.fpath_tdb=minetest.get_worldpath().."/advtrains_trackdb2" -local file, err = io.open(advtrains.fpath_tdb, "r") -if not file then - local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains save file "..er) -else - local tbl = minetest.deserialize(file:read("*a")) - if type(tbl) == "table" then - advtrains.trackdb=tbl - end - file:close() -end -function advtrains.save_trackdb() - local datastr = minetest.serialize(advtrains.trackdb) - if not datastr then - minetest.log("error", "[advtrains] Failed to serialize trackdb data!") - return - end - local file, err = io.open(advtrains.fpath_tdb, "w") - if err then - return err - end - file:write(datastr) - file:close() -end - ---get_node with pseudoload. ---returns: ---true, conn1, conn2, rely1, rely2, railheight in case everything's right. ---false if it's not a rail or the train does not drive on this rail, but it is loaded or ---nil if the node is neither loaded nor in trackdb ---the distraction between false and nil will be needed only in special cases.(train initpos) -function advtrains.get_rail_info_at(pos, drives_on) - local node=minetest.get_node_or_nil(pos) - if not node then - --try raildb - local rdp=vector.round(pos) - local dbe=(advtrains.trackdb[traintype] and advtrains.trackdb[traintype][rdp.y] and advtrains.trackdb[traintype][rdp.y][rdp.x] and advtrains.trackdb[traintype][rdp.y][rdp.x][rdp.z]) - if dbe then - for tt,_ in pairs(drives_on) do - if not dbe.tracktype or tt==dbe.tracktype then - return true, dbe.conn1, dbe.conn2, dbe.rely1 or 0, dbe.rely2 or 0, dbe.railheight or 0 - end - end - else - return nil - end - end - local nodename=node.name - if(not advtrains.is_track_and_drives_on(nodename, drives_on)) then - return false - end - local conn1, conn2, rely1, rely2, railheight, tracktype=advtrains.get_track_connections(node.name, node.param2) - - --already in trackdb? - local rdp=vector.round(pos) - if not (advtrains.trackdb and advtrains.trackdb[rdp.y] and advtrains.trackdb[rdp.y][rdp.x] and advtrains.trackdb[rdp.y][rdp.x][rdp.z]) then--TODO is this necessary? - if not advtrains.trackdb then advtrains.trackdb={} end - if not advtrains.trackdb[rdp.y] then advtrains.trackdb[rdp.y]={} end - if not advtrains.trackdb[rdp.y][rdp.x] then advtrains.trackdb[rdp.y][rdp.x]={} end - advtrains.trackdb[rdp.y][rdp.x][rdp.z]={ - conn1=conn1, conn2=conn2, - rely1=rely1, rely2=rely2, - railheight=railheight, tracktype=tracktype - } - end - - return true, conn1, conn2, rely1, rely2, railheight -end -function advtrains.reset_trackdb_position(pos) - local rdp=vector.round(pos) - if not advtrains.trackdb then advtrains.trackdb={} end - if not advtrains.trackdb[rdp.y] then advtrains.trackdb[rdp.y]={} end - if not advtrains.trackdb[rdp.y][rdp.x] then advtrains.trackdb[rdp.y][rdp.x]={} end - advtrains.trackdb[rdp.y][rdp.x][rdp.z]=nil - advtrains.get_rail_info_at(pos, advtrains.all_tracktypes)--to restore it. -end - - diff --git a/advtrains/readme.txt b/advtrains/readme.txt deleted file mode 100644 index ad093bd..0000000 --- a/advtrains/readme.txt +++ /dev/null @@ -1,23 +0,0 @@ - -## ADVTRAINS ## realistic trains in Minetest! -by orwell96 and contributors(see below) - -For up-to-date information, visit https://forum.minetest.net/viewtopic.php?f=9&t=14726 - - -Manual: -If manual.pdf is not present (which is the case when you downloaded the zip file), see https://github.com/orwell96/advtrains/blob/master/manual.pdf - -License of code: LGPL 2.1 -License of media: CC-BY-NC-SA 3.0 - -Contributions: - -Gravel Texture : from Minetest Game -Initial rail model/texture : DS-minetest -Models for signals/bumpers : mbb -Steam engine / wagon texture: mbb -Industrial engine/wagons : mbb -Inventory images : mbb -Small code contributions : NaruTrey / gpcf -Mod Description : hajo \ No newline at end of file diff --git a/advtrains/screenshot.png b/advtrains/screenshot.png new file mode 100644 index 0000000..78783e1 Binary files /dev/null and b/advtrains/screenshot.png differ diff --git a/advtrains/signals.lua b/advtrains/signals.lua deleted file mode 100644 index 8be65e0..0000000 --- a/advtrains/signals.lua +++ /dev/null @@ -1,76 +0,0 @@ ---advtrains by orwell96 ---signals.lua -for r,f in pairs({on="off", off="on"}) do - - advtrains.trackplacer.register_tracktype("advtrains:retrosignal", "") - advtrains.trackplacer.register_tracktype("advtrains:signal", "") - - for rotid, rotation in ipairs({"", "_30", "_45", "_60"}) do - local crea=1 - if rotid==1 and r=="off" then crea=0 end - - minetest.register_node("advtrains:retrosignal_"..r..rotation, { - drawtype = "mesh", - paramtype="light", - paramtype2="facedir", - walkable = false, - selection_box = { - type = "fixed", - fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4}, - }, - mesh = "advtrains_retrosignal_"..r..rotation..".b3d", - tiles = {"advtrains_retrosignal.png"}, - inventory_image="advtrains_retrosignal_inv.png", - drop="advtrains:retrosignal_off", - description="Lampless Signal ("..r..rotation..")", - on_rightclick=switchfunc, - sunlight_propagates=true, - groups = { - choppy=3, - not_blocking_trains=1, - not_in_creative_inventory=crea, - }, - mesecons = {effector = { - ["action_"..f] = function (pos, node) - minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2}) - end - }}, - on_rightclick=function(pos, node, clicker) - minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2}) - end, - }) - advtrains.trackplacer.add_worked("advtrains:retrosignal", r, rotation, nil) - minetest.register_node("advtrains:signal_"..r..rotation, { - drawtype = "mesh", - paramtype="light", - paramtype2="facedir", - walkable = false, - selection_box = { - type = "fixed", - fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4}, - }, - mesh = "advtrains_signal"..rotation..".b3d", - tiles = {"advtrains_signal_"..r..".png"}, - inventory_image="advtrains_signal_inv.png", - drop="advtrains:signal_off", - description="Signal ("..r..rotation..")", - on_rightclick=switchfunc, - groups = { - choppy=3, - not_blocking_trains=1, - not_in_creative_inventory=crea, - }, - light_source = 1, - sunlight_propagates=true, - mesecons = {effector = { - ["action_"..f] = function (pos, node) - minetest.swap_node(pos, {name = "advtrains:signal_"..f..rotation, param2 = node.param2}) - end - }}, - on_rightclick=function(pos, node, clicker) - minetest.swap_node(pos, {name = "advtrains:signal_"..f..rotation, param2 = node.param2}) - end, - }) - advtrains.trackplacer.add_worked("advtrains:signal", r, rotation, nil) - end -end diff --git a/advtrains/textures/advtrains_couple.png b/advtrains/textures/advtrains_couple.png deleted file mode 100644 index 9e997e4..0000000 Binary files a/advtrains/textures/advtrains_couple.png and /dev/null differ diff --git a/advtrains/textures/advtrains_discouple.png b/advtrains/textures/advtrains_discouple.png deleted file mode 100644 index b27c4fb..0000000 Binary files a/advtrains/textures/advtrains_discouple.png and /dev/null differ diff --git a/advtrains/textures/advtrains_dtrack_atc_placer.png b/advtrains/textures/advtrains_dtrack_atc_placer.png deleted file mode 100644 index 31c2b30..0000000 Binary files a/advtrains/textures/advtrains_dtrack_atc_placer.png and /dev/null differ diff --git a/advtrains/textures/advtrains_dtrack_bumper_placer.png b/advtrains/textures/advtrains_dtrack_bumper_placer.png deleted file mode 100644 index 27191fe..0000000 Binary files a/advtrains/textures/advtrains_dtrack_bumper_placer.png and /dev/null differ diff --git a/advtrains/textures/advtrains_dtrack_detector_placer.png b/advtrains/textures/advtrains_dtrack_detector_placer.png deleted file mode 100644 index e6c6ad6..0000000 Binary files a/advtrains/textures/advtrains_dtrack_detector_placer.png and /dev/null differ diff --git a/advtrains/textures/advtrains_dtrack_placer.png b/advtrains/textures/advtrains_dtrack_placer.png deleted file mode 100644 index 7bef8a9..0000000 Binary files a/advtrains/textures/advtrains_dtrack_placer.png and /dev/null differ diff --git a/advtrains/textures/advtrains_dtrack_rail.png b/advtrains/textures/advtrains_dtrack_rail.png deleted file mode 100644 index 1cf7f83..0000000 Binary files a/advtrains/textures/advtrains_dtrack_rail.png and /dev/null differ diff --git a/advtrains/textures/advtrains_dtrack_rail_atc.png b/advtrains/textures/advtrains_dtrack_rail_atc.png deleted file mode 100644 index d171985..0000000 Binary files a/advtrains/textures/advtrains_dtrack_rail_atc.png and /dev/null differ diff --git a/advtrains/textures/advtrains_dtrack_rail_detector_on.png b/advtrains/textures/advtrains_dtrack_rail_detector_on.png deleted file mode 100644 index 4f09b35..0000000 Binary files a/advtrains/textures/advtrains_dtrack_rail_detector_on.png and /dev/null differ diff --git a/advtrains/textures/advtrains_dtrack_slopeplacer.png b/advtrains/textures/advtrains_dtrack_slopeplacer.png deleted file mode 100644 index 1d456b0..0000000 Binary files a/advtrains/textures/advtrains_dtrack_slopeplacer.png and /dev/null differ diff --git a/advtrains/textures/advtrains_newlocomotive.xcf b/advtrains/textures/advtrains_newlocomotive.xcf deleted file mode 100644 index 9ad5187..0000000 Binary files a/advtrains/textures/advtrains_newlocomotive.xcf and /dev/null differ diff --git a/advtrains/textures/advtrains_platform.png b/advtrains/textures/advtrains_platform.png deleted file mode 100644 index 5ba9663..0000000 Binary files a/advtrains/textures/advtrains_platform.png and /dev/null differ diff --git a/advtrains/textures/advtrains_retrosignal.png b/advtrains/textures/advtrains_retrosignal.png deleted file mode 100644 index 141198d..0000000 Binary files a/advtrains/textures/advtrains_retrosignal.png and /dev/null differ diff --git a/advtrains/textures/advtrains_retrosignal_inv.png b/advtrains/textures/advtrains_retrosignal_inv.png deleted file mode 100644 index 1036594..0000000 Binary files a/advtrains/textures/advtrains_retrosignal_inv.png and /dev/null differ diff --git a/advtrains/textures/advtrains_signal_inv.png b/advtrains/textures/advtrains_signal_inv.png deleted file mode 100644 index ed64ed9..0000000 Binary files a/advtrains/textures/advtrains_signal_inv.png and /dev/null differ diff --git a/advtrains/textures/advtrains_signal_off.png b/advtrains/textures/advtrains_signal_off.png deleted file mode 100644 index 8046e52..0000000 Binary files a/advtrains/textures/advtrains_signal_off.png and /dev/null differ diff --git a/advtrains/textures/advtrains_signal_on.png b/advtrains/textures/advtrains_signal_on.png deleted file mode 100644 index 5228bb3..0000000 Binary files a/advtrains/textures/advtrains_signal_on.png and /dev/null differ diff --git a/advtrains/textures/advtrains_track_cr.png b/advtrains/textures/advtrains_track_cr.png deleted file mode 100644 index 40f0cc5..0000000 Binary files a/advtrains/textures/advtrains_track_cr.png and /dev/null differ diff --git a/advtrains/textures/advtrains_track_cr_45.png b/advtrains/textures/advtrains_track_cr_45.png deleted file mode 100644 index 54966b3..0000000 Binary files a/advtrains/textures/advtrains_track_cr_45.png and /dev/null differ diff --git a/advtrains/textures/advtrains_track_placer.png b/advtrains/textures/advtrains_track_placer.png deleted file mode 100644 index 03e17ed..0000000 Binary files a/advtrains/textures/advtrains_track_placer.png and /dev/null differ diff --git a/advtrains/textures/advtrains_track_st.png b/advtrains/textures/advtrains_track_st.png deleted file mode 100644 index 5ad7e4f..0000000 Binary files a/advtrains/textures/advtrains_track_st.png and /dev/null differ diff --git a/advtrains/textures/advtrains_track_st_45.png b/advtrains/textures/advtrains_track_st_45.png deleted file mode 100644 index 63b4c96..0000000 Binary files a/advtrains/textures/advtrains_track_st_45.png and /dev/null differ diff --git a/advtrains/textures/advtrains_track_swlcr.png b/advtrains/textures/advtrains_track_swlcr.png deleted file mode 100644 index d9b5c0b..0000000 Binary files a/advtrains/textures/advtrains_track_swlcr.png and /dev/null differ diff --git a/advtrains/textures/advtrains_track_swlcr_45.png b/advtrains/textures/advtrains_track_swlcr_45.png deleted file mode 100644 index f098fc9..0000000 Binary files a/advtrains/textures/advtrains_track_swlcr_45.png and /dev/null differ diff --git a/advtrains/textures/advtrains_track_swlst.png b/advtrains/textures/advtrains_track_swlst.png deleted file mode 100644 index 314bd2d..0000000 Binary files a/advtrains/textures/advtrains_track_swlst.png and /dev/null differ diff --git a/advtrains/textures/advtrains_track_swlst_45.png b/advtrains/textures/advtrains_track_swlst_45.png deleted file mode 100644 index 765d0ec..0000000 Binary files a/advtrains/textures/advtrains_track_swlst_45.png and /dev/null differ diff --git a/advtrains/textures/advtrains_track_swrcr.png b/advtrains/textures/advtrains_track_swrcr.png deleted file mode 100644 index f74e1bc..0000000 Binary files a/advtrains/textures/advtrains_track_swrcr.png and /dev/null differ diff --git a/advtrains/textures/advtrains_track_swrcr_45.png b/advtrains/textures/advtrains_track_swrcr_45.png deleted file mode 100644 index fa432aa..0000000 Binary files a/advtrains/textures/advtrains_track_swrcr_45.png and /dev/null differ diff --git a/advtrains/textures/advtrains_track_swrst.png b/advtrains/textures/advtrains_track_swrst.png deleted file mode 100644 index 06ea29e..0000000 Binary files a/advtrains/textures/advtrains_track_swrst.png and /dev/null differ diff --git a/advtrains/textures/advtrains_track_swrst_45.png b/advtrains/textures/advtrains_track_swrst_45.png deleted file mode 100644 index be477b7..0000000 Binary files a/advtrains/textures/advtrains_track_swrst_45.png and /dev/null differ diff --git a/advtrains/textures/advtrains_trackworker.png b/advtrains/textures/advtrains_trackworker.png deleted file mode 100644 index b50bcae..0000000 Binary files a/advtrains/textures/advtrains_trackworker.png and /dev/null differ diff --git a/advtrains/textures/drwho_screwdriver.png b/advtrains/textures/drwho_screwdriver.png deleted file mode 100644 index b50bcae..0000000 Binary files a/advtrains/textures/drwho_screwdriver.png and /dev/null differ diff --git a/advtrains/textures/larger rails.xcf b/advtrains/textures/larger rails.xcf deleted file mode 100644 index 42ae592..0000000 Binary files a/advtrains/textures/larger rails.xcf and /dev/null differ diff --git a/advtrains/trackplacer.lua b/advtrains/trackplacer.lua deleted file mode 100644 index b24103a..0000000 --- a/advtrains/trackplacer.lua +++ /dev/null @@ -1,297 +0,0 @@ ---trackplacer.lua ---holds code for the track-placing system. the default 'track' item will be a craftitem that places rails as needed. this will neither place or change switches nor place vertical rails. - ---all new trackplacer code -local tp={ - tracks={} -} - -function tp.register_tracktype(nnprefix, n_suffix) - tp.tracks[nnprefix]={ - default=n_suffix, - single_conn={}, - double_conn={}, - --keys:conn1_conn2 (example:1_4) - --values:{name=x, param2=x} - twcycle={}, - twrotate={},--indexed by suffix, list, tells order of rotations - modify={} - } -end -function tp.add_double_conn(nnprefix, suffix, rotation, conns) - local nodename=nnprefix.."_"..suffix..rotation - for i=0,3 do - tp.tracks[nnprefix].double_conn[((conns.conn1+4*i)%16).."_"..((conns.conn2+4*i)%16)]={name=nodename, param2=i} - tp.tracks[nnprefix].double_conn[((conns.conn2+4*i)%16).."_"..((conns.conn1+4*i)%16)]={name=nodename, param2=i} - end - tp.tracks[nnprefix].modify[nodename]=true -end -function tp.add_single_conn(nnprefix, suffix, rotation, conns) - local nodename=nnprefix.."_"..suffix..rotation - for i=0,3 do - tp.tracks[nnprefix].single_conn[((conns.conn1+4*i)%16)]={name=nodename, param2=i} - tp.tracks[nnprefix].single_conn[((conns.conn2+4*i)%16)]={name=nodename, param2=i} - end - tp.tracks[nnprefix].modify[nodename]=true -end - -function tp.add_worked(nnprefix, suffix, rotation, cycle_follows) - tp.tracks[nnprefix].twcycle[suffix]=cycle_follows - if not tp.tracks[nnprefix].twrotate[suffix] then tp.tracks[nnprefix].twrotate[suffix]={} end - table.insert(tp.tracks[nnprefix].twrotate[suffix], rotation) -end - - ---[[ - rewrite algorithm. - selection criteria: these will never be changed or even selected: - - tracks being already connected on both sides - - tracks that are already connected on one side but are not bendable to the desired position - the following situations can occur: - 1. there are two more than two rails around - 1.1 there is one or more subset(s) that can be directly connected - -> choose the first possibility - 2.2 not - -> choose the first one and orient straight - 2. there's exactly 1 rail around - -> choose and orient straight - 3. there's no rail around - -> set straight -]] -function tp.find_already_connected(pos)--TODO vertical calculations(check node below) - local function istrackandbc(pos, conn) - local cnode=minetest.get_node(advtrains.dirCoordSet(pos, conn)) - local bconn=(conn+8)%16 - if advtrains.is_track_and_drives_on(cnode.name, advtrains.all_tracktypes) then - local cconn1, cconn2=advtrains.get_track_connections(cnode.name, cnode.param2) - return cconn1==bconn or cconn2==bconn - end - return false - end - local dnode=minetest.get_node(pos) - local dconn1, dconn2=advtrains.get_track_connections(dnode.name, dnode.param2) - local t={[true]="true", [false]="false"} - if istrackandbc(pos, dconn1) and istrackandbc(pos, dconn2) then return dconn1, dconn2 - elseif istrackandbc(pos, dconn1) then return dconn1 - elseif istrackandbc(pos, dconn2) then return dconn2 - end - return nil -end -function tp.rail_and_can_be_bent(originpos, conn, nnpref) - local pos=advtrains.dirCoordSet(originpos, conn) - local newdir=(conn+8)%16 - local node=minetest.get_node(pos) - local tr=tp.tracks[nnpref] - if not advtrains.is_track_and_drives_on(node.name, advtrains.all_tracktypes) then - return false - end - --rail at other end? - local adj1, adj2=tp.find_already_connected(pos) - if adj1 and adj2 then - return false--dont destroy existing track - elseif adj1 and not adj2 then - if tr.double_conn[adj1.."_"..newdir] then - return true--if exists, connect new rail and old end - end - return false - else - if tr.single_conn[newdir] then--just rotate old rail to right orientation - return true - end - return false - end -end -function tp.bend_rail(originpos, conn, nnpref) - local pos=advtrains.dirCoordSet(originpos, conn) - local newdir=(conn+8)%16 - local node=minetest.get_node(pos) - local tr=tp.tracks[nnpref] - --is rail already connected? no need to bend. - local conn1, conn2=advtrains.get_track_connections(node.name, node.param2) - if newdir==conn1 or newdir==conn2 then - return - end - --rail at other end? - local adj1, adj2=tp.find_already_connected(pos) - if adj1 and adj2 then - return false--dont destroy existing track - elseif adj1 and not adj2 then - if tr.double_conn[adj1.."_"..newdir] then - minetest.set_node(pos, tr.double_conn[adj1.."_"..newdir]) - return true--if exists, connect new rail and old end - end - return false - else - if tr.single_conn[newdir] then--just rotate old rail to right orientation - minetest.set_node(pos, tr.single_conn[newdir]) - return true - end - return false - end -end -function tp.placetrack(pos, nnpref, placer, itemstack, pointed_thing) - --1. find all rails that are likely to be connected - local tr=tp.tracks[nnpref] - local p_rails={} - for i=0,15 do - if tp.rail_and_can_be_bent(pos, i, nnpref) then - p_rails[#p_rails+1]=i - end - end - if #p_rails==0 then - minetest.set_node(pos, {name=nnpref.."_"..tr.default}) - if minetest.registered_nodes[nnpref.."_"..tr.default] and minetest.registered_nodes[nnpref.."_"..tr.default].after_place_node then - minetest.registered_nodes[nnpref.."_"..tr.default].after_place_node(pos, placer, itemstack, pointed_thing) - end - elseif #p_rails==1 then - tp.bend_rail(pos, p_rails[1], nnpref) - minetest.set_node(pos, tr.single_conn[p_rails[1]]) - local nname=tr.single_conn[p_rails[1]].name - if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then - minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) - end - else - --iterate subsets - for k1, conn1 in ipairs(p_rails) do - for k2, conn2 in ipairs(p_rails) do - if k1~=k2 then - if (tr.double_conn[conn1.."_"..conn2]) then - tp.bend_rail(pos, conn1, nnpref) - tp.bend_rail(pos, conn2, nnpref) - minetest.set_node(pos, tr.double_conn[conn1.."_"..conn2]) - local nname=tr.double_conn[conn1.."_"..conn2].name - if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then - minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) - end - return - end - end - end - end - --not found - tp.bend_rail(pos, p_rails[1], nnpref) - minetest.set_node(pos, tr.single_conn[p_rails[1]]) - local nname=tr.single_conn[p_rails[1]].name - if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then - minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) - end - end -end - - -function tp.register_track_placer(nnprefix, imgprefix, dispname) - minetest.register_craftitem(nnprefix.."_placer",{ - description = dispname, - inventory_image = imgprefix.."_placer.png", - wield_image = imgprefix.."_placer.png", - groups={}, - on_place = function(itemstack, placer, pointed_thing) - local name = placer:get_player_name() - if not name then - return itemstack - end - if pointed_thing.type=="node" then - local pos=pointed_thing.above - local upos=pointed_thing.under - if minetest.is_protected(pos,name) and minetest.is_protected(upos,name) then - return itemstack - end - if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to - and minetest.registered_nodes[minetest.get_node(upos).name] and minetest.registered_nodes[minetest.get_node(upos).name].walkable then - tp.placetrack(pos, nnprefix, placer, itemstack, pointed_thing) - if not minetest.setting_getbool("creative_mode") then - itemstack:take_item() - end - end - end - return itemstack - end, - }) -end - - - -minetest.register_craftitem("advtrains:trackworker",{ - description = "Track Worker Tool\n\nLeft-click: change rail type (straight/curve/switch)\nRight-click: rotate rail/bumper/signal/etc.", - groups = {cracky=1}, -- key=name, value=rating; rating=1..3. - inventory_image = "advtrains_trackworker.png", - wield_image = "advtrains_trackworker.png", - stack_max = 1, - on_place = function(itemstack, placer, pointed_thing) - local name = placer:get_player_name() - if not name then - return - end - if pointed_thing.type=="node" then - local pos=pointed_thing.under - if minetest.is_protected(pos, name) then - return - end - local node=minetest.get_node(pos) - - --if not advtrains.is_track_and_drives_on(minetest.get_node(pos).name, advtrains.all_tracktypes) then return end - if advtrains.is_train_at_pos(pos) then return end - - local nnprefix, suffix, rotation=string.match(node.name, "^(.+)_([^_]+)(_[^_]+)$") - --print(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) - if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then - nnprefix, suffix=string.match(node.name, "^(.+)_([^_]+)$") - rotation = "" - if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then - minetest.chat_send_player(placer:get_player_name(), "This node can't be rotated using the trackworker!") - return - end - end - local modext=tp.tracks[nnprefix].twrotate[suffix] - - if rotation==modext[#modext] then --increase param2 - minetest.swap_node(pos, {name=nnprefix.."_"..suffix..modext[1], param2=(node.param2+1)%4}) - return - else - local modpos - for k,v in pairs(modext) do if v==rotation then modpos=k end end - if not modpos then - minetest.chat_send_player(placer:get_player_name(), "This node can't be rotated using the trackworker!") - return - end - minetest.swap_node(pos, {name=nnprefix.."_"..suffix..modext[modpos+1], param2=node.param2}) - end - advtrains.invalidate_all_paths() - end - end, - on_use=function(itemstack, user, pointed_thing) - local name = user:get_player_name() - if not name then - return - end - if pointed_thing.type=="node" then - local pos=pointed_thing.under - local node=minetest.get_node(pos) - if minetest.is_protected(pos, name) then - return - end - - --if not advtrains.is_track_and_drives_on(minetest.get_node(pos).name, advtrains.all_tracktypes) then return end - if advtrains.is_train_at_pos(pos) then return end - local nnprefix, suffix, rotation=string.match(node.name, "^(.+)_([^_]+)(_[^_]+)$") - --print(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) - if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twcycle[suffix] then - nnprefix, suffix=string.match(node.name, "^(.+)_([^_]+)$") - rotation = "" - if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twcycle[suffix] then - minetest.chat_send_player(user:get_player_name(), "This node can't be changed using the trackworker!") - return - end - end - local nextsuffix=tp.tracks[nnprefix].twcycle[suffix] - minetest.swap_node(pos, {name=nnprefix.."_"..nextsuffix..rotation, param2=node.param2}) - --invalidate trains - advtrains.invalidate_all_paths() - else - print(name, dump(tp.tracks)) - end - end, -}) - ---putting into right place -advtrains.trackplacer=tp diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua deleted file mode 100644 index beb0bbc..0000000 --- a/advtrains/tracks.lua +++ /dev/null @@ -1,721 +0,0 @@ ---advtrains by orwell96, see readme.txt - ---dev-time settings: ---EDIT HERE ---If the old non-model rails on straight tracks should be replaced by the new... ---false: no ---true: yes -advtrains.register_replacement_lbms=false - ---[[TracksDefinition -nodename_prefix -texture_prefix -description -common={} -straight={} -straight45={} -curve={} -curve45={} -lswitchst={} -lswitchst45={} -rswitchst={} -rswitchst45={} -lswitchcr={} -lswitchcr45={} -rswitchcr={} -rswitchcr45={} -vert1={ - --you'll probably want to override mesh here -} -vert2={ - --you'll probably want to override mesh here -} -]]-- -advtrains.all_tracktypes={} - ---definition preparation -local function conns(c1, c2, r1, r2, rh, rots) return {conn1=c1, conn2=c2, rely1=r1, rely2=r2, railheight=rh} end - -local ap={} -ap.t_30deg={ - regstep=1, - variant={ - st=conns(0,8), - cr=conns(0,7), - swlst=conns(0,8), - swlcr=conns(0,7), - swrst=conns(0,8), - swrcr=conns(0,9), - vst1=conns(8,0,0,0.5,0.25), - vst2=conns(8,0,0.5,1,0.75), - vst31=conns(8,0,0,0.33,0.16), - vst32=conns(8,0,0.33,0.66,0.5), - vst33=conns(8,0,0.66,1,0.83), - }, - description={ - st="straight", - cr="curve", - swlst="left switch (straight)", - swlcr="left switch (curve)", - swrst="right switch (straight)", - swrcr="right switch (curve)", - vst1="steep uphill 1/2", - vst2="steep uphill 2/2", - vst31="uphill 1/3", - vst32="uphill 2/3", - vst33="uphill 3/3", - }, - switch={ - swlst="swlcr", - swlcr="swlst", - swrst="swrcr", - swrcr="swrst", - }, - switchmc={ - swlst="on", - swlcr="off", - swrst="on", - swrcr="off", - }, - regtp=true, - trackplacer={ - st=true, - cr=true, - }, - tpsingle={ - st=true, - }, - tpdefault="st", - trackworker={ - ["swrcr"]="st", - ["swrst"]="st", - ["st"]="cr", - ["cr"]="swlst", - ["swlcr"]="swrcr", - ["swlst"]="swrst", - }, - regsp=true, - slopenodes={ - vst1=true, vst2=true, - vst31=true, vst32=true, vst33=true, - }, - slopeplacer={ - [2]={"vst1", "vst2"}, - [3]={"vst31", "vst32", "vst33"}, - max=3,--highest entry - }, - slopeplacer_45={ - [2]={"vst1_45", "vst2_45"}, - max=2, - }, - rotation={"", "_30", "_45", "_60"}, - increativeinv={}, -} -ap.t_30deg_straightonly={ - regstep=1, - variant={ - st=conns(0,8), - }, - description={ - st="straight", - }, - switch={ - }, - switchmc={ - }, - regtp=true, - trackplacer={ - }, - tpsingle={ - }, - tpdefault="st", - trackworker={ - ["st"]="st", - }, - slopenodes={}, - rotation={"", "_30", "_45", "_60"}, - increativeinv={st}, -} -ap.t_30deg_straightonly_noplacer={ - regstep=1, - variant={ - st=conns(0,8), - }, - description={ - st="straight", - }, - switch={ - }, - switchmc={ - }, - regtp=false, - trackplacer={ - }, - tpsingle={ - }, - tpdefault="st", - trackworker={ - ["st"]="st", - }, - slopenodes={}, - rotation={"", "_30", "_45", "_60"}, - increativeinv={st}, -} -ap.t_45deg={ - regstep=2, - variant={ - st=conns(0,8), - cr=conns(0,6), - swlst=conns(0,8), - swlcr=conns(0,6), - swrst=conns(0,8), - swrcr=conns(0,10), - vst1=conns(8,0,0,0.5,0.25), - vst2=conns(8,0,0.5,1,0.75), - }, - description={ - st="straight", - cr="curve", - swlst="left switch (straight)", - swlcr="left switch (curve)", - swrst="right switch (straight)", - swrcr="right switch (curve)", - vst1="vertical lower node", - vst2="vertical upper node", - }, - switch={ - swlst="swlcr", - swlcr="swlst", - swrst="swrcr", - swrcr="swrst", - }, - switchmc={ - swlst="on", - swlcr="off", - swrst="on", - swrcr="off", - }, - regtp=true, - trackplacer={ - st=true, - cr=true, - }, - tpsingle={ - st=true, - }, - tpdefault="st", - trackworker={ - ["swrcr"]="st", - ["swrst"]="st", - ["st"]="cr", - ["cr"]="swlst", - ["swlcr"]="swrcr", - ["swlst"]="swrst", - }, - slopenodes={}, - rotation={"", "_45"}, - increativeinv={vst1=true, vst2=true} -} -advtrains.trackpresets = ap - ---definition format: ([] optional) ---[[{ - nodename_prefix - texture_prefix - [shared_texture] - models_prefix - models_suffix (with dot) - [shared_model] - formats={ - st,cr,swlst,swlcr,swrst,swrcr,vst1,vst2 - (each a table with indices 0-3, for if to register a rail with this 'rotation' table entry. nil is assumed as 'all', set {} to not register at all) - } - common={} change something on common rail appearance -}]] -function advtrains.register_tracks(tracktype, def, preset) - local function make_switchfunc(suffix_target, mesecon_state) - local switchfunc=function(pos, node) - if advtrains.is_train_at_pos(pos) then return end - minetest.set_node(pos, {name=def.nodename_prefix.."_"..suffix_target, param2=node.param2}) - advtrains.invalidate_all_paths() - advtrains.reset_trackdb_position(pos) - end - return switchfunc, {effector = { - ["action_"..mesecon_state] = switchfunc, - rules=advtrains.meseconrules - }} - end - local function make_overdef(suffix, rotation, conns, switchfunc, mesecontbl, in_creative_inv, drop_slope) - local img_suffix=suffix..rotation - return { - mesh = def.shared_model or (def.models_prefix.."_"..img_suffix..def.models_suffix), - tiles = {def.shared_texture or (def.texture_prefix.."_"..img_suffix..".png")}, - --inventory_image = def.texture_prefix.."_"..img_suffix..".png", - --wield_image = def.texture_prefix.."_"..img_suffix..".png", - description=def.description.."("..preset.description[suffix]..rotation..")", - connect1=conns.conn1, - connect2=conns.conn2, - rely1=conns.rely1 or 0, - rely2=conns.rely2 or 0, - railheight=conns.railheight or 0, - on_rightclick=switchfunc, - groups = { - attached_node=1, - ["advtrains_track_"..tracktype]=1, - dig_immediate=2, - not_in_creative_inventory=(not in_creative_inv and 1 or nil), - not_blocking_trains=1, - }, - mesecons=mesecontbl, - drop = increativeinv and def.nodename_prefix.."_"..suffix..rotation or (drop_slope and def.nodename_prefix.."_slopeplacer" or def.nodename_prefix.."_placer"), - } - end - local function cycle_conns(conns, rotid) - local add=(rotid-1)*preset.regstep - return { - conn1=(conns.conn1+add)%16, - conn2=(conns.conn2+add)%16, - rely1=conns.rely1 or 0, - rely2=conns.rely2 or 0, - railheight=conns.railheight or 0, - } - end - local common_def=advtrains.merge_tables({ - description = def.description, - drawtype = "mesh", - paramtype="light", - paramtype2="facedir", - walkable = false, - selection_box = { - type = "fixed", - fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2}, - }, - rely1=0, - rely2=0, - railheight=0, - drop=def.nodename_prefix.."_placer", - can_dig=function(pos) - return not advtrains.is_train_at_pos(pos) - end, - after_dig_node=function(pos) - advtrains.invalidate_all_paths() - advtrains.reset_trackdb_position(pos) - end, - after_place_node=function(pos) - advtrains.reset_trackdb_position(pos) - end, - on_place_rail=function(pos) - advtrains.reset_trackdb_position(pos) - end, - }, def.common or {}) - --make trackplacer base def - advtrains.trackplacer.register_tracktype(def.nodename_prefix, preset.tpdefault) - if preset.regtp then - advtrains.trackplacer.register_track_placer(def.nodename_prefix, def.texture_prefix, def.description) - end - if preset.regsp then - advtrains.slope.register_placer(def, preset) - 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 - local switchfunc, mesecontbl - 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], preset.slopenodes[suffix] - ), - adef - ) - ) - --trackplacer - 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 - end - end - advtrains.all_tracktypes[tracktype]=true -end - - -function advtrains.is_track_and_drives_on(nodename, drives_on_p) - if not minetest.registered_nodes[nodename] then - return false - end - local nodedef=minetest.registered_nodes[nodename] - for k,v in pairs(drives_on_p) do - if nodedef.groups["advtrains_track_"..k] then - return true - end - end - return false -end - -function advtrains.get_track_connections(name, param2) - local nodedef=minetest.registered_nodes[name] - if not nodedef then print("[advtrains] get_track_connections couldn't find nodedef for nodename "..(name or "nil")) return 0, 8, 0, 0, 0 end - local noderot=param2 - if not param2 then noderot=0 end - if noderot > 3 then print("[advtrains] get_track_connections: rail has invaild param2 of "..noderot) noderot=0 end - - return (nodedef.connect1 + 4 * noderot)%16, (nodedef.connect2 + 4 * noderot)%16, nodedef.rely1 or 0, nodedef.rely2 or 0, nodedef.railheight or 0 -end - ---detector code ---holds a table with nodes on which trains are on. - -advtrains.detector = {} -advtrains.detector.on_node = {} -advtrains.detector.on_node_restore = {} ---set if paths were invalidated before. tells trainlogic.lua to call advtrains.detector.finalize_restore() -advtrains.detector.clean_step_before = false - ---when train enters a node, call this ---The entry already being contained in advtrains.detector.on_node_restore will not trigger an on_train_enter event on the node. (when path is reset, this is saved). -function advtrains.detector.enter_node(pos, train_id) - local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - --print("enterNode "..pts.." "..sid(train_id)) - if advtrains.detector.on_node[pts] then - if advtrains.trains[advtrains.detector.on_node[pts]] then - --print(""..pts.." already occupied") - return false - else - advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) - end - end - advtrains.detector.on_node[pts]=train_id - if advtrains.detector.on_node_restore[pts] then - advtrains.detector.on_node_restore[pts]=nil - else - advtrains.detector.call_enter_callback(advtrains.round_vector_floor_y(pos), train_id) - end - return true -end -function advtrains.detector.leave_node(pos, train_id) - local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - --print("leaveNode "..pts.." "..sid(train_id)) - if not advtrains.detector.on_node[pts] then - --print(""..pts.." leave: nothing here") - return false - end - if advtrains.detector.on_node[pts]==train_id then - advtrains.detector.call_leave_callback(advtrains.round_vector_floor_y(pos), train_id) - advtrains.detector.on_node[pts]=nil - else - if advtrains.trains[advtrains.detector.on_node[pts]] then - --print(""..pts.." occupied by another train") - return false - else - advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) - return false - end - end - return true -end ---called immediately before invalidating paths -function advtrains.detector.setup_restore() - --print("setup_restore") - advtrains.detector.on_node_restore = advtrains.detector.on_node - advtrains.detector.on_node = {} -end ---called one step after invalidating paths, when all trains have restored their path and called enter_node for their contents. -function advtrains.detector.finalize_restore() - --print("finalize_restore") - for pts, train_id in pairs(advtrains.detector.on_node_restore) do - --print("called leave callback "..pts.." "..train_id) - advtrains.detector.call_leave_callback(minetest.string_to_pos(pts), train_id) - end - advtrains.detector.on_node_restore = {} -end -function advtrains.detector.call_enter_callback(pos, train_id) - --print("instructed to call enter calback") - - local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case - local mregnode=minetest.registered_nodes[node.name] - if mregnode and mregnode.advtrains and mregnode.advtrains.on_train_enter then - mregnode.advtrains.on_train_enter(pos, train_id) - end - - --atc code wants to be notified too - advtrains.atc.trigger_controller_train_enter(pos, train_id) -end -function advtrains.detector.call_leave_callback(pos, train_id) - --print("instructed to call leave calback") - - local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case - local mregnode=minetest.registered_nodes[node.name] - if mregnode and mregnode.advtrains and mregnode.advtrains.on_train_leave then - mregnode.advtrains.on_train_leave(pos, train_id) - end -end - --- slope placer. Defined in register_tracks. ---crafted with rail and gravel -local sl={} -function sl.register_placer(def, preset) - minetest.register_craftitem(def.nodename_prefix.."_slopeplacer",{ - description = def.description.." Slope", - inventory_image = def.texture_prefix.."_slopeplacer.png", - wield_image = def.texture_prefix.."_slopeplacer.png", - groups={}, - on_place = sl.create_slopeplacer_on_place(def, preset) - }) -end ---(itemstack, placer, pointed_thing) -function sl.create_slopeplacer_on_place(def, preset) - return function(istack, player, pt) - if not pt.type=="node" then - minetest.chat_send_player(player:get_player_name(), "Can't place: not pointing at node") - return istack - end - local pos=pt.above - if not pos then - minetest.chat_send_player(player:get_player_name(), "Can't place: not pointing at node") - return istack - end - local node=minetest.get_node(pos) - if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].buildable_to then - minetest.chat_send_player(player:get_player_name(), "Can't place: space occupied!") - return istack - end - if minetest.is_protected(pos, player:get_player_name()) then - minetest.chat_send_player(player:get_player_name(), "Can't place: protected position!") - return istack - end - --determine player orientation (only horizontal component) - --get_look_horizontal may not be available - local yaw=player.get_look_horizontal and player:get_look_horizontal() or (player:get_look_yaw() - math.pi/2) - - --rounding unit vectors is a nice way for selecting 1 of 8 directions since sin(30°) is 0.5. - dirvec={x=math.floor(math.sin(-yaw)+0.5), y=0, z=math.floor(math.cos(-yaw)+0.5)} - --translate to direction to look up inside the preset table - local param2, rot45=({ - [-1]={ - [-1]=2, - [0]=3, - [1]=3, - }, - [0]={ - [-1]=2, - [1]=0, - }, - [1]={ - [-1]=1, - [0]=1, - [1]=0, - }, - })[dirvec.x][dirvec.z], dirvec.x~=0 and dirvec.z~=0 - local lookup=preset.slopeplacer - if rot45 then lookup=preset.slopeplacer_45 end - - --go unitvector forward and look how far the next node is - local step=1 - while step<=lookup.max do - local node=minetest.get_node(vector.add(pos, dirvec)) - --next node solid? - if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].buildable_to or minetest.is_protected(pos, player:get_player_name()) then - --do slopes of this distance exist? - if lookup[step] then - if minetest.setting_getbool("creative_mode") or istack:get_count()>=step then - --start placing - local placenodes=lookup[step] - while step>0 do - minetest.set_node(pos, {name=def.nodename_prefix.."_"..placenodes[step], param2=param2}) - if not minetest.setting_getbool("creative_mode") then - istack:take_item() - end - step=step-1 - pos=vector.subtract(pos, dirvec) - end - else - minetest.chat_send_player(player:get_player_name(), "Can't place: Not enough slope items left ("..step.." required)") - end - else - minetest.chat_send_player(player:get_player_name(), "Can't place: There's no slope of length "..step) - end - return istack - end - step=step+1 - pos=vector.add(pos, dirvec) - end - minetest.chat_send_player(player:get_player_name(), "Can't place: no supporting node at upper end.") - return itemstack - end -end - -advtrains.slope=sl - ---END code, BEGIN definition ---definition format: ([] optional) ---[[{ - nodename_prefix - texture_prefix - [shared_texture] - models_prefix - models_suffix (with dot) - [shared_model] - formats={ - st,cr,swlst,swlcr,swrst,swrcr,vst1,vst2 - (each a table with indices 0-3, for if to register a rail with this 'rotation' table entry. nil is assumed as 'all', set {} to not register at all) - } - common={} change something on common rail appearance -}]] - -advtrains.register_tracks("regular", { - nodename_prefix="advtrains:track", - texture_prefix="advtrains_track", - shared_model="trackplane.b3d", - description="Deprecated Track", - formats={vst1={}, vst2={}}, -}, ap.t_45deg) - - -advtrains.register_tracks("default", { - nodename_prefix="advtrains:dtrack", - texture_prefix="advtrains_dtrack", - models_prefix="advtrains_dtrack", - models_suffix=".b3d", - shared_texture="advtrains_dtrack_rail.png", - description="Track", - formats={vst1={true, false, true}, vst2={true, false, true}, vst31={true}, vst32={true}, vst33={true}}, -}, ap.t_30deg) - ---bumpers -advtrains.register_tracks("default", { - nodename_prefix="advtrains:dtrack_bumper", - texture_prefix="advtrains_dtrack_bumper", - models_prefix="advtrains_dtrack_bumper", - models_suffix=".b3d", - shared_texture="advtrains_dtrack_rail.png", - description="Bumper", - formats={}, -}, ap.t_30deg_straightonly) ---legacy bumpers -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, param2=minetest.get_node(pos).param2}) - mesecon.receptor_on(pos, advtrains.meseconrules) - end - } - } - end - }, ap.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, param2=minetest.get_node(pos).param2}) - mesecon.receptor_off(pos, advtrains.meseconrules) - end - } - } - end - }, ap.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 - minetest.register_abm({ - -- In the following two fields, also group:groupname will work. - nodenames = {"advtrains:track_"..name}, - interval = 1.0, -- Operation interval in seconds - chance = 1, -- Chance of trigger per-node per-interval is 1.0 / this - action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:track_"..rep, param2=node.param2}) end, - }) - minetest.register_abm({ - -- In the following two fields, also group:groupname will work. - nodenames = {"advtrains:track_"..name.."_45"}, - interval = 1.0, -- Operation interval in seconds - chance = 1, -- Chance of trigger per-node per-interval is 1.0 / this - action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:track_"..rep.."_45", param2=node.param2}) end, - }) -end - -if advtrains.register_replacement_lbms then -minetest.register_lbm({ - name = "advtrains:ramp_replacement_1", --- In the following two fields, also group:groupname will work. - nodenames = {"advtrains:track_vert1"}, - action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_vst1", param2=(node.param2+2)%4}) end, -}) -minetest.register_lbm({ - name = "advtrains:ramp_replacement_1", --- -- In the following two fields, also group:groupname will work. - nodenames = {"advtrains:track_vert2"}, - action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_vst2", param2=(node.param2+2)%4}) end, -}) - minetest.register_abm({ - name = "advtrains:st_rep_1", - -- In the following two fields, also group:groupname will work. - nodenames = {"advtrains:track_st"}, - interval=1, - chance=1, - action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_st", param2=node.param2}) end, - }) - minetest.register_lbm({ - name = "advtrains:st_rep_1", - -- -- In the following two fields, also group:groupname will work. - nodenames = {"advtrains:track_st_45"}, - action = function(pos, node, active_object_count, active_object_count_wider) minetest.set_node(pos, {name="advtrains:dtrack_st_45", param2=node.param2}) end, - }) -end - - - - - - - - diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua deleted file mode 100644 index e69f04a..0000000 --- a/advtrains/trainhud.lua +++ /dev/null @@ -1,109 +0,0 @@ ---trainhud.lua: holds all the code for train controlling - -advtrains.hud = {} - -minetest.register_on_leaveplayer(function(player) -advtrains.hud[player:get_player_name()] = nil -end) - -local mletter={[1]="F", [-1]="R", [0]="N"} - -function advtrains.on_control_change(pc, train, flip) - if pc.sneak then - if pc.up then - train.tarvelocity = train.max_speed or 10 - end - if pc.down then - train.tarvelocity = 0 - end - if pc.left then - train.tarvelocity = 4 - end - if pc.right then - train.tarvelocity = 8 - end - if pc.jump then - train.brake = true - --0: released, 1: brake and pressed, 2: released and brake, 3: pressed and brake - if not train.brake_hold_state or train.brake_hold_state==0 then - train.brake_hold_state = 1 - elseif train.brake_hold_state==2 then - train.brake_hold_state = 3 - end - elseif train.brake_hold_state==1 then - train.brake_hold_state = 2 - elseif train.brake_hold_state==3 then - train.brake = false - train.brake_hold_state = 0 - end - --shift+use:see wagons.lua - else - if pc.up then - train.tarvelocity = train.tarvelocity + 1 - end - if pc.down then - if train.velocity>0 then - train.tarvelocity = math.max(train.tarvelocity - 1, 0) - else - train.movedir = -train.movedir - end - end - if train.brake_hold_state~=2 then - train.brake = false - end - if pc.jump then - train.brake = true - end - if pc.aux1 then - --horn - end - end -end -function advtrains.update_driver_hud(pname, train, flip) - advtrains.set_trainhud(pname, advtrains.hud_train_format(train, flip)) -end -function advtrains.clear_driver_hud(pname) - advtrains.set_trainhud(pname, "") -end - -function advtrains.set_trainhud(name, text) - local hud = advtrains.hud[name] - local player=minetest.get_player_by_name(name) - if not player then - return - end - if not hud then - hud = {} - advtrains.hud[name] = hud - hud.id = player:hud_add({ - hud_elem_type = "text", - name = "ADVTRAINS", - number = 0xFFFFFF, - position = {x=0.5, y=0.7}, - offset = {x=0, y=0}, - text = text, - scale = {x=200, y=60}, - alignment = {x=0, y=0}, - }) - hud.oldText=text - return - elseif hud.oldText ~= text then - player:hud_change(hud.id, "text", text) - hud.oldText=text - end -end -function advtrains.hud_train_format(train, flip) - local fct=flip and -1 or 1 - if not train then return "" end - - local max=train.max_speed or 10 - local vel=advtrains.abs_ceil(train.velocity) - local tvel=advtrains.abs_ceil(train.tarvelocity) - local topLine, firstLine, secondLine - - topLine="Train".." ["..mletter[fct*train.movedir].."] "..(train.brake and "="..( train.brake_hold_state==2 and "^" or "" ).."B=" or "") - firstLine="Speed: |"..string.rep("+", vel)..string.rep("_", max-vel)..">" - secondLine="Target: |"..string.rep("+", tvel)..string.rep("_", max-tvel)..">" - - return topLine.."\n"..firstLine.."\n"..secondLine -end diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua deleted file mode 100644 index eb45500..0000000 --- a/advtrains/trainlogic.lua +++ /dev/null @@ -1,875 +0,0 @@ ---trainlogic.lua ---controls train entities stuff about connecting/disconnecting/colliding trains and other things - - -local benchmark=false -local bm={} -local bmlt=0 -local bmsteps=0 -local bmstepint=200 -printbm=function(action, ta) - if not benchmark then return end - local t=(os.clock()-ta)*1000 - if not bm[action] then - bm[action]=t - else - bm[action]=bm[action]+t - end - bmlt=bmlt+t -end -function endstep() - if not benchmark then return end - bmsteps=bmsteps-1 - if bmsteps<=0 then - bmsteps=bmstepint - for key, value in pairs(bm) do - minetest.chat_send_all(key.." "..(value/bmstepint).." ms avg.") - end - minetest.chat_send_all("Total time consumed by all advtrains actions per step: "..(bmlt/bmstepint).." ms avg.") - bm={} - bmlt=0 - end -end - -advtrains.train_accel_force=2--per second and divided by number of wagons -advtrains.train_brake_force=3--per second, not divided by number of wagons -advtrains.train_roll_force=0.5--per second, not divided by number of wagons, acceleration when rolling without brake -advtrains.train_emerg_force=10--for emergency brakes(when going off track) - -advtrains.audit_interval=30 - - -advtrains.trains={} -advtrains.wagon_save={} - ---load initially -advtrains.fpath=minetest.get_worldpath().."/advtrains" -local file, err = io.open(advtrains.fpath, "r") -if not file then - local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains save file "..er) -else - local tbl = minetest.deserialize(file:read("*a")) - if type(tbl) == "table" then - advtrains.trains=tbl - end - file:close() -end -advtrains.fpath_ws=minetest.get_worldpath().."/advtrains_wagon_save" -local file, err = io.open(advtrains.fpath_ws, "r") -if not file then - local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains save file "..er) -else - local tbl = minetest.deserialize(file:read("*a")) - if type(tbl) == "table" then - advtrains.wagon_save=tbl - end - file:close() -end - - -advtrains.save = function() - --print("[advtrains]saving") - advtrains.invalidate_all_paths() - local datastr = minetest.serialize(advtrains.trains) - if not datastr then - minetest.log("error", "[advtrains] Failed to serialize train data!") - return - end - local file, err = io.open(advtrains.fpath, "w") - if err then - return err - end - file:write(datastr) - file:close() - - -- update wagon saves - for _,wagon in pairs(minetest.luaentities) do - if wagon.is_wagon and wagon.initialized then - wagon:get_staticdata() - end - end - --cross out userdata - for w_id, data in pairs(advtrains.wagon_save) do - data.name=nil - data.object=nil - if data.driver then - data.driver_name=data.driver:get_player_name() - data.driver=nil - else - data.driver_name=nil - end - if data.discouple then - data.discouple.object:remove() - data.discouple=nil - end - end - --print(dump(advtrains.wagon_save)) - datastr = minetest.serialize(advtrains.wagon_save) - if not datastr then - minetest.log("error", "[advtrains] Failed to serialize train data!") - return - end - file, err = io.open(advtrains.fpath_ws, "w") - if err then - return err - end - file:write(datastr) - file:close() - - advtrains.save_trackdb() - advtrains.atc.save() -end -minetest.register_on_shutdown(advtrains.save) - -advtrains.save_and_audit_timer=advtrains.audit_interval -minetest.register_globalstep(function(dtime) - advtrains.save_and_audit_timer=advtrains.save_and_audit_timer-dtime - if advtrains.save_and_audit_timer<=0 then - local t=os.clock() - - --save - advtrains.save() - advtrains.save_and_audit_timer=advtrains.audit_interval - printbm("saving", t) - end - --regular train step - local t=os.clock() - for k,v in pairs(advtrains.trains) do - advtrains.train_step(k, v, dtime) - end - - --see tracks.lua - if advtrains.detector.clean_step_before then - advtrains.detector.finalize_restore() - end - - printbm("trainsteps", t) - endstep() -end) - -function advtrains.train_step(id, train, dtime) - --Legacy: set drives_on and max_speed - if not train.drives_on or not train.max_speed then - advtrains.update_trainpart_properties(id) - end - --TODO check for all vars to be present - if not train.velocity then - train.velocity=0 - end - if not train.movedir or (train.movedir~=1 and train.movedir~=-1) then - train.movedir=1 - end - --very unimportant thing: check if couple is here - if train.couple_eid_front and (not minetest.luaentities[train.couple_eid_front] or not minetest.luaentities[train.couple_eid_front].is_couple) then train.couple_eid_front=nil end - if train.couple_eid_back and (not minetest.luaentities[train.couple_eid_back] or not minetest.luaentities[train.couple_eid_back].is_couple) then train.couple_eid_back=nil end - - --skip certain things (esp. collision) when not moving - local train_moves=(train.velocity~=0) - - --if not train.last_pos then advtrains.trains[id]=nil return end - - if not advtrains.pathpredict(id, train) then - print("pathpredict failed(returned false)") - train.velocity=0 - train.tarvelocity=0 - return - end - - local path=advtrains.get_or_create_path(id, train) - if not path then - train.velocity=0 - train.tarvelocity=0 - print("train has no path for whatever reason") - return - end - - local train_end_index=advtrains.get_train_end_index(train) - --apply off-track handling: - local front_off_track=train.max_index_on_track and train.index>train.max_index_on_track - local back_off_track=train.min_index_on_track and train_end_index1 then train.tarvelocity=1 end - elseif front_off_track then--allow movement only backward - if train.movedir==1 and train.tarvelocity>0 then train.tarvelocity=0 end - if train.movedir==-1 and train.tarvelocity>1 then train.tarvelocity=1 end - elseif back_off_track then--allow movement only forward - if train.movedir==-1 and train.tarvelocity>0 then train.tarvelocity=0 end - if train.movedir==1 and train.tarvelocity>1 then train.tarvelocity=1 end - end - - --update advtrains.detector - if not train.detector_old_index then - train.detector_old_index = math.floor(train_end_index) - train.detector_old_end_index = math.floor(train_end_index) - end - local ifo, ifn, ibo, ibn = train.detector_old_index, math.floor(train.index), train.detector_old_end_index, math.floor(train_end_index) - if ifn>ifo then - for i=ifo, ifn do - if path[i] then - advtrains.detector.enter_node(path[i], id) - end - end - elseif ifnibo then - for i=ibo, ibn do - if path[i] then - advtrains.detector.leave_node(path[i], id) - end - end - end - train.detector_old_index = math.floor(train.index) - train.detector_old_end_index = math.floor(train_end_index) - - --remove? - if #train.trainparts==0 then - print("[advtrains][train "..sid(id).."] has empty trainparts, removing.") - advtrains.detector.leave_node(path[train.detector_old_index], id) - advtrains.trains[id]=nil - return - end - - if train_moves then - --check for collisions by finding objects - - --heh, new collision again. - --this time, based on NODES and the advtrains.detector.on_node table. - local collpos - local coll_grace=1 - if train.movedir==1 then - collpos=advtrains.get_real_index_position(path, train.index-coll_grace) - else - collpos=advtrains.get_real_index_position(path, train_end_index+coll_grace) - end - if collpos then - local rcollpos=advtrains.round_vector_floor_y(collpos) - for x=-1,1 do - for z=-1,1 do - local testpos=vector.add(rcollpos, {x=x, y=0, z=z}) - local testpts=minetest.pos_to_string(testpos) - if advtrains.detector.on_node[testpts] and advtrains.detector.on_node[testpts]~=id then - --collides - advtrains.spawn_couple_on_collide(id, testpos, advtrains.detector.on_node[testpts], train.movedir==-1) - - train.recently_collided_with_env=true - train.velocity=0.5*train.velocity - train.movedir=train.movedir*-1 - train.tarvelocity=0 - - end - end - end - end - end - --check for any trainpart entities if they have been unloaded. do this only if train is near a player, to not spawn entities into unloaded areas - --todo function will be taken by update_trainpart_properties - train.check_trainpartload=(train.check_trainpartload or 0)-dtime - local node_range=(math.max((minetest.setting_get("active_block_range") or 0),1)*16) - if train.check_trainpartload<=0 then - local ori_pos=advtrains.get_real_index_position(path, train.index) --not much to calculate - --print("[advtrains][train "..id.."] at "..minetest.pos_to_string(vector.round(ori_pos))) - - local should_check=false - for _,p in ipairs(minetest.get_connected_players()) do - should_check=should_check or ((vector.distance(ori_pos, p:getpos())=train.velocity then - train.atc_brake_target=nil - end - if train.atc_wait_finish then - if not train.atc_brake_target and train.velocity==train.tarvelocity then - train.atc_wait_finish=nil - end - end - if train.atc_command then - if train.atc_delay<=0 and not train.atc_wait_finish then - advtrains.atc.execute_atc_command(id, train) - else - train.atc_delay=train.atc_delay-dtime - end - end - - --make brake adjust the tarvelocity if necessary - if train.brake and (math.ceil(train.velocity)-1)0 then--accelerating, force will be brought on only by locomotives. - --print("accelerating with default force") - applydiff=(math.min((advtrains.train_accel_force*train.locomotives_in_train*dtime)/mass, math.abs(diff))) - else--decelerating - if front_off_track or back_off_track or train.recently_collided_with_env then --every wagon has a brake, so not divided by mass. - --print("braking with emergency force") - applydiff= -(math.min((advtrains.train_emerg_force*dtime), math.abs(diff))) - elseif train.brake or (train.atc_brake_target and train.atc_brake_target0 then - if train.movedir>0 then - pregen_front=2+math.ceil(train.velocity*0.15) --assumes server step of 0.1 seconds, +50% tolerance - else - pregen_back=2+math.ceil(train.velocity*0.15) - end - end - - - local maxn=advtrains.maxN(train.path) - while (maxn-train.index) < pregen_front do--pregenerate - --print("[advtrains]maxn conway for ",maxn,minetest.pos_to_string(path[maxn]),maxn-1,minetest.pos_to_string(path[maxn-1])) - local conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.drives_on) - if conway then - train.path[maxn+1]=conway - train.max_index_on_track=maxn - else - --do as if nothing has happened and preceed with path - --but do not update max_index_on_track - --print("over-generating path max to index "..maxn+1) - train.path[maxn+1]=vector.add(train.path[maxn], vector.subtract(train.path[maxn], train.path[maxn-1])) - end - train.path_dist[maxn]=vector.distance(train.path[maxn+1], train.path[maxn]) - maxn=advtrains.maxN(train.path) - end - - local minn=advtrains.minN(train.path) - while (train.index-minn) < (train.trainlen or 0) + pregen_back do --post_generate. has to be at least trainlen. (we let go of the exact calculation here since this would be unuseful here) - --print("[advtrains]minn conway for ",minn,minetest.pos_to_string(path[minn]),minn+1,minetest.pos_to_string(path[minn+1])) - local conway=advtrains.conway(train.path[minn], train.path[minn+1], train.drives_on) - if conway then - train.path[minn-1]=conway - train.min_index_on_track=minn - else - --do as if nothing has happened and preceed with path - --but do not update min_index_on_track - --print("over-generating path min to index "..minn-1) - train.path[minn-1]=vector.add(train.path[minn], vector.subtract(train.path[minn], train.path[minn+1])) - end - train.path_dist[minn-1]=vector.distance(train.path[minn], train.path[minn-1]) - minn=advtrains.minN(train.path) - end - if not train.min_index_on_track then train.min_index_on_track=0 end - if not train.max_index_on_track then train.max_index_on_track=0 end - - --make pos/yaw available for possible recover calls - if train.max_index_on_tracktrain.index then --whoops, train went even more far. same behavior - train.savedpos_off_track_index_offset=train.index-train.min_index_on_track - train.last_pos=train.path[train.min_index_on_track+1] - train.last_pos_prev=train.path[train.min_index_on_track] - --print("train is off-track (back), last positions kept at "..minetest.pos_to_string(train.last_pos).." / "..minetest.pos_to_string(train.last_pos_prev)) - else --regular case - train.savedpos_off_track_index_offset=nil - train.last_pos=train.path[math.floor(train.index+0.5)] - train.last_pos_prev=train.path[math.floor(train.index-0.5)] - end - return train.path -end -function advtrains.get_train_end_index(train) - return advtrains.get_real_path_index(train, train.trainlen or 2)--this function can be found inside wagons.lua since it's more related to wagons. we just set trainlen as pos_in_train -end - -function advtrains.get_or_create_path(id, train) - if not train.path then return advtrains.pathpredict(id, train) end - return train.path -end - -function advtrains.add_wagon_to_train(wagon, train_id, index) - local train=advtrains.trains[train_id] - if index then - table.insert(train.trainparts, index, wagon.unique_id) - else - table.insert(train.trainparts, wagon.unique_id) - end - --this is not the usual case!!! - --we may set initialized because the wagon has no chance to step() - wagon.initialized=true - --TODO is this art or can we throw it away? - advtrains.update_trainpart_properties(train_id) -end -function advtrains.update_trainpart_properties(train_id, invert_flipstate) - local train=advtrains.trains[train_id] - train.drives_on=advtrains.all_tracktypes - train.max_speed=100 - local rel_pos=0 - local count_l=0 - for i, w_id in ipairs(train.trainparts) do - local wagon=nil - for _,iwagon in pairs(minetest.luaentities) do - if iwagon.is_wagon and iwagon.initialized and iwagon.unique_id==w_id then - if wagon then - --duplicate - iwagon.object:remove() - else - wagon=iwagon - end - end - end - if not wagon then - if advtrains.wagon_save[w_id] then - --spawn a new and initialize it with the properties from wagon_save - wagon=minetest.env:add_entity(train.last_pos, advtrains.wagon_save[w_id].entity_name):get_luaentity() - wagon:init_from_wagon_save(w_id) - end - end - if wagon then - rel_pos=rel_pos+wagon.wagon_span - wagon.train_id=train_id - wagon.pos_in_train=rel_pos - wagon.pos_in_trainparts=i - wagon.old_velocity_vector=nil - if wagon.is_locomotive then - count_l=count_l+1 - end - if invert_flipstate then - wagon.wagon_flipped = not wagon.wagon_flipped - end - rel_pos=rel_pos+wagon.wagon_span - any_loaded=true - - if wagon.drives_on then - for k,_ in pairs(train.drives_on) do - if not wagon.drives_on[k] then - train.drives_on[k]=nil - end - end - end - train.max_speed=math.min(train.max_speed, wagon.max_speed) - else - print(w_id.." not loaded and no save available") - --what the hell... - table.remove(train.trainparts, pit) - end - end - train.trainlen=rel_pos - train.locomotives_in_train=count_l -end - -function advtrains.split_train_at_wagon(wagon) - --get train - local train=advtrains.trains[wagon.train_id] - local real_pos_in_train=advtrains.get_real_path_index(train, wagon.pos_in_train) - local pos_for_new_train=advtrains.get_or_create_path(wagon.train_id, train)[math.floor(real_pos_in_train+wagon.wagon_span)] - local pos_for_new_train_prev=advtrains.get_or_create_path(wagon.train_id, train)[math.floor(real_pos_in_train-1+wagon.wagon_span)] - - --before doing anything, check if both are rails. else do not allow - if not pos_for_new_train then - print("split_train: pos_for_new_train not set") - return false - end - local node_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.drives_on) - if not node_ok then - print("split_train: pos_for_new_train "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") - return false - end - - if not train.last_pos_prev then - print("split_train: pos_for_new_train_prev not set") - return false - end - - local prevnode_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.drives_on) - if not prevnode_ok then - print("split_train: pos_for_new_train_prev "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") - return false - end - - --create subtrain - local newtrain_id=advtrains.create_new_train_at(pos_for_new_train, pos_for_new_train_prev) - local newtrain=advtrains.trains[newtrain_id] - --insert all wagons to new train - for k,v in ipairs(train.trainparts) do - if k>=wagon.pos_in_trainparts then - table.insert(newtrain.trainparts, v) - train.trainparts[k]=nil - end - end - --update train parts - advtrains.update_trainpart_properties(wagon.train_id)--atm it still is the desierd id. - advtrains.update_trainpart_properties(newtrain_id) - train.tarvelocity=0 - newtrain.velocity=train.velocity - newtrain.tarvelocity=0 -end - ---there are 4 cases: ---1/2. F<->R F<->R regular, put second train behind first ---->frontpos of first train will match backpos of second ---3. F<->R R<->F flip one of these trains, take the other as new train ---->backpos's will match ---4. R<->F F<->R flip one of these trains and take it as new parent ---->frontpos's will match - ---true when trains are facing each other. needed on colliding. --- check done by iterating paths and checking their direction ---returns nil when not on the same track at all OR when required path items are not generated. this distinction may not always be needed. -function advtrains.trains_facing(train1, train2) - local sr_pos=train1.path[math.floor(train1.index)] - local sr_pos_p=train1.path[math.floor(train1.index)-1] - - for i=advtrains.minN(train2.path), advtrains.maxN(train2.path) do - if vector.equals(sr_pos, train2.path[i]) then - if train2.path[i+1] and vector.equals(sr_pos_p, train2.path[i+1]) then return true end - if train2.path[i-1] and vector.equals(sr_pos_p, train2.path[i-1]) then return false end - return nil - end - end - return nil -end - -function advtrains.spawn_couple_on_collide(id1, pos, id2, t1_is_backpos) - print("COLLISION: "..sid(id1).." and "..sid(id2).." at "..minetest.pos_to_string(pos)..", t1_is_backpos="..(t1_is_backpos and "true" or "false")) - --TODO: - local train1=advtrains.trains[id1] - local train2=advtrains.trains[id2] - - local found - for i=advtrains.minN(train1.path), advtrains.maxN(train1.path) do - if vector.equals(train1.path[i], pos) then - found=true - end - end - if not found then - print("Err: pos not in path") - return - end - - local frontpos2=train2.path[math.floor(train2.detector_old_index)] - local backpos2=train2.path[math.floor(train2.detector_old_end_index)] - local t2_is_backpos - print("End positions: "..minetest.pos_to_string(frontpos2)..minetest.pos_to_string(backpos2)) - - if vector.equals(frontpos2, pos) then - t2_is_backpos=false - elseif vector.equals(backpos2, pos) then - t2_is_backpos=true - else - print("Err: not a endpos") - return --the collision position is not the end position. - end - print("t2_is_backpos="..(t2_is_backpos and "true" or "false")) - - local t1_has_couple - if t1_is_backpos then - t1_has_couple=train1.couple_eid_back - else - t1_has_couple=train1.couple_eid_front - end - local t2_has_couple - if t2_is_backpos then - t2_has_couple=train2.couple_eid_back - else - t2_has_couple=train2.couple_eid_front - end - - if t1_has_couple then - if minetest.object_refs[t1_has_couple] then minetest.object_refs[t1_has_couple]:remove() end - end - if t2_has_couple then - if minetest.object_refs[t2_has_couple] then minetest.object_refs[t2_has_couple]:remove() end - end - local obj=minetest.add_entity(pos, "advtrains:couple") - if not obj then print("failed creating object") return end - local le=obj:get_luaentity() - le.train_id_1=id1 - le.train_id_2=id2 - le.train1_is_backpos=t1_is_backpos - le.train2_is_backpos=t2_is_backpos - --find in object_refs - for aoi, compare in pairs(minetest.object_refs) do - if compare==obj then - if t1_is_backpos then - train1.couple_eid_back=aoi - else - train1.couple_eid_front=aoi - end - if t2_is_backpos then - train2.couple_eid_back=aoi - else - train2.couple_eid_front=aoi - end - end - end - print("Couple entity:"..dump(le)) - - --also TODO: integrate check_trainpartload into update_trainpart_properties. -end ---order of trains may be irrelevant in some cases. check opposite cases. TODO does this work? ---pos1 and pos2 are just needed to form a median. - - -function advtrains.do_connect_trains(first_id, second_id) - local first_wagoncnt=#advtrains.trains[first_id].trainparts - local second_wagoncnt=#advtrains.trains[second_id].trainparts - - for _,v in ipairs(advtrains.trains[second_id].trainparts) do - table.insert(advtrains.trains[first_id].trainparts, v) - end - --kick it like physics (with mass being #wagons) - local new_velocity=((advtrains.trains[first_id].velocity*first_wagoncnt)+(advtrains.trains[second_id].velocity*second_wagoncnt))/(first_wagoncnt+second_wagoncnt) - advtrains.trains[second_id]=nil - advtrains.update_trainpart_properties(first_id) - advtrains.trains[first_id].velocity=new_velocity - advtrains.trains[first_id].tarvelocity=0 -end - -function advtrains.invert_train(train_id) - local train=advtrains.trains[train_id] - - local old_path=advtrains.get_or_create_path(train_id, train) - train.path={} - train.index= - advtrains.get_train_end_index(train) - train.velocity=-train.velocity - train.tarvelocity=-train.tarvelocity - for k,v in pairs(old_path) do - train.path[-k]=v - end - local old_trainparts=train.trainparts - train.trainparts={} - for k,v in ipairs(old_trainparts) do - table.insert(train.trainparts, 1, v)--notice insertion at first place - end - advtrains.update_trainpart_properties(train_id, true) -end - -function advtrains.is_train_at_pos(pos) - --print("istrainat: pos "..minetest.pos_to_string(pos)) - local checked_trains={} - local objrefs=minetest.get_objects_inside_radius(pos, 2) - for _,v in pairs(objrefs) do - local le=v:get_luaentity() - if le and le.is_wagon and le.initialized and le.train_id and not checked_trains[le.train_id] then - --print("istrainat: checking "..le.train_id) - checked_trains[le.train_id]=true - local path=advtrains.get_or_create_path(le.train_id, le:train()) - if path then - --print("has path") - for i=math.floor(advtrains.get_train_end_index(le:train())+0.5),math.floor(le:train().index+0.5) do - if path[i] then - --print("has pathitem "..i.." "..minetest.pos_to_string(path[i])) - if vector.equals(advtrains.round_vector_floor_y(path[i]), pos) then - return true - end - end - end - end - end - end - return false -end -function advtrains.invalidate_all_paths() - --print("invalidating all paths") - for k,v in pairs(advtrains.trains) do - if v.index then - v.restore_add_index=v.index-math.floor(v.index+0.5) - end - v.path=nil - v.path_dist=nil - v.index=nil - v.min_index_on_track=nil - v.max_index_on_track=nil - - advtrains.detector.setup_restore() - v.detector_old_index=nil - v.detector_old_end_index=nil - end -end - ---not blocking trains group -function advtrains.train_collides(node) - if node and minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].walkable then - if not minetest.registered_nodes[node.name].groups.not_blocking_trains then - return true - end - end - return false -end - -local nonblocknodes={ - "default:fence_wood", - "default:fence_acacia_wood", - "default:fence_aspen_wood", - "default:fence_pine_wood", - "default:fence_junglewood", - "default:torch", - - "default:sign_wall", - "signs:sign_wall", - "signs:sign_wall_blue", - "signs:sign_wall_brown", - "signs:sign_wall_orange", - "signs:sign_wall_green", - "signs:sign_yard", - "signs:sign_wall_white_black", - "signs:sign_wall_red", - "signs:sign_wall_white_red", - "signs:sign_wall_yellow", - "signs:sign_post", - "signs:sign_hanging", - - -} -minetest.after(0, function() - for _,name in ipairs(nonblocknodes) do - if minetest.registered_nodes[name] then - minetest.registered_nodes[name].groups.not_blocking_trains=1 - end - end -end) diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua deleted file mode 100644 index 495f914..0000000 --- a/advtrains/wagons.lua +++ /dev/null @@ -1,573 +0,0 @@ ---atan2 counts angles clockwise, minetest does counterclockwise ---local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end -local print=function() end - -local wagon={ - collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, - --physical = true, - visual = "mesh", - mesh = "wagon.b3d", - visual_size = {x=3, y=3}, - textures = {"black.png"}, - is_wagon=true, - wagon_span=1,--how many index units of space does this wagon consume - has_inventory=false, -} - - - -function wagon:on_rightclick(clicker) - if not self:ensure_init() then return end - if not clicker or not clicker:is_player() then - return - end - if clicker:get_player_control().aux1 then - --advtrains.dumppath(self:train().path) - --minetest.chat_send_all("at index "..(self:train().index or "nil")) - --advtrains.invert_train(self.train_id) - minetest.chat_send_all(dump(self:train())) - return - end - local no=self:get_seatno(clicker:get_player_name()) - if no then - self:get_off(no) - else - self:show_get_on_form(clicker:get_player_name()) - end -end - -function wagon:train() - return advtrains.trains[self.train_id] -end - ---[[about 'initalized': - when initialized is false, the entity hasn't got any data yet and should wait for these to be set before doing anything - when loading an existing object (with staticdata), it will be set - when instanciating a new object via add_entity, it is not set at the time on_activate is called. - then, wagon:initialize() will be called - - wagon will save only uid in staticdata, no serialized table -]] -function wagon:on_activate(sd_uid, dtime_s) - print("[advtrains][wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] activated") - self.object:set_armor_groups({immortal=1}) - if sd_uid and sd_uid~="" then - --legacy - --expect this to be a serialized table and handle - if minetest.deserialize(sd_uid) then - self:init_from_wagon_save(minetest.deserialize(sd_uid).unique_id) - else - self:init_from_wagon_save(sd_uid) - end - end - self.entity_name=self.name - - --duplicates? - for ao_id,wagon in pairs(minetest.luaentities) do - if wagon.is_wagon and wagon.initialized and wagon.unique_id==self.unique_id and wagon~=self then--i am a duplicate! - print("[advtrains][wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] duplicate found(ao_id:"..ao_id.."), removing") - self.object:remove() - minetest.after(0.5, function() advtrains.update_trainpart_properties(self.train_id) end) - return - end - end - - if self.custom_on_activate then - self:custom_on_activate(dtime_s) - end -end - -function wagon:get_staticdata() - if not self:ensure_init() then return end - print("[advtrains][wagon "..((self.unique_id and self.unique_id~="" and self.unique_id) or "no-id").."]: saving to wagon_save") - --serialize inventory, if it has one - if self.has_inventory then - local inv=minetest.get_inventory({type="detached", name="advtrains_wgn_"..self.unique_id}) - self.ser_inv=advtrains.serialize_inventory(inv) - end - --save to table before being unloaded - advtrains.wagon_save[self.unique_id]=advtrains.merge_tables(self) - advtrains.wagon_save[self.unique_id].entity_name=self.name - advtrains.wagon_save[self.unique_id].name=nil - advtrains.wagon_save[self.unique_id].object=nil - return self.unique_id -end ---returns: uid of wagon -function wagon:init_new_instance(train_id, properties) - self.unique_id=os.time()..os.clock() - self.train_id=train_id - for k,v in pairs(properties) do - if k~="name" and k~="object" then - self[k]=v - end - end - self:init_shared() - self.initialized=true - print("init_new_instance "..self.unique_id.." ("..self.train_id..")") - return self.unique_id -end -function wagon:init_from_wagon_save(uid) - if not advtrains.wagon_save[uid] then - self.object:remove() - return - end - self.unique_id=uid - for k,v in pairs(advtrains.wagon_save[uid]) do - if k~="name" and k~="object" then - self[k]=v - end - end - if not self.train_id or not self:train() then - self.object:remove() - return - end - self:init_shared() - self.initialized=true - minetest.after(1, function() self:reattach_all() end) - print("init_from_wagon_save "..self.unique_id.." ("..self.train_id..")") - advtrains.update_trainpart_properties(self.train_id) -end -function wagon:init_shared() - if self.has_inventory then - local uid_noptr=self.unique_id.."" - --to be used later - local inv=minetest.create_detached_inventory("advtrains_wgn_"..self.unique_id, { - allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) - return count - end, - allow_put = function(inv, listname, index, stack, player) - return stack:get_count() - end, - allow_take = function(inv, listname, index, stack, player) - return stack:get_count() - end - }) - if self.ser_inv then - advtrains.deserialize_inventory(self.ser_inv, inv) - end - if self.inventory_list_sizes then - for lst, siz in pairs(self.inventory_list_sizes) do - inv:set_size(lst, siz) - end - end - end -end -function wagon:ensure_init() - if self.initialized then return true end - self.object:setvelocity({x=0,y=0,z=0}) - return false -end - --- Remove the wagon -function wagon:on_punch(puncher, time_from_last_punch, tool_capabilities, direction) - if not self:ensure_init() then return end - if not puncher or not puncher:is_player() then - return - end - if self.owner and puncher:get_player_name()~=self.owner then - minetest.chat_send_player(puncher:get_player_name(), "This wagon is owned by "..self.owner..", you can't destroy it.") - return - end - - if minetest.setting_getbool("creative_mode") then - if not self:destroy() then return end - - local inv = puncher:get_inventory() - if not inv:contains_item("main", self.name) then - inv:add_item("main", self.name) - end - else - local pc=puncher:get_player_control() - if not pc.sneak then - minetest.chat_send_player(puncher:get_player_name(), "Warning: If you destroy this wagon, you only get some steel back! If you are sure, shift-leftclick the wagon.") - return - end - - if not self:destroy() then return end - - local inv = puncher:get_inventory() - for _,item in ipairs(self.drops or {self.name}) do - inv:add_item("main", item) - end - end -end -function wagon:destroy() - --some rules: - -- you get only some items back - -- single left-click shows warning - -- shift leftclick destroys - -- not when a driver is inside - - for _,_ in pairs(self.seatp) do - return - end - - if self.custom_may_destroy then - if not self.custom_may_destroy(self, puncher, time_from_last_punch, tool_capabilities, direction) then - return - end - end - if self.custom_on_destroy then - self.custom_on_destroy(self, puncher, time_from_last_punch, tool_capabilities, direction) - end - - print("[advtrains][wagon "..((self.unique_id and self.unique_id~="" and self.unique_id) or "no-id").."]: destroying") - - self.object:remove() - - table.remove(self:train().trainparts, self.pos_in_trainparts) - advtrains.update_trainpart_properties(self.train_id) - advtrains.wagon_save[self.unique_id]=nil - if self.discouple then self.discouple.object:remove() end--will have no effect on unloaded objects - return true -end - - -function wagon:on_step(dtime) - if not self:ensure_init() then return end - - local t=os.clock() - local pos = self.object:getpos() - - if not pos then - print("["..self.unique_id.."][fatal] missing position (object:getpos() returned nil)") - return - end - - self.entity_name=self.name - - --is my train still here - if not self.train_id or not self:train() then - print("[advtrains][wagon "..self.unique_id.."] missing train_id, destroying") - self.object:remove() - return - elseif not self.initialized then - self.initialized=true - end - if not self.seatp then - self.seatp={} - end - - --custom on_step function - if self.custom_on_step then - self:custom_on_step(self, dtime) - end - - --driver control - for seatno, seat in ipairs(self.seats) do - if seat.driving_ctrl_access then - local driver=self.seatp[seatno] and minetest.get_player_by_name(self.seatp[seatno]) - local get_off_pressed=false - if driver and driver:get_player_control_bits()~=self.old_player_control_bits then - local pc=driver:get_player_control() - - advtrains.on_control_change(pc, self:train(), self.wagon_flipped) - if pc.aux1 and pc.sneak then - get_off_pressed=true - end - - self.old_player_control_bits=driver:get_player_control_bits() - end - if driver then - if get_off_pressed then - self:get_off(seatno) - else - advtrains.update_driver_hud(driver:get_player_name(), self:train(), self.wagon_flipped) - end - end - end - end - - local gp=self:train() - - --DisCouple - if self.pos_in_trainparts and self.pos_in_trainparts>1 then - if gp.velocity==0 then - if not self.discouple or not self.discouple.object:getyaw() then - local object=minetest.add_entity(pos, "advtrains:discouple") - if object then - local le=object:get_luaentity() - le.wagon=self - --box is hidden when attached, so unuseful. - --object:set_attach(self.object, "", {x=0, y=0, z=self.wagon_span*10}, {x=0, y=0, z=0}) - self.discouple=le - else - print("Couldn't spawn DisCouple") - end - end - else - if self.discouple and self.discouple.object:getyaw() then - self.discouple.object:remove() - end - end - end - --for path to be available. if not, skip step - if not advtrains.get_or_create_path(self.train_id, gp) then - self.object:setvelocity({x=0, y=0, z=0}) - return - end - if not self.pos_in_train then - --why ever. but better continue next step... - advtrains.update_trainpart_properties(self.train_id) - return - end - - local index=advtrains.get_real_path_index(self:train(), self.pos_in_train) - --print("trainindex "..gp.index.." wagonindex "..index) - - --position recalculation - local first_pos=gp.path[math.floor(index)] - local second_pos=gp.path[math.floor(index)+1] - if not first_pos or not second_pos then - --print("[advtrains] object "..self.unique_id.." path end reached!") - self.object:setvelocity({x=0,y=0,z=0}) - return - end - - --checking for environment collisions(a 3x3 cube around the center) - if not gp.recently_collided_with_env then - local collides=false - for x=-1,1 do - for y=0,2 do - for z=-1,1 do - local node=minetest.get_node_or_nil(vector.add(first_pos, {x=x, y=y, z=z})) - if (advtrains.train_collides(node)) then - collides=true - end - end - end - end - if collides then - gp.recently_collided_with_env=true - gp.velocity=-0.5*gp.velocity - gp.tarvelocity=0 - end - end - - --FIX: use index of the wagon, not of the train. - local velocity=(gp.velocity*gp.movedir)/(gp.path_dist[math.floor(index)] or 1) - local acceleration=(gp.last_accel or 0)/(gp.path_dist[math.floor(index)] or 1) - local factor=index-math.floor(index) - local actual_pos={x=first_pos.x-(first_pos.x-second_pos.x)*factor, y=first_pos.y-(first_pos.y-second_pos.y)*factor, z=first_pos.z-(first_pos.z-second_pos.z)*factor,} - local velocityvec={x=(first_pos.x-second_pos.x)*velocity*-1, z=(first_pos.z-second_pos.z)*velocity*-1, y=(first_pos.y-second_pos.y)*velocity*-1} - local accelerationvec={x=(first_pos.x-second_pos.x)*acceleration*-1, z=(first_pos.z-second_pos.z)*acceleration*-1, y=(first_pos.y-second_pos.y)*acceleration*-1} - - --some additional positions to determine orientation - local aposfwd=gp.path[math.floor(index+2)] - local aposbwd=gp.path[math.floor(index-1)] - - local yaw - if aposfwd and aposbwd then - yaw=advtrains.get_wagon_yaw(aposfwd, second_pos, first_pos, aposbwd, factor)+math.pi--TODO remove when cleaning up - else - yaw=math.atan2((first_pos.x-second_pos.x), (second_pos.z-first_pos.z)) - end - if self.wagon_flipped then - yaw=yaw+math.pi - end - - self.updatepct_timer=(self.updatepct_timer or 0)-dtime - if not self.old_velocity_vector - or not vector.equals(velocityvec, self.old_velocity_vector) - or not self.old_acceleration_vector - or not vector.equals(accelerationvec, self.old_acceleration_vector) - or self.old_yaw~=yaw - or self.updatepct_timer<=0 then--only send update packet if something changed - self.object:setpos(actual_pos) - self.object:setvelocity(velocityvec) - self.object:setacceleration(accelerationvec) - self.object:setyaw(yaw) - self.updatepct_timer=2 - if self.update_animation then - self:update_animation(gp.velocity) - end - end - - - self.old_velocity_vector=velocityvec - self.old_acceleration_vector=accelerationvec - self.old_yaw=yaw - printbm("wagon step", t) -end - -function advtrains.get_real_path_index(train, pit) - local pos_in_train_left=pit - local index=train.index - if pos_in_train_left>(index-math.floor(index))*(train.path_dist[math.floor(index)] or 1) then - pos_in_train_left=pos_in_train_left - (index-math.floor(index))*(train.path_dist[math.floor(index)] or 1) - index=math.floor(index) - while pos_in_train_left>(train.path_dist[index-1] or 1) do - pos_in_train_left=pos_in_train_left - (train.path_dist[index-1] or 1) - index=index-1 - end - index=index-(pos_in_train_left/(train.path_dist[index-1] or 1)) - else - index=index-(pos_in_train_left/(train.path_dist[math.floor(index-1)] or 1)) - end - return index -end - -function wagon:get_on(clicker, seatno) - if not self.seatp then - self.seatp={} - end - if not self.seats[seatno] then return end - if self.seatp[seatno] and self.seatp[seatno]~=clicker:get_player_name() then - self:get_off(seatno) - end - self.seatp[seatno] = clicker:get_player_name() - advtrains.player_to_train_mapping[clicker:get_player_name()]=self.train_id - clicker:set_attach(self.object, "", self.seats[seatno].attach_offset, {x=0,y=0,z=0}) - clicker:set_eye_offset(self.seats[seatno].view_offset, self.seats[seatno].view_offset) -end -function wagon:get_off_plr(pname) - local no=self:get_seatno(pname) - if no then - self:get_off(no) - end -end -function wagon:get_seatno(pname) - for no, cont in pairs(self.seatp) do - if cont==pname then - return no - end - end - return nil -end -function wagon:get_off(seatno) - if not self.seatp[seatno] then return end - local pname = self.seatp[seatno] - local clicker = minetest.get_player_by_name(pname) - advtrains.player_to_train_mapping[pname]=nil - advtrains.clear_driver_hud(pname) - if clicker then - clicker:set_detach() - clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0}) - local objpos=advtrains.round_vector_floor_y(self.object:getpos()) - local yaw=self.object:getyaw() - local isx=(yaw < math.pi/4) or (yaw > 3*math.pi/4 and yaw < 5*math.pi/4) or (yaw > 7*math.pi/4) - --abuse helper function - for _,r in ipairs({-1, 1}) do - local p=vector.add({x=isx and r or 0, y=0, z=not isx and r or 0}, objpos) - if minetest.get_item_group(minetest.get_node(p).name, "platform")>0 then - minetest.after(0.2, function() clicker:setpos({x=p.x, y=p.y+1, z=p.z}) end) - end - end - end - self.seatp[seatno]=nil -end -function wagon:show_get_on_form(pname) - if not self.initialized then return end - if #self.seats==0 then - if self.has_inventory and self.get_inventory_formspec then - minetest.show_formspec(pname, "advtrains_inv_"..self.unique_id, self:get_inventory_formspec(pname)) - end - return - end - local form, comma="size[5,8]label[0.5,0.5;Select seat:]textlist[0.5,1;4,6;seat;", "" - for seatno, seattbl in ipairs(self.seats) do - local addtext, colorcode="", "" - if self.seatp and self.seatp[seatno] then - colorcode="#FF0000" - addtext=" ("..self.seatp[seatno]..")" - end - form=form..comma..colorcode..seattbl.name..addtext - comma="," - end - form=form..";0,false]" - if self.has_inventory and self.get_inventory_formspec then - form=form.."button_exit[1,7;3,1;inv;Show Inventory]" - end - minetest.show_formspec(pname, "advtrains_geton_"..self.unique_id, form) -end -minetest.register_on_player_receive_fields(function(player, formname, fields) - local uid=string.match(formname, "^advtrains_geton_(.+)$") - if uid then - for _,wagon in pairs(minetest.luaentities) do - if wagon.is_wagon and wagon.initialized and wagon.unique_id==uid then - if fields.inv then - if wagon.has_inventory and wagon.get_inventory_formspec then - minetest.show_formspec(player:get_player_name(), "advtrains_inv_"..uid, wagon:get_inventory_formspec(player:get_player_name())) - end - elseif fields.seat then - local val=minetest.explode_textlist_event(fields.seat) - if val and val.type~="INV" and not wagon.seatp[player:get_player_name()] then - --get on - wagon:get_on(player, val.index) - --will work with the new close_formspec functionality. close exactly this formspec. - minetest.show_formspec(player:get_player_name(), formname, "") - end - end - end - end - end -end) -function wagon:reattach_all() - if not self.seatp then self.seatp={} end - for seatno, pname in pairs(self.seatp) do - local p=minetest.get_player_by_name(pname) - if p then - self:get_on(p ,seatno) - end - end -end -minetest.register_on_joinplayer(function(player) - for _,wagon in pairs(minetest.luaentities) do - if wagon.is_wagon and wagon.initialized then - wagon:reattach_all() - end - end -end) - -function advtrains.register_wagon(sysname, prototype, desc, inv_img) - setmetatable(prototype, {__index=wagon}) - minetest.register_entity(":advtrains:"..sysname,prototype) - - minetest.register_craftitem(":advtrains:"..sysname, { - description = desc, - inventory_image = inv_img, - wield_image = inv_img, - stack_max = 1, - - on_place = function(itemstack, placer, pointed_thing) - if not pointed_thing.type == "node" then - return - end - - local node=minetest.env:get_node_or_nil(pointed_thing.under) - if not node then print("[advtrains]Ignore at placer position") return itemstack end - local nodename=node.name - if(not advtrains.is_track_and_drives_on(nodename, prototype.drives_on)) then - print("[advtrains]no track here, not placing.") - return itemstack - end - local conn1=advtrains.get_track_connections(node.name, node.param2) - local id=advtrains.create_new_train_at(pointed_thing.under, advtrains.dirCoordSet(pointed_thing.under, conn1)) - - local ob=minetest.env:add_entity(pointed_thing.under, "advtrains:"..sysname) - if not ob then - print("[advtrains]couldn't add_entity, aborting") - end - local le=ob:get_luaentity() - - le.owner=placer:get_player_name() - le.infotext=desc..", owned by "..placer:get_player_name() - - local wagon_uid=le:init_new_instance(id, {}) - - advtrains.add_wagon_to_train(le, id) - if not minetest.setting_getbool("creative_mode") then - itemstack:take_item() - end - return itemstack - - end, - }) -end - ---[[ - wagons can define update_animation(self, velocity) if they have a speed-dependent animation - this function will be called when the velocity vector changes or every 2 seconds. -]] - - diff --git a/advtrains_train_industrial/depends.txt b/advtrains_train_industrial/depends.txt deleted file mode 100644 index 6f00bf6..0000000 --- a/advtrains_train_industrial/depends.txt +++ /dev/null @@ -1 +0,0 @@ -advtrains \ No newline at end of file diff --git a/advtrains_train_industrial/init.lua b/advtrains_train_industrial/init.lua deleted file mode 100644 index 379832c..0000000 --- a/advtrains_train_industrial/init.lua +++ /dev/null @@ -1,67 +0,0 @@ -advtrains.register_wagon("engine_industrial", { - mesh="advtrains_engine_industrial.b3d", - textures = {"advtrains_engine_industrial.png"}, - drives_on={default=true}, - max_speed=20, - seats = { - { - name="Driver Stand (left)", - attach_offset={x=-5, y=10, z=-10}, - view_offset={x=0, y=10, z=0}, - driving_ctrl_access=true, - }, - { - name="Driver Stand (right)", - attach_offset={x=5, y=10, z=-10}, - view_offset={x=0, y=10, z=0}, - driving_ctrl_access=true, - }, - }, - visual_size = {x=1, y=1}, - wagon_span=2.6, - is_locomotive=true, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, -}, "Industrial Train Engine", "advtrains_engine_industrial_inv.png") -advtrains.register_wagon("wagon_tank", { - mesh="advtrains_wagon_tank.b3d", - textures = {"advtrains_wagon_tank.png"}, - seats = {}, - drives_on={default=true}, - max_speed=20, - visual_size = {x=1, y=1}, - wagon_span=2.2, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, - has_inventory = true, - get_inventory_formspec = function(self) - return "size[8,11]".. - "list[detached:advtrains_wgn_"..self.unique_id..";box;0,0;8,6;]".. - "list[current_player;main;0,7;8,4;]".. - "listring[]" - end, - inventory_list_sizes = { - box=8*6, - }, -}, "Industrial tank wagon", "advtrains_wagon_tank_inv.png") -advtrains.register_wagon("wagon_wood", { - mesh="advtrains_wagon_wood.b3d", - textures = {"advtrains_wagon_wood.png"}, - seats = {}, - drives_on={default=true}, - max_speed=20, - visual_size = {x=1, y=1}, - wagon_span=1.8, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, - has_inventory = true, - get_inventory_formspec = function(self) - return "size[8,11]".. - "list[detached:advtrains_wgn_"..self.unique_id..";box;0,0;8,6;]".. - "list[current_player;main;0,7;8,4;]".. - "listring[]" - end, - inventory_list_sizes = { - box=8*6, - }, -}, "Industrial wood wagon", "advtrains_wagon_wood_inv.png") diff --git a/advtrains_train_industrial/models/advtrains_engine_industrial.b3d b/advtrains_train_industrial/models/advtrains_engine_industrial.b3d deleted file mode 100644 index f1ea485..0000000 Binary files a/advtrains_train_industrial/models/advtrains_engine_industrial.b3d and /dev/null differ diff --git a/advtrains_train_industrial/models/advtrains_wagon_tank.b3d b/advtrains_train_industrial/models/advtrains_wagon_tank.b3d deleted file mode 100644 index af2604b..0000000 Binary files a/advtrains_train_industrial/models/advtrains_wagon_tank.b3d and /dev/null differ diff --git a/advtrains_train_industrial/models/advtrains_wagon_wood.b3d b/advtrains_train_industrial/models/advtrains_wagon_wood.b3d deleted file mode 100644 index 0e7fb4b..0000000 Binary files a/advtrains_train_industrial/models/advtrains_wagon_wood.b3d and /dev/null differ diff --git a/advtrains_train_industrial/textures/advtrains_engine_industrial.png b/advtrains_train_industrial/textures/advtrains_engine_industrial.png deleted file mode 100644 index 38a872f..0000000 Binary files a/advtrains_train_industrial/textures/advtrains_engine_industrial.png and /dev/null differ diff --git a/advtrains_train_industrial/textures/advtrains_engine_industrial_inv.png b/advtrains_train_industrial/textures/advtrains_engine_industrial_inv.png deleted file mode 100644 index be4e80f..0000000 Binary files a/advtrains_train_industrial/textures/advtrains_engine_industrial_inv.png and /dev/null differ diff --git a/advtrains_train_industrial/textures/advtrains_wagon_tank.png b/advtrains_train_industrial/textures/advtrains_wagon_tank.png deleted file mode 100644 index 79b1316..0000000 Binary files a/advtrains_train_industrial/textures/advtrains_wagon_tank.png and /dev/null differ diff --git a/advtrains_train_industrial/textures/advtrains_wagon_tank_inv.png b/advtrains_train_industrial/textures/advtrains_wagon_tank_inv.png deleted file mode 100644 index 03401be..0000000 Binary files a/advtrains_train_industrial/textures/advtrains_wagon_tank_inv.png and /dev/null differ diff --git a/advtrains_train_industrial/textures/advtrains_wagon_wood.png b/advtrains_train_industrial/textures/advtrains_wagon_wood.png deleted file mode 100644 index acc6f72..0000000 Binary files a/advtrains_train_industrial/textures/advtrains_wagon_wood.png and /dev/null differ diff --git a/advtrains_train_industrial/textures/advtrains_wagon_wood_inv.png b/advtrains_train_industrial/textures/advtrains_wagon_wood_inv.png deleted file mode 100644 index 87109dd..0000000 Binary files a/advtrains_train_industrial/textures/advtrains_wagon_wood_inv.png and /dev/null differ diff --git a/advtrains_train_japan/depends.txt b/advtrains_train_japan/depends.txt deleted file mode 100644 index 6f00bf6..0000000 --- a/advtrains_train_japan/depends.txt +++ /dev/null @@ -1 +0,0 @@ -advtrains \ No newline at end of file diff --git a/advtrains_train_japan/init.lua b/advtrains_train_japan/init.lua deleted file mode 100644 index 47f50cf..0000000 --- a/advtrains_train_japan/init.lua +++ /dev/null @@ -1,38 +0,0 @@ -advtrains.register_wagon("engine_japan", { - mesh="advtrains_engine_japan.b3d", - textures = {"advtrains_engine_japan.png"}, - drives_on={default=true}, - max_speed=20, - seats = { - { - name="Default Seat (driver stand)", - attach_offset={x=0, y=10, z=0}, - view_offset={x=0, y=6, z=0}, - driving_ctrl_access=true, - }, - }, - visual_size = {x=1, y=1}, - wagon_span=2.5, - is_locomotive=true, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, -}, "Japanese Train Engine", "advtrains_engine_japan_inv.png") - -advtrains.register_wagon("wagon_japan", { - mesh="advtrains_wagon_japan.b3d", - textures = {"advtrains_wagon_japan.png"}, - drives_on={default=true}, - max_speed=20, - seats = { - { - name="Default Seat", - attach_offset={x=0, y=10, z=0}, - view_offset={x=0, y=6, z=0}, - }, - }, - visual_size = {x=1, y=1}, - wagon_span=2.3, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, -}, "Japanese Train Wagon", "advtrains_wagon_japan_inv.png") - diff --git a/advtrains_train_japan/models/advtrains_engine_japan.b3d b/advtrains_train_japan/models/advtrains_engine_japan.b3d deleted file mode 100644 index f82c33e..0000000 Binary files a/advtrains_train_japan/models/advtrains_engine_japan.b3d and /dev/null differ diff --git a/advtrains_train_japan/models/advtrains_wagon_japan.b3d b/advtrains_train_japan/models/advtrains_wagon_japan.b3d deleted file mode 100644 index 7970438..0000000 Binary files a/advtrains_train_japan/models/advtrains_wagon_japan.b3d and /dev/null differ diff --git a/advtrains_train_japan/textures/advtrains_engine_japan.png b/advtrains_train_japan/textures/advtrains_engine_japan.png deleted file mode 100644 index b286b38..0000000 Binary files a/advtrains_train_japan/textures/advtrains_engine_japan.png and /dev/null differ diff --git a/advtrains_train_japan/textures/advtrains_engine_japan_inv.png b/advtrains_train_japan/textures/advtrains_engine_japan_inv.png deleted file mode 100644 index 6af0636..0000000 Binary files a/advtrains_train_japan/textures/advtrains_engine_japan_inv.png and /dev/null differ diff --git a/advtrains_train_japan/textures/advtrains_wagon_japan.png b/advtrains_train_japan/textures/advtrains_wagon_japan.png deleted file mode 100644 index bee565e..0000000 Binary files a/advtrains_train_japan/textures/advtrains_wagon_japan.png and /dev/null differ diff --git a/advtrains_train_japan/textures/advtrains_wagon_japan_inv.png b/advtrains_train_japan/textures/advtrains_wagon_japan_inv.png deleted file mode 100644 index 3e6357c..0000000 Binary files a/advtrains_train_japan/textures/advtrains_wagon_japan_inv.png and /dev/null differ diff --git a/advtrains_train_steam/depends.txt b/advtrains_train_steam/depends.txt deleted file mode 100644 index 6f00bf6..0000000 --- a/advtrains_train_steam/depends.txt +++ /dev/null @@ -1 +0,0 @@ -advtrains \ No newline at end of file diff --git a/advtrains_train_steam/init.lua b/advtrains_train_steam/init.lua deleted file mode 100644 index ca52516..0000000 --- a/advtrains_train_steam/init.lua +++ /dev/null @@ -1,121 +0,0 @@ -advtrains.register_wagon("newlocomotive", { - mesh="advtrains_engine_steam.b3d", - textures = {"advtrains_newlocomotive.png"}, - is_locomotive=true, - drives_on={default=true}, - max_speed=10, - seats = { - { - name="Driver Stand (left)", - attach_offset={x=-5, y=10, z=-10}, - view_offset={x=0, y=6, z=0}, - driving_ctrl_access=true, - }, - { - name="Driver Stand (right)", - attach_offset={x=5, y=10, z=-10}, - view_offset={x=0, y=6, z=0}, - driving_ctrl_access=true, - }, - }, - visual_size = {x=1, y=1}, - wagon_span=1.85, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - --update_animation=function(self, velocity) - --if self.old_anim_velocity~=advtrains.abs_ceil(velocity) then - -- self.object:set_animation({x=1,y=60}, 100)--math.floor(velocity)) - --self.old_anim_velocity=advtrains.abs_ceil(velocity) - --end - --end, - custom_on_activate = function(self, staticdata_table, dtime_s) - minetest.add_particlespawner({ - amount = 10, - time = 0, - -- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base - minpos = {x=0, y=2, z=1.2}, - maxpos = {x=0, y=2, z=1.2}, - minvel = {x=-0.2, y=1.8, z=-0.2}, - maxvel = {x=0.2, y=2, z=0.2}, - minacc = {x=0, y=-0.1, z=0}, - maxacc = {x=0, y=-0.3, z=0}, - minexptime = 2, - maxexptime = 4, - minsize = 1, - maxsize = 5, - -- ^ The particle's properties are random values in between the bounds: - -- ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration), - -- ^ minsize/maxsize, minexptime/maxexptime (expirationtime) - collisiondetection = true, - -- ^ collisiondetection: if true uses collision detection - vertical = false, - -- ^ vertical: if true faces player using y axis only - texture = "smoke_puff.png", - -- ^ Uses texture (string) - attached = self.object, - }) - end, - drops={"default:steelblock 4"}, -}, "Steam Engine", "advtrains_newlocomotive_inv.png") -advtrains.register_wagon("wagon_default", { - mesh="advtrains_wagon.b3d", - textures = {"advtrains_wagon.png"}, - drives_on={default=true}, - max_speed=10, - seats = { - { - name="Default Seat", - attach_offset={x=0, y=10, z=0}, - view_offset={x=0, y=6, z=0}, - }, - }, - visual_size = {x=1, y=1}, - wagon_span=1.8, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, -}, "Passenger Wagon", "advtrains_wagon_inv.png") -advtrains.register_wagon("wagon_box", { - mesh="advtrains_wagon.b3d", - textures = {"advtrains_wagon_box.png"}, - drives_on={default=true}, - max_speed=10, - seats = {}, - visual_size = {x=1, y=1}, - wagon_span=1.8, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - drops={"default:steelblock 4"}, - has_inventory = true, - get_inventory_formspec = function(self) - return "size[8,11]".. - "list[detached:advtrains_wgn_"..self.unique_id..";box;0,0;8,6;]".. - "list[current_player;main;0,7;8,4;]".. - "listring[]" - end, - inventory_list_sizes = { - box=8*6, - }, -}, "Box Wagon", "advtrains_wagon_box_inv.png") - -minetest.register_craft({ - output = 'advtrains:newlocomotive', - recipe = { - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - {'default:steelblock', 'dye:black', 'default:steelblock'}, - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - }, -}) -minetest.register_craft({ - output = 'advtrains:wagon_default', - recipe = { - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - {'default:steelblock', 'dye:dark_green', 'default:steelblock'}, - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - }, -}) -minetest.register_craft({ - output = 'advtrains:wagon_box', - recipe = { - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - {'default:steelblock', 'default:chest', 'default:steelblock'}, - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - }, -}) diff --git a/advtrains_train_steam/models/advtrains_engine_steam.b3d b/advtrains_train_steam/models/advtrains_engine_steam.b3d deleted file mode 100644 index 36bdd15..0000000 Binary files a/advtrains_train_steam/models/advtrains_engine_steam.b3d and /dev/null differ diff --git a/advtrains_train_steam/models/advtrains_wagon.b3d b/advtrains_train_steam/models/advtrains_wagon.b3d deleted file mode 100644 index 5c8214c..0000000 Binary files a/advtrains_train_steam/models/advtrains_wagon.b3d and /dev/null differ diff --git a/advtrains_train_steam/textures/advtrains_newlocomotive.png b/advtrains_train_steam/textures/advtrains_newlocomotive.png deleted file mode 100644 index e461bc7..0000000 Binary files a/advtrains_train_steam/textures/advtrains_newlocomotive.png and /dev/null differ diff --git a/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png b/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png deleted file mode 100644 index 8d3fafb..0000000 Binary files a/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png and /dev/null differ diff --git a/advtrains_train_steam/textures/advtrains_wagon.png b/advtrains_train_steam/textures/advtrains_wagon.png deleted file mode 100644 index c37c979..0000000 Binary files a/advtrains_train_steam/textures/advtrains_wagon.png and /dev/null differ diff --git a/advtrains_train_steam/textures/advtrains_wagon_box.png b/advtrains_train_steam/textures/advtrains_wagon_box.png deleted file mode 100644 index 8bfbe06..0000000 Binary files a/advtrains_train_steam/textures/advtrains_wagon_box.png and /dev/null differ diff --git a/advtrains_train_steam/textures/advtrains_wagon_box_inv.png b/advtrains_train_steam/textures/advtrains_wagon_box_inv.png deleted file mode 100644 index 480f245..0000000 Binary files a/advtrains_train_steam/textures/advtrains_wagon_box_inv.png and /dev/null differ diff --git a/advtrains_train_steam/textures/advtrains_wagon_inv.png b/advtrains_train_steam/textures/advtrains_wagon_inv.png deleted file mode 100644 index 0b72ac3..0000000 Binary files a/advtrains_train_steam/textures/advtrains_wagon_inv.png and /dev/null differ diff --git a/advtrains_train_subway/depends.txt b/advtrains_train_subway/depends.txt deleted file mode 100644 index 6f00bf6..0000000 --- a/advtrains_train_subway/depends.txt +++ /dev/null @@ -1 +0,0 @@ -advtrains \ No newline at end of file diff --git a/advtrains_train_subway/init.lua b/advtrains_train_subway/init.lua deleted file mode 100644 index b5bdb18..0000000 --- a/advtrains_train_subway/init.lua +++ /dev/null @@ -1,30 +0,0 @@ - -advtrains.register_wagon("subway_wagon", { - mesh="advtrains_subway_train.b3d", - textures = {"advtrains_subway_train.png"}, - drives_on={default=true}, - max_speed=15, - seats = { - { - name="Default Seat (driver stand)", - attach_offset={x=0, y=10, z=0}, - view_offset={x=0, y=6, z=0}, - driving_ctrl_access=true, - }, - }, - visual_size = {x=1, y=1}, - wagon_span=1.8, - collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - is_locomotive=true, - drops={"default:steelblock 4"}, -}, "Subway Passenger Wagon", "advtrains_subway_train_inv.png") - ---wagons -minetest.register_craft({ - output = 'advtrains:subway_wagon', - recipe = { - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - {'default:steelblock', 'dye:yellow', 'default:steelblock'}, - {'default:steelblock', 'default:steelblock', 'default:steelblock'}, - }, -}) diff --git a/advtrains_train_subway/models/advtrains_subway_train.b3d b/advtrains_train_subway/models/advtrains_subway_train.b3d deleted file mode 100644 index a824d33..0000000 Binary files a/advtrains_train_subway/models/advtrains_subway_train.b3d and /dev/null differ diff --git a/advtrains_train_subway/textures/advtrains_subway_train.png b/advtrains_train_subway/textures/advtrains_subway_train.png deleted file mode 100644 index 1d569f3..0000000 Binary files a/advtrains_train_subway/textures/advtrains_subway_train.png and /dev/null differ diff --git a/advtrains_train_subway/textures/advtrains_subway_train_inv.png b/advtrains_train_subway/textures/advtrains_subway_train_inv.png deleted file mode 100644 index 1d0e809..0000000 Binary files a/advtrains_train_subway/textures/advtrains_subway_train_inv.png and /dev/null differ diff --git a/assets/advtrains_newlocomotive.xcf b/assets/advtrains_newlocomotive.xcf new file mode 100644 index 0000000..9ad5187 Binary files /dev/null and b/assets/advtrains_newlocomotive.xcf differ diff --git a/assets/blender/engine-with-animation.blend b/assets/blender/engine-with-animation.blend new file mode 100644 index 0000000..2649587 Binary files /dev/null and b/assets/blender/engine-with-animation.blend differ diff --git a/assets/blender/gleis/detectorpart.png b/assets/blender/gleis/detectorpart.png new file mode 100644 index 0000000..fc24181 Binary files /dev/null and b/assets/blender/gleis/detectorpart.png differ diff --git a/assets/blender/gleis/infos/Grafik_weiche.png b/assets/blender/gleis/infos/Grafik_weiche.png new file mode 100644 index 0000000..6674eb3 Binary files /dev/null and b/assets/blender/gleis/infos/Grafik_weiche.png differ diff --git a/assets/blender/gleis/infos/breite b/assets/blender/gleis/infos/breite new file mode 100644 index 0000000..b2862c6 --- /dev/null +++ b/assets/blender/gleis/infos/breite @@ -0,0 +1 @@ +1435mm diff --git a/assets/blender/gleis/licence.txt~ b/assets/blender/gleis/licence.txt~ new file mode 100644 index 0000000..e69de29 diff --git a/assets/blender/gleis/rail_my.blend b/assets/blender/gleis/rail_my.blend new file mode 100644 index 0000000..3c741bc Binary files /dev/null and b/assets/blender/gleis/rail_my.blend differ diff --git a/assets/blender/gleis/rail_my.blend1 b/assets/blender/gleis/rail_my.blend1 new file mode 100644 index 0000000..6322856 Binary files /dev/null and b/assets/blender/gleis/rail_my.blend1 differ diff --git a/assets/blender/gleis/rail_my_rt.blend b/assets/blender/gleis/rail_my_rt.blend new file mode 100644 index 0000000..8372a0c Binary files /dev/null and b/assets/blender/gleis/rail_my_rt.blend differ diff --git a/assets/blender/gleis/rail_my_rt.blend1 b/assets/blender/gleis/rail_my_rt.blend1 new file mode 100644 index 0000000..7d0978e Binary files /dev/null and b/assets/blender/gleis/rail_my_rt.blend1 differ diff --git a/assets/blender/gleis/rail_my_rt_final.blend b/assets/blender/gleis/rail_my_rt_final.blend new file mode 100644 index 0000000..d07a65d Binary files /dev/null and b/assets/blender/gleis/rail_my_rt_final.blend differ diff --git a/assets/blender/gleis/rail_my_rt_final.blend1 b/assets/blender/gleis/rail_my_rt_final.blend1 new file mode 100644 index 0000000..8a2d213 Binary files /dev/null and b/assets/blender/gleis/rail_my_rt_final.blend1 differ diff --git a/assets/blender/gleis/rail_my_rt_switches.blend b/assets/blender/gleis/rail_my_rt_switches.blend new file mode 100644 index 0000000..fdce427 Binary files /dev/null and b/assets/blender/gleis/rail_my_rt_switches.blend differ diff --git a/assets/blender/gleis/rail_my_rt_switches.blend1 b/assets/blender/gleis/rail_my_rt_switches.blend1 new file mode 100644 index 0000000..04370ba Binary files /dev/null and b/assets/blender/gleis/rail_my_rt_switches.blend1 differ diff --git a/assets/blender/gleis/rail_my_rt_switches2.blend b/assets/blender/gleis/rail_my_rt_switches2.blend new file mode 100644 index 0000000..9562e4d Binary files /dev/null and b/assets/blender/gleis/rail_my_rt_switches2.blend differ diff --git a/assets/blender/gleis/rail_my_rt_switches2.blend1 b/assets/blender/gleis/rail_my_rt_switches2.blend1 new file mode 100644 index 0000000..07a155f Binary files /dev/null and b/assets/blender/gleis/rail_my_rt_switches2.blend1 differ diff --git a/assets/blender/gleis/rail_together.blend b/assets/blender/gleis/rail_together.blend new file mode 100644 index 0000000..cff51ea Binary files /dev/null and b/assets/blender/gleis/rail_together.blend differ diff --git a/assets/blender/gleis/rail_together.png b/assets/blender/gleis/rail_together.png new file mode 100644 index 0000000..386cd5c Binary files /dev/null and b/assets/blender/gleis/rail_together.png differ diff --git a/assets/blender/gleis/rail_together2.png b/assets/blender/gleis/rail_together2.png new file mode 100644 index 0000000..3effe34 Binary files /dev/null and b/assets/blender/gleis/rail_together2.png differ diff --git a/assets/blender/gleis/rail_together3.png b/assets/blender/gleis/rail_together3.png new file mode 100644 index 0000000..4a183c1 Binary files /dev/null and b/assets/blender/gleis/rail_together3.png differ diff --git a/assets/blender/gleis/rail_verticals.blend b/assets/blender/gleis/rail_verticals.blend new file mode 100644 index 0000000..45c37e1 Binary files /dev/null and b/assets/blender/gleis/rail_verticals.blend differ diff --git a/assets/blender/gleis/rail_verticals.blend1 b/assets/blender/gleis/rail_verticals.blend1 new file mode 100644 index 0000000..320f30b Binary files /dev/null and b/assets/blender/gleis/rail_verticals.blend1 differ diff --git a/assets/blender/gleis/rail_verticals3.blend b/assets/blender/gleis/rail_verticals3.blend new file mode 100644 index 0000000..5d62959 Binary files /dev/null and b/assets/blender/gleis/rail_verticals3.blend differ diff --git a/assets/blender/gleis/rail_verticals3.blend1 b/assets/blender/gleis/rail_verticals3.blend1 new file mode 100644 index 0000000..893f2ea Binary files /dev/null and b/assets/blender/gleis/rail_verticals3.blend1 differ diff --git a/assets/blender/gleis/rail_verticals45.blend b/assets/blender/gleis/rail_verticals45.blend new file mode 100644 index 0000000..a1589e3 Binary files /dev/null and b/assets/blender/gleis/rail_verticals45.blend differ diff --git a/assets/blender/gleis/rail_verticals45.blend1 b/assets/blender/gleis/rail_verticals45.blend1 new file mode 100644 index 0000000..6b44d1c Binary files /dev/null and b/assets/blender/gleis/rail_verticals45.blend1 differ diff --git a/assets/blender/gleis/rail_verticals45.blend11 b/assets/blender/gleis/rail_verticals45.blend11 new file mode 100644 index 0000000..48316e8 Binary files /dev/null and b/assets/blender/gleis/rail_verticals45.blend11 differ diff --git a/assets/blender/gleis/texturen/rail.png b/assets/blender/gleis/texturen/rail.png new file mode 100644 index 0000000..8478cf6 Binary files /dev/null and b/assets/blender/gleis/texturen/rail.png differ diff --git a/assets/blender/gleis/texturen/uv.png b/assets/blender/gleis/texturen/uv.png new file mode 100644 index 0000000..fb0af3e Binary files /dev/null and b/assets/blender/gleis/texturen/uv.png differ diff --git a/assets/blender/industrial/industry_loc.blend b/assets/blender/industrial/industry_loc.blend new file mode 100644 index 0000000..1a6cb2b Binary files /dev/null and b/assets/blender/industrial/industry_loc.blend differ diff --git a/assets/blender/industrial/industry_loc.blend1 b/assets/blender/industrial/industry_loc.blend1 new file mode 100644 index 0000000..af54c3f Binary files /dev/null and b/assets/blender/industrial/industry_loc.blend1 differ diff --git a/assets/blender/industrial/industry_loc.blend11 b/assets/blender/industrial/industry_loc.blend11 new file mode 100644 index 0000000..a089a65 Binary files /dev/null and b/assets/blender/industrial/industry_loc.blend11 differ diff --git a/assets/blender/industrial/industry_oil_ wagong.blend b/assets/blender/industrial/industry_oil_ wagong.blend new file mode 100644 index 0000000..30bde51 Binary files /dev/null and b/assets/blender/industrial/industry_oil_ wagong.blend differ diff --git a/assets/blender/industrial/industry_oil_ wagong.blend1 b/assets/blender/industrial/industry_oil_ wagong.blend1 new file mode 100644 index 0000000..849971d Binary files /dev/null and b/assets/blender/industrial/industry_oil_ wagong.blend1 differ diff --git a/assets/blender/industrial/industry_tree_wagong.blend b/assets/blender/industrial/industry_tree_wagong.blend new file mode 100644 index 0000000..23de208 Binary files /dev/null and b/assets/blender/industrial/industry_tree_wagong.blend differ diff --git a/assets/blender/industrial/industry_tree_wagong.blend1 b/assets/blender/industrial/industry_tree_wagong.blend1 new file mode 100644 index 0000000..bf2c9ed Binary files /dev/null and b/assets/blender/industrial/industry_tree_wagong.blend1 differ diff --git a/assets/blender/industrial/industry_tree_wagong.png b/assets/blender/industrial/industry_tree_wagong.png new file mode 100644 index 0000000..87109dd Binary files /dev/null and b/assets/blender/industrial/industry_tree_wagong.png differ diff --git a/assets/blender/locomotive.blend b/assets/blender/locomotive.blend new file mode 100644 index 0000000..8fd6059 Binary files /dev/null and b/assets/blender/locomotive.blend differ diff --git a/assets/blender/magnet_track.blend b/assets/blender/magnet_track.blend new file mode 100644 index 0000000..0ab14e7 Binary files /dev/null and b/assets/blender/magnet_track.blend differ diff --git a/assets/blender/mbb/advtrains_wagon_japan.xcf b/assets/blender/mbb/advtrains_wagon_japan.xcf new file mode 100644 index 0000000..4fc88c0 Binary files /dev/null and b/assets/blender/mbb/advtrains_wagon_japan.xcf differ diff --git a/assets/blender/mbb/modern_japanlocomotive.blend b/assets/blender/mbb/modern_japanlocomotive.blend new file mode 100644 index 0000000..6eb8f3d Binary files /dev/null and b/assets/blender/mbb/modern_japanlocomotive.blend differ diff --git a/assets/blender/mbb/modern_japanlocomotive.blend1 b/assets/blender/mbb/modern_japanlocomotive.blend1 new file mode 100644 index 0000000..a2e745d Binary files /dev/null and b/assets/blender/mbb/modern_japanlocomotive.blend1 differ diff --git a/assets/blender/mbb/modern_japanlocomotive.png b/assets/blender/mbb/modern_japanlocomotive.png new file mode 100644 index 0000000..b80d16f Binary files /dev/null and b/assets/blender/mbb/modern_japanlocomotive.png differ diff --git a/assets/blender/mbb/modern_japanlocomotive.xcf b/assets/blender/mbb/modern_japanlocomotive.xcf new file mode 100644 index 0000000..bb28534 Binary files /dev/null and b/assets/blender/mbb/modern_japanlocomotive.xcf differ diff --git a/assets/blender/mbb/modern_locomotive.blend b/assets/blender/mbb/modern_locomotive.blend new file mode 100644 index 0000000..8e72233 Binary files /dev/null and b/assets/blender/mbb/modern_locomotive.blend differ diff --git a/assets/blender/mbb/modern_wagong.blend b/assets/blender/mbb/modern_wagong.blend new file mode 100644 index 0000000..f32710a Binary files /dev/null and b/assets/blender/mbb/modern_wagong.blend differ diff --git a/assets/blender/mbb/modern_wagong.blend1 b/assets/blender/mbb/modern_wagong.blend1 new file mode 100644 index 0000000..376831c Binary files /dev/null and b/assets/blender/mbb/modern_wagong.blend1 differ diff --git a/assets/blender/mbb/modern_wagong_uv.blend b/assets/blender/mbb/modern_wagong_uv.blend new file mode 100644 index 0000000..4c10fb3 Binary files /dev/null and b/assets/blender/mbb/modern_wagong_uv.blend differ diff --git a/assets/blender/mbb/modern_wagong_uv.blend1 b/assets/blender/mbb/modern_wagong_uv.blend1 new file mode 100644 index 0000000..ce77416 Binary files /dev/null and b/assets/blender/mbb/modern_wagong_uv.blend1 differ diff --git a/assets/blender/mbb/modern_wagong_uv.png b/assets/blender/mbb/modern_wagong_uv.png new file mode 100644 index 0000000..68018ea Binary files /dev/null and b/assets/blender/mbb/modern_wagong_uv.png differ diff --git a/assets/blender/mbb/prellbock.blend b/assets/blender/mbb/prellbock.blend new file mode 100644 index 0000000..1c20ab2 Binary files /dev/null and b/assets/blender/mbb/prellbock.blend differ diff --git a/assets/blender/mbb/prellbock.blend1 b/assets/blender/mbb/prellbock.blend1 new file mode 100644 index 0000000..981538e Binary files /dev/null and b/assets/blender/mbb/prellbock.blend1 differ diff --git a/assets/blender/mbb/prellbock.uv.png b/assets/blender/mbb/prellbock.uv.png new file mode 100644 index 0000000..7730753 Binary files /dev/null and b/assets/blender/mbb/prellbock.uv.png differ diff --git a/assets/blender/mbb/regio-lokomotive.blend b/assets/blender/mbb/regio-lokomotive.blend new file mode 100644 index 0000000..210e60e Binary files /dev/null and b/assets/blender/mbb/regio-lokomotive.blend differ diff --git a/assets/blender/mbb/regio-waron.blend b/assets/blender/mbb/regio-waron.blend new file mode 100644 index 0000000..19b07ce Binary files /dev/null and b/assets/blender/mbb/regio-waron.blend differ diff --git a/assets/blender/mbb/retrosignal.blend b/assets/blender/mbb/retrosignal.blend new file mode 100644 index 0000000..b795215 Binary files /dev/null and b/assets/blender/mbb/retrosignal.blend differ diff --git a/assets/blender/mbb/retrosignal.blend1 b/assets/blender/mbb/retrosignal.blend1 new file mode 100644 index 0000000..94af470 Binary files /dev/null and b/assets/blender/mbb/retrosignal.blend1 differ diff --git a/assets/blender/mbb/signal(2)_hoch.blend b/assets/blender/mbb/signal(2)_hoch.blend new file mode 100644 index 0000000..70391f6 Binary files /dev/null and b/assets/blender/mbb/signal(2)_hoch.blend differ diff --git a/assets/blender/mbb/signal(2)_unten.blend b/assets/blender/mbb/signal(2)_unten.blend new file mode 100644 index 0000000..4e917bc Binary files /dev/null and b/assets/blender/mbb/signal(2)_unten.blend differ diff --git a/assets/blender/mbb/signal.blend b/assets/blender/mbb/signal.blend new file mode 100644 index 0000000..135c7b4 Binary files /dev/null and b/assets/blender/mbb/signal.blend differ diff --git a/assets/blender/mbb/signal.blend1 b/assets/blender/mbb/signal.blend1 new file mode 100644 index 0000000..63a8c99 Binary files /dev/null and b/assets/blender/mbb/signal.blend1 differ diff --git a/assets/blender/mbb/signal.png b/assets/blender/mbb/signal.png new file mode 100644 index 0000000..779cdda Binary files /dev/null and b/assets/blender/mbb/signal.png differ diff --git a/assets/blender/mbb/signal.xcf b/assets/blender/mbb/signal.xcf new file mode 100644 index 0000000..f667739 Binary files /dev/null and b/assets/blender/mbb/signal.xcf differ diff --git a/assets/blender/mbb/signal2.png b/assets/blender/mbb/signal2.png new file mode 100644 index 0000000..7af4e2d Binary files /dev/null and b/assets/blender/mbb/signal2.png differ diff --git a/assets/blender/mbb/tr-logo.png b/assets/blender/mbb/tr-logo.png new file mode 100644 index 0000000..9bc0f10 Binary files /dev/null and b/assets/blender/mbb/tr-logo.png differ diff --git a/assets/blender/mbb/weichenhebel1.blend b/assets/blender/mbb/weichenhebel1.blend new file mode 100644 index 0000000..70b997d Binary files /dev/null and b/assets/blender/mbb/weichenhebel1.blend differ diff --git a/assets/blender/mbb/weichenhebel2.blend b/assets/blender/mbb/weichenhebel2.blend new file mode 100644 index 0000000..c1c3aac Binary files /dev/null and b/assets/blender/mbb/weichenhebel2.blend differ diff --git a/assets/blender/newlocomotive.blend b/assets/blender/newlocomotive.blend new file mode 100644 index 0000000..858882b Binary files /dev/null and b/assets/blender/newlocomotive.blend differ diff --git a/assets/blender/newlocomotive.blend1 b/assets/blender/newlocomotive.blend1 new file mode 100644 index 0000000..4b8b24f Binary files /dev/null and b/assets/blender/newlocomotive.blend1 differ diff --git a/assets/blender/newlocomotive_uvs.png b/assets/blender/newlocomotive_uvs.png new file mode 100644 index 0000000..879be65 Binary files /dev/null and b/assets/blender/newlocomotive_uvs.png differ diff --git a/assets/blender/newwagon.blend b/assets/blender/newwagon.blend new file mode 100644 index 0000000..1cedc55 Binary files /dev/null and b/assets/blender/newwagon.blend differ diff --git a/assets/blender/newwagon.blend1 b/assets/blender/newwagon.blend1 new file mode 100644 index 0000000..eb30fde Binary files /dev/null and b/assets/blender/newwagon.blend1 differ diff --git a/assets/blender/newwagon.png b/assets/blender/newwagon.png new file mode 100644 index 0000000..812bc32 Binary files /dev/null and b/assets/blender/newwagon.png differ diff --git a/assets/blender/subway-train.blend b/assets/blender/subway-train.blend new file mode 100644 index 0000000..690d87b Binary files /dev/null and b/assets/blender/subway-train.blend differ diff --git a/assets/blender/subway-train.blend1 b/assets/blender/subway-train.blend1 new file mode 100644 index 0000000..86d1f92 Binary files /dev/null and b/assets/blender/subway-train.blend1 differ diff --git a/assets/blender/subway-train.png b/assets/blender/subway-train.png new file mode 100644 index 0000000..d0b9731 Binary files /dev/null and b/assets/blender/subway-train.png differ diff --git a/assets/blender/subway-train.xcf b/assets/blender/subway-train.xcf new file mode 100644 index 0000000..775b87c Binary files /dev/null and b/assets/blender/subway-train.xcf differ diff --git a/assets/blender/trackplane.blend b/assets/blender/trackplane.blend new file mode 100644 index 0000000..79365f7 Binary files /dev/null and b/assets/blender/trackplane.blend differ diff --git a/assets/blender/trackvertical1.blend b/assets/blender/trackvertical1.blend new file mode 100644 index 0000000..fca6742 Binary files /dev/null and b/assets/blender/trackvertical1.blend differ diff --git a/assets/blender/trackvertical1.blend1 b/assets/blender/trackvertical1.blend1 new file mode 100644 index 0000000..b146b56 Binary files /dev/null and b/assets/blender/trackvertical1.blend1 differ diff --git a/assets/blender/trackvertical1.png b/assets/blender/trackvertical1.png new file mode 100644 index 0000000..a998dcb Binary files /dev/null and b/assets/blender/trackvertical1.png differ diff --git a/assets/blender/trackvertical2.blend b/assets/blender/trackvertical2.blend new file mode 100644 index 0000000..a066b84 Binary files /dev/null and b/assets/blender/trackvertical2.blend differ diff --git a/assets/blender/trackvertical2.png b/assets/blender/trackvertical2.png new file mode 100644 index 0000000..43142f9 Binary files /dev/null and b/assets/blender/trackvertical2.png differ diff --git a/assets/init.lua b/assets/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/assets/larger rails.xcf b/assets/larger rails.xcf new file mode 100644 index 0000000..42ae592 Binary files /dev/null and b/assets/larger rails.xcf differ diff --git a/assets/oldmodels/locomotive.b3d b/assets/oldmodels/locomotive.b3d new file mode 100644 index 0000000..5e16be3 Binary files /dev/null and b/assets/oldmodels/locomotive.b3d differ diff --git a/assets/oldmodels/trackvertical1.b3d b/assets/oldmodels/trackvertical1.b3d new file mode 100644 index 0000000..5620f60 Binary files /dev/null and b/assets/oldmodels/trackvertical1.b3d differ diff --git a/assets/oldmodels/trackvertical2.b3d b/assets/oldmodels/trackvertical2.b3d new file mode 100644 index 0000000..22dbb20 Binary files /dev/null and b/assets/oldmodels/trackvertical2.b3d differ diff --git a/license.txt b/license.txt deleted file mode 100644 index 68a4b60..0000000 --- a/license.txt +++ /dev/null @@ -1,142 +0,0 @@ -GNU LESSER GENERAL PUBLIC LICENSE - -Version 2.1, February 1999 - -Copyright (C) 1991, 1999 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - -Preamble - -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. - -This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. - -When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. - -To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. - -For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. - -We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. - -To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. - -Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. - -Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. - -When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. - -We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. - -For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. - -In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. - -Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. - -The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". - -A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. - -The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) - -"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. - -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - -1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. - -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. - c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. - d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. - - (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. - -3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - -Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. - -This option is useful when you wish to copy part of the code of the Library into a program that is not a library. - -4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. - -If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. - -5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. - -However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. - -When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. - -If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) - -Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - -6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. - -You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: - - a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) - b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. - c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. - d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. - e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. - -For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. - -It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - -7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. - b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. - -8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. - -9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. - -10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. - -11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - -12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. - -13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - -14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - -NO WARRANTY - -15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -END OF TERMS AND CONDITIONS diff --git a/license_media.txt b/license_media.txt deleted file mode 100644 index c0da560..0000000 --- a/license_media.txt +++ /dev/null @@ -1,63 +0,0 @@ -License - -THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. - -BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. - -1. Definitions - - "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. - "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(g) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License. - "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership. - "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, Noncommercial, ShareAlike. - "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. - "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. - "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. - "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. - "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. - "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. - -2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. - -3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: - - to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; - to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified."; - to Distribute and Publicly Perform the Work including as incorporated in Collections; and, - to Distribute and Publicly Perform Adaptations. - -The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved, including but not limited to the rights described in Section 4(e). - -4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: - - You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(d), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(d), as requested. - You may Distribute or Publicly Perform an Adaptation only under: (i) the terms of this License; (ii) a later version of this License with the same License Elements as this License; (iii) a Creative Commons jurisdiction license (either this or a later license version) that contains the same License Elements as this License (e.g., Attribution-NonCommercial-ShareAlike 3.0 US) ("Applicable License"). You must include a copy of, or the URI, for Applicable License with every copy of each Adaptation You Distribute or Publicly Perform. You may not offer or impose any terms on the Adaptation that restrict the terms of the Applicable License or the ability of the recipient of the Adaptation to exercise the rights granted to that recipient under the terms of the Applicable License. You must keep intact all notices that refer to the Applicable License and to the disclaimer of warranties with every copy of the Work as included in the Adaptation You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Adaptation, You may not impose any effective technological measures on the Adaptation that restrict the ability of a recipient of the Adaptation from You to exercise the rights granted to that recipient under the terms of the Applicable License. This Section 4(b) applies to the Adaptation as incorporated in a Collection, but this does not require the Collection apart from the Adaptation itself to be made subject to the terms of the Applicable License. - You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation. The exchange of the Work for other copyrighted works by means of digital file-sharing or otherwise shall not be considered to be intended for or directed toward commercial advantage or private monetary compensation, provided there is no payment of any monetary compensation in con-nection with the exchange of copyrighted works. - If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and, (iv) consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4(d) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. - - For the avoidance of doubt: - Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; - Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License if Your exercise of such rights is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(c) and otherwise waives the right to collect royalties through any statutory or compulsory licensing scheme; and, - Voluntary License Schemes. The Licensor reserves the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License that is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(c). - Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise. - -5. Representations, Warranties and Disclaimer - -UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING AND TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THIS EXCLUSION MAY NOT APPLY TO YOU. - -6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. Termination - - This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. - Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. - -8. Miscellaneous - - Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. - Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. - If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. - No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. - This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. - The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. - diff --git a/manual.pdf b/manual.pdf deleted file mode 100644 index e8c6380..0000000 Binary files a/manual.pdf and /dev/null differ diff --git a/screenshot.png b/screenshot.png deleted file mode 100644 index 78783e1..0000000 Binary files a/screenshot.png and /dev/null differ -- cgit v1.2.3 From 400cb55bb0da9eb130f72f13a2872d682de9736c Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 4 Jan 2017 21:23:15 +0100 Subject: Fix bug in track database the entire database was broken due to a not removed indexing --- advtrains/advtrains/helpers.lua | 22 ++++++++---------- advtrains/advtrains/pseudoload.lua | 9 ++++---- advtrains/advtrains/tracks.lua | 9 +++++++- advtrains/advtrains/trainlogic.lua | 46 ++++++++++++++++++++++---------------- 4 files changed, 48 insertions(+), 38 deletions(-) diff --git a/advtrains/advtrains/helpers.lua b/advtrains/advtrains/helpers.lua index 1a02621..7ee7e71 100644 --- a/advtrains/advtrains/helpers.lua +++ b/advtrains/advtrains/helpers.lua @@ -58,11 +58,7 @@ rely1, rely2 tell to which height the connections are pointed to. 1 means it wil function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return local mid=advtrains.round_vector_floor_y(midreal) - if not advtrains.get_rail_info_at(advtrains.round_vector_floor_y(prev), drives_on) then - return nil - end - - local midnode_ok, middir1, middir2, midrely1, midrely2=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(mid), drives_on) + local midnode_ok, middir1, middir2, midrely1, midrely2=advtrains.get_rail_info_at(mid, drives_on) if not midnode_ok then return nil end @@ -72,7 +68,7 @@ function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return --print("[advtrains] in order mid1,mid2",middir1,middir2) --try if it is dir1 local cor1=advtrains.dirCoordSet(mid, middir2)--<<<< - if math.floor(cor1.x+0.5)==math.floor(prev.x+0.5) and math.floor(cor1.z+0.5)==math.floor(prev.z+0.5) then--this was previous + if cor1.x==prev.x and cor1.z==prev.z then--this was previous next=advtrains.dirCoordSet(mid, middir1) if midrely1>=1 then next.y=next.y+1 @@ -99,7 +95,7 @@ function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return --print("[advtrains]dir applied next pos: "..(next and minetest.pos_to_string(next) or "nil").."(chkdir is "..(chkdir or "nil")..", y-offset "..y_offset..")") --is there a next if not next then - --print("[advtrains]in conway: no next rail(nil), returning!") + print("[advtrains]in conway: no next rail(nil), returning!") return nil end @@ -107,31 +103,31 @@ function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return --is it a rail? if(not nextnode_ok) then - --print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not a rail, trying one node below!") + print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not a rail, trying one node below!") next.y=next.y-1 y_offset=y_offset-1 nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) if(not nextnode_ok) then - --print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!") + print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!") return nil end end --is this next rail connecting to the mid? if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely-y_offset) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely-y_offset) ) then - --print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not connecting, trying one node below!") + print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not connecting, trying one node below!") next.y=next.y-1 y_offset=y_offset-1 nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) if(not nextnode_ok) then - --print("[advtrains]in conway: (at connecting if check again) one below "..minetest.pos_to_string(next).." is not a rail either, returning!") + print("[advtrains]in conway: (at connecting if check again) one below "..minetest.pos_to_string(next).." is not a rail either, returning!") return nil end if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely) ) then - --print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." rail not connecting, returning!") - --print("[advtrains] in order mid1,2,next1,2,chkdir "..middir1.." "..middir2.." "..nextdir1.." "..nextdir2.." "..chkdir) + print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." rail not connecting, returning!") + print("[advtrains] in order mid1,2,next1,2,chkdir "..middir1.." "..middir2.." "..nextdir1.." "..nextdir2.." "..chkdir) return nil end end diff --git a/advtrains/advtrains/pseudoload.lua b/advtrains/advtrains/pseudoload.lua index 677cd14..14db58f 100644 --- a/advtrains/advtrains/pseudoload.lua +++ b/advtrains/advtrains/pseudoload.lua @@ -134,11 +134,11 @@ end --nil if the node is neither loaded nor in trackdb --the distraction between false and nil will be needed only in special cases.(train initpos) function advtrains.get_rail_info_at(pos, drives_on) - local node=minetest.get_node_or_nil(pos) + local rdp=advtrains.round_vector_floor_y(pos) + local node=minetest.get_node_or_nil(rdp) if not node then --try raildb - local rdp=vector.round(pos) - local dbe=(advtrains.trackdb[traintype] and advtrains.trackdb[traintype][rdp.y] and advtrains.trackdb[traintype][rdp.y][rdp.x] and advtrains.trackdb[traintype][rdp.y][rdp.x][rdp.z]) + local dbe=(advtrains.trackdb[rdp.y] and advtrains.trackdb[rdp.y][rdp.x] and advtrains.trackdb[rdp.y][rdp.x][rdp.z]) if dbe then for tt,_ in pairs(drives_on) do if not dbe.tracktype or tt==dbe.tracktype then @@ -156,7 +156,6 @@ function advtrains.get_rail_info_at(pos, drives_on) local conn1, conn2, rely1, rely2, railheight, tracktype=advtrains.get_track_connections(node.name, node.param2) --already in trackdb? - local rdp=vector.round(pos) if not (advtrains.trackdb and advtrains.trackdb[rdp.y] and advtrains.trackdb[rdp.y][rdp.x] and advtrains.trackdb[rdp.y][rdp.x][rdp.z]) then--TODO is this necessary? if not advtrains.trackdb then advtrains.trackdb={} end if not advtrains.trackdb[rdp.y] then advtrains.trackdb[rdp.y]={} end @@ -171,7 +170,7 @@ function advtrains.get_rail_info_at(pos, drives_on) return true, conn1, conn2, rely1, rely2, railheight end function advtrains.reset_trackdb_position(pos) - local rdp=vector.round(pos) + local rdp=advtrains.round_vector_floor_y(pos) if not advtrains.trackdb then advtrains.trackdb={} end if not advtrains.trackdb[rdp.y] then advtrains.trackdb[rdp.y]={} end if not advtrains.trackdb[rdp.y][rdp.x] then advtrains.trackdb[rdp.y][rdp.x]={} end diff --git a/advtrains/advtrains/tracks.lua b/advtrains/advtrains/tracks.lua index beb0bbc..c20be70 100644 --- a/advtrains/advtrains/tracks.lua +++ b/advtrains/advtrains/tracks.lua @@ -375,7 +375,14 @@ function advtrains.get_track_connections(name, param2) if not param2 then noderot=0 end if noderot > 3 then print("[advtrains] get_track_connections: rail has invaild param2 of "..noderot) noderot=0 end - return (nodedef.connect1 + 4 * noderot)%16, (nodedef.connect2 + 4 * noderot)%16, nodedef.rely1 or 0, nodedef.rely2 or 0, nodedef.railheight or 0 + local tracktype + for k,_ in pairs(nodedef.groups) do + local tt=string.match(k, "^advtrains_track_(.+)$") + if tt then + tracktype=tt + end + end + return (nodedef.connect1 + 4 * noderot)%16, (nodedef.connect2 + 4 * noderot)%16, nodedef.rely1 or 0, nodedef.rely2 or 0, nodedef.railheight or 0, tracktype end --detector code diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua index eb45500..0ad7874 100644 --- a/advtrains/advtrains/trainlogic.lua +++ b/advtrains/advtrains/trainlogic.lua @@ -36,7 +36,7 @@ advtrains.train_brake_force=3--per second, not divided by number of wagons advtrains.train_roll_force=0.5--per second, not divided by number of wagons, acceleration when rolling without brake advtrains.train_emerg_force=10--for emergency brakes(when going off track) -advtrains.audit_interval=30 +advtrains.audit_interval=10 advtrains.trains={} @@ -70,7 +70,7 @@ end advtrains.save = function() - --print("[advtrains]saving") + print("[advtrains]saving") advtrains.invalidate_all_paths() local datastr = minetest.serialize(advtrains.trains) if not datastr then @@ -261,14 +261,18 @@ function advtrains.train_step(id, train, dtime) local testpos=vector.add(rcollpos, {x=x, y=0, z=z}) local testpts=minetest.pos_to_string(testpos) if advtrains.detector.on_node[testpts] and advtrains.detector.on_node[testpts]~=id then - --collides - advtrains.spawn_couple_on_collide(id, testpos, advtrains.detector.on_node[testpts], train.movedir==-1) - - train.recently_collided_with_env=true - train.velocity=0.5*train.velocity - train.movedir=train.movedir*-1 - train.tarvelocity=0 - + if advtrains.trains[advtrains.detector.on_node[testpts]] then + --collides + advtrains.spawn_couple_on_collide(id, testpos, advtrains.detector.on_node[testpts], train.movedir==-1) + + train.recently_collided_with_env=true + train.velocity=0.5*train.velocity + train.movedir=train.movedir*-1 + train.tarvelocity=0 + else + --unexistant train left in this place + advtrains.detector.on_node[testpts]=nil + end end end end @@ -422,6 +426,7 @@ function advtrains.pathpredict(id, train) if node_ok==nil then --block not loaded, do nothing + print("[advtrains]last_pos not available") return nil elseif node_ok==false then print("[advtrains]no track here, (fail) removing train.") @@ -440,6 +445,7 @@ function advtrains.pathpredict(id, train) if prevnode_ok==nil then --block not loaded, do nothing + print("[advtrains]prev not available") return nil elseif prevnode_ok==false then print("[advtrains]no track at prev, (fail) removing train.") @@ -468,7 +474,7 @@ function advtrains.pathpredict(id, train) end - local maxn=advtrains.maxN(train.path) + local maxn=train.max_index_on_track or 0 while (maxn-train.index) < pregen_front do--pregenerate --print("[advtrains]maxn conway for ",maxn,minetest.pos_to_string(path[maxn]),maxn-1,minetest.pos_to_string(path[maxn-1])) local conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.drives_on) @@ -478,14 +484,14 @@ function advtrains.pathpredict(id, train) else --do as if nothing has happened and preceed with path --but do not update max_index_on_track - --print("over-generating path max to index "..maxn+1) + print("over-generating path max to index "..(maxn+1).." (position "..minetest.pos_to_string(train.path[maxn]).." )") train.path[maxn+1]=vector.add(train.path[maxn], vector.subtract(train.path[maxn], train.path[maxn-1])) end train.path_dist[maxn]=vector.distance(train.path[maxn+1], train.path[maxn]) maxn=advtrains.maxN(train.path) end - local minn=advtrains.minN(train.path) + local minn=train.min_index_on_track or 0 while (train.index-minn) < (train.trainlen or 0) + pregen_back do --post_generate. has to be at least trainlen. (we let go of the exact calculation here since this would be unuseful here) --print("[advtrains]minn conway for ",minn,minetest.pos_to_string(path[minn]),minn+1,minetest.pos_to_string(path[minn+1])) local conway=advtrains.conway(train.path[minn], train.path[minn+1], train.drives_on) @@ -495,7 +501,7 @@ function advtrains.pathpredict(id, train) else --do as if nothing has happened and preceed with path --but do not update min_index_on_track - --print("over-generating path min to index "..minn-1) + print("over-generating path min to index "..(minn-1).." (position "..minetest.pos_to_string(train.path[minn]).." )") train.path[minn-1]=vector.add(train.path[minn], vector.subtract(train.path[minn], train.path[minn+1])) end train.path_dist[minn-1]=vector.distance(train.path[minn], train.path[minn-1]) @@ -509,12 +515,12 @@ function advtrains.pathpredict(id, train) train.savedpos_off_track_index_offset=train.index-train.max_index_on_track train.last_pos=train.path[train.max_index_on_track] train.last_pos_prev=train.path[train.max_index_on_track-1] - --print("train is off-track (front), last positions kept at "..minetest.pos_to_string(train.last_pos).." / "..minetest.pos_to_string(train.last_pos_prev)) + print("train is off-track (front), last positions kept at "..minetest.pos_to_string(train.last_pos).." / "..minetest.pos_to_string(train.last_pos_prev)) elseif train.min_index_on_track+1>train.index then --whoops, train went even more far. same behavior train.savedpos_off_track_index_offset=train.index-train.min_index_on_track train.last_pos=train.path[train.min_index_on_track+1] train.last_pos_prev=train.path[train.min_index_on_track] - --print("train is off-track (back), last positions kept at "..minetest.pos_to_string(train.last_pos).." / "..minetest.pos_to_string(train.last_pos_prev)) + print("train is off-track (back), last positions kept at "..minetest.pos_to_string(train.last_pos).." / "..minetest.pos_to_string(train.last_pos_prev)) else --regular case train.savedpos_off_track_index_offset=nil train.last_pos=train.path[math.floor(train.index+0.5)] @@ -547,7 +553,7 @@ end function advtrains.update_trainpart_properties(train_id, invert_flipstate) local train=advtrains.trains[train_id] train.drives_on=advtrains.all_tracktypes - train.max_speed=100 + train.max_speed=20 local rel_pos=0 local count_l=0 for i, w_id in ipairs(train.trainparts) do @@ -680,6 +686,8 @@ function advtrains.spawn_couple_on_collide(id1, pos, id2, t1_is_backpos) local train1=advtrains.trains[id1] local train2=advtrains.trains[id2] + if not train1 or not train2 then return end + local found for i=advtrains.minN(train1.path), advtrains.maxN(train1.path) do if vector.equals(train1.path[i], pos) then @@ -696,9 +704,9 @@ function advtrains.spawn_couple_on_collide(id1, pos, id2, t1_is_backpos) local t2_is_backpos print("End positions: "..minetest.pos_to_string(frontpos2)..minetest.pos_to_string(backpos2)) - if vector.equals(frontpos2, pos) then + if vector.distance(frontpos2, pos)<2 then t2_is_backpos=false - elseif vector.equals(backpos2, pos) then + elseif vector.distance(backpos2, pos)<2 then t2_is_backpos=true else print("Err: not a endpos") -- cgit v1.2.3 From dd4e98963975f1d5008d14734fb0df92d66c088f Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 4 Jan 2017 21:25:32 +0100 Subject: update makefile to new circumstances --- Makefile | 4 ++++ advtrains.zip | Bin 0 -> 4438013 bytes advtrains/Makefile | 5 ----- 3 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 Makefile create mode 100644 advtrains.zip delete mode 100644 advtrains/Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3f6193d --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +tarball: clean + which zip && zip -r advtrains.zip advtrains +clean: + rm -f advtrains.zip diff --git a/advtrains.zip b/advtrains.zip new file mode 100644 index 0000000..91b52ba Binary files /dev/null and b/advtrains.zip differ diff --git a/advtrains/Makefile b/advtrains/Makefile deleted file mode 100644 index 7300426..0000000 --- a/advtrains/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -tarball: clean -# tar czf advtrains.tar.gz textures/*.png models/*.b3d *.lua *.txt - which zip && zip advtrains.zip textures/*.png models/*.b3d *.lua *.txt -clean: - rm -f advtrains.zip advtrains.tar.gz -- cgit v1.2.3 From bf68c6f0d5d20cfb6daeff0709e2a7ffb12116d9 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 4 Jan 2017 21:34:18 +0100 Subject: Purge all debug messages and change 'print' function name to 'atprint' Ready for 2.0 release. --- advtrains.zip | Bin 4438013 -> 4437952 bytes advtrains/advtrains/atc.lua | 26 +++++------ advtrains/advtrains/couple.lua | 6 +-- advtrains/advtrains/helpers.lua | 41 ++++++++-------- advtrains/advtrains/init.lua | 3 +- advtrains/advtrains/pseudoload.lua | 12 ++--- advtrains/advtrains/trackplacer.lua | 6 +-- advtrains/advtrains/tracks.lua | 24 +++++----- advtrains/advtrains/trainlogic.lua | 90 ++++++++++++++++++------------------ advtrains/advtrains/wagons.lua | 32 ++++++------- 10 files changed, 118 insertions(+), 122 deletions(-) diff --git a/advtrains.zip b/advtrains.zip index 91b52ba..b934318 100644 Binary files a/advtrains.zip and b/advtrains.zip differ diff --git a/advtrains/advtrains/atc.lua b/advtrains/advtrains/atc.lua index f070b20..1b7ba5a 100644 --- a/advtrains/advtrains/atc.lua +++ b/advtrains/advtrains/atc.lua @@ -10,7 +10,7 @@ advtrains.fpath_atc=minetest.get_worldpath().."/advtrains_atc" local file, err = io.open(advtrains.fpath_atc, "r") if not file then local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains atc save file "..er) + atprint("[advtrains]Failed loading advtrains atc save file "..er) else local tbl = minetest.deserialize(file:read("*a")) if type(tbl) == "table" then @@ -44,11 +44,11 @@ end function atc.send_command(pos) local pts=minetest.pos_to_string(pos) if atc.controllers[pts] then - print("Called send_command at "..pts) + atprint("Called send_command at "..pts) local train_id = advtrains.detector.on_node[pts] if train_id then if advtrains.trains[train_id] then - print("send_command inside if: "..sid(train_id)) + atprint("send_command inside if: "..sid(train_id)) atc.train_reset_command(train_id) local arrowconn=atc.controllers[pts].arrowconn local train=advtrains.trains[train_id] @@ -60,7 +60,7 @@ function atc.send_command(pos) advtrains.round_vector_floor_y(train.path[index+train.movedir]) ) advtrains.trains[train_id].atc_command=atc.controllers[pts].command - print("Sending ATC Command: "..atc.controllers[pts].command) + atprint("Sending ATC Command: "..atc.controllers[pts].command) end end end @@ -190,7 +190,7 @@ local matchptn={ train.movedir=train.movedir*-1 train.atc_arrow = not train.atc_arrow else - print("ATC Reverse command warning: didn't reverse train!") + atprint("ATC Reverse command warning: didn't reverse train!") end return 1 end, @@ -235,15 +235,15 @@ function atc.execute_atc_command(id, train) end end if is_cond then - print("Evaluating if statement: "..command) - print("Cond: "..(cond or "nil")) - print("Applies: "..(cond_applies and "true" or "false")) - print("Rest: "..rest) + atprint("Evaluating if statement: "..command) + atprint("Cond: "..(cond or "nil")) + atprint("Applies: "..(cond_applies and "true" or "false")) + atprint("Rest: "..rest) --find end of conditional statement local nest, pos, elsepos=0, 1 while nest>=0 do if pos>#rest then - print("ATC command syntax error: I statement not closed: "..command) + minetest.chat_send_all("ATC command syntax error: I statement not closed: "..command) atc.train_reset_command(id) return end @@ -265,7 +265,7 @@ function atc.execute_atc_command(id, train) else command=string.sub(rest, elsepos+1, pos-2)..string.sub(rest, pos) end - print("Result: "..command) + atprint("Result: "..command) train.atc_command=command atc.execute_atc_command(id, train) return @@ -275,7 +275,7 @@ function atc.execute_atc_command(id, train) if match then local patlen=func(id, train, match) - print("Executing: "..string.sub(command, 1, patlen)) + atprint("Executing: "..string.sub(command, 1, patlen)) train.atc_command=string.sub(command, patlen+1) if train.atc_delay<=0 and not train.atc_wait_finish then @@ -286,7 +286,7 @@ function atc.execute_atc_command(id, train) end end end - print("ATC command parse error: "..command) + minetest.chat_send_all("ATC command parse error: "..command) atc.train_reset_command(id) end diff --git a/advtrains/advtrains/couple.lua b/advtrains/advtrains/couple.lua index 974f450..c0dea84 100644 --- a/advtrains/advtrains/couple.lua +++ b/advtrains/advtrains/couple.lua @@ -69,7 +69,7 @@ minetest.register_entity("advtrains:discouple", { self.object:setvelocity(velocityvec) self.updatepct_timer=2 end - printbm("discouple_step", t) + atprintbm("discouple_step", t) end, }) @@ -122,7 +122,7 @@ minetest.register_entity("advtrains:couple", { end, on_step=function(self, dtime) local t=os.clock() - if not self.train_id_1 or not self.train_id_2 then print("wtf no train ids?")return end + if not self.train_id_1 or not self.train_id_2 then atprint("wtf no train ids?")return end local train1=advtrains.trains[self.train_id_1] local train2=advtrains.trains[self.train_id_2] if not train1 or not train2 or not train1.path or not train2.path or not train1.index or not train2.index then @@ -151,6 +151,6 @@ minetest.register_entity("advtrains:couple", { self.object:setpos(pos_median) end end - printbm("couple step", t) + atprintbm("couple step", t) end, }) diff --git a/advtrains/advtrains/helpers.lua b/advtrains/advtrains/helpers.lua index 7ee7e71..e29eaa5 100644 --- a/advtrains/advtrains/helpers.lua +++ b/advtrains/advtrains/helpers.lua @@ -1,5 +1,4 @@ --advtrains by orwell96, see readme.txt -local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end advtrains.dir_trans_tbl={ [0]={x=0, z=1}, @@ -65,19 +64,19 @@ function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return local next, chkdir, chkrely, y_offset y_offset=0 - --print("[advtrains] in order mid1,mid2",middir1,middir2) + --atprint("[advtrains] in order mid1,mid2",middir1,middir2) --try if it is dir1 local cor1=advtrains.dirCoordSet(mid, middir2)--<<<< if cor1.x==prev.x and cor1.z==prev.z then--this was previous next=advtrains.dirCoordSet(mid, middir1) if midrely1>=1 then next.y=next.y+1 - --print("[advtrains]found midrely1 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) + --atprint("[advtrains]found midrely1 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) y_offset=1 end chkdir=middir1 chkrely=midrely1 - --print("[advtrains]dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") + --atprint("[advtrains]dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") end --dir2??? local cor2=advtrains.dirCoordSet(mid, middir1)--<<<< @@ -85,17 +84,17 @@ function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return next=advtrains.dirCoordSet(mid, middir2)--dir2 wird überprüft, alles gut. if midrely2>=1 then next.y=next.y+1 - --print("[advtrains]found midrely2 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) + --atprint("[advtrains]found midrely2 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) y_offset=1 end chkdir=middir2 chkrely=midrely2 - --print("[advtrains] dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") + --atprint("[advtrains] dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") end - --print("[advtrains]dir applied next pos: "..(next and minetest.pos_to_string(next) or "nil").."(chkdir is "..(chkdir or "nil")..", y-offset "..y_offset..")") + --atprint("[advtrains]dir applied next pos: "..(next and minetest.pos_to_string(next) or "nil").."(chkdir is "..(chkdir or "nil")..", y-offset "..y_offset..")") --is there a next if not next then - print("[advtrains]in conway: no next rail(nil), returning!") + atprint("[advtrains]in conway: no next rail(nil), returning!") return nil end @@ -103,36 +102,36 @@ function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return --is it a rail? if(not nextnode_ok) then - print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not a rail, trying one node below!") + atprint("[advtrains]in conway: next "..minetest.pos_to_string(next).." not a rail, trying one node below!") next.y=next.y-1 y_offset=y_offset-1 nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) if(not nextnode_ok) then - print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!") + atprint("[advtrains]in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!") return nil end end --is this next rail connecting to the mid? if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely-y_offset) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely-y_offset) ) then - print("[advtrains]in conway: next "..minetest.pos_to_string(next).." not connecting, trying one node below!") + atprint("[advtrains]in conway: next "..minetest.pos_to_string(next).." not connecting, trying one node below!") next.y=next.y-1 y_offset=y_offset-1 nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) if(not nextnode_ok) then - print("[advtrains]in conway: (at connecting if check again) one below "..minetest.pos_to_string(next).." is not a rail either, returning!") + atprint("[advtrains]in conway: (at connecting if check again) one below "..minetest.pos_to_string(next).." is not a rail either, returning!") return nil end if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely) ) then - print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." rail not connecting, returning!") - print("[advtrains] in order mid1,2,next1,2,chkdir "..middir1.." "..middir2.." "..nextdir1.." "..nextdir2.." "..chkdir) + atprint("[advtrains]in conway: one below "..minetest.pos_to_string(next).." rail not connecting, returning!") + atprint("[advtrains] in order mid1,2,next1,2,chkdir "..middir1.." "..middir2.." "..nextdir1.." "..nextdir2.." "..chkdir) return nil end end - --print("[advtrains]conway found rail.") + --atprint("[advtrains]conway found rail.") return vector.add(advtrains.round_vector_floor_y(next), {x=0, y=nextrailheight, z=0}), chkdir end --TODO use this @@ -172,10 +171,10 @@ function advtrains.minAngleDiffRad(r1, r2) end end function advtrains.dumppath(path) - if not path then print("dumppath: no path(nil)") return end + if not path then atprint("dumppath: no path(nil)") return end local min=advtrains.minN(path) local max=advtrains.maxN(path) - for i=min, max do print("["..i.."] "..(path[i] and minetest.pos_to_string(path[i]) or "nil")) end + for i=min, max do atprint("["..i.."] "..(path[i] and minetest.pos_to_string(path[i]) or "nil")) end end function advtrains.merge_tables(a, ...) @@ -187,18 +186,18 @@ function advtrains.merge_tables(a, ...) end function advtrains.yaw_from_3_positions(prev, curr, next) local pts=minetest.pos_to_string - --print("p3 "..pts(prev)..pts(curr)..pts(next)) + --atprint("p3 "..pts(prev)..pts(curr)..pts(next)) local prev2curr=math.atan2((curr.x-prev.x), (prev.z-curr.z)) local curr2next=math.atan2((next.x-curr.x), (curr.z-next.z)) - --print("y3 "..(prev2curr*360/(2*math.pi)).." "..(curr2next*360/(2*math.pi))) + --atprint("y3 "..(prev2curr*360/(2*math.pi)).." "..(curr2next*360/(2*math.pi))) return prev2curr+(advtrains.minAngleDiffRad(prev2curr, curr2next)/2) end function advtrains.get_wagon_yaw(front, first, second, back, pct) local pts=minetest.pos_to_string - --print("p "..pts(front)..pts(first)..pts(second)..pts(back)) + --atprint("p "..pts(front)..pts(first)..pts(second)..pts(back)) local y2=advtrains.yaw_from_3_positions(second, first, front) local y1=advtrains.yaw_from_3_positions(back, second, first) - --print("y "..(y1*360/(2*math.pi)).." "..(y2*360/(2*math.pi))) + --atprint("y "..(y1*360/(2*math.pi)).." "..(y2*360/(2*math.pi))) return y1+advtrains.minAngleDiffRad(y1, y2)*pct end function advtrains.get_real_index_position(path, index) diff --git a/advtrains/advtrains/init.lua b/advtrains/advtrains/init.lua index 33aa962..ce3cc9f 100644 --- a/advtrains/advtrains/init.lua +++ b/advtrains/advtrains/init.lua @@ -4,7 +4,8 @@ advtrains={} advtrains.modpath = minetest.get_modpath("advtrains") -print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end +atprint=function() end +--atprint=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end sid=function(id) return string.sub(id, -4) end dofile(advtrains.modpath.."/helpers.lua"); diff --git a/advtrains/advtrains/pseudoload.lua b/advtrains/advtrains/pseudoload.lua index 14db58f..0636d2e 100644 --- a/advtrains/advtrains/pseudoload.lua +++ b/advtrains/advtrains/pseudoload.lua @@ -1,5 +1,3 @@ -local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end - --pseudoload.lua --responsible for keeping up a database of all rail nodes existant in the world, regardless of whether the mapchunk is loaded. @@ -22,7 +20,7 @@ for tt, _ in pairs(advtrains.all_traintypes) do local file, err = io.open(pl_fpath, "r") if not file then local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains trackdb save file "..er) + atprint("[advtrains]Failed loading advtrains trackdb save file "..er) else --custom format to save memory while true do @@ -30,7 +28,7 @@ for tt, _ in pairs(advtrains.all_traintypes) do if not xbytes or #xbytes<2 then break --eof reached end - print(xbytes) + atprint(xbytes) local ybytes=file:read(2) local zbytes=file:read(2) local x=(string.byte(xbytes[1])-128)*256+(string.byte(xbytes[2])) @@ -76,13 +74,13 @@ function advtrains.save_trackdb() local file, err = io.open(pl_fpath, "w") if not file then local er=err or "Unknown Error" - print("[advtrains]Failed saving advtrains trackdb save file "..er) + atprint("[advtrains]Failed saving advtrains trackdb save file "..er) else --custom format to save memory for y,tyl in pairs(advtrains.trackdb[tt]) do for x,txl in pairs(tyl) do for z,rail in pairs(txl) do - print("write "..x.." "..y.." "..z.." "..minetest.serialize(rail)) + atprint("write "..x.." "..y.." "..z.." "..minetest.serialize(rail)) file:write(string.char(math.floor(x/256)+128)..string.char((x%256))) file:write(string.char(math.floor(y/256)+128)..string.char((y%256))) file:write(string.char(math.floor(z/256)+128)..string.char((z%256))) @@ -105,7 +103,7 @@ advtrains.fpath_tdb=minetest.get_worldpath().."/advtrains_trackdb2" local file, err = io.open(advtrains.fpath_tdb, "r") if not file then local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains save file "..er) + atprint("[advtrains]Failed loading advtrains save file "..er) else local tbl = minetest.deserialize(file:read("*a")) if type(tbl) == "table" then diff --git a/advtrains/advtrains/trackplacer.lua b/advtrains/advtrains/trackplacer.lua index b24103a..e40cb59 100644 --- a/advtrains/advtrains/trackplacer.lua +++ b/advtrains/advtrains/trackplacer.lua @@ -233,7 +233,7 @@ minetest.register_craftitem("advtrains:trackworker",{ if advtrains.is_train_at_pos(pos) then return end local nnprefix, suffix, rotation=string.match(node.name, "^(.+)_([^_]+)(_[^_]+)$") - --print(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) + --atprint(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twrotate[suffix] then nnprefix, suffix=string.match(node.name, "^(.+)_([^_]+)$") rotation = "" @@ -274,7 +274,7 @@ minetest.register_craftitem("advtrains:trackworker",{ --if not advtrains.is_track_and_drives_on(minetest.get_node(pos).name, advtrains.all_tracktypes) then return end if advtrains.is_train_at_pos(pos) then return end local nnprefix, suffix, rotation=string.match(node.name, "^(.+)_([^_]+)(_[^_]+)$") - --print(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) + --atprint(node.name.."\npattern recognizes:"..nodeprefix.." / "..railtype.." / "..rotation) if not tp.tracks[nnprefix] or not tp.tracks[nnprefix].twcycle[suffix] then nnprefix, suffix=string.match(node.name, "^(.+)_([^_]+)$") rotation = "" @@ -288,7 +288,7 @@ minetest.register_craftitem("advtrains:trackworker",{ --invalidate trains advtrains.invalidate_all_paths() else - print(name, dump(tp.tracks)) + atprint(name, dump(tp.tracks)) end end, }) diff --git a/advtrains/advtrains/tracks.lua b/advtrains/advtrains/tracks.lua index c20be70..53f5ce7 100644 --- a/advtrains/advtrains/tracks.lua +++ b/advtrains/advtrains/tracks.lua @@ -370,10 +370,10 @@ end function advtrains.get_track_connections(name, param2) local nodedef=minetest.registered_nodes[name] - if not nodedef then print("[advtrains] get_track_connections couldn't find nodedef for nodename "..(name or "nil")) return 0, 8, 0, 0, 0 end + if not nodedef then atprint("[advtrains] get_track_connections couldn't find nodedef for nodename "..(name or "nil")) return 0, 8, 0, 0, 0 end local noderot=param2 if not param2 then noderot=0 end - if noderot > 3 then print("[advtrains] get_track_connections: rail has invaild param2 of "..noderot) noderot=0 end + if noderot > 3 then atprint("[advtrains] get_track_connections: rail has invaild param2 of "..noderot) noderot=0 end local tracktype for k,_ in pairs(nodedef.groups) do @@ -398,10 +398,10 @@ advtrains.detector.clean_step_before = false --The entry already being contained in advtrains.detector.on_node_restore will not trigger an on_train_enter event on the node. (when path is reset, this is saved). function advtrains.detector.enter_node(pos, train_id) local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - --print("enterNode "..pts.." "..sid(train_id)) + --atprint("enterNode "..pts.." "..sid(train_id)) if advtrains.detector.on_node[pts] then if advtrains.trains[advtrains.detector.on_node[pts]] then - --print(""..pts.." already occupied") + --atprint(""..pts.." already occupied") return false else advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) @@ -417,9 +417,9 @@ function advtrains.detector.enter_node(pos, train_id) end function advtrains.detector.leave_node(pos, train_id) local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - --print("leaveNode "..pts.." "..sid(train_id)) + --atprint("leaveNode "..pts.." "..sid(train_id)) if not advtrains.detector.on_node[pts] then - --print(""..pts.." leave: nothing here") + --atprint(""..pts.." leave: nothing here") return false end if advtrains.detector.on_node[pts]==train_id then @@ -427,7 +427,7 @@ function advtrains.detector.leave_node(pos, train_id) advtrains.detector.on_node[pts]=nil else if advtrains.trains[advtrains.detector.on_node[pts]] then - --print(""..pts.." occupied by another train") + --atprint(""..pts.." occupied by another train") return false else advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) @@ -438,21 +438,21 @@ function advtrains.detector.leave_node(pos, train_id) end --called immediately before invalidating paths function advtrains.detector.setup_restore() - --print("setup_restore") + --atprint("setup_restore") advtrains.detector.on_node_restore = advtrains.detector.on_node advtrains.detector.on_node = {} end --called one step after invalidating paths, when all trains have restored their path and called enter_node for their contents. function advtrains.detector.finalize_restore() - --print("finalize_restore") + --atprint("finalize_restore") for pts, train_id in pairs(advtrains.detector.on_node_restore) do - --print("called leave callback "..pts.." "..train_id) + --atprint("called leave callback "..pts.." "..train_id) advtrains.detector.call_leave_callback(minetest.string_to_pos(pts), train_id) end advtrains.detector.on_node_restore = {} end function advtrains.detector.call_enter_callback(pos, train_id) - --print("instructed to call enter calback") + --atprint("instructed to call enter calback") local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case local mregnode=minetest.registered_nodes[node.name] @@ -464,7 +464,7 @@ function advtrains.detector.call_enter_callback(pos, train_id) advtrains.atc.trigger_controller_train_enter(pos, train_id) end function advtrains.detector.call_leave_callback(pos, train_id) - --print("instructed to call leave calback") + --atprint("instructed to call leave calback") local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case local mregnode=minetest.registered_nodes[node.name] diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua index 0ad7874..ac870c0 100644 --- a/advtrains/advtrains/trainlogic.lua +++ b/advtrains/advtrains/trainlogic.lua @@ -7,7 +7,7 @@ local bm={} local bmlt=0 local bmsteps=0 local bmstepint=200 -printbm=function(action, ta) +atprintbm=function(action, ta) if not benchmark then return end local t=(os.clock()-ta)*1000 if not bm[action] then @@ -47,7 +47,7 @@ advtrains.fpath=minetest.get_worldpath().."/advtrains" local file, err = io.open(advtrains.fpath, "r") if not file then local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains save file "..er) + atprint("[advtrains]Failed loading advtrains save file "..er) else local tbl = minetest.deserialize(file:read("*a")) if type(tbl) == "table" then @@ -59,7 +59,7 @@ advtrains.fpath_ws=minetest.get_worldpath().."/advtrains_wagon_save" local file, err = io.open(advtrains.fpath_ws, "r") if not file then local er=err or "Unknown Error" - print("[advtrains]Failed loading advtrains save file "..er) + atprint("[advtrains]Failed loading advtrains save file "..er) else local tbl = minetest.deserialize(file:read("*a")) if type(tbl) == "table" then @@ -70,7 +70,7 @@ end advtrains.save = function() - print("[advtrains]saving") + atprint("[advtrains]saving") advtrains.invalidate_all_paths() local datastr = minetest.serialize(advtrains.trains) if not datastr then @@ -105,7 +105,7 @@ advtrains.save = function() data.discouple=nil end end - --print(dump(advtrains.wagon_save)) + --atprint(dump(advtrains.wagon_save)) datastr = minetest.serialize(advtrains.wagon_save) if not datastr then minetest.log("error", "[advtrains] Failed to serialize train data!") @@ -132,7 +132,7 @@ minetest.register_globalstep(function(dtime) --save advtrains.save() advtrains.save_and_audit_timer=advtrains.audit_interval - printbm("saving", t) + atprintbm("saving", t) end --regular train step local t=os.clock() @@ -145,7 +145,7 @@ minetest.register_globalstep(function(dtime) advtrains.detector.finalize_restore() end - printbm("trainsteps", t) + atprintbm("trainsteps", t) endstep() end) @@ -171,7 +171,7 @@ function advtrains.train_step(id, train, dtime) --if not train.last_pos then advtrains.trains[id]=nil return end if not advtrains.pathpredict(id, train) then - print("pathpredict failed(returned false)") + atprint("pathpredict failed(returned false)") train.velocity=0 train.tarvelocity=0 return @@ -181,7 +181,7 @@ function advtrains.train_step(id, train, dtime) if not path then train.velocity=0 train.tarvelocity=0 - print("train has no path for whatever reason") + atprint("train has no path for whatever reason") return end @@ -236,7 +236,7 @@ function advtrains.train_step(id, train, dtime) --remove? if #train.trainparts==0 then - print("[advtrains][train "..sid(id).."] has empty trainparts, removing.") + atprint("[advtrains][train "..sid(id).."] has empty trainparts, removing.") advtrains.detector.leave_node(path[train.detector_old_index], id) advtrains.trains[id]=nil return @@ -284,7 +284,7 @@ function advtrains.train_step(id, train, dtime) local node_range=(math.max((minetest.setting_get("active_block_range") or 0),1)*16) if train.check_trainpartload<=0 then local ori_pos=advtrains.get_real_index_position(path, train.index) --not much to calculate - --print("[advtrains][train "..id.."] at "..minetest.pos_to_string(vector.round(ori_pos))) + --atprint("[advtrains][train "..id.."] at "..minetest.pos_to_string(vector.round(ori_pos))) local should_check=false for _,p in ipairs(minetest.get_connected_players()) do @@ -335,19 +335,19 @@ function advtrains.train_step(id, train, dtime) local mass=#train.trainparts local diff=train.tarvelocity-train.velocity if diff>0 then--accelerating, force will be brought on only by locomotives. - --print("accelerating with default force") + --atprint("accelerating with default force") applydiff=(math.min((advtrains.train_accel_force*train.locomotives_in_train*dtime)/mass, math.abs(diff))) else--decelerating if front_off_track or back_off_track or train.recently_collided_with_env then --every wagon has a brake, so not divided by mass. - --print("braking with emergency force") + --atprint("braking with emergency force") applydiff= -(math.min((advtrains.train_emerg_force*dtime), math.abs(diff))) elseif train.brake or (train.atc_brake_target and train.atc_brake_targettrain.index then --whoops, train went even more far. same behavior train.savedpos_off_track_index_offset=train.index-train.min_index_on_track train.last_pos=train.path[train.min_index_on_track+1] train.last_pos_prev=train.path[train.min_index_on_track] - print("train is off-track (back), last positions kept at "..minetest.pos_to_string(train.last_pos).." / "..minetest.pos_to_string(train.last_pos_prev)) + atprint("train is off-track (back), last positions kept at "..minetest.pos_to_string(train.last_pos).." / "..minetest.pos_to_string(train.last_pos_prev)) else --regular case train.savedpos_off_track_index_offset=nil train.last_pos=train.path[math.floor(train.index+0.5)] @@ -599,7 +599,7 @@ function advtrains.update_trainpart_properties(train_id, invert_flipstate) end train.max_speed=math.min(train.max_speed, wagon.max_speed) else - print(w_id.." not loaded and no save available") + atprint(w_id.." not loaded and no save available") --what the hell... table.remove(train.trainparts, pit) end @@ -617,23 +617,23 @@ function advtrains.split_train_at_wagon(wagon) --before doing anything, check if both are rails. else do not allow if not pos_for_new_train then - print("split_train: pos_for_new_train not set") + atprint("split_train: pos_for_new_train not set") return false end local node_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.drives_on) if not node_ok then - print("split_train: pos_for_new_train "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") + atprint("split_train: pos_for_new_train "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") return false end if not train.last_pos_prev then - print("split_train: pos_for_new_train_prev not set") + atprint("split_train: pos_for_new_train_prev not set") return false end local prevnode_ok=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(pos_for_new_train), train.drives_on) if not prevnode_ok then - print("split_train: pos_for_new_train_prev "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") + atprint("split_train: pos_for_new_train_prev "..minetest.pos_to_string(advtrains.round_vector_floor_y(pos_for_new_train_prev)).." not loaded or is not a rail") return false end @@ -681,7 +681,7 @@ function advtrains.trains_facing(train1, train2) end function advtrains.spawn_couple_on_collide(id1, pos, id2, t1_is_backpos) - print("COLLISION: "..sid(id1).." and "..sid(id2).." at "..minetest.pos_to_string(pos)..", t1_is_backpos="..(t1_is_backpos and "true" or "false")) + atprint("COLLISION: "..sid(id1).." and "..sid(id2).." at "..minetest.pos_to_string(pos)..", t1_is_backpos="..(t1_is_backpos and "true" or "false")) --TODO: local train1=advtrains.trains[id1] local train2=advtrains.trains[id2] @@ -695,24 +695,24 @@ function advtrains.spawn_couple_on_collide(id1, pos, id2, t1_is_backpos) end end if not found then - print("Err: pos not in path") + atprint("Err: pos not in path") return end local frontpos2=train2.path[math.floor(train2.detector_old_index)] local backpos2=train2.path[math.floor(train2.detector_old_end_index)] local t2_is_backpos - print("End positions: "..minetest.pos_to_string(frontpos2)..minetest.pos_to_string(backpos2)) + atprint("End positions: "..minetest.pos_to_string(frontpos2)..minetest.pos_to_string(backpos2)) if vector.distance(frontpos2, pos)<2 then t2_is_backpos=false elseif vector.distance(backpos2, pos)<2 then t2_is_backpos=true else - print("Err: not a endpos") + atprint("Err: not a endpos") return --the collision position is not the end position. end - print("t2_is_backpos="..(t2_is_backpos and "true" or "false")) + atprint("t2_is_backpos="..(t2_is_backpos and "true" or "false")) local t1_has_couple if t1_is_backpos then @@ -734,7 +734,7 @@ function advtrains.spawn_couple_on_collide(id1, pos, id2, t1_is_backpos) if minetest.object_refs[t2_has_couple] then minetest.object_refs[t2_has_couple]:remove() end end local obj=minetest.add_entity(pos, "advtrains:couple") - if not obj then print("failed creating object") return end + if not obj then atprint("failed creating object") return end local le=obj:get_luaentity() le.train_id_1=id1 le.train_id_2=id2 @@ -755,7 +755,7 @@ function advtrains.spawn_couple_on_collide(id1, pos, id2, t1_is_backpos) end end end - print("Couple entity:"..dump(le)) + atprint("Couple entity:"..dump(le)) --also TODO: integrate check_trainpartload into update_trainpart_properties. end @@ -798,20 +798,20 @@ function advtrains.invert_train(train_id) end function advtrains.is_train_at_pos(pos) - --print("istrainat: pos "..minetest.pos_to_string(pos)) + --atprint("istrainat: pos "..minetest.pos_to_string(pos)) local checked_trains={} local objrefs=minetest.get_objects_inside_radius(pos, 2) for _,v in pairs(objrefs) do local le=v:get_luaentity() if le and le.is_wagon and le.initialized and le.train_id and not checked_trains[le.train_id] then - --print("istrainat: checking "..le.train_id) + --atprint("istrainat: checking "..le.train_id) checked_trains[le.train_id]=true local path=advtrains.get_or_create_path(le.train_id, le:train()) if path then - --print("has path") + --atprint("has path") for i=math.floor(advtrains.get_train_end_index(le:train())+0.5),math.floor(le:train().index+0.5) do if path[i] then - --print("has pathitem "..i.." "..minetest.pos_to_string(path[i])) + --atprint("has pathitem "..i.." "..minetest.pos_to_string(path[i])) if vector.equals(advtrains.round_vector_floor_y(path[i]), pos) then return true end @@ -823,7 +823,7 @@ function advtrains.is_train_at_pos(pos) return false end function advtrains.invalidate_all_paths() - --print("invalidating all paths") + --atprint("invalidating all paths") for k,v in pairs(advtrains.trains) do if v.index then v.restore_add_index=v.index-math.floor(v.index+0.5) diff --git a/advtrains/advtrains/wagons.lua b/advtrains/advtrains/wagons.lua index 495f914..8c3cd0a 100644 --- a/advtrains/advtrains/wagons.lua +++ b/advtrains/advtrains/wagons.lua @@ -1,6 +1,4 @@ --atan2 counts angles clockwise, minetest does counterclockwise ---local print=function(t) minetest.log("action", t) minetest.chat_send_all(t) end -local print=function() end local wagon={ collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, @@ -49,7 +47,7 @@ end wagon will save only uid in staticdata, no serialized table ]] function wagon:on_activate(sd_uid, dtime_s) - print("[advtrains][wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] activated") + atprint("[advtrains][wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] activated") self.object:set_armor_groups({immortal=1}) if sd_uid and sd_uid~="" then --legacy @@ -65,7 +63,7 @@ function wagon:on_activate(sd_uid, dtime_s) --duplicates? for ao_id,wagon in pairs(minetest.luaentities) do if wagon.is_wagon and wagon.initialized and wagon.unique_id==self.unique_id and wagon~=self then--i am a duplicate! - print("[advtrains][wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] duplicate found(ao_id:"..ao_id.."), removing") + atprint("[advtrains][wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] duplicate found(ao_id:"..ao_id.."), removing") self.object:remove() minetest.after(0.5, function() advtrains.update_trainpart_properties(self.train_id) end) return @@ -79,7 +77,7 @@ end function wagon:get_staticdata() if not self:ensure_init() then return end - print("[advtrains][wagon "..((self.unique_id and self.unique_id~="" and self.unique_id) or "no-id").."]: saving to wagon_save") + atprint("[advtrains][wagon "..((self.unique_id and self.unique_id~="" and self.unique_id) or "no-id").."]: saving to wagon_save") --serialize inventory, if it has one if self.has_inventory then local inv=minetest.get_inventory({type="detached", name="advtrains_wgn_"..self.unique_id}) @@ -103,7 +101,7 @@ function wagon:init_new_instance(train_id, properties) end self:init_shared() self.initialized=true - print("init_new_instance "..self.unique_id.." ("..self.train_id..")") + atprint("init_new_instance "..self.unique_id.." ("..self.train_id..")") return self.unique_id end function wagon:init_from_wagon_save(uid) @@ -124,7 +122,7 @@ function wagon:init_from_wagon_save(uid) self:init_shared() self.initialized=true minetest.after(1, function() self:reattach_all() end) - print("init_from_wagon_save "..self.unique_id.." ("..self.train_id..")") + atprint("init_from_wagon_save "..self.unique_id.." ("..self.train_id..")") advtrains.update_trainpart_properties(self.train_id) end function wagon:init_shared() @@ -211,7 +209,7 @@ function wagon:destroy() self.custom_on_destroy(self, puncher, time_from_last_punch, tool_capabilities, direction) end - print("[advtrains][wagon "..((self.unique_id and self.unique_id~="" and self.unique_id) or "no-id").."]: destroying") + atprint("[advtrains][wagon "..((self.unique_id and self.unique_id~="" and self.unique_id) or "no-id").."]: destroying") self.object:remove() @@ -230,7 +228,7 @@ function wagon:on_step(dtime) local pos = self.object:getpos() if not pos then - print("["..self.unique_id.."][fatal] missing position (object:getpos() returned nil)") + atprint("["..self.unique_id.."][fatal] missing position (object:getpos() returned nil)") return end @@ -238,7 +236,7 @@ function wagon:on_step(dtime) --is my train still here if not self.train_id or not self:train() then - print("[advtrains][wagon "..self.unique_id.."] missing train_id, destroying") + atprint("[advtrains][wagon "..self.unique_id.."] missing train_id, destroying") self.object:remove() return elseif not self.initialized then @@ -292,7 +290,7 @@ function wagon:on_step(dtime) --object:set_attach(self.object, "", {x=0, y=0, z=self.wagon_span*10}, {x=0, y=0, z=0}) self.discouple=le else - print("Couldn't spawn DisCouple") + atprint("Couldn't spawn DisCouple") end end else @@ -313,13 +311,13 @@ function wagon:on_step(dtime) end local index=advtrains.get_real_path_index(self:train(), self.pos_in_train) - --print("trainindex "..gp.index.." wagonindex "..index) + --atprint("trainindex "..gp.index.." wagonindex "..index) --position recalculation local first_pos=gp.path[math.floor(index)] local second_pos=gp.path[math.floor(index)+1] if not first_pos or not second_pos then - --print("[advtrains] object "..self.unique_id.." path end reached!") + --atprint("[advtrains] object "..self.unique_id.." path end reached!") self.object:setvelocity({x=0,y=0,z=0}) return end @@ -387,7 +385,7 @@ function wagon:on_step(dtime) self.old_velocity_vector=velocityvec self.old_acceleration_vector=accelerationvec self.old_yaw=yaw - printbm("wagon step", t) + atprintbm("wagon step", t) end function advtrains.get_real_path_index(train, pit) @@ -535,10 +533,10 @@ function advtrains.register_wagon(sysname, prototype, desc, inv_img) end local node=minetest.env:get_node_or_nil(pointed_thing.under) - if not node then print("[advtrains]Ignore at placer position") return itemstack end + if not node then atprint("[advtrains]Ignore at placer position") return itemstack end local nodename=node.name if(not advtrains.is_track_and_drives_on(nodename, prototype.drives_on)) then - print("[advtrains]no track here, not placing.") + atprint("[advtrains]no track here, not placing.") return itemstack end local conn1=advtrains.get_track_connections(node.name, node.param2) @@ -546,7 +544,7 @@ function advtrains.register_wagon(sysname, prototype, desc, inv_img) local ob=minetest.env:add_entity(pointed_thing.under, "advtrains:"..sysname) if not ob then - print("[advtrains]couldn't add_entity, aborting") + atprint("[advtrains]couldn't add_entity, aborting") end local le=ob:get_luaentity() -- cgit v1.2.3 From c0957b8a31df8484436e204b14b5d6d0d08a2eaa Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 4 Jan 2017 21:49:16 +0100 Subject: also print ATC reverse command warning and move atc_command.txt at a better place --- advtrains.zip | Bin 4437952 -> 4437929 bytes advtrains/advtrains/atc.lua | 2 +- advtrains/advtrains/atc_command.txt | 68 ------------------------------------ advtrains/atc_command.txt | 68 ++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 69 deletions(-) delete mode 100644 advtrains/advtrains/atc_command.txt create mode 100644 advtrains/atc_command.txt diff --git a/advtrains.zip b/advtrains.zip index b934318..0230ca8 100644 Binary files a/advtrains.zip and b/advtrains.zip differ diff --git a/advtrains/advtrains/atc.lua b/advtrains/advtrains/atc.lua index 1b7ba5a..2bc07be 100644 --- a/advtrains/advtrains/atc.lua +++ b/advtrains/advtrains/atc.lua @@ -190,7 +190,7 @@ local matchptn={ train.movedir=train.movedir*-1 train.atc_arrow = not train.atc_arrow else - atprint("ATC Reverse command warning: didn't reverse train!") + minetest.chat_send_all("ATC Reverse command warning: didn't reverse train!") end return 1 end, diff --git a/advtrains/advtrains/atc_command.txt b/advtrains/advtrains/atc_command.txt deleted file mode 100644 index fa846e3..0000000 --- a/advtrains/advtrains/atc_command.txt +++ /dev/null @@ -1,68 +0,0 @@ -ATC Command Syntax - -A train runs the current ATC command once it receives it, including delayed instructions. If the train receives a new command, the current command is discarded. -Spaces can be inserted into commands as needed and are ignored. - -# simple commands: - -S<[0-9]+ speed or 'M'> -Set target speed of train to . Accelerates if slower, rolls if faster. 'M' means maximum speed. -Execution of command continues immediately. - -B<[0-9]+ speed> -Brake until speed is reached. If faster, apply brakes, if slower, do nothing. -Execution of command continues immediately. - -Examples: -SM : accelerate to maximum speed -S0 : roll to stand -B0 : brake to stand -S0B3 or B3S0: brake to 3, then roll to stand. - -W -Wait until S and/or B commands reached the desired speed before continuing execution. - -D<[0-9]+ time> -Delay: Wait for time seconds before continuing execution. - -R -Reverse: change movement direction of train. ONLY WORKS WHEN TRAIN STANDS, else no-op. -Use B0WR to definitely change direction. - -Examples: -B0 W R D10 SM -Subway train stopping in dead end station and returning in opposite direction - -# conditional statements: - -I; -Execute code only if condition applies -IE; -Execute code1 only if condition applies, else execute code2 - -Conditions: -+ / - -Tests the train's movement direction against the arrow on the ATC rail: M+ is true when train drives in direction of arrow. - -[/<=/>=][speed] -Test if train's speed is greater or smaller than the given value - -Examples: -I- B0 W R ; S8 -If the train drives in the 'wrong' direction, stop and reverse; independently accelerate to speed 8 afterwards. - -I<8 S8 ; -If the train is slower than 8, accelerate to 8. - -# ATC controller operation modes -static: Only give 1 static command. -mesecon: Give 2 different commands depending on if the controller is mesecon-powered or not -digiline: Don't give any commands by itself. When a train passes, a digiline message in the form of "[+/-][speed]" is sent on the set channel (where +/- means the same as with conditions). Any digiline message sent to the controller will be interpreted as ATC command and sent to the train. - -# Persistence -ATC controllers that are configured as 'static' or 'mesecon' are persistent over mapblock unloads and will even command the train when the mapblock is unloaded. This is not possible with digilines since these do not work in unloaded mapchunks. - -# LUA ATC controller (in development) -The LUA ATC Controller will operate by using LUA code. All operations shown above will have a function equivalent. Additionally all LUA ATC controllers share an environment and setting signal and switch status will be possible to allow for complicated railway systems/fully automated subways a.s.o. -Also planned: -- digicompute add-on to allow computer access to the ATC environment (railway maps... ... ... ... ...) diff --git a/advtrains/atc_command.txt b/advtrains/atc_command.txt new file mode 100644 index 0000000..fa846e3 --- /dev/null +++ b/advtrains/atc_command.txt @@ -0,0 +1,68 @@ +ATC Command Syntax + +A train runs the current ATC command once it receives it, including delayed instructions. If the train receives a new command, the current command is discarded. +Spaces can be inserted into commands as needed and are ignored. + +# simple commands: + +S<[0-9]+ speed or 'M'> +Set target speed of train to . Accelerates if slower, rolls if faster. 'M' means maximum speed. +Execution of command continues immediately. + +B<[0-9]+ speed> +Brake until speed is reached. If faster, apply brakes, if slower, do nothing. +Execution of command continues immediately. + +Examples: +SM : accelerate to maximum speed +S0 : roll to stand +B0 : brake to stand +S0B3 or B3S0: brake to 3, then roll to stand. + +W +Wait until S and/or B commands reached the desired speed before continuing execution. + +D<[0-9]+ time> +Delay: Wait for time seconds before continuing execution. + +R +Reverse: change movement direction of train. ONLY WORKS WHEN TRAIN STANDS, else no-op. +Use B0WR to definitely change direction. + +Examples: +B0 W R D10 SM +Subway train stopping in dead end station and returning in opposite direction + +# conditional statements: + +I; +Execute code only if condition applies +IE; +Execute code1 only if condition applies, else execute code2 + +Conditions: ++ / - +Tests the train's movement direction against the arrow on the ATC rail: M+ is true when train drives in direction of arrow. + +[/<=/>=][speed] +Test if train's speed is greater or smaller than the given value + +Examples: +I- B0 W R ; S8 +If the train drives in the 'wrong' direction, stop and reverse; independently accelerate to speed 8 afterwards. + +I<8 S8 ; +If the train is slower than 8, accelerate to 8. + +# ATC controller operation modes +static: Only give 1 static command. +mesecon: Give 2 different commands depending on if the controller is mesecon-powered or not +digiline: Don't give any commands by itself. When a train passes, a digiline message in the form of "[+/-][speed]" is sent on the set channel (where +/- means the same as with conditions). Any digiline message sent to the controller will be interpreted as ATC command and sent to the train. + +# Persistence +ATC controllers that are configured as 'static' or 'mesecon' are persistent over mapblock unloads and will even command the train when the mapblock is unloaded. This is not possible with digilines since these do not work in unloaded mapchunks. + +# LUA ATC controller (in development) +The LUA ATC Controller will operate by using LUA code. All operations shown above will have a function equivalent. Additionally all LUA ATC controllers share an environment and setting signal and switch status will be possible to allow for complicated railway systems/fully automated subways a.s.o. +Also planned: +- digicompute add-on to allow computer access to the ATC environment (railway maps... ... ... ... ...) -- cgit v1.2.3 From 9bc069f825daded364b2b52d443c8cb7b45a5a15 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Fri, 6 Jan 2017 17:54:16 +0100 Subject: Add fancy passenger wagon --- advtrains/advtrains_train_steam/init.lua | 25 ++++++++++++++++----- .../models/advtrains_passenger_wagon.b3d | Bin 0 -> 341965 bytes .../textures/advtrains_wagon.png | Bin 35724 -> 42023 bytes assets/wagonfancytexture.png | Bin 0 -> 42023 bytes assets/wagong_fancy.blend | Bin 0 -> 1044484 bytes assets/wagong_fancy.blend1 | Bin 0 -> 1044524 bytes 6 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 advtrains/advtrains_train_steam/models/advtrains_passenger_wagon.b3d create mode 100644 assets/wagonfancytexture.png create mode 100644 assets/wagong_fancy.blend create mode 100644 assets/wagong_fancy.blend1 diff --git a/advtrains/advtrains_train_steam/init.lua b/advtrains/advtrains_train_steam/init.lua index ca52516..5010902 100644 --- a/advtrains/advtrains_train_steam/init.lua +++ b/advtrains/advtrains_train_steam/init.lua @@ -57,19 +57,34 @@ advtrains.register_wagon("newlocomotive", { drops={"default:steelblock 4"}, }, "Steam Engine", "advtrains_newlocomotive_inv.png") advtrains.register_wagon("wagon_default", { - mesh="advtrains_wagon.b3d", + mesh="advtrains_passenger_wagon.b3d", textures = {"advtrains_wagon.png"}, drives_on={default=true}, max_speed=10, seats = { { - name="Default Seat", - attach_offset={x=0, y=10, z=0}, - view_offset={x=0, y=6, z=0}, + name="1", + attach_offset={x=-4, y=8, z=8}, + view_offset={x=0, y=0, z=0}, + }, + { + name="2", + attach_offset={x=4, y=8, z=8}, + view_offset={x=0, y=0, z=0}, + }, + { + name="3", + attach_offset={x=-4, y=8, z=-8}, + view_offset={x=0, y=0, z=0}, + }, + { + name="4", + attach_offset={x=4, y=8, z=-8}, + view_offset={x=0, y=0, z=0}, }, }, visual_size = {x=1, y=1}, - wagon_span=1.8, + wagon_span=3.1, collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, drops={"default:steelblock 4"}, }, "Passenger Wagon", "advtrains_wagon_inv.png") diff --git a/advtrains/advtrains_train_steam/models/advtrains_passenger_wagon.b3d b/advtrains/advtrains_train_steam/models/advtrains_passenger_wagon.b3d new file mode 100644 index 0000000..bb057f8 Binary files /dev/null and b/advtrains/advtrains_train_steam/models/advtrains_passenger_wagon.b3d differ diff --git a/advtrains/advtrains_train_steam/textures/advtrains_wagon.png b/advtrains/advtrains_train_steam/textures/advtrains_wagon.png index c37c979..c850518 100644 Binary files a/advtrains/advtrains_train_steam/textures/advtrains_wagon.png and b/advtrains/advtrains_train_steam/textures/advtrains_wagon.png differ diff --git a/assets/wagonfancytexture.png b/assets/wagonfancytexture.png new file mode 100644 index 0000000..c850518 Binary files /dev/null and b/assets/wagonfancytexture.png differ diff --git a/assets/wagong_fancy.blend b/assets/wagong_fancy.blend new file mode 100644 index 0000000..f9e44d5 Binary files /dev/null and b/assets/wagong_fancy.blend differ diff --git a/assets/wagong_fancy.blend1 b/assets/wagong_fancy.blend1 new file mode 100644 index 0000000..5c6c328 Binary files /dev/null and b/assets/wagong_fancy.blend1 differ -- cgit v1.2.3 From eae99812e95eb74d28a9f7d3ee20f792f7eb8c9e Mon Sep 17 00:00:00 2001 From: orwell96 Date: Fri, 6 Jan 2017 19:10:53 +0100 Subject: update zip --- advtrains.zip | Bin 4437929 -> 4533122 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/advtrains.zip b/advtrains.zip index 0230ca8..028222e 100644 Binary files a/advtrains.zip and b/advtrains.zip differ -- cgit v1.2.3 From 0d2ec6f49a781f4539f934217ec8eb157f6a7796 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Sun, 8 Jan 2017 21:10:02 +0100 Subject: Clean up debug message code --- advtrains/advtrains/atc.lua | 4 ++-- advtrains/advtrains/helpers.lua | 29 +++++++++++++++-------------- advtrains/advtrains/init.lua | 34 ++++++++++++++++++++++++++++++++-- advtrains/advtrains/misc_nodes.lua | 2 +- advtrains/advtrains/pseudoload.lua | 8 ++++---- advtrains/advtrains/tracks.lua | 4 ++-- advtrains/advtrains/trainlogic.lua | 33 +++++++++++++++++---------------- advtrains/advtrains/wagons.lua | 18 +++++++++--------- 8 files changed, 82 insertions(+), 50 deletions(-) diff --git a/advtrains/advtrains/atc.lua b/advtrains/advtrains/atc.lua index 2bc07be..bd02425 100644 --- a/advtrains/advtrains/atc.lua +++ b/advtrains/advtrains/atc.lua @@ -10,7 +10,7 @@ advtrains.fpath_atc=minetest.get_worldpath().."/advtrains_atc" local file, err = io.open(advtrains.fpath_atc, "r") if not file then local er=err or "Unknown Error" - atprint("[advtrains]Failed loading advtrains atc save file "..er) + atprint("Failed loading advtrains atc save file "..er) else local tbl = minetest.deserialize(file:read("*a")) if type(tbl) == "table" then @@ -22,7 +22,7 @@ function atc.save() --leave space for more save data. local datastr = minetest.serialize({controllers = atc.controllers}) if not datastr then - minetest.log("error", "[advtrains] Failed to serialize trackdb data!") + minetest.log("error", " Failed to serialize trackdb data!") return end local file, err = io.open(advtrains.fpath_atc, "w") diff --git a/advtrains/advtrains/helpers.lua b/advtrains/advtrains/helpers.lua index e29eaa5..cc7deb8 100644 --- a/advtrains/advtrains/helpers.lua +++ b/advtrains/advtrains/helpers.lua @@ -64,19 +64,19 @@ function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return local next, chkdir, chkrely, y_offset y_offset=0 - --atprint("[advtrains] in order mid1,mid2",middir1,middir2) + --atprint(" in order mid1,mid2",middir1,middir2) --try if it is dir1 local cor1=advtrains.dirCoordSet(mid, middir2)--<<<< if cor1.x==prev.x and cor1.z==prev.z then--this was previous next=advtrains.dirCoordSet(mid, middir1) if midrely1>=1 then next.y=next.y+1 - --atprint("[advtrains]found midrely1 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) + --atprint("found midrely1 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) y_offset=1 end chkdir=middir1 chkrely=midrely1 - --atprint("[advtrains]dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") + --atprint("dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") end --dir2??? local cor2=advtrains.dirCoordSet(mid, middir1)--<<<< @@ -84,17 +84,17 @@ function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return next=advtrains.dirCoordSet(mid, middir2)--dir2 wird überprüft, alles gut. if midrely2>=1 then next.y=next.y+1 - --atprint("[advtrains]found midrely2 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) + --atprint("found midrely2 to be >=1: next is now "..(next and minetest.pos_to_string(next) or "nil")) y_offset=1 end chkdir=middir2 chkrely=midrely2 - --atprint("[advtrains] dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") + --atprint(" dir2 applied next pos:",minetest.pos_to_string(next),"(chkdir is ",chkdir,")") end - --atprint("[advtrains]dir applied next pos: "..(next and minetest.pos_to_string(next) or "nil").."(chkdir is "..(chkdir or "nil")..", y-offset "..y_offset..")") + --atprint("dir applied next pos: "..(next and minetest.pos_to_string(next) or "nil").."(chkdir is "..(chkdir or "nil")..", y-offset "..y_offset..")") --is there a next if not next then - atprint("[advtrains]in conway: no next rail(nil), returning!") + atprint("in conway: no next rail(nil), returning!") return nil end @@ -102,36 +102,36 @@ function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return --is it a rail? if(not nextnode_ok) then - atprint("[advtrains]in conway: next "..minetest.pos_to_string(next).." not a rail, trying one node below!") + atprint("in conway: next "..minetest.pos_to_string(next).." not a rail, trying one node below!") next.y=next.y-1 y_offset=y_offset-1 nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) if(not nextnode_ok) then - atprint("[advtrains]in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!") + atprint("in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!") return nil end end --is this next rail connecting to the mid? if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely-y_offset) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely-y_offset) ) then - atprint("[advtrains]in conway: next "..minetest.pos_to_string(next).." not connecting, trying one node below!") + atprint("in conway: next "..minetest.pos_to_string(next).." not connecting, trying one node below!") next.y=next.y-1 y_offset=y_offset-1 nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on) if(not nextnode_ok) then - atprint("[advtrains]in conway: (at connecting if check again) one below "..minetest.pos_to_string(next).." is not a rail either, returning!") + atprint("in conway: (at connecting if check again) one below "..minetest.pos_to_string(next).." is not a rail either, returning!") return nil end if not ( (((nextdir1+8)%16)==chkdir and nextrely1==chkrely) or (((nextdir2+8)%16)==chkdir and nextrely2==chkrely) ) then - atprint("[advtrains]in conway: one below "..minetest.pos_to_string(next).." rail not connecting, returning!") - atprint("[advtrains] in order mid1,2,next1,2,chkdir "..middir1.." "..middir2.." "..nextdir1.." "..nextdir2.." "..chkdir) + atprint("in conway: one below "..minetest.pos_to_string(next).." rail not connecting, returning!") + atprint(" in order mid1,2,next1,2,chkdir "..middir1.." "..middir2.." "..nextdir1.." "..nextdir2.." "..chkdir) return nil end end - --atprint("[advtrains]conway found rail.") + --atprint("conway found rail.") return vector.add(advtrains.round_vector_floor_y(next), {x=0, y=nextrailheight, z=0}), chkdir end --TODO use this @@ -241,3 +241,4 @@ function advtrains.deserialize_inventory(sers, inv) end return false end + diff --git a/advtrains/advtrains/init.lua b/advtrains/advtrains/init.lua index ce3cc9f..03ec553 100644 --- a/advtrains/advtrains/init.lua +++ b/advtrains/advtrains/init.lua @@ -4,8 +4,38 @@ advtrains={} advtrains.modpath = minetest.get_modpath("advtrains") -atprint=function() end ---atprint=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end +local function print_concat_table(a) + local str="" + local stra="" + for i=1,50 do + t=a[i] + if t==nil then + stra=stra.."nil " + else + str=str..stra + stra="" + if type(t)=="table" then + if t.x and t.y and t.z then + str=str..minetest.pos_to_string(t) + else + str=str..dump(t) + end + elseif type(t)=="boolean" then + if t then + str=str.."true" + else + str=str.."false" + end + else + str=str..t + end + str=str.." " + end + end + return str +end +--atprint=function() end +atprint=function(t, ...) minetest.log("action", "[advtrains]"..print_concat_table({t, ...})) minetest.chat_send_all("[advtrains]"..print_concat_table({t, ...})) end sid=function(id) return string.sub(id, -4) end dofile(advtrains.modpath.."/helpers.lua"); diff --git a/advtrains/advtrains/misc_nodes.lua b/advtrains/advtrains/misc_nodes.lua index 93829f0..70b18fb 100644 --- a/advtrains/advtrains/misc_nodes.lua +++ b/advtrains/advtrains/misc_nodes.lua @@ -3,7 +3,7 @@ function advtrains.register_platform(preset) local ndef=minetest.registered_nodes[preset] if not ndef then - minetest.log("warning", "[advtrains] register_platform couldn't find preset node "..preset) + minetest.log("warning", " register_platform couldn't find preset node "..preset) return end local btex=ndef.tiles diff --git a/advtrains/advtrains/pseudoload.lua b/advtrains/advtrains/pseudoload.lua index 0636d2e..5cbd2c6 100644 --- a/advtrains/advtrains/pseudoload.lua +++ b/advtrains/advtrains/pseudoload.lua @@ -20,7 +20,7 @@ for tt, _ in pairs(advtrains.all_traintypes) do local file, err = io.open(pl_fpath, "r") if not file then local er=err or "Unknown Error" - atprint("[advtrains]Failed loading advtrains trackdb save file "..er) + atprint("Failed loading advtrains trackdb save file "..er) else --custom format to save memory while true do @@ -74,7 +74,7 @@ function advtrains.save_trackdb() local file, err = io.open(pl_fpath, "w") if not file then local er=err or "Unknown Error" - atprint("[advtrains]Failed saving advtrains trackdb save file "..er) + atprint("Failed saving advtrains trackdb save file "..er) else --custom format to save memory for y,tyl in pairs(advtrains.trackdb[tt]) do @@ -103,7 +103,7 @@ advtrains.fpath_tdb=minetest.get_worldpath().."/advtrains_trackdb2" local file, err = io.open(advtrains.fpath_tdb, "r") if not file then local er=err or "Unknown Error" - atprint("[advtrains]Failed loading advtrains save file "..er) + atprint("Failed loading advtrains save file "..er) else local tbl = minetest.deserialize(file:read("*a")) if type(tbl) == "table" then @@ -114,7 +114,7 @@ end function advtrains.save_trackdb() local datastr = minetest.serialize(advtrains.trackdb) if not datastr then - minetest.log("error", "[advtrains] Failed to serialize trackdb data!") + minetest.log("error", " Failed to serialize trackdb data!") return end local file, err = io.open(advtrains.fpath_tdb, "w") diff --git a/advtrains/advtrains/tracks.lua b/advtrains/advtrains/tracks.lua index 53f5ce7..9fc3a56 100644 --- a/advtrains/advtrains/tracks.lua +++ b/advtrains/advtrains/tracks.lua @@ -370,10 +370,10 @@ end function advtrains.get_track_connections(name, param2) local nodedef=minetest.registered_nodes[name] - if not nodedef then atprint("[advtrains] get_track_connections couldn't find nodedef for nodename "..(name or "nil")) return 0, 8, 0, 0, 0 end + if not nodedef then atprint(" get_track_connections couldn't find nodedef for nodename "..(name or "nil")) return 0, 8, 0, 0, 0 end local noderot=param2 if not param2 then noderot=0 end - if noderot > 3 then atprint("[advtrains] get_track_connections: rail has invaild param2 of "..noderot) noderot=0 end + if noderot > 3 then atprint(" get_track_connections: rail has invaild param2 of "..noderot) noderot=0 end local tracktype for k,_ in pairs(nodedef.groups) do diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua index ac870c0..07a48cc 100644 --- a/advtrains/advtrains/trainlogic.lua +++ b/advtrains/advtrains/trainlogic.lua @@ -47,7 +47,7 @@ advtrains.fpath=minetest.get_worldpath().."/advtrains" local file, err = io.open(advtrains.fpath, "r") if not file then local er=err or "Unknown Error" - atprint("[advtrains]Failed loading advtrains save file "..er) + atprint("Failed loading advtrains save file "..er) else local tbl = minetest.deserialize(file:read("*a")) if type(tbl) == "table" then @@ -59,7 +59,7 @@ advtrains.fpath_ws=minetest.get_worldpath().."/advtrains_wagon_save" local file, err = io.open(advtrains.fpath_ws, "r") if not file then local er=err or "Unknown Error" - atprint("[advtrains]Failed loading advtrains save file "..er) + atprint("Failed loading advtrains save file "..er) else local tbl = minetest.deserialize(file:read("*a")) if type(tbl) == "table" then @@ -70,11 +70,11 @@ end advtrains.save = function() - atprint("[advtrains]saving") + atprint("saving") advtrains.invalidate_all_paths() local datastr = minetest.serialize(advtrains.trains) if not datastr then - minetest.log("error", "[advtrains] Failed to serialize train data!") + minetest.log("error", " Failed to serialize train data!") return end local file, err = io.open(advtrains.fpath, "w") @@ -108,7 +108,7 @@ advtrains.save = function() --atprint(dump(advtrains.wagon_save)) datastr = minetest.serialize(advtrains.wagon_save) if not datastr then - minetest.log("error", "[advtrains] Failed to serialize train data!") + minetest.log("error", " Failed to serialize train data!") return end file, err = io.open(advtrains.fpath_ws, "w") @@ -236,7 +236,7 @@ function advtrains.train_step(id, train, dtime) --remove? if #train.trainparts==0 then - atprint("[advtrains][train "..sid(id).."] has empty trainparts, removing.") + atprint("[train "..sid(id).."] has empty trainparts, removing.") advtrains.detector.leave_node(path[train.detector_old_index], id) advtrains.trains[id]=nil return @@ -284,7 +284,7 @@ function advtrains.train_step(id, train, dtime) local node_range=(math.max((minetest.setting_get("active_block_range") or 0),1)*16) if train.check_trainpartload<=0 then local ori_pos=advtrains.get_real_index_position(path, train.index) --not much to calculate - --atprint("[advtrains][train "..id.."] at "..minetest.pos_to_string(vector.round(ori_pos))) + --atprint("[train "..id.."] at "..minetest.pos_to_string(vector.round(ori_pos))) local should_check=false for _,p in ipairs(minetest.get_connected_players()) do @@ -417,7 +417,7 @@ function advtrains.pathpredict(id, train) if not train.path or #train.path<2 then if not train.last_pos then --no chance to recover - atprint("[advtrains]train hasn't saved last-pos, removing train.") + atprint("train hasn't saved last-pos, removing train.") advtrains.train[id]=nil return false end @@ -426,17 +426,17 @@ function advtrains.pathpredict(id, train) if node_ok==nil then --block not loaded, do nothing - atprint("[advtrains]last_pos not available") + atprint("last_pos not available") return nil elseif node_ok==false then - atprint("[advtrains]no track here, (fail) removing train.") + atprint("no track here, (fail) removing train.") advtrains.trains[id]=nil return false end if not train.last_pos_prev then --no chance to recover - atprint("[advtrains]train hasn't saved last-pos_prev, removing train.") + atprint("train hasn't saved last-pos_prev, removing train.") advtrains.trains[id]=nil return false end @@ -445,10 +445,10 @@ function advtrains.pathpredict(id, train) if prevnode_ok==nil then --block not loaded, do nothing - atprint("[advtrains]prev not available") + atprint("prev not available") return nil elseif prevnode_ok==false then - atprint("[advtrains]no track at prev, (fail) removing train.") + atprint("no track at prev, (fail) removing train.") advtrains.trains[id]=nil return false end @@ -476,7 +476,7 @@ function advtrains.pathpredict(id, train) local maxn=train.max_index_on_track or 0 while (maxn-train.index) < pregen_front do--pregenerate - --atprint("[advtrains]maxn conway for ",maxn,minetest.pos_to_string(path[maxn]),maxn-1,minetest.pos_to_string(path[maxn-1])) + --atprint("maxn conway for ",maxn,minetest.pos_to_string(path[maxn]),maxn-1,minetest.pos_to_string(path[maxn-1])) local conway=advtrains.conway(train.path[maxn], train.path[maxn-1], train.drives_on) if conway then train.path[maxn+1]=conway @@ -493,7 +493,7 @@ function advtrains.pathpredict(id, train) local minn=train.min_index_on_track or 0 while (train.index-minn) < (train.trainlen or 0) + pregen_back do --post_generate. has to be at least trainlen. (we let go of the exact calculation here since this would be unuseful here) - --atprint("[advtrains]minn conway for ",minn,minetest.pos_to_string(path[minn]),minn+1,minetest.pos_to_string(path[minn+1])) + --atprint("minn conway for ",minn,minetest.pos_to_string(path[minn]),minn+1,minetest.pos_to_string(path[minn+1])) local conway=advtrains.conway(train.path[minn], train.path[minn+1], train.drives_on) if conway then train.path[minn-1]=conway @@ -558,10 +558,11 @@ function advtrains.update_trainpart_properties(train_id, invert_flipstate) local count_l=0 for i, w_id in ipairs(train.trainparts) do local wagon=nil - for _,iwagon in pairs(minetest.luaentities) do + for aoid,iwagon in pairs(minetest.luaentities) do if iwagon.is_wagon and iwagon.initialized and iwagon.unique_id==w_id then if wagon then --duplicate + atprint("update_trainpart_properties: Removing duplicate wagon with id="..aoid) iwagon.object:remove() else wagon=iwagon diff --git a/advtrains/advtrains/wagons.lua b/advtrains/advtrains/wagons.lua index 8c3cd0a..bedffda 100644 --- a/advtrains/advtrains/wagons.lua +++ b/advtrains/advtrains/wagons.lua @@ -47,7 +47,7 @@ end wagon will save only uid in staticdata, no serialized table ]] function wagon:on_activate(sd_uid, dtime_s) - atprint("[advtrains][wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] activated") + atprint("[wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] activated") self.object:set_armor_groups({immortal=1}) if sd_uid and sd_uid~="" then --legacy @@ -63,7 +63,7 @@ function wagon:on_activate(sd_uid, dtime_s) --duplicates? for ao_id,wagon in pairs(minetest.luaentities) do if wagon.is_wagon and wagon.initialized and wagon.unique_id==self.unique_id and wagon~=self then--i am a duplicate! - atprint("[advtrains][wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] duplicate found(ao_id:"..ao_id.."), removing") + atprint("[wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] duplicate found(ao_id:"..ao_id.."), removing") self.object:remove() minetest.after(0.5, function() advtrains.update_trainpart_properties(self.train_id) end) return @@ -77,7 +77,7 @@ end function wagon:get_staticdata() if not self:ensure_init() then return end - atprint("[advtrains][wagon "..((self.unique_id and self.unique_id~="" and self.unique_id) or "no-id").."]: saving to wagon_save") + atprint("[wagon "..((self.unique_id and self.unique_id~="" and self.unique_id) or "no-id").."]: saving to wagon_save") --serialize inventory, if it has one if self.has_inventory then local inv=minetest.get_inventory({type="detached", name="advtrains_wgn_"..self.unique_id}) @@ -209,7 +209,7 @@ function wagon:destroy() self.custom_on_destroy(self, puncher, time_from_last_punch, tool_capabilities, direction) end - atprint("[advtrains][wagon "..((self.unique_id and self.unique_id~="" and self.unique_id) or "no-id").."]: destroying") + atprint("[wagon "..((self.unique_id and self.unique_id~="" and self.unique_id) or "no-id").."]: destroying") self.object:remove() @@ -236,7 +236,7 @@ function wagon:on_step(dtime) --is my train still here if not self.train_id or not self:train() then - atprint("[advtrains][wagon "..self.unique_id.."] missing train_id, destroying") + atprint("[wagon "..self.unique_id.."] missing train_id, destroying") self.object:remove() return elseif not self.initialized then @@ -317,7 +317,7 @@ function wagon:on_step(dtime) local first_pos=gp.path[math.floor(index)] local second_pos=gp.path[math.floor(index)+1] if not first_pos or not second_pos then - --atprint("[advtrains] object "..self.unique_id.." path end reached!") + --atprint(" object "..self.unique_id.." path end reached!") self.object:setvelocity({x=0,y=0,z=0}) return end @@ -533,10 +533,10 @@ function advtrains.register_wagon(sysname, prototype, desc, inv_img) end local node=minetest.env:get_node_or_nil(pointed_thing.under) - if not node then atprint("[advtrains]Ignore at placer position") return itemstack end + if not node then atprint("Ignore at placer position") return itemstack end local nodename=node.name if(not advtrains.is_track_and_drives_on(nodename, prototype.drives_on)) then - atprint("[advtrains]no track here, not placing.") + atprint("no track here, not placing.") return itemstack end local conn1=advtrains.get_track_connections(node.name, node.param2) @@ -544,7 +544,7 @@ function advtrains.register_wagon(sysname, prototype, desc, inv_img) local ob=minetest.env:add_entity(pointed_thing.under, "advtrains:"..sysname) if not ob then - atprint("[advtrains]couldn't add_entity, aborting") + atprint("couldn't add_entity, aborting") end local le=ob:get_luaentity() -- cgit v1.2.3 From c2a92608fa896d805a8e7cf4c13846c06e987b4f Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 10 Jan 2017 22:44:27 +0100 Subject: Fix restoring the detector.on_node table when paths get cleaned up --- advtrains/advtrains/tracks.lua | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/advtrains/advtrains/tracks.lua b/advtrains/advtrains/tracks.lua index 9fc3a56..671c861 100644 --- a/advtrains/advtrains/tracks.lua +++ b/advtrains/advtrains/tracks.lua @@ -398,17 +398,17 @@ advtrains.detector.clean_step_before = false --The entry already being contained in advtrains.detector.on_node_restore will not trigger an on_train_enter event on the node. (when path is reset, this is saved). function advtrains.detector.enter_node(pos, train_id) local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - --atprint("enterNode "..pts.." "..sid(train_id)) + atprint("enterNode "..pts.." "..sid(train_id)) if advtrains.detector.on_node[pts] then if advtrains.trains[advtrains.detector.on_node[pts]] then - --atprint(""..pts.." already occupied") + atprint(""..pts.." already occupied") return false else advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) end end advtrains.detector.on_node[pts]=train_id - if advtrains.detector.on_node_restore[pts] then + if advtrains.detector.on_node_restore[pts]==train_id then advtrains.detector.on_node_restore[pts]=nil else advtrains.detector.call_enter_callback(advtrains.round_vector_floor_y(pos), train_id) @@ -417,9 +417,9 @@ function advtrains.detector.enter_node(pos, train_id) end function advtrains.detector.leave_node(pos, train_id) local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - --atprint("leaveNode "..pts.." "..sid(train_id)) + atprint("leaveNode "..pts.." "..sid(train_id)) if not advtrains.detector.on_node[pts] then - --atprint(""..pts.." leave: nothing here") + atprint(""..pts.." leave: nothing here") return false end if advtrains.detector.on_node[pts]==train_id then @@ -427,7 +427,7 @@ function advtrains.detector.leave_node(pos, train_id) advtrains.detector.on_node[pts]=nil else if advtrains.trains[advtrains.detector.on_node[pts]] then - --atprint(""..pts.." occupied by another train") + atprint(""..pts.." occupied by another train") return false else advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) @@ -438,21 +438,30 @@ function advtrains.detector.leave_node(pos, train_id) end --called immediately before invalidating paths function advtrains.detector.setup_restore() - --atprint("setup_restore") - advtrains.detector.on_node_restore = advtrains.detector.on_node + atprint("setup_restore") + -- don't execute if it already has been called. For some reason it gets called twice... + if advtrains.detector.clean_step_before then + return + end + advtrains.detector.on_node_restore={} + for k, v in pairs(advtrains.detector.on_node) do + advtrains.detector.on_node_restore[k]=v + end advtrains.detector.on_node = {} + advtrains.detector.clean_step_before = true end --called one step after invalidating paths, when all trains have restored their path and called enter_node for their contents. function advtrains.detector.finalize_restore() - --atprint("finalize_restore") + atprint("finalize_restore") for pts, train_id in pairs(advtrains.detector.on_node_restore) do --atprint("called leave callback "..pts.." "..train_id) advtrains.detector.call_leave_callback(minetest.string_to_pos(pts), train_id) end advtrains.detector.on_node_restore = {} + advtrains.detector.clean_step_before = false end function advtrains.detector.call_enter_callback(pos, train_id) - --atprint("instructed to call enter calback") + atprint("instructed to call enter calback") local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case local mregnode=minetest.registered_nodes[node.name] @@ -464,7 +473,7 @@ function advtrains.detector.call_enter_callback(pos, train_id) advtrains.atc.trigger_controller_train_enter(pos, train_id) end function advtrains.detector.call_leave_callback(pos, train_id) - --atprint("instructed to call leave calback") + atprint("instructed to call leave calback") local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case local mregnode=minetest.registered_nodes[node.name] -- cgit v1.2.3 From ddd42163be2f845cd1f201a2fb7b6fb2267b3705 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 10 Jan 2017 22:54:10 +0100 Subject: Prevent non-initialized wagons from accidentally polluting the world sometimes wagons get created/loaded but are not initialized. These stand around and can't be removed. Now if a wagon does not get initialized after 20 steps, something went wrong and the wagon is removed. --- advtrains/advtrains/init.lua | 4 ++-- advtrains/advtrains/wagons.lua | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/advtrains/advtrains/init.lua b/advtrains/advtrains/init.lua index 03ec553..a415857 100644 --- a/advtrains/advtrains/init.lua +++ b/advtrains/advtrains/init.lua @@ -34,8 +34,8 @@ local function print_concat_table(a) end return str end ---atprint=function() end -atprint=function(t, ...) minetest.log("action", "[advtrains]"..print_concat_table({t, ...})) minetest.chat_send_all("[advtrains]"..print_concat_table({t, ...})) end +atprint=function() end +--atprint=function(t, ...) minetest.log("action", "[advtrains]"..print_concat_table({t, ...})) minetest.chat_send_all("[advtrains]"..print_concat_table({t, ...})) end sid=function(id) return string.sub(id, -4) end dofile(advtrains.modpath.."/helpers.lua"); diff --git a/advtrains/advtrains/wagons.lua b/advtrains/advtrains/wagons.lua index bedffda..13811ad 100644 --- a/advtrains/advtrains/wagons.lua +++ b/advtrains/advtrains/wagons.lua @@ -151,8 +151,17 @@ function wagon:init_shared() end end function wagon:ensure_init() - if self.initialized then return true end - self.object:setvelocity({x=0,y=0,z=0}) + if self.initialized then + if self.noninitticks then self.noninitticks=nil end + return true + end + if not self.noninitticks then self.noninitticks=0 end + self.noninitticks=self.noninitticks+1 + if self.noninitticks>20 then + self.object:remove() + else + self.object:setvelocity({x=0,y=0,z=0}) + end return false end -- cgit v1.2.3 From 04d14dc1bf4d7527635652e48493114254750dd3 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 10 Jan 2017 23:05:01 +0100 Subject: zip --- advtrains.zip | Bin 4533122 -> 4533407 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/advtrains.zip b/advtrains.zip index 028222e..b2c36cb 100644 Binary files a/advtrains.zip and b/advtrains.zip differ -- cgit v1.2.3 From dc8b47a066ff8b3251ad09d4b490647e3f057d10 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Thu, 12 Jan 2017 17:33:43 +0100 Subject: Unite all save data (except the track database) into a single save file --- advtrains/advtrains/atc.lua | 33 ++--------- advtrains/advtrains/init.lua | 112 ++++++++++++++++++++++++++++++++++++- advtrains/advtrains/pseudoload.lua | 3 +- advtrains/advtrains/trainlogic.lua | 85 ---------------------------- 4 files changed, 115 insertions(+), 118 deletions(-) diff --git a/advtrains/advtrains/atc.lua b/advtrains/advtrains/atc.lua index bd02425..e015d47 100644 --- a/advtrains/advtrains/atc.lua +++ b/advtrains/advtrains/atc.lua @@ -2,37 +2,10 @@ --registers and controls the ATC system local atc={} --- ATC persistence table -atc.controllers = {} +-- ATC persistence table. advtrains.atc is created by init.lua when it loads the save file. +atc.controllers = advtrains.atc.controllers --contents: {command="...", arrowconn=0-15 where arrow points} -advtrains.fpath_atc=minetest.get_worldpath().."/advtrains_atc" -local file, err = io.open(advtrains.fpath_atc, "r") -if not file then - local er=err or "Unknown Error" - atprint("Failed loading advtrains atc save file "..er) -else - local tbl = minetest.deserialize(file:read("*a")) - if type(tbl) == "table" then - atc.controllers=tbl.controllers - end - file:close() -end -function atc.save() - --leave space for more save data. - local datastr = minetest.serialize({controllers = atc.controllers}) - if not datastr then - minetest.log("error", " Failed to serialize trackdb data!") - return - end - local file, err = io.open(advtrains.fpath_atc, "w") - if err then - return err - end - file:write(datastr) - file:close() -end - --call from advtrains.detector subprogram function atc.trigger_controller_train_enter(pos, train_id) @@ -290,5 +263,7 @@ function atc.execute_atc_command(id, train) atc.train_reset_command(id) end + + --move table to desired place advtrains.atc=atc diff --git a/advtrains/advtrains/init.lua b/advtrains/advtrains/init.lua index a415857..74201b5 100644 --- a/advtrains/advtrains/init.lua +++ b/advtrains/advtrains/init.lua @@ -1,6 +1,7 @@ --advtrains -advtrains={} +--create the base table structure. +advtrains={atc={controllers={}}, detector={}, trackplacer={}, trains={}, trackdb={}, wagon_save={}} advtrains.modpath = minetest.get_modpath("advtrains") @@ -34,8 +35,8 @@ local function print_concat_table(a) end return str end -atprint=function() end ---atprint=function(t, ...) minetest.log("action", "[advtrains]"..print_concat_table({t, ...})) minetest.chat_send_all("[advtrains]"..print_concat_table({t, ...})) end +--atprint=function() end +atprint=function(t, ...) minetest.log("action", "[advtrains]"..print_concat_table({t, ...})) minetest.chat_send_all("[advtrains]"..print_concat_table({t, ...})) end sid=function(id) return string.sub(id, -4) end dofile(advtrains.modpath.."/helpers.lua"); @@ -55,6 +56,110 @@ advtrains.meseconrules = {x=0, y=1, z=-1}, {x=0, y=-1, z=-1}, {x=0, y=-2, z=0}} + + + +--load/save + +advtrains.fpath=minetest.get_worldpath().."/advtrains" +local file, err = io.open(advtrains.fpath, "r") +if not file then + minetest.log("error", " Failed to read advtrains save data from file "..advtrains.fpath..": "..(err or "Unknown Error")) +else + local tbl = minetest.deserialize(file:read("*a")) + if type(tbl) == "table" then + if tbl.version then + --congrats, we have the new save format. + advtrains.atc.controllers = tbl.atc_controllers + advtrains.trains = tbl.trains + advtrains.wagon_save = tbl.wagon_save + else + --oh no, its the old one... + advtrains.trains=tbl + --load ATC + advtrains.fpath_atc=minetest.get_worldpath().."/advtrains_atc" + local file, err = io.open(advtrains.fpath_atc, "r") + if not file then + local er=err or "Unknown Error" + atprint("Failed loading advtrains atc save file "..er) + else + local tbl = minetest.deserialize(file:read("*a")) + if type(tbl) == "table" then + advtrains.atc.controllers=tbl.controllers + end + file:close() + end + --load wagon saves + advtrains.fpath_ws=minetest.get_worldpath().."/advtrains_wagon_save" + local file, err = io.open(advtrains.fpath_ws, "r") + if not file then + local er=err or "Unknown Error" + atprint("Failed loading advtrains save file "..er) + else + local tbl = minetest.deserialize(file:read("*a")) + if type(tbl) == "table" then + advtrains.wagon_save=tbl + end + file:close() + end + end + else + minetest.log("error", " Failed to deserialize advtrains save data: Not a table!") + end + file:close() +end + +advtrains.save = function() + atprint("saving") + advtrains.invalidate_all_paths() + + -- update wagon saves + for _,wagon in pairs(minetest.luaentities) do + if wagon.is_wagon and wagon.initialized then + wagon:get_staticdata() + end + end + --cross out userdata + for w_id, data in pairs(advtrains.wagon_save) do + data.name=nil + data.object=nil + if data.driver then + data.driver_name=data.driver:get_player_name() + data.driver=nil + else + data.driver_name=nil + end + if data.discouple then + data.discouple.object:remove() + data.discouple=nil + end + end + --atprint(dump(advtrains.wagon_save)) + + --versions: + -- 1 - Initial new save format. + local save_tbl={ + trains = advtrains.trains, + wagon_save = advtrains.wagon_save, + atc_controllers = advtrains.atc.controllers, + version = 1, + } + local datastr = minetest.serialize(save_tbl) + if not datastr then + minetest.log("error", " Failed to serialize advtrains save data!") + return + end + local file, err = io.open(advtrains.fpath, "w") + if err then + minetest.log("error", " Failed to write advtrains save data to file "..advtrains.fpath..": "..(err or "Unknown Error")) + return + end + file:write(datastr) + file:close() +end +minetest.register_on_shutdown(advtrains.save) + + dofile(advtrains.modpath.."/trainlogic.lua") dofile(advtrains.modpath.."/trainhud.lua") dofile(advtrains.modpath.."/trackplacer.lua") @@ -69,3 +174,4 @@ dofile(advtrains.modpath.."/damage.lua") dofile(advtrains.modpath.."/signals.lua") dofile(advtrains.modpath.."/misc_nodes.lua") dofile(advtrains.modpath.."/crafting.lua") + diff --git a/advtrains/advtrains/pseudoload.lua b/advtrains/advtrains/pseudoload.lua index 5cbd2c6..818808d 100644 --- a/advtrains/advtrains/pseudoload.lua +++ b/advtrains/advtrains/pseudoload.lua @@ -98,7 +98,8 @@ function advtrains.save_trackdb() end end ]]--end temp outcomment -advtrains.trackdb={} + +--trackdb keeps its own save file. advtrains.fpath_tdb=minetest.get_worldpath().."/advtrains_trackdb2" local file, err = io.open(advtrains.fpath_tdb, "r") if not file then diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua index 07a48cc..c9c7403 100644 --- a/advtrains/advtrains/trainlogic.lua +++ b/advtrains/advtrains/trainlogic.lua @@ -39,96 +39,11 @@ advtrains.train_emerg_force=10--for emergency brakes(when going off track) advtrains.audit_interval=10 -advtrains.trains={} -advtrains.wagon_save={} - ---load initially -advtrains.fpath=minetest.get_worldpath().."/advtrains" -local file, err = io.open(advtrains.fpath, "r") -if not file then - local er=err or "Unknown Error" - atprint("Failed loading advtrains save file "..er) -else - local tbl = minetest.deserialize(file:read("*a")) - if type(tbl) == "table" then - advtrains.trains=tbl - end - file:close() -end -advtrains.fpath_ws=minetest.get_worldpath().."/advtrains_wagon_save" -local file, err = io.open(advtrains.fpath_ws, "r") -if not file then - local er=err or "Unknown Error" - atprint("Failed loading advtrains save file "..er) -else - local tbl = minetest.deserialize(file:read("*a")) - if type(tbl) == "table" then - advtrains.wagon_save=tbl - end - file:close() -end - - -advtrains.save = function() - atprint("saving") - advtrains.invalidate_all_paths() - local datastr = minetest.serialize(advtrains.trains) - if not datastr then - minetest.log("error", " Failed to serialize train data!") - return - end - local file, err = io.open(advtrains.fpath, "w") - if err then - return err - end - file:write(datastr) - file:close() - - -- update wagon saves - for _,wagon in pairs(minetest.luaentities) do - if wagon.is_wagon and wagon.initialized then - wagon:get_staticdata() - end - end - --cross out userdata - for w_id, data in pairs(advtrains.wagon_save) do - data.name=nil - data.object=nil - if data.driver then - data.driver_name=data.driver:get_player_name() - data.driver=nil - else - data.driver_name=nil - end - if data.discouple then - data.discouple.object:remove() - data.discouple=nil - end - end - --atprint(dump(advtrains.wagon_save)) - datastr = minetest.serialize(advtrains.wagon_save) - if not datastr then - minetest.log("error", " Failed to serialize train data!") - return - end - file, err = io.open(advtrains.fpath_ws, "w") - if err then - return err - end - file:write(datastr) - file:close() - - advtrains.save_trackdb() - advtrains.atc.save() -end -minetest.register_on_shutdown(advtrains.save) - advtrains.save_and_audit_timer=advtrains.audit_interval minetest.register_globalstep(function(dtime) advtrains.save_and_audit_timer=advtrains.save_and_audit_timer-dtime if advtrains.save_and_audit_timer<=0 then local t=os.clock() - --save advtrains.save() advtrains.save_and_audit_timer=advtrains.audit_interval -- cgit v1.2.3 From b649ea5fe4c9a7bc9b2b318fec97e5abe470fa9b Mon Sep 17 00:00:00 2001 From: orwell96 Date: Mon, 16 Jan 2017 20:07:04 +0100 Subject: replace trackdb by nodedb - trackdb is kept for large rail networks to still work but not saved anymore - saving node name and param2 instead of track connections, so also signals can be saved. - small serialization format - fast access times, almost no redundancy --- advtrains/advtrains/atc.lua | 15 ++- advtrains/advtrains/debugitems.lua | 10 +- advtrains/advtrains/init.lua | 41 +++--- advtrains/advtrains/lua_atc.lua | 166 +++++++++++++++++++++++ advtrains/advtrains/nodedb.lua | 232 +++++++++++++++++++++++++++++++++ advtrains/advtrains/pseudoload.lua | 180 ------------------------- advtrains/advtrains/signals.lua | 6 +- advtrains/advtrains/trackdb_legacy.lua | 27 ++++ advtrains/advtrains/trackplacer.lua | 16 +-- advtrains/advtrains/tracks.lua | 32 ++--- 10 files changed, 484 insertions(+), 241 deletions(-) create mode 100644 advtrains/advtrains/lua_atc.lua create mode 100644 advtrains/advtrains/nodedb.lua delete mode 100644 advtrains/advtrains/pseudoload.lua create mode 100644 advtrains/advtrains/trackdb_legacy.lua diff --git a/advtrains/advtrains/atc.lua b/advtrains/advtrains/atc.lua index e015d47..ece7075 100644 --- a/advtrains/advtrains/atc.lua +++ b/advtrains/advtrains/atc.lua @@ -3,7 +3,13 @@ local atc={} -- ATC persistence table. advtrains.atc is created by init.lua when it loads the save file. -atc.controllers = advtrains.atc.controllers +atc.controllers = {} +function atc.load_data(data) + atc.controllers = data and data.controllers or {} +end +function atc.save_data() + return atc.controllers +end --contents: {command="...", arrowconn=0-15 where arrow points} --call from advtrains.detector subprogram @@ -52,8 +58,8 @@ end --nodes local idxtrans={static=1, mesecon=2, digiline=3} -local apn_func=function(pos) - advtrains.reset_trackdb_position(pos) +local apn_func=function(pos, node) + advtrains.ndb.update(pos, node) local meta=minetest.get_meta(pos) if meta then meta:set_string("infotext", "ATC controller, unconfigured.") @@ -72,10 +78,9 @@ advtrains.register_tracks("default", { get_additional_definiton = function(def, preset, suffix, rotation) return { after_place_node=apn_func, - on_place_rail=apn_func, after_dig_node=function(pos) advtrains.invalidate_all_paths() - advtrains.reset_trackdb_position(pos) + advtrains.ndb.clear(pos) local pts=minetest.pos_to_string(pos) atc.controllers[pts]=nil end, diff --git a/advtrains/advtrains/debugitems.lua b/advtrains/advtrains/debugitems.lua index b3164ff..dcc95d9 100644 --- a/advtrains/advtrains/debugitems.lua +++ b/advtrains/advtrains/debugitems.lua @@ -24,13 +24,5 @@ minetest.register_tool("advtrains:tunnelborer", end end end, ---[[ -^ default: nil -^ Function must return either nil if no item shall be removed from -inventory, or an itemstack to replace the original itemstack. -e.g. itemstack:take_item(); return itemstack -^ Otherwise, the function is free to do what it wants. -^ The default functions handle regular use cases. -]] } -) +) diff --git a/advtrains/advtrains/init.lua b/advtrains/advtrains/init.lua index 74201b5..c8c4b56 100644 --- a/advtrains/advtrains/init.lua +++ b/advtrains/advtrains/init.lua @@ -1,7 +1,6 @@ --advtrains ---create the base table structure. -advtrains={atc={controllers={}}, detector={}, trackplacer={}, trains={}, trackdb={}, wagon_save={}} +advtrains = {trains={}, wagon_save={}} advtrains.modpath = minetest.get_modpath("advtrains") @@ -57,7 +56,21 @@ advtrains.meseconrules = {x=0, y=-1, z=-1}, {x=0, y=-2, z=0}} +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.."/trackdb_legacy.lua") +dofile(advtrains.modpath.."/nodedb.lua") +dofile(advtrains.modpath.."/couple.lua") +dofile(advtrains.modpath.."/damage.lua") + +dofile(advtrains.modpath.."/signals.lua") +dofile(advtrains.modpath.."/misc_nodes.lua") +dofile(advtrains.modpath.."/crafting.lua") --load/save @@ -70,9 +83,11 @@ else if type(tbl) == "table" then if tbl.version then --congrats, we have the new save format. - advtrains.atc.controllers = tbl.atc_controllers advtrains.trains = tbl.trains advtrains.wagon_save = tbl.wagon_save + advtrains.ndb.load_data(tbl.ndb) + advtrains.atc.load_data(tbl.atc) + --advtrains.latc.load_data(tbl.latc) else --oh no, its the old one... advtrains.trains=tbl @@ -110,7 +125,7 @@ else end advtrains.save = function() - atprint("saving") + --atprint("saving") advtrains.invalidate_all_paths() -- update wagon saves @@ -134,14 +149,15 @@ advtrains.save = function() data.discouple=nil end end - --atprint(dump(advtrains.wagon_save)) --versions: -- 1 - Initial new save format. local save_tbl={ trains = advtrains.trains, wagon_save = advtrains.wagon_save, - atc_controllers = advtrains.atc.controllers, + atc = advtrains.atc.save_data(), + --latc = advtrains.latc.save_data(), + ndb = advtrains.ndb.save_data(), version = 1, } local datastr = minetest.serialize(save_tbl) @@ -160,18 +176,5 @@ end minetest.register_on_shutdown(advtrains.save) -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") -dofile(advtrains.modpath.."/couple.lua") -dofile(advtrains.modpath.."/damage.lua") - -dofile(advtrains.modpath.."/signals.lua") -dofile(advtrains.modpath.."/misc_nodes.lua") -dofile(advtrains.modpath.."/crafting.lua") diff --git a/advtrains/advtrains/lua_atc.lua b/advtrains/advtrains/lua_atc.lua new file mode 100644 index 0000000..313d70d --- /dev/null +++ b/advtrains/advtrains/lua_atc.lua @@ -0,0 +1,166 @@ +------------- +--LUA ATC controllers + +local latc={} + +function latc.load_data(data) +end +function latc.save_data() + return stuff +end + +latc.data +latc.env_cdata +latc.init_code="" +latc.step_code="" + +advtrains.fpath_latc=minetest.get_worldpath().."/advtrains_latc" +local file, err = io.open(advtrains.fpath_atc, "r") +if not file then + local er=err or "Unknown Error" + atprint("Failed loading advtrains latc save file "..er) +else + local tbl = minetest.deserialize(file:read("*a")) + if type(tbl) == "table" then + atc.controllers=tbl.controllers + end + file:close() +end +function latc.save() + + local datastr = minetest.serialize({controllers = atc.controllers}) + if not datastr then + minetest.log("error", " Failed to serialize latc data!") + return + end + local file, err = io.open(advtrains.fpath_atc, "w") + if err then + return err + end + file:write(datastr) + file:close() +end + +--Privilege +--Only trusted players should be enabled to build stuff which can break the server. +--If I later decide to have multiple environments ('data' tables), I better store an owner for every controller for future reference. + +minetest.register_privilege("advtrains_lua_atc", { description = "Player can place and modify LUA ATC components. Grant with care! Allows to execute bad LUA code.", give_to_singleplayer = false, default= false }) + +--Environment +--Code from mesecons_luacontroller (credit goes to Jeija and mesecons contributors) + +local safe_globals = { + "assert", "error", "ipairs", "next", "pairs", "select", + "tonumber", "tostring", "type", "unpack", "_VERSION" +} +local function safe_print(param) + print(dump(param)) +end + +local function safe_date() + return(os.date("*t",os.time())) +end + +-- string.rep(str, n) with a high value for n can be used to DoS +-- the server. Therefore, limit max. length of generated string. +local function safe_string_rep(str, n) + if #str * n > mesecon.setting("luacontroller_string_rep_max", 64000) then + debug.sethook() -- Clear hook + error("string.rep: string length overflow", 2) + end + + return string.rep(str, n) +end + +-- string.find with a pattern can be used to DoS the server. +-- Therefore, limit string.find to patternless matching. +local function safe_string_find(...) + if (select(4, ...)) ~= true then + debug.sethook() -- Clear hook + error("string.find: 'plain' (fourth parameter) must always be true in a LuaController") + end + + return string.find(...) +end + +latc.static_env = { + print = safe_print, + string = { + byte = string.byte, + char = string.char, + format = string.format, + len = string.len, + lower = string.lower, + upper = string.upper, + rep = safe_string_rep, + reverse = string.reverse, + sub = string.sub, + find = safe_string_find, + }, + math = { + abs = math.abs, + acos = math.acos, + asin = math.asin, + atan = math.atan, + atan2 = math.atan2, + ceil = math.ceil, + cos = math.cos, + cosh = math.cosh, + deg = math.deg, + exp = math.exp, + floor = math.floor, + fmod = math.fmod, + frexp = math.frexp, + huge = math.huge, + ldexp = math.ldexp, + log = math.log, + log10 = math.log10, + max = math.max, + min = math.min, + modf = math.modf, + pi = math.pi, + pow = math.pow, + rad = math.rad, + random = math.random, + sin = math.sin, + sinh = math.sinh, + sqrt = math.sqrt, + tan = math.tan, + tanh = math.tanh, + }, + table = { + concat = table.concat, + insert = table.insert, + maxn = table.maxn, + remove = table.remove, + sort = table.sort, + }, + os = { + clock = os.clock, + difftime = os.difftime, + time = os.time, + datetable = safe_date, + }, +} +latc.static_env._G = env + +for _, name in pairs(safe_globals) do + latc.static_env[name] = _G[name] +end + + +--The environment all code calls get is a proxy table with a metatable. +--When an index is read: +-- Look in static_env +-- Look in volatile_env (user_written functions and userdata) +-- Look in saved_env (everything that's not a function or userdata) +--when an index is written: +-- If in static_env, do not allow +-- if function or userdata, volatile_env +-- if table, see below +-- else, save in saved_env + + + +advtrains.latc=latc diff --git a/advtrains/advtrains/nodedb.lua b/advtrains/advtrains/nodedb.lua new file mode 100644 index 0000000..0e1d836 --- /dev/null +++ b/advtrains/advtrains/nodedb.lua @@ -0,0 +1,232 @@ +--nodedb.lua +--database of all nodes that have 'save_in_nodedb' field set to true in node definition + + + +--serialization format: +--(6byte poshash) (2byte contentid) +--contentid := (14bit nodeid, 2bit param2) + +local function hash_to_bytes(x) + local aH = math.floor(x / 1099511627776) % 256; + local aL = math.floor(x / 4294967296) % 256; + local bH = math.floor(x / 16777216) % 256; + local bL = math.floor(x / 65536) % 256; + local cH = math.floor(x / 256) % 256; + local cL = math.floor(x ) % 256; + return(string.char(aH, aL, bH, bL, cH, cL)); +end +local function cid_to_bytes(x) + local cH = math.floor(x / 256) % 256; + local cL = math.floor(x ) % 256; + return(string.char(cH, cL)); +end +local function bytes_to_hash(bytes) + local t={string.byte(bytes,1,-1)} + local n = + t[1] * 1099511627776 + + t[2] * 4294967296 + + t[3] * 16777216 + + t[4] * 65536 + + t[5] * 256 + + t[6] + return n +end +local function bytes_to_cid(bytes) + local t={string.byte(bytes,1,-1)} + local n = + t[1] * 256 + + t[2] + return n +end +local function l2b(x) + return x%4 +end +local function u14b(x) + return math.floor(x/4) +end +local ndb={} + +--local variables for performance +local ndb_nodeids={} +local ndb_nodes={} + +--load +--nodeids get loaded by advtrains init.lua and passed here +function ndb.load_data(data) + ndb_nodeids = data and data.nodeids or {} +end + +local path=minetest.get_worldpath().."/advtrains_ndb" + +local file, err = io.open(path, "r") +if not file then + atprint("load ndb failed: ", err or "Unknown Error") +else + local cnt=0 + local hst=file:read(6) + local cid=file:read(2) + while hst and #hst==6 and cid and #cid==2 do + ndb_nodes[bytes_to_hash(hst)]=bytes_to_cid(cid) + cnt=cnt+1 + hst=file:read(6) + cid=file:read(2) + end + atprint("nodedb: read", cnt, "nodes.") + file:close() +end + +--save +function ndb.save_data() + local file, err = io.open(path, "w") + if not file then + atprint("load ndb failed: ", err or "Unknown Error") + else + for hash, cid in pairs(ndb_nodes) do + file:write(hash_to_bytes(hash)) + file:write(cid_to_bytes(cid)) + end + file:close() + end + return {nodeids = ndb_nodeids} +end + +--function to get node. track database is not helpful here. +function ndb.get_node_or_nil(pos) + local node=minetest.get_node_or_nil(pos) + if node then + return node + else + --maybe we have the node in the database... + local cid=ndb_nodes[minetest.hash_node_position(pos)] + if cid then + local nodeid = ndb_nodeids[u14b(cid)] + if nodeid then + --atprint("ndb.get_node_or_nil",pos,"found node",nodeid,"cid",cid,"par2",l2b(cid)) + return {name=nodeid, param2 = l2b(cid)} + end + end + end + atprint("ndb.get_node_or_nil",pos,"not found") +end +function ndb.get_node(pos) + local n=ndb.get_node_or_nil(pos) + if not n then + return {name="ignore", param2=0} + end + return n +end + +function ndb.swap_node(pos, node) + minetest.swap_node(pos, node) + ndb.update(pos, node) +end + +function ndb.update(pos, pnode) + local node = pnode or minetest.get_node_or_nil(pos) + if not node or node.name=="ignore" then return end + if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].groups.save_in_nodedb then + local nid + for tnid, nname in pairs(ndb_nodeids) do + if nname==node.name then + nid=tnid + end + end + if not nid then + nid=#ndb_nodeids+1 + ndb_nodeids[nid]=node.name + end + local hash = minetest.hash_node_position(pos) + ndb_nodes[hash] = (nid * 4) + (l2b(node.param2 or 0)) + --atprint("nodedb: updating node", pos, "stored nid",nid,"assigned",ndb_nodeids[nid],"resulting cid",ndb_nodes[hash]) + else + --at this position there is no longer a node that needs to be tracked. + local hash = minetest.hash_node_position(pos) + ndb_nodes[hash] = nil + end +end + +function ndb.clear(pos) + local hash = minetest.hash_node_position(pos) + ndb_nodes[hash] = nil +end + + +--get_node with pseudoload. now we only need track data, so we can use the trackdb as second fallback +--nothing new will be saved inside the trackdb. +--returns: +--true, conn1, conn2, rely1, rely2, railheight in case everything's right. +--false if it's not a rail or the train does not drive on this rail, but it is loaded or +--nil if the node is neither loaded nor in trackdb +--the distraction between false and nil will be needed only in special cases.(train initpos) +function advtrains.get_rail_info_at(pos, drives_on) + local rdp=advtrains.round_vector_floor_y(pos) + + local node=ndb.get_node_or_nil(rdp) + + --still no node? + --advtrains.trackdb is nil when there's no data available. + if not node then + if advtrains.trackdb then + --try raildb (see trackdb_legacy.lua) + local dbe=(advtrains.trackdb[rdp.y] and advtrains.trackdb[rdp.y][rdp.x] and advtrains.trackdb[rdp.y][rdp.x][rdp.z]) + if dbe then + for tt,_ in pairs(drives_on) do + if not dbe.tracktype or tt==dbe.tracktype then + return true, dbe.conn1, dbe.conn2, dbe.rely1 or 0, dbe.rely2 or 0, dbe.railheight or 0 + end + end + end + end + return nil + end + local nodename=node.name + if(not advtrains.is_track_and_drives_on(nodename, drives_on)) then + return false + end + local conn1, conn2, rely1, rely2, railheight, tracktype=advtrains.get_track_connections(node.name, node.param2) + + return true, conn1, conn2, rely1, rely2, railheight +end + + +minetest.register_abm({ + name = "advtrains:nodedb_on_load_update", + nodenames = {"group:save_in_nodedb"}, + run_at_every_load = true, + action = function(pos, node) + local cid=ndb_nodes[minetest.hash_node_position(pos)] + if cid then + --if in database, detect changes and apply. + local nodeid = ndb_nodeids[u14b(cid)] + local param2 = l2b(cid) + if not nodeid then + --something went wrong + atprint("nodedb: lbm nid not found", pos, "with nid", u14b(cid), "param2", param2, "cid is", cid) + ndb.update(pos, node) + else + if (nodeid~=node.name or param2~=node.param2) then + atprint("nodedb: lbm replaced", pos, "with nodeid", nodeid, "param2", param2, "cid is", cid) + minetest.swap_node(pos, {name=nodeid, param2 = param2}) + end + end + else + --if not in database, take it. + atprint("nodedb: ", pos, "not in database") + ndb.update(pos, node) + end + end, + interval=10, + chance=1, + }) + +minetest.register_on_dignode(function(pos, oldnode, digger) + ndb.clear(pos) +end) + +function ndb.t() + return ndb_nodes[141061759008906] +end + +advtrains.ndb=ndb + diff --git a/advtrains/advtrains/pseudoload.lua b/advtrains/advtrains/pseudoload.lua deleted file mode 100644 index 818808d..0000000 --- a/advtrains/advtrains/pseudoload.lua +++ /dev/null @@ -1,180 +0,0 @@ ---pseudoload.lua ---responsible for keeping up a database of all rail nodes existant in the world, regardless of whether the mapchunk is loaded. - -advtrains.trackdb={} ---trackdb[tt][y][x][z]={conn1, conn2, rely1, rely2, railheight} ---serialization format: ---(2byte x)(2byte y)(2byte z)(4bits conn1, 4bits conn2)[(plain rely1)|(plain rely2)|(plain railheight)]\n ---[] may be missing if 0,0,0 - ---load initially - ---[[ TODO temporary outcomment - ---delayed since all traintypes need to be registered -minetest.after(0, function() - -for tt, _ in pairs(advtrains.all_traintypes) do - local pl_fpath=minetest.get_worldpath().."/advtrains_trackdb_"..tt - advtrains.trackdb[tt]={} - local file, err = io.open(pl_fpath, "r") - if not file then - local er=err or "Unknown Error" - atprint("Failed loading advtrains trackdb save file "..er) - else - --custom format to save memory - while true do - local xbytes=file:read(2) - if not xbytes or #xbytes<2 then - break --eof reached - end - atprint(xbytes) - local ybytes=file:read(2) - local zbytes=file:read(2) - local x=(string.byte(xbytes[1])-128)*256+(string.byte(xbytes[2])) - local y=(string.byte(ybytes[1])-128)*256+(string.byte(ybytes[2])) - local z=(string.byte(zbytes[1])-128)*256+(string.byte(zbytes[2])) - - local conn1=string.byte(file:read(1)) - local conn1=string.byte(file:read(1)) - - if not advtrains.trackdb[tt][y] then advtrains.trackdb[tt][y]={} end - if not advtrains.trackdb[tt][y][x] then advtrains.trackdb[tt][y][x]={} end - - local rest=file.read("*l") - if rest~="" then - local rely1, rely2, railheight=string.match(rest, "([^|]+)|([^|]+)|([^|]+)") - if rely1 and rely2 and railheight then - advtrains.trackdb[tt][y][x][z]={ - conn1=conn1, conn2=conn2, - rely1=rely1, rely2=rely2, - railheight=railheight - } - else - advtrains.trackdb[tt][y][x][z]={ - conn1=conn1, conn2=conn2 - } - end - else - advtrains.trackdb[tt][y][x][z]={ - conn1=conn1, conn2=conn2 - } - end - end - file:close() - end -end - ---end minetest.after -end) - -function advtrains.save_trackdb() - for tt, _ in pairs(advtrains.all_traintypes) do - local pl_fpath=minetest.get_worldpath().."/advtrains_trackdb_"..tt - local file, err = io.open(pl_fpath, "w") - if not file then - local er=err or "Unknown Error" - atprint("Failed saving advtrains trackdb save file "..er) - else - --custom format to save memory - for y,tyl in pairs(advtrains.trackdb[tt]) do - for x,txl in pairs(tyl) do - for z,rail in pairs(txl) do - atprint("write "..x.." "..y.." "..z.." "..minetest.serialize(rail)) - file:write(string.char(math.floor(x/256)+128)..string.char((x%256))) - file:write(string.char(math.floor(y/256)+128)..string.char((y%256))) - file:write(string.char(math.floor(z/256)+128)..string.char((z%256))) - file:write(string.char(rail.conn1)) - file:write(string.char(rail.conn2)) - if (rail.rely1 and rail.rely1~=0) or (rail.rely2 and rail.rely2~=0) or (rail.railheight and rail.railheight~=0) then - file:write(rail.rely1.."|"..rail.rely2.."|"..rail.railheight) - end - file:write("\n") - end - end - end - file:close() - end - end -end -]]--end temp outcomment - ---trackdb keeps its own save file. -advtrains.fpath_tdb=minetest.get_worldpath().."/advtrains_trackdb2" -local file, err = io.open(advtrains.fpath_tdb, "r") -if not file then - local er=err or "Unknown Error" - atprint("Failed loading advtrains save file "..er) -else - local tbl = minetest.deserialize(file:read("*a")) - if type(tbl) == "table" then - advtrains.trackdb=tbl - end - file:close() -end -function advtrains.save_trackdb() - local datastr = minetest.serialize(advtrains.trackdb) - if not datastr then - minetest.log("error", " Failed to serialize trackdb data!") - return - end - local file, err = io.open(advtrains.fpath_tdb, "w") - if err then - return err - end - file:write(datastr) - file:close() -end - ---get_node with pseudoload. ---returns: ---true, conn1, conn2, rely1, rely2, railheight in case everything's right. ---false if it's not a rail or the train does not drive on this rail, but it is loaded or ---nil if the node is neither loaded nor in trackdb ---the distraction between false and nil will be needed only in special cases.(train initpos) -function advtrains.get_rail_info_at(pos, drives_on) - local rdp=advtrains.round_vector_floor_y(pos) - local node=minetest.get_node_or_nil(rdp) - if not node then - --try raildb - local dbe=(advtrains.trackdb[rdp.y] and advtrains.trackdb[rdp.y][rdp.x] and advtrains.trackdb[rdp.y][rdp.x][rdp.z]) - if dbe then - for tt,_ in pairs(drives_on) do - if not dbe.tracktype or tt==dbe.tracktype then - return true, dbe.conn1, dbe.conn2, dbe.rely1 or 0, dbe.rely2 or 0, dbe.railheight or 0 - end - end - else - return nil - end - end - local nodename=node.name - if(not advtrains.is_track_and_drives_on(nodename, drives_on)) then - return false - end - local conn1, conn2, rely1, rely2, railheight, tracktype=advtrains.get_track_connections(node.name, node.param2) - - --already in trackdb? - if not (advtrains.trackdb and advtrains.trackdb[rdp.y] and advtrains.trackdb[rdp.y][rdp.x] and advtrains.trackdb[rdp.y][rdp.x][rdp.z]) then--TODO is this necessary? - if not advtrains.trackdb then advtrains.trackdb={} end - if not advtrains.trackdb[rdp.y] then advtrains.trackdb[rdp.y]={} end - if not advtrains.trackdb[rdp.y][rdp.x] then advtrains.trackdb[rdp.y][rdp.x]={} end - advtrains.trackdb[rdp.y][rdp.x][rdp.z]={ - conn1=conn1, conn2=conn2, - rely1=rely1, rely2=rely2, - railheight=railheight, tracktype=tracktype - } - end - - return true, conn1, conn2, rely1, rely2, railheight -end -function advtrains.reset_trackdb_position(pos) - local rdp=advtrains.round_vector_floor_y(pos) - if not advtrains.trackdb then advtrains.trackdb={} end - if not advtrains.trackdb[rdp.y] then advtrains.trackdb[rdp.y]={} end - if not advtrains.trackdb[rdp.y][rdp.x] then advtrains.trackdb[rdp.y][rdp.x]={} end - advtrains.trackdb[rdp.y][rdp.x][rdp.z]=nil - advtrains.get_rail_info_at(pos, advtrains.all_tracktypes)--to restore it. -end - - diff --git a/advtrains/advtrains/signals.lua b/advtrains/advtrains/signals.lua index 8be65e0..59c5af1 100644 --- a/advtrains/advtrains/signals.lua +++ b/advtrains/advtrains/signals.lua @@ -29,14 +29,15 @@ for r,f in pairs({on="off", off="on"}) do choppy=3, not_blocking_trains=1, not_in_creative_inventory=crea, + save_in_nodedb=1, }, mesecons = {effector = { ["action_"..f] = function (pos, node) - minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2}) + advtrains.np.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2}) end }}, on_rightclick=function(pos, node, clicker) - minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2}) + advtrains.np.swap_node(pos, {name = "advtrains:retrosignal_"..f..rotation, param2 = node.param2}) end, }) advtrains.trackplacer.add_worked("advtrains:retrosignal", r, rotation, nil) @@ -59,6 +60,7 @@ for r,f in pairs({on="off", off="on"}) do choppy=3, not_blocking_trains=1, not_in_creative_inventory=crea, + save_in_nodedb=1, }, light_source = 1, sunlight_propagates=true, diff --git a/advtrains/advtrains/trackdb_legacy.lua b/advtrains/advtrains/trackdb_legacy.lua new file mode 100644 index 0000000..99349e8 --- /dev/null +++ b/advtrains/advtrains/trackdb_legacy.lua @@ -0,0 +1,27 @@ +--trackdb_legacy.lua +--loads the (old) track database. the only use for this is to provide data for rails that haven't been written into the ndb database. +--nothing will be saved. +--if the user thinks that he has loaded every track in his world at least once, he can delete the track database. + +--trackdb[[y][x][z]={conn1, conn2, rely1, rely2, railheight} + + +--trackdb keeps its own save file. +advtrains.fpath_tdb=minetest.get_worldpath().."/advtrains_trackdb2" +local file, err = io.open(advtrains.fpath_tdb, "r") +if not file then + atprint("Not loading a trackdb file.") +else + local tbl = minetest.deserialize(file:read("*a")) + if type(tbl) == "table" then + advtrains.trackdb=tbl + atprint("Loaded trackdb file.") + end + file:close() +end + + + + + + diff --git a/advtrains/advtrains/trackplacer.lua b/advtrains/advtrains/trackplacer.lua index e40cb59..1cb7680 100644 --- a/advtrains/advtrains/trackplacer.lua +++ b/advtrains/advtrains/trackplacer.lua @@ -117,13 +117,13 @@ function tp.bend_rail(originpos, conn, nnpref) return false--dont destroy existing track elseif adj1 and not adj2 then if tr.double_conn[adj1.."_"..newdir] then - minetest.set_node(pos, tr.double_conn[adj1.."_"..newdir]) + advtrains.ndb.swap_node(pos, tr.double_conn[adj1.."_"..newdir]) return true--if exists, connect new rail and old end end return false else if tr.single_conn[newdir] then--just rotate old rail to right orientation - minetest.set_node(pos, tr.single_conn[newdir]) + advtrains.ndb.swap_node(pos, tr.single_conn[newdir]) return true end return false @@ -145,7 +145,7 @@ function tp.placetrack(pos, nnpref, placer, itemstack, pointed_thing) end elseif #p_rails==1 then tp.bend_rail(pos, p_rails[1], nnpref) - minetest.set_node(pos, tr.single_conn[p_rails[1]]) + advtrains.ndb.swap_node(pos, tr.single_conn[p_rails[1]]) local nname=tr.single_conn[p_rails[1]].name if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) @@ -158,7 +158,7 @@ function tp.placetrack(pos, nnpref, placer, itemstack, pointed_thing) if (tr.double_conn[conn1.."_"..conn2]) then tp.bend_rail(pos, conn1, nnpref) tp.bend_rail(pos, conn2, nnpref) - minetest.set_node(pos, tr.double_conn[conn1.."_"..conn2]) + advtrains.ndb.swap_node(pos, tr.double_conn[conn1.."_"..conn2]) local nname=tr.double_conn[conn1.."_"..conn2].name if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) @@ -170,7 +170,7 @@ function tp.placetrack(pos, nnpref, placer, itemstack, pointed_thing) end --not found tp.bend_rail(pos, p_rails[1], nnpref) - minetest.set_node(pos, tr.single_conn[p_rails[1]]) + advtrains.ndb.swap_node(pos, tr.single_conn[p_rails[1]]) local nname=tr.single_conn[p_rails[1]].name if minetest.registered_nodes[nname] and minetest.registered_nodes[nname].after_place_node then minetest.registered_nodes[nname].after_place_node(pos, placer, itemstack, pointed_thing) @@ -245,7 +245,7 @@ minetest.register_craftitem("advtrains:trackworker",{ local modext=tp.tracks[nnprefix].twrotate[suffix] if rotation==modext[#modext] then --increase param2 - minetest.swap_node(pos, {name=nnprefix.."_"..suffix..modext[1], param2=(node.param2+1)%4}) + advtrains.ndb.swap_node(pos, {name=nnprefix.."_"..suffix..modext[1], param2=(node.param2+1)%4}) return else local modpos @@ -254,7 +254,7 @@ minetest.register_craftitem("advtrains:trackworker",{ minetest.chat_send_player(placer:get_player_name(), "This node can't be rotated using the trackworker!") return end - minetest.swap_node(pos, {name=nnprefix.."_"..suffix..modext[modpos+1], param2=node.param2}) + advtrains.ndb.swap_node(pos, {name=nnprefix.."_"..suffix..modext[modpos+1], param2=node.param2}) end advtrains.invalidate_all_paths() end @@ -284,7 +284,7 @@ minetest.register_craftitem("advtrains:trackworker",{ end end local nextsuffix=tp.tracks[nnprefix].twcycle[suffix] - minetest.swap_node(pos, {name=nnprefix.."_"..nextsuffix..rotation, param2=node.param2}) + advtrains.ndb.swap_node(pos, {name=nnprefix.."_"..nextsuffix..rotation, param2=node.param2}) --invalidate trains advtrains.invalidate_all_paths() else diff --git a/advtrains/advtrains/tracks.lua b/advtrains/advtrains/tracks.lua index 671c861..1108a06 100644 --- a/advtrains/advtrains/tracks.lua +++ b/advtrains/advtrains/tracks.lua @@ -235,10 +235,7 @@ advtrains.trackpresets = ap function advtrains.register_tracks(tracktype, def, preset) local function make_switchfunc(suffix_target, mesecon_state) local switchfunc=function(pos, node) - if advtrains.is_train_at_pos(pos) then return end - minetest.set_node(pos, {name=def.nodename_prefix.."_"..suffix_target, param2=node.param2}) - advtrains.invalidate_all_paths() - advtrains.reset_trackdb_position(pos) + advtrains.ndb.swap_node(pos, {name=def.nodename_prefix.."_"..suffix_target, param2=node.param2}) end return switchfunc, {effector = { ["action_"..mesecon_state] = switchfunc, @@ -258,10 +255,12 @@ function advtrains.register_tracks(tracktype, def, preset) rely1=conns.rely1 or 0, rely2=conns.rely2 or 0, railheight=conns.railheight or 0, + on_rightclick=switchfunc, groups = { attached_node=1, ["advtrains_track_"..tracktype]=1, + save_in_nodedb=1, dig_immediate=2, not_in_creative_inventory=(not in_creative_inv and 1 or nil), not_blocking_trains=1, @@ -299,13 +298,10 @@ function advtrains.register_tracks(tracktype, def, preset) end, after_dig_node=function(pos) advtrains.invalidate_all_paths() - advtrains.reset_trackdb_position(pos) + advtrains.ndb.update(pos) end, after_place_node=function(pos) - advtrains.reset_trackdb_position(pos) - end, - on_place_rail=function(pos) - advtrains.reset_trackdb_position(pos) + advtrains.ndb.update(pos) end, }, def.common or {}) --make trackplacer base def @@ -398,10 +394,10 @@ advtrains.detector.clean_step_before = false --The entry already being contained in advtrains.detector.on_node_restore will not trigger an on_train_enter event on the node. (when path is reset, this is saved). function advtrains.detector.enter_node(pos, train_id) local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - atprint("enterNode "..pts.." "..sid(train_id)) + --atprint("enterNode "..pts.." "..sid(train_id)) if advtrains.detector.on_node[pts] then if advtrains.trains[advtrains.detector.on_node[pts]] then - atprint(""..pts.." already occupied") + --atprint(""..pts.." already occupied") return false else advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) @@ -417,9 +413,9 @@ function advtrains.detector.enter_node(pos, train_id) end function advtrains.detector.leave_node(pos, train_id) local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos)) - atprint("leaveNode "..pts.." "..sid(train_id)) + --atprint("leaveNode "..pts.." "..sid(train_id)) if not advtrains.detector.on_node[pts] then - atprint(""..pts.." leave: nothing here") + --atprint(""..pts.." leave: nothing here") return false end if advtrains.detector.on_node[pts]==train_id then @@ -427,7 +423,7 @@ function advtrains.detector.leave_node(pos, train_id) advtrains.detector.on_node[pts]=nil else if advtrains.trains[advtrains.detector.on_node[pts]] then - atprint(""..pts.." occupied by another train") + --atprint(""..pts.." occupied by another train") return false else advtrains.detector.leave_node(pos, advtrains.detector.on_node[pts]) @@ -438,7 +434,7 @@ function advtrains.detector.leave_node(pos, train_id) end --called immediately before invalidating paths function advtrains.detector.setup_restore() - atprint("setup_restore") + --atprint("setup_restore") -- don't execute if it already has been called. For some reason it gets called twice... if advtrains.detector.clean_step_before then return @@ -452,7 +448,7 @@ function advtrains.detector.setup_restore() end --called one step after invalidating paths, when all trains have restored their path and called enter_node for their contents. function advtrains.detector.finalize_restore() - atprint("finalize_restore") + --atprint("finalize_restore") for pts, train_id in pairs(advtrains.detector.on_node_restore) do --atprint("called leave callback "..pts.." "..train_id) advtrains.detector.call_leave_callback(minetest.string_to_pos(pts), train_id) @@ -461,7 +457,7 @@ function advtrains.detector.finalize_restore() advtrains.detector.clean_step_before = false end function advtrains.detector.call_enter_callback(pos, train_id) - atprint("instructed to call enter calback") + --atprint("instructed to call enter calback") local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case local mregnode=minetest.registered_nodes[node.name] @@ -473,7 +469,7 @@ function advtrains.detector.call_enter_callback(pos, train_id) advtrains.atc.trigger_controller_train_enter(pos, train_id) end function advtrains.detector.call_leave_callback(pos, train_id) - atprint("instructed to call leave calback") + --atprint("instructed to call leave calback") local node = minetest.get_node(pos) --this spares the check if node is nil, it has a name in any case local mregnode=minetest.registered_nodes[node.name] -- cgit v1.2.3 From 275579c36425601078716f7f26bb3ac3e5b2ca99 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 17 Jan 2017 15:29:37 +0100 Subject: Don't crash when wagons do not exist but show a warning instead --- advtrains/advtrains/atc.lua | 4 ++-- advtrains/advtrains/trainlogic.lua | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/advtrains/advtrains/atc.lua b/advtrains/advtrains/atc.lua index ece7075..2a4d226 100644 --- a/advtrains/advtrains/atc.lua +++ b/advtrains/advtrains/atc.lua @@ -23,11 +23,11 @@ end function atc.send_command(pos) local pts=minetest.pos_to_string(pos) if atc.controllers[pts] then - atprint("Called send_command at "..pts) + --atprint("Called send_command at "..pts) local train_id = advtrains.detector.on_node[pts] if train_id then if advtrains.trains[train_id] then - atprint("send_command inside if: "..sid(train_id)) + --atprint("send_command inside if: "..sid(train_id)) atc.train_reset_command(train_id) local arrowconn=atc.controllers[pts].arrowconn local train=advtrains.trains[train_id] diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua index c9c7403..5bedfec 100644 --- a/advtrains/advtrains/trainlogic.lua +++ b/advtrains/advtrains/trainlogic.lua @@ -474,7 +474,7 @@ function advtrains.update_trainpart_properties(train_id, invert_flipstate) for i, w_id in ipairs(train.trainparts) do local wagon=nil for aoid,iwagon in pairs(minetest.luaentities) do - if iwagon.is_wagon and iwagon.initialized and iwagon.unique_id==w_id then + if iwagon.is_wagon and iwagon.unique_id==w_id then if wagon then --duplicate atprint("update_trainpart_properties: Removing duplicate wagon with id="..aoid) @@ -488,7 +488,11 @@ function advtrains.update_trainpart_properties(train_id, invert_flipstate) if advtrains.wagon_save[w_id] then --spawn a new and initialize it with the properties from wagon_save wagon=minetest.env:add_entity(train.last_pos, advtrains.wagon_save[w_id].entity_name):get_luaentity() - wagon:init_from_wagon_save(w_id) + if not wagon then + minetest.chat_send_all("[advtrains] Warning: Wagon "..advtrains.wagon_save[w_id].entity_name.." does not exist. Make sure all required modules are loaded!") + else + wagon:init_from_wagon_save(w_id) + end end end if wagon then -- cgit v1.2.3 From 33c3631ef5594b316254b308bcccdf46ef6df09f Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 17 Jan 2017 15:44:11 +0100 Subject: Download recent contributions and put them into the assets directory --- assets/AdvTrains_Additions.zip | Bin 0 -> 889352 bytes assets/Weichenhebel-CooleLokAnimiert.zip | Bin 0 -> 154594 bytes assets/advtrains_wagon.png | Bin 0 -> 72273 bytes assets/dampflock4.blend | Bin 0 -> 1000628 bytes assets/magleves_lockomotive.blend | Bin 0 -> 747680 bytes assets/magleves_track.blend | Bin 0 -> 464960 bytes assets/magleves_wagon.blend | Bin 0 -> 709904 bytes assets/mbbrailtextures/advtrains_dtrack_rail.png | Bin 0 -> 4582 bytes assets/mbbrailtextures/advtrains_dtrack_rail_atc.png | Bin 0 -> 4596 bytes .../advtrains_dtrack_rail_detector_on.png | Bin 0 -> 4579 bytes assets/uban_fancy.blend | Bin 0 -> 1020740 bytes 11 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/AdvTrains_Additions.zip create mode 100644 assets/Weichenhebel-CooleLokAnimiert.zip create mode 100644 assets/advtrains_wagon.png create mode 100644 assets/dampflock4.blend create mode 100644 assets/magleves_lockomotive.blend create mode 100644 assets/magleves_track.blend create mode 100644 assets/magleves_wagon.blend create mode 100644 assets/mbbrailtextures/advtrains_dtrack_rail.png create mode 100644 assets/mbbrailtextures/advtrains_dtrack_rail_atc.png create mode 100644 assets/mbbrailtextures/advtrains_dtrack_rail_detector_on.png create mode 100644 assets/uban_fancy.blend diff --git a/assets/AdvTrains_Additions.zip b/assets/AdvTrains_Additions.zip new file mode 100644 index 0000000..7588acf Binary files /dev/null and b/assets/AdvTrains_Additions.zip differ diff --git a/assets/Weichenhebel-CooleLokAnimiert.zip b/assets/Weichenhebel-CooleLokAnimiert.zip new file mode 100644 index 0000000..1175880 Binary files /dev/null and b/assets/Weichenhebel-CooleLokAnimiert.zip differ diff --git a/assets/advtrains_wagon.png b/assets/advtrains_wagon.png new file mode 100644 index 0000000..143154b Binary files /dev/null and b/assets/advtrains_wagon.png differ diff --git a/assets/dampflock4.blend b/assets/dampflock4.blend new file mode 100644 index 0000000..883c3d3 Binary files /dev/null and b/assets/dampflock4.blend differ diff --git a/assets/magleves_lockomotive.blend b/assets/magleves_lockomotive.blend new file mode 100644 index 0000000..8c82b00 Binary files /dev/null and b/assets/magleves_lockomotive.blend differ diff --git a/assets/magleves_track.blend b/assets/magleves_track.blend new file mode 100644 index 0000000..82f11ef Binary files /dev/null and b/assets/magleves_track.blend differ diff --git a/assets/magleves_wagon.blend b/assets/magleves_wagon.blend new file mode 100644 index 0000000..cc89531 Binary files /dev/null and b/assets/magleves_wagon.blend differ diff --git a/assets/mbbrailtextures/advtrains_dtrack_rail.png b/assets/mbbrailtextures/advtrains_dtrack_rail.png new file mode 100644 index 0000000..bd0c217 Binary files /dev/null and b/assets/mbbrailtextures/advtrains_dtrack_rail.png differ diff --git a/assets/mbbrailtextures/advtrains_dtrack_rail_atc.png b/assets/mbbrailtextures/advtrains_dtrack_rail_atc.png new file mode 100644 index 0000000..7e4c20f Binary files /dev/null and b/assets/mbbrailtextures/advtrains_dtrack_rail_atc.png differ diff --git a/assets/mbbrailtextures/advtrains_dtrack_rail_detector_on.png b/assets/mbbrailtextures/advtrains_dtrack_rail_detector_on.png new file mode 100644 index 0000000..c878324 Binary files /dev/null and b/assets/mbbrailtextures/advtrains_dtrack_rail_detector_on.png differ diff --git a/assets/uban_fancy.blend b/assets/uban_fancy.blend new file mode 100644 index 0000000..f049966 Binary files /dev/null and b/assets/uban_fancy.blend differ -- cgit v1.2.3 From 9c400f7d435b4b1c303f1dd5ac31a8a52b263355 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 17 Jan 2017 20:02:25 +0100 Subject: Model, animate, texture and integrate new subway wagon engine follows! --- advtrains/advtrains_train_subway/init.lua | 10 +++++++--- .../models/advtrains_subway_train.b3d | Bin 95856 -> 0 bytes .../models/advtrains_subway_wagon.b3d | Bin 0 -> 459309 bytes .../textures/advtrains_subway_train.png | Bin 12002 -> 0 bytes .../textures/advtrains_subway_train_inv.png | Bin 900 -> 0 bytes .../textures/advtrains_subway_wagon.png | Bin 0 -> 3618 bytes .../textures/advtrains_subway_wagon_inv.png | Bin 0 -> 900 bytes assets/blender/subway-train.blend | Bin 536268 -> 518888 bytes assets/blender/subway-train.blend1 | Bin 538188 -> 536268 bytes assets/blender/subway-train_animate.blend | Bin 0 -> 568668 bytes assets/blender/subway-train_animate.blend1 | Bin 0 -> 558980 bytes assets/blender/subway-train_animate_mirrored.blend | Bin 0 -> 798328 bytes .../blender/subway-train_animate_mirrored.blend1 | Bin 0 -> 863656 bytes .../subway-train_animate_mirrored_solidify.blend | Bin 0 -> 879916 bytes .../subway-train_animate_mirrored_solidify.blend1 | Bin 0 -> 879884 bytes ...subway-train_animate_mirrored_solidify_uv.blend | Bin 0 -> 832204 bytes ...ubway-train_animate_mirrored_solidify_uv.blend1 | Bin 0 -> 832396 bytes .../subway-train_animate_mirrored_solidify_uv.png | Bin 0 -> 177111 bytes .../subway-train_animate_mirrored_solidify_uv.xcf | Bin 0 -> 369791 bytes 19 files changed, 7 insertions(+), 3 deletions(-) delete mode 100644 advtrains/advtrains_train_subway/models/advtrains_subway_train.b3d create mode 100644 advtrains/advtrains_train_subway/models/advtrains_subway_wagon.b3d delete mode 100644 advtrains/advtrains_train_subway/textures/advtrains_subway_train.png delete mode 100644 advtrains/advtrains_train_subway/textures/advtrains_subway_train_inv.png create mode 100644 advtrains/advtrains_train_subway/textures/advtrains_subway_wagon.png create mode 100644 advtrains/advtrains_train_subway/textures/advtrains_subway_wagon_inv.png create mode 100644 assets/blender/subway-train_animate.blend create mode 100644 assets/blender/subway-train_animate.blend1 create mode 100644 assets/blender/subway-train_animate_mirrored.blend create mode 100644 assets/blender/subway-train_animate_mirrored.blend1 create mode 100644 assets/blender/subway-train_animate_mirrored_solidify.blend create mode 100644 assets/blender/subway-train_animate_mirrored_solidify.blend1 create mode 100644 assets/blender/subway-train_animate_mirrored_solidify_uv.blend create mode 100644 assets/blender/subway-train_animate_mirrored_solidify_uv.blend1 create mode 100644 assets/blender/subway-train_animate_mirrored_solidify_uv.png create mode 100644 assets/blender/subway-train_animate_mirrored_solidify_uv.xcf diff --git a/advtrains/advtrains_train_subway/init.lua b/advtrains/advtrains_train_subway/init.lua index b5bdb18..c68395c 100644 --- a/advtrains/advtrains_train_subway/init.lua +++ b/advtrains/advtrains_train_subway/init.lua @@ -1,7 +1,7 @@ advtrains.register_wagon("subway_wagon", { - mesh="advtrains_subway_train.b3d", - textures = {"advtrains_subway_train.png"}, + mesh="advtrains_subway_wagon.b3d", + textures = {"advtrains_subway_wagon.png"}, drives_on={default=true}, max_speed=15, seats = { @@ -17,7 +17,11 @@ advtrains.register_wagon("subway_wagon", { collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, is_locomotive=true, drops={"default:steelblock 4"}, -}, "Subway Passenger Wagon", "advtrains_subway_train_inv.png") + --custom_on_activate = function(self, dtime_s) + -- atprint("subway custom_on_activate") + -- self.object:set_animation({x=1,y=80}, 15, 0, true) + --end, +}, "Subway Passenger Wagon", "advtrains_subway_wagon_inv.png") --wagons minetest.register_craft({ diff --git a/advtrains/advtrains_train_subway/models/advtrains_subway_train.b3d b/advtrains/advtrains_train_subway/models/advtrains_subway_train.b3d deleted file mode 100644 index a824d33..0000000 Binary files a/advtrains/advtrains_train_subway/models/advtrains_subway_train.b3d and /dev/null differ diff --git a/advtrains/advtrains_train_subway/models/advtrains_subway_wagon.b3d b/advtrains/advtrains_train_subway/models/advtrains_subway_wagon.b3d new file mode 100644 index 0000000..8f35769 Binary files /dev/null and b/advtrains/advtrains_train_subway/models/advtrains_subway_wagon.b3d differ diff --git a/advtrains/advtrains_train_subway/textures/advtrains_subway_train.png b/advtrains/advtrains_train_subway/textures/advtrains_subway_train.png deleted file mode 100644 index 1d569f3..0000000 Binary files a/advtrains/advtrains_train_subway/textures/advtrains_subway_train.png and /dev/null differ diff --git a/advtrains/advtrains_train_subway/textures/advtrains_subway_train_inv.png b/advtrains/advtrains_train_subway/textures/advtrains_subway_train_inv.png deleted file mode 100644 index 1d0e809..0000000 Binary files a/advtrains/advtrains_train_subway/textures/advtrains_subway_train_inv.png and /dev/null differ diff --git a/advtrains/advtrains_train_subway/textures/advtrains_subway_wagon.png b/advtrains/advtrains_train_subway/textures/advtrains_subway_wagon.png new file mode 100644 index 0000000..079d797 Binary files /dev/null and b/advtrains/advtrains_train_subway/textures/advtrains_subway_wagon.png differ diff --git a/advtrains/advtrains_train_subway/textures/advtrains_subway_wagon_inv.png b/advtrains/advtrains_train_subway/textures/advtrains_subway_wagon_inv.png new file mode 100644 index 0000000..1d0e809 Binary files /dev/null and b/advtrains/advtrains_train_subway/textures/advtrains_subway_wagon_inv.png differ diff --git a/assets/blender/subway-train.blend b/assets/blender/subway-train.blend index 690d87b..01bb233 100644 Binary files a/assets/blender/subway-train.blend and b/assets/blender/subway-train.blend differ diff --git a/assets/blender/subway-train.blend1 b/assets/blender/subway-train.blend1 index 86d1f92..690d87b 100644 Binary files a/assets/blender/subway-train.blend1 and b/assets/blender/subway-train.blend1 differ diff --git a/assets/blender/subway-train_animate.blend b/assets/blender/subway-train_animate.blend new file mode 100644 index 0000000..75cdc52 Binary files /dev/null and b/assets/blender/subway-train_animate.blend differ diff --git a/assets/blender/subway-train_animate.blend1 b/assets/blender/subway-train_animate.blend1 new file mode 100644 index 0000000..04171fc Binary files /dev/null and b/assets/blender/subway-train_animate.blend1 differ diff --git a/assets/blender/subway-train_animate_mirrored.blend b/assets/blender/subway-train_animate_mirrored.blend new file mode 100644 index 0000000..aa11c34 Binary files /dev/null and b/assets/blender/subway-train_animate_mirrored.blend differ diff --git a/assets/blender/subway-train_animate_mirrored.blend1 b/assets/blender/subway-train_animate_mirrored.blend1 new file mode 100644 index 0000000..4d64915 Binary files /dev/null and b/assets/blender/subway-train_animate_mirrored.blend1 differ diff --git a/assets/blender/subway-train_animate_mirrored_solidify.blend b/assets/blender/subway-train_animate_mirrored_solidify.blend new file mode 100644 index 0000000..7a25b6f Binary files /dev/null and b/assets/blender/subway-train_animate_mirrored_solidify.blend differ diff --git a/assets/blender/subway-train_animate_mirrored_solidify.blend1 b/assets/blender/subway-train_animate_mirrored_solidify.blend1 new file mode 100644 index 0000000..f81e303 Binary files /dev/null and b/assets/blender/subway-train_animate_mirrored_solidify.blend1 differ diff --git a/assets/blender/subway-train_animate_mirrored_solidify_uv.blend b/assets/blender/subway-train_animate_mirrored_solidify_uv.blend new file mode 100644 index 0000000..b05b0a5 Binary files /dev/null and b/assets/blender/subway-train_animate_mirrored_solidify_uv.blend differ diff --git a/assets/blender/subway-train_animate_mirrored_solidify_uv.blend1 b/assets/blender/subway-train_animate_mirrored_solidify_uv.blend1 new file mode 100644 index 0000000..145137b Binary files /dev/null and b/assets/blender/subway-train_animate_mirrored_solidify_uv.blend1 differ diff --git a/assets/blender/subway-train_animate_mirrored_solidify_uv.png b/assets/blender/subway-train_animate_mirrored_solidify_uv.png new file mode 100644 index 0000000..e63a7f2 Binary files /dev/null and b/assets/blender/subway-train_animate_mirrored_solidify_uv.png differ diff --git a/assets/blender/subway-train_animate_mirrored_solidify_uv.xcf b/assets/blender/subway-train_animate_mirrored_solidify_uv.xcf new file mode 100644 index 0000000..42adace Binary files /dev/null and b/assets/blender/subway-train_animate_mirrored_solidify_uv.xcf differ -- cgit v1.2.3 From b6e2aeea71394431889e9b554f190dda4adb0305 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 17 Jan 2017 21:54:50 +0100 Subject: Add animation for steam engine I needed to completely rewrite the animation because irrlicht couldn't handle the animation NathanS created. --- advtrains/advtrains_train_steam/init.lua | 13 +++++++------ .../models/advtrains_engine_steam.b3d | Bin 298687 -> 437126 bytes .../textures/advtrains_newlocomotive.png | Bin 31800 -> 31915 bytes assets/blender/engine-with-animation_newtry.blend | Bin 0 -> 638904 bytes assets/blender/engine-with-animation_newtry.blend1 | Bin 0 -> 615608 bytes 5 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 assets/blender/engine-with-animation_newtry.blend create mode 100644 assets/blender/engine-with-animation_newtry.blend1 diff --git a/advtrains/advtrains_train_steam/init.lua b/advtrains/advtrains_train_steam/init.lua index 5010902..232ffe1 100644 --- a/advtrains/advtrains_train_steam/init.lua +++ b/advtrains/advtrains_train_steam/init.lua @@ -21,12 +21,13 @@ advtrains.register_wagon("newlocomotive", { visual_size = {x=1, y=1}, wagon_span=1.85, collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, - --update_animation=function(self, velocity) - --if self.old_anim_velocity~=advtrains.abs_ceil(velocity) then - -- self.object:set_animation({x=1,y=60}, 100)--math.floor(velocity)) - --self.old_anim_velocity=advtrains.abs_ceil(velocity) - --end - --end, + update_animation=function(self, velocity) + if self.old_anim_velocity~=advtrains.abs_ceil(velocity) then + atprint("set_anim",advtrains.abs_ceil(velocity)*15) + self.object:set_animation({x=1,y=80}, advtrains.abs_ceil(velocity)*15, 0, true) + self.old_anim_velocity=advtrains.abs_ceil(velocity) + end + end, custom_on_activate = function(self, staticdata_table, dtime_s) minetest.add_particlespawner({ amount = 10, diff --git a/advtrains/advtrains_train_steam/models/advtrains_engine_steam.b3d b/advtrains/advtrains_train_steam/models/advtrains_engine_steam.b3d index 36bdd15..6a92f57 100644 Binary files a/advtrains/advtrains_train_steam/models/advtrains_engine_steam.b3d and b/advtrains/advtrains_train_steam/models/advtrains_engine_steam.b3d differ diff --git a/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive.png b/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive.png index e461bc7..4b27e77 100644 Binary files a/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive.png and b/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive.png differ diff --git a/assets/blender/engine-with-animation_newtry.blend b/assets/blender/engine-with-animation_newtry.blend new file mode 100644 index 0000000..101dc71 Binary files /dev/null and b/assets/blender/engine-with-animation_newtry.blend differ diff --git a/assets/blender/engine-with-animation_newtry.blend1 b/assets/blender/engine-with-animation_newtry.blend1 new file mode 100644 index 0000000..77d82d4 Binary files /dev/null and b/assets/blender/engine-with-animation_newtry.blend1 differ -- cgit v1.2.3 From 262826fb8c7e2d5b64b2be1af07fcab1b24f0bd2 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 17 Jan 2017 21:59:32 +0100 Subject: Correct view offset and wagon_span on new subway wagon --- advtrains/advtrains_train_subway/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advtrains/advtrains_train_subway/init.lua b/advtrains/advtrains_train_subway/init.lua index c68395c..b105f1a 100644 --- a/advtrains/advtrains_train_subway/init.lua +++ b/advtrains/advtrains_train_subway/init.lua @@ -8,12 +8,12 @@ advtrains.register_wagon("subway_wagon", { { name="Default Seat (driver stand)", attach_offset={x=0, y=10, z=0}, - view_offset={x=0, y=6, z=0}, + view_offset={x=0, y=0, z=0}, driving_ctrl_access=true, }, }, visual_size = {x=1, y=1}, - wagon_span=1.8, + wagon_span=2, collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, is_locomotive=true, drops={"default:steelblock 4"}, -- cgit v1.2.3 From 2f5ebd63c38932dbda30b96e8ce20e70474b1f15 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 17 Jan 2017 22:31:29 +0100 Subject: Add detailed steam engine contributed by mbb and Krokoschlange --- advtrains/advtrains_train_steam/init.lua | 65 ++++++++++++++++++++- .../models/advtrains_detailed_steam_engine.b3d | Bin 0 -> 468002 bytes .../textures/advtrains_detailed_steam_engine.png | Bin 0 -> 61988 bytes .../textures/advtrains_engine_steam.png | Bin 0 -> 31915 bytes .../textures/advtrains_engine_steam_inv.png | Bin 0 -> 469 bytes .../textures/advtrains_newlocomotive.png | Bin 31915 -> 0 bytes .../textures/advtrains_newlocomotive_inv.png | Bin 469 -> 0 bytes .../dampflock4pipe_animated.blend | Bin 0 -> 859028 bytes .../dampflock4pipe_animated.blend1 | Bin 0 -> 859028 bytes 9 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 advtrains/advtrains_train_steam/models/advtrains_detailed_steam_engine.b3d create mode 100644 advtrains/advtrains_train_steam/textures/advtrains_detailed_steam_engine.png create mode 100644 advtrains/advtrains_train_steam/textures/advtrains_engine_steam.png create mode 100644 advtrains/advtrains_train_steam/textures/advtrains_engine_steam_inv.png delete mode 100644 advtrains/advtrains_train_steam/textures/advtrains_newlocomotive.png delete mode 100644 advtrains/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png create mode 100644 assets/Weichenhebel-CooleLokAnimiert/dampflock4pipe_animated.blend create mode 100644 assets/Weichenhebel-CooleLokAnimiert/dampflock4pipe_animated.blend1 diff --git a/advtrains/advtrains_train_steam/init.lua b/advtrains/advtrains_train_steam/init.lua index 232ffe1..22f525f 100644 --- a/advtrains/advtrains_train_steam/init.lua +++ b/advtrains/advtrains_train_steam/init.lua @@ -1,6 +1,6 @@ advtrains.register_wagon("newlocomotive", { mesh="advtrains_engine_steam.b3d", - textures = {"advtrains_newlocomotive.png"}, + textures = {"advtrains_engine_steam.png"}, is_locomotive=true, drives_on={default=true}, max_speed=10, @@ -23,7 +23,6 @@ advtrains.register_wagon("newlocomotive", { collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, update_animation=function(self, velocity) if self.old_anim_velocity~=advtrains.abs_ceil(velocity) then - atprint("set_anim",advtrains.abs_ceil(velocity)*15) self.object:set_animation({x=1,y=80}, advtrains.abs_ceil(velocity)*15, 0, true) self.old_anim_velocity=advtrains.abs_ceil(velocity) end @@ -56,7 +55,67 @@ advtrains.register_wagon("newlocomotive", { }) end, drops={"default:steelblock 4"}, -}, "Steam Engine", "advtrains_newlocomotive_inv.png") +}, "Steam Engine", "advtrains_engine_steam_inv.png") + +advtrains.register_wagon("detailed_steam_engine", { + mesh="advtrains_detailed_steam_engine.b3d", + textures = {"advtrains_detailed_steam_engine.png"}, + is_locomotive=true, + drives_on={default=true}, + max_speed=10, + seats = { + { + name="Driver Stand (left)", + attach_offset={x=-5, y=10, z=-10}, + view_offset={x=0, y=6, z=0}, + driving_ctrl_access=true, + }, + { + name="Driver Stand (right)", + attach_offset={x=5, y=10, z=-10}, + view_offset={x=0, y=6, z=0}, + driving_ctrl_access=true, + }, + }, + visual_size = {x=1, y=1}, + wagon_span=2.05, + collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0}, + update_animation=function(self, velocity) + if self.old_anim_velocity~=advtrains.abs_ceil(velocity) then + self.object:set_animation({x=1,y=80}, advtrains.abs_ceil(velocity)*15, 0, true) + self.old_anim_velocity=advtrains.abs_ceil(velocity) + end + end, + custom_on_activate = function(self, staticdata_table, dtime_s) + minetest.add_particlespawner({ + amount = 10, + time = 0, + -- ^ If time is 0 has infinite lifespan and spawns the amount on a per-second base + minpos = {x=0, y=2.3, z=1.45}, + maxpos = {x=0, y=2.3, z=1.4}, + minvel = {x=-0.2, y=1.8, z=-0.2}, + maxvel = {x=0.2, y=2, z=0.2}, + minacc = {x=0, y=-0.1, z=0}, + maxacc = {x=0, y=-0.3, z=0}, + minexptime = 2, + maxexptime = 4, + minsize = 1, + maxsize = 5, + -- ^ The particle's properties are random values in between the bounds: + -- ^ minpos/maxpos, minvel/maxvel (velocity), minacc/maxacc (acceleration), + -- ^ minsize/maxsize, minexptime/maxexptime (expirationtime) + collisiondetection = true, + -- ^ collisiondetection: if true uses collision detection + vertical = false, + -- ^ vertical: if true faces player using y axis only + texture = "smoke_puff.png", + -- ^ Uses texture (string) + attached = self.object, + }) + end, + drops={"default:steelblock 4"}, +}, "Detailed Steam Engine", "advtrains_engine_steam_inv.png") + advtrains.register_wagon("wagon_default", { mesh="advtrains_passenger_wagon.b3d", textures = {"advtrains_wagon.png"}, diff --git a/advtrains/advtrains_train_steam/models/advtrains_detailed_steam_engine.b3d b/advtrains/advtrains_train_steam/models/advtrains_detailed_steam_engine.b3d new file mode 100644 index 0000000..7418d8a Binary files /dev/null and b/advtrains/advtrains_train_steam/models/advtrains_detailed_steam_engine.b3d differ diff --git a/advtrains/advtrains_train_steam/textures/advtrains_detailed_steam_engine.png b/advtrains/advtrains_train_steam/textures/advtrains_detailed_steam_engine.png new file mode 100644 index 0000000..eab4dc8 Binary files /dev/null and b/advtrains/advtrains_train_steam/textures/advtrains_detailed_steam_engine.png differ diff --git a/advtrains/advtrains_train_steam/textures/advtrains_engine_steam.png b/advtrains/advtrains_train_steam/textures/advtrains_engine_steam.png new file mode 100644 index 0000000..4b27e77 Binary files /dev/null and b/advtrains/advtrains_train_steam/textures/advtrains_engine_steam.png differ diff --git a/advtrains/advtrains_train_steam/textures/advtrains_engine_steam_inv.png b/advtrains/advtrains_train_steam/textures/advtrains_engine_steam_inv.png new file mode 100644 index 0000000..8d3fafb Binary files /dev/null and b/advtrains/advtrains_train_steam/textures/advtrains_engine_steam_inv.png differ diff --git a/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive.png b/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive.png deleted file mode 100644 index 4b27e77..0000000 Binary files a/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive.png and /dev/null differ diff --git a/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png b/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png deleted file mode 100644 index 8d3fafb..0000000 Binary files a/advtrains/advtrains_train_steam/textures/advtrains_newlocomotive_inv.png and /dev/null differ diff --git a/assets/Weichenhebel-CooleLokAnimiert/dampflock4pipe_animated.blend b/assets/Weichenhebel-CooleLokAnimiert/dampflock4pipe_animated.blend new file mode 100644 index 0000000..cf3b1da Binary files /dev/null and b/assets/Weichenhebel-CooleLokAnimiert/dampflock4pipe_animated.blend differ diff --git a/assets/Weichenhebel-CooleLokAnimiert/dampflock4pipe_animated.blend1 b/assets/Weichenhebel-CooleLokAnimiert/dampflock4pipe_animated.blend1 new file mode 100644 index 0000000..cbc247b Binary files /dev/null and b/assets/Weichenhebel-CooleLokAnimiert/dampflock4pipe_animated.blend1 differ -- cgit v1.2.3 From ea01c9605cc717df118b9d4f5ca5aa1ec1e501b9 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 17 Jan 2017 22:34:15 +0100 Subject: Update readme.txt with contributions --- advtrains/advtrains/readme.txt | 23 ----------------------- advtrains/readme.txt | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 23 deletions(-) delete mode 100644 advtrains/advtrains/readme.txt create mode 100644 advtrains/readme.txt diff --git a/advtrains/advtrains/readme.txt b/advtrains/advtrains/readme.txt deleted file mode 100644 index ad093bd..0000000 --- a/advtrains/advtrains/readme.txt +++ /dev/null @@ -1,23 +0,0 @@ - -## ADVTRAINS ## realistic trains in Minetest! -by orwell96 and contributors(see below) - -For up-to-date information, visit https://forum.minetest.net/viewtopic.php?f=9&t=14726 - - -Manual: -If manual.pdf is not present (which is the case when you downloaded the zip file), see https://github.com/orwell96/advtrains/blob/master/manual.pdf - -License of code: LGPL 2.1 -License of media: CC-BY-NC-SA 3.0 - -Contributions: - -Gravel Texture : from Minetest Game -Initial rail model/texture : DS-minetest -Models for signals/bumpers : mbb -Steam engine / wagon texture: mbb -Industrial engine/wagons : mbb -Inventory images : mbb -Small code contributions : NaruTrey / gpcf -Mod Description : hajo \ No newline at end of file diff --git a/advtrains/readme.txt b/advtrains/readme.txt new file mode 100644 index 0000000..40516e4 --- /dev/null +++ b/advtrains/readme.txt @@ -0,0 +1,25 @@ + +## ADVTRAINS ## realistic trains in Minetest! +by orwell96 and contributors(see below) + +For up-to-date information, visit https://forum.minetest.net/viewtopic.php?f=9&t=14726 + + +Manual: +If manual.pdf is not present (which is the case when you downloaded the zip file), see https://github.com/orwell96/advtrains/blob/master/manual.pdf + +License of code: LGPL 2.1 +License of media: CC-BY-NC-SA 3.0 + +Contributions: + +Gravel Texture : from Minetest Game +Initial rail model/texture : DS-minetest +Models for signals/bumpers : mbb +Steam engine / wagon texture: mbb +Detailed Steam engine : mbb / Krokoschlange(animation) +Industrial engine/wagons : mbb +Inventory images : mbb +Small code contributions : NaruTrey / gpcf +Mod Description : hajo +If I forgot someone please punish me for that. \ No newline at end of file -- cgit v1.2.3 From 4bc5163787c6c4c42fd14016c1c5103529d0e239 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 17 Jan 2017 22:35:33 +0100 Subject: update zip file and disable debug messages --- advtrains.zip | Bin 4533407 -> 4810179 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/advtrains.zip b/advtrains.zip index b2c36cb..3eafd1a 100644 Binary files a/advtrains.zip and b/advtrains.zip differ -- cgit v1.2.3