diff options
author | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2018-03-21 18:30:48 +0100 |
---|---|---|
committer | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2018-03-21 18:30:48 +0100 |
commit | cb219eff2cf7ba4e95f56fc891ca43b766416b54 (patch) | |
tree | 48f819bd128f4f92ef453588c6aab50f1d4050a2 | |
parent | 3b353a049eda3964660aa36b2e6026120f62d714 (diff) | |
download | advtrains_construction_train-cb219eff2cf7ba4e95f56fc891ca43b766416b54.tar.gz advtrains_construction_train-cb219eff2cf7ba4e95f56fc891ca43b766416b54.tar.bz2 advtrains_construction_train-cb219eff2cf7ba4e95f56fc891ca43b766416b54.zip |
fixed bug with diagonal slopes, replaces blocks with cobble so the gravel doesn't drop
-rw-r--r-- | init.lua | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -13,7 +13,7 @@ advtrains.register_wagon("construction_train", { mesh="advtrains_subway_wagon.b3d", textures = {"advtrains_subway_wagon.png"}, drives_on={default=true}, - max_speed=15, + max_speed=2, seats = { { name="Driver stand", @@ -88,24 +88,27 @@ advtrains.register_wagon("construction_train", { rpos.y = rpos.y -1 -- Find train tracks, if we find train tracks, we will only replace blocking nodes local tracks_below = false - for x = -2,2 do - for z = -2,2 do - local ps = {x=rpos.x+x, y=rpos.y, z=rpos.z+z} - if minetest.get_item_group(minetest.get_node(ps).name, "advtrains_track") > 0 then - tracks_below = true - minetest.chat_send_all("Found a track!") - break - end - end + for y =-1,0 do + for x = -2,2 do + for z = -2,2 do + local ps = {x=rpos.x+x, y=rpos.y+y, z=rpos.z+z} + if minetest.get_item_group(minetest.get_node(ps).name, "advtrains_track") > 0 then + tracks_below = true + minetest.chat_send_all("Found a track!") + break + end + end + end end for x = -1,1 do for z = -1,1 do local ps = {x=rpos.x+x, y=rpos.y, z=rpos.z+z} - if (not tracks_below) or (minetest.get_item_group(minetest.get_node(ps).name, "not_blocking_trains") == 0 and minetest.get_node(ps).name ~= "air" ) then + local name = minetest.get_node(ps).name + if (not tracks_below) or (minetest.get_item_group(name, "not_blocking_trains") == 0 and minetest.get_node(ps).walkable and name ~= "air" ) then minetest.set_node(ps, {name = "default:gravel"}) ps.y = ps.y-1 - if minetest.get_node(ps).name == "air" then + if not minetest.get_node(ps).walkable then minetest.set_node(ps, {name = "default:cobble"}) end end |