diff options
author | orwell96 <orwell@bleipb.de> | 2017-12-18 21:44:36 +0100 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2017-12-18 23:09:23 +0100 |
commit | ef7d73e1cd69a2d23f95cd1bb55383ff17e591a5 (patch) | |
tree | 899b098706aa5bd6ff3f0443c41d21f5aac9a9da | |
parent | a152a188a65966a364614cdb0aa2613758c46f67 (diff) | |
download | basic_trains-ef7d73e1cd69a2d23f95cd1bb55383ff17e591a5.tar.gz basic_trains-ef7d73e1cd69a2d23f95cd1bb55383ff17e591a5.tar.bz2 basic_trains-ef7d73e1cd69a2d23f95cd1bb55383ff17e591a5.zip |
Rewrite rail connection system...
...to support an arbitrary number of connections for rails, which leads to these new features:
- switches now get recognized by the trackworker correctly
- ability to add real rail crosses
During this, I also rewrote the rail registering system and the conway function (important part of path prediction)
Note, developers: the track preset format changed, you might need to rewrite them according to the presets in tracks.lua if you wrote your own
(possibly breaks advcarts)
-rw-r--r-- | advtrains_train_subway/init.lua | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/advtrains_train_subway/init.lua b/advtrains_train_subway/init.lua index 9dd6f28..310ccf8 100644 --- a/advtrains_train_subway/init.lua +++ b/advtrains_train_subway/init.lua @@ -128,8 +128,14 @@ minetest.register_craftitem(":advtrains:subway_train", { minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) return 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 tconns=advtrains.get_track_connections(node.name, node.param2) + local yaw = placer:get_look_horizontal() + (math.pi/2) + local plconnid = advtrains.yawToClosestConn(yaw, tconns) + + local prevpos = advtrains.get_adjacent_rail(pointed_thing.under, tconns, plconnid, prototype.drives_on) + if not prevpos then return end + local id=advtrains.create_new_train_at(pointed_thing.under, prevpos) for i=1,3 do local ob=minetest.add_entity(pointed_thing.under, "advtrains:subway_wagon") |