From f5f6e232cc9e1f6e33810a8b04a8f652fb90091e Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 9 Apr 2021 16:46:41 +0200 Subject: [PATCH 1/4] Attemp to fix #1513 --- mods/ITEMS/REDSTONE/mesecons/internal.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index ef12bcc48..6a90b98eb 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -52,8 +52,10 @@ local get_node_force = mesecon.get_node_force local receptor_get_rules = mesecon.receptor_get_rules local invertRule = mesecon.invertRule local copy, insert = table.copy, table.insert -local registered_nodes = minetest.registered_nodes - +local registered_nodes +minetest.register_on_mods_loaded(function() + registered_nodes = minetest.registered_nodes +end) -- General function mesecon.get_effector(nodename) if registered_nodes[nodename] From 3375e903ce87c4a5f07d8d84aea682c914e1db12 Mon Sep 17 00:00:00 2001 From: kay27 Date: Fri, 9 Apr 2021 18:52:03 +0400 Subject: [PATCH 2/4] [mesecons] Fix attempt to call upvalue in internal.lua --- mods/ITEMS/REDSTONE/mesecons/internal.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index 6a90b98eb..a552fed70 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -49,7 +49,6 @@ local equals = vector.equals local get_node_force = mesecon.get_node_force -local receptor_get_rules = mesecon.receptor_get_rules local invertRule = mesecon.invertRule local copy, insert = table.copy, table.insert local registered_nodes @@ -137,7 +136,7 @@ function mesecon.is_receptor(nodename) return false end -function mesecon.receptor_get_rules(node) +local function receptor_get_rules(node) local receptor = mesecon.get_receptor(node.name) if receptor then local rules = receptor.rules @@ -150,6 +149,7 @@ function mesecon.receptor_get_rules(node) return mesecon.rules.default end +mesecon.receptor_get_rules = receptor_get_rules -- Effectors -- Nodes that can be powered by mesecons From d50fd06c82193e9e83efb2d1f3d77e629fa78696 Mon Sep 17 00:00:00 2001 From: kay27 Date: Fri, 9 Apr 2021 19:03:45 +0400 Subject: [PATCH 3/4] Revert "Attemp to fix #1513" in favour of next commit 3375e903ce This reverts commit f5f6e232cc9e1f6e33810a8b04a8f652fb90091e. --- mods/ITEMS/REDSTONE/mesecons/internal.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index a552fed70..f4ed9df4e 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -51,10 +51,8 @@ local equals = vector.equals local get_node_force = mesecon.get_node_force local invertRule = mesecon.invertRule local copy, insert = table.copy, table.insert -local registered_nodes -minetest.register_on_mods_loaded(function() - registered_nodes = minetest.registered_nodes -end) +local registered_nodes = minetest.registered_nodes + -- General function mesecon.get_effector(nodename) if registered_nodes[nodename] From 849823af1f4d381f85fe8fed4faa96171c92284a Mon Sep 17 00:00:00 2001 From: epCode Date: Fri, 9 Apr 2021 14:33:14 -0700 Subject: [PATCH 4/4] Add player pushing ;) --- mods/PLAYER/mcl_playerplus/init.lua | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 52c87a514..a9f6bd5a1 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -22,11 +22,48 @@ local mcl_playerplus_internal = {} local def = {} local time = 0 +local player_collision = function(player) + + local pos = player:get_pos() + local vel = player:get_velocity() + local x = 0 + local z = 0 + local width = .75 + + for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do + + if object:is_player() + or (object:get_luaentity()._cmi_is_mob == true and object ~= player) then + + local pos2 = object:get_pos() + local vec = {x = pos.x - pos2.x, z = pos.z - pos2.z} + local force = (width + 0.5) - vector.distance( + {x = pos.x, y = 0, z = pos.z}, + {x = pos2.x, y = 0, z = pos2.z}) + + x = x + (vec.x * force) + z = z + (vec.z * force) + end + end + + return({x * 5,z * 5}) +end + -- converts yaw to degrees local function degrees(rad) return rad * 180.0 / math.pi end +local pi = math.pi +local atann = math.atan +local atan = function(x) + if not x or x ~= x then + return 0 + else + return atann(x) + end +end + local dir_to_pitch = function(dir) local dir2 = vector.normalize(dir) local xz = math.abs(dir.x) + math.abs(dir.z) @@ -88,6 +125,13 @@ minetest.register_globalstep(function(dtime) for _,player in pairs(get_connected_players()) do + c_x, c_y = unpack(player_collision(player)) + + if player:get_velocity().x + player:get_velocity().y < .5 and c_x + c_y > 0 then + --minetest.chat_send_player(player:get_player_name(), "pushed at " .. c_x + c_y .. " parsecs.") + player:add_velocity({x=c_x, y=0, z=c_y}) + end + --[[ _ _ _ __ _ _ __ (_)_ __ ___ __ _| |_(_) ___ _ __ ___