summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.lua27
1 files changed, 15 insertions, 12 deletions
diff --git a/init.lua b/init.lua
index 985e6f6..dc54dbc 100644
--- a/init.lua
+++ b/init.lua
@@ -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