From 5f233819f85c019d4d98c03866b864896f5f75c5 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Wed, 3 Apr 2024 06:19:11 +0000 Subject: [PATCH] Fix startup --- mods/ENVIRONMENT/mcl_physics/api.lua | 6 +++--- mods/ENVIRONMENT/mcl_physics/init.lua | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_physics/api.lua b/mods/ENVIRONMENT/mcl_physics/api.lua index b744d774f..6453cdac4 100644 --- a/mods/ENVIRONMENT/mcl_physics/api.lua +++ b/mods/ENVIRONMENT/mcl_physics/api.lua @@ -2,8 +2,8 @@ local mod = mcl_physics local registered_environment_effects = {} -function mod.register_enviornment_effect(effect) - local list = registered_effects +function mod.register_environment_effect(effect) + local list = registered_environment_effects list[#list + 1] = effect end @@ -22,7 +22,7 @@ function mod.get_environment_effect(pos, vel, staticdata, mass) end end - if vector.length(v) > 0.01 or vector.length(a) > vector.length(a) > 0.01 then + if vector.length(v) > 0.01 or vector.length(a) > 0.01 then return v,a else return -- nil,nil diff --git a/mods/ENVIRONMENT/mcl_physics/init.lua b/mods/ENVIRONMENT/mcl_physics/init.lua index fa072e20b..4652466b1 100644 --- a/mods/ENVIRONMENT/mcl_physics/init.lua +++ b/mods/ENVIRONMENT/mcl_physics/init.lua @@ -7,7 +7,7 @@ dofile(modpath.."/api.lua") -- TODO: move to Flowlib local FLOW_SPEED = 1.39 -mod.register_effect(function(pos, vel, staticdata) +mod.register_environment_effect(function(pos, vel, staticdata) -- Get the node and node definition local node = minetest.get_node_or_nil(pos) if not node then return end @@ -36,5 +36,16 @@ mod.register_effect(function(pos, vel, staticdata) end) -- Node effects -mod.register_effect +mod.register_environment_effect(function(pos, vel, staticdata) + local pos_r = vector.round(pos) + local node = minetest.get_node(pos_r) + local nodedef = minetest.registered_nodes[node.name] + if not nodedef then return end + + if nodedef._mcl_physics_effect then + return nodedef._mcl_physics_effect(pos, vel, staticdata) + end + + return -- nil,nil +end)