From 702c954cf07a3aa6a2981caabc8a2de5731dc235 Mon Sep 17 00:00:00 2001 From: Guy Liner Date: Fri, 7 Jan 2022 07:46:53 -0500 Subject: [PATCH] Corrected coding style --- mods/PLAYER/mcl_playerinfo/init.lua | 44 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/mods/PLAYER/mcl_playerinfo/init.lua b/mods/PLAYER/mcl_playerinfo/init.lua index e2404347f..56c03a026 100644 --- a/mods/PLAYER/mcl_playerinfo/init.lua +++ b/mods/PLAYER/mcl_playerinfo/init.lua @@ -51,7 +51,7 @@ function mcl_playerinfo:collision_detect(pos,player) local deg = math.deg(player:get_look_horizontal()) --will help determine blocks near the player - local nearme = {x=pos.x,y=pos.y,z=pos.z} + local nearme = vector.new(pos) --[[ Basically turns the X and Z axises into a 2D plane @@ -62,40 +62,40 @@ function mcl_playerinfo:collision_detect(pos,player) ]] if deg > 0 and deg < 90 then - around_player["left_ofplayer"] = {x=nearme.x-1,y=nearme.y,z=nearme.z} - around_player["right_ofplayer"] = {x=nearme.x+1,y=nearme.y,z=nearme.z} - around_player["front_ofplayer"] = {x=nearme.x,y=nearme.y,z=nearme.z+1} - around_player["front_ofplayerplus"] = {x=nearme.x,y=nearme.y+1,z=nearme.z+1} - + around_player["left_ofplayer"] = vector.add(nearme, vector.new(-1,0,0)) + around_player["right_ofplayer"] = vector.add(nearme, vector.new(1,0,0)) + around_player["front_ofplayer"] = vector.add(nearme, vector.new(0,0,1)) + around_player["front_ofplayerplus"] = vector.add(nearme, vector.new(0,1,1)) elseif deg > 90 and deg < 180 then - around_player["left_ofplayer"] = {x=nearme.x,y=nearme.y,z=nearme.z-1} - around_player["right_ofplayer"] = {x=nearme.x,y=nearme.y,z=nearme.z+1} - around_player["front_ofplayer"] = {x=nearme.x-1,y=nearme.y,z=nearme.z} - around_player["front_ofplayerplus"] = {x=nearme.x-1,y=nearme.y+1,z=nearme.z} + around_player["left_ofplayer"] = vector.add(nearme, vector.new(0,0,-1)) + around_player["right_ofplayer"] = vector.add(nearme, vector.new(0,0,1)) + around_player["front_ofplayer"] = vector.add(nearme, vector.new(-1,0,0)) + around_player["front_ofplayerplus"] = vector.add(nearme, vector.new(-1,1,0)) elseif deg > 180 and deg < 270 then - around_player["left_ofplayer"] = {x=nearme.x+1,y=nearme.y,z=nearme.z} - around_player["right_ofplayer"] = {x=nearme.x-1,y=nearme.y,z=nearme.z} - around_player["front_ofplayer"] = {x=nearme.x,y=nearme.y,z=nearme.z-1} - around_player["front_ofplayerplus"] = {x=nearme.x,y=nearme.y+1,z=nearme.z-1} + around_player["left_ofplayer"] = vector.add(nearme, vector.new(1,0,0)) + around_player["right_ofplayer"] = vector.add(nearme, vector.new(-1,0,0)) + around_player["front_ofplayer"] = vector.add(nearme, vector.new(0,0,-1)) + around_player["front_ofplayerplus"] = vector.add(nearme, vector.new(0,1,-1)) elseif deg > 270 and deg < 360 then - around_player["left_ofplayer"] = {x=nearme.x,y=nearme.y,z=nearme.z+1} - around_player["right_ofplayer"] = {x=nearme.x,y=nearme.y,z=nearme.z-1} - around_player["front_ofplayer"] = {x=nearme.x+1,y=nearme.y,z=nearme.z} - around_player["front_ofplayerplus"] = {x=nearme.x+1,y=nearme.y+1,z=nearme.z} + around_player["left_ofplayer"] = vector.add(nearme, vector.new(0,0,1)) + around_player["right_ofplayer"] = vector.add(nearme, vector.new(0,0,-1)) + around_player["front_ofplayer"] = vector.add(nearme, vector.new(1,0,0)) + around_player["front_ofplayerplus"] = vector.add(nearme, vector.new(1,0,0)) end for placement,coord in pairs(around_player) do local node = minetest.get_node(coord) + local distance = vector.distance(pos, coord) -- How far is the player from the block in the given direction and -- if the block is not air the player is colliding with it - print(node.name) - print(vector.distance(pos, coord)) + --print(node.name) + --print(distance) if vector.distance(pos, coord) < too_close and node.name ~= "air" then return false - --Should be able to detect when you head is touching a slab - elseif vector.distance(pos, coord) < slab_too_close and vector.distance(pos, coord) > too_close and placement == "front_ofplayerplus" and node.name ~= "air" then + --Should be able to detect when your head is touching a slab + elseif distance < slab_too_close and distance > too_close and placement == "front_ofplayerplus" and node.name ~= "air" then return false end end