diff options
author | 1F616EMO <root@1f616emo.xyz> | 2025-04-14 20:18:18 +0800 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2025-05-05 21:05:17 +0200 |
commit | 950ac381214883505206e847700fbafc70973c52 (patch) | |
tree | 93dea07fd05062d419085e711e9d336240b52eea | |
parent | d9605e0c20e47f691893e3a5edafcd7a35a770f7 (diff) | |
download | advtrains-950ac381214883505206e847700fbafc70973c52.tar.gz advtrains-950ac381214883505206e847700fbafc70973c52.tar.bz2 advtrains-950ac381214883505206e847700fbafc70973c52.zip |
Allow using def.suitable_substrate to override default substrate detection
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.
-rw-r--r-- | advtrains/track_reg_helper.lua | 8 |
1 files 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) |