Adds def.suitable_substrate to track definition that takes upos and decide whether a surface is suitable for that track. Not sure if this is a fix of regression or new feature, cuz I have seen def.suitable_substrate being used and worked before.
I do think this is a fix that restores an old API, since I find it
removed in the diff that reworks the API (950d6f640) after being added
in 7977776. That commit specifically was made to help linetrack
compatibility, so merging this will help in fixing linetrack to work for
2.5. +1 to merge!
---
advtrains/track_reg_helper.lua | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/advtrains/track_reg_helper.lua b/advtrains/track_reg_helper.lua
index 31741d6..e2f71e8 100644
--- a/advtrains/track_reg_helper.lua+++ b/advtrains/track_reg_helper.lua
@@ -484,6 +484,11 @@ local function append_statemap_suffix(state_map, nnpref, rot)
return t
end
+function advtrains.default_suitable_substrate(upos)+ return core.registered_nodes[core.get_node(upos).name]+ and core.registered_nodes[core.get_node(upos).name].walkable+end+function advtrains.register_tracks(tracktype, def, preset)
if not preset.v25_format then
error("advtrains.register_tracks(): A track preset for pre-v2.5 is used with advtrains 2.5+. Mod probably defines own track preset instead of using it from the advtrains.ap table! Please check track mod compatibility!")
@@ -509,8 +514,7 @@ function advtrains.register_tracks(tracktype, def, preset)
return itemstack, false
end
if minetest.registered_nodes[minetest.get_node(pos).name] and minetest.registered_nodes[minetest.get_node(pos).name].buildable_to then
- local s = minetest.registered_nodes[minetest.get_node(upos).name] and minetest.registered_nodes[minetest.get_node(upos).name].walkable- if s then+ if (def.suitable_substrate and def.suitable_substrate or advtrains.default_suitable_substrate)(upos) then -- minetest.chat_send_all(nnprefix)
local yaw = placer:get_look_horizontal()
advtrains.trackplacer.place_track(pos, nnprefix, name, yaw)
--
2.49.0