aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2021-06-29 16:12:29 +0200
committerorwell96 <orwell@bleipb.de>2021-06-29 16:12:29 +0200
commit9b0ec771d70c4bdc97a08f480a1a9c31b1ee8ca1 (patch)
treef34e6f6b638a7bb9ce99c36dec77c4670c6eb836
parent0efe7ef1f3bf8d12d4aaf1b58a600c514953201c (diff)
downloadadvtrains-9b0ec771d70c4bdc97a08f480a1a9c31b1ee8ca1.tar.gz
advtrains-9b0ec771d70c4bdc97a08f480a1a9c31b1ee8ca1.tar.bz2
advtrains-9b0ec771d70c4bdc97a08f480a1a9c31b1ee8ca1.zip
Train-World collisions: Collide only with 'normal'-drawtype nodes.
As per discussion on the forum (https://forum.minetest.net/viewtopic.php?p=396745#p396745), changes the train-world collision logic to make trains only collide with nodes that are solid cubes. This allows for more creative freedom, but shifts the responsibility of building realistic railways to the players. In the future, a more sophisticated environment collision system might be invented, but this is low-priority and should be optional to save CPU.
-rw-r--r--advtrains/trainlogic.lua43
1 files changed, 8 insertions, 35 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index 0fb778b..7093929 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -1369,43 +1369,16 @@ end
--not blocking trains group
function advtrains.train_collides(node)
- if node and minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].walkable then
- if not minetest.registered_nodes[node.name].groups.not_blocking_trains then
+ if node and minetest.registered_nodes[node.name] then
+ local ndef = minetest.registered_nodes[node.name]
+ -- if the node is drawtype normal (that is a full cube) then it does collide
+ if ndef.drawtype == "normal" then
+ -- except if it is not_blocking_trains
+ if ndef.groups.not_blocking_trains and ndef.groups.not_blocking_trains ~= 0 then
+ return false
+ end
return true
end
end
return false
end
-
-local nonblocknodes={
- "default:fence_wood",
- "default:fence_acacia_wood",
- "default:fence_aspen_wood",
- "default:fence_pine_wood",
- "default:fence_junglewood",
- "default:torch",
- "bones:bones",
-
- "default:sign_wall",
- "signs:sign_wall",
- "signs:sign_wall_blue",
- "signs:sign_wall_brown",
- "signs:sign_wall_orange",
- "signs:sign_wall_green",
- "signs:sign_yard",
- "signs:sign_wall_white_black",
- "signs:sign_wall_red",
- "signs:sign_wall_white_red",
- "signs:sign_wall_yellow",
- "signs:sign_post",
- "signs:sign_hanging",
-
-
-}
-minetest.after(0, function()
- for _,name in ipairs(nonblocknodes) do
- if minetest.registered_nodes[name] then
- minetest.registered_nodes[name].groups.not_blocking_trains=1
- end
- end
-end)