From b1a4172f1107b4fd1509ad2d4d96ff9e6b9b1216 Mon Sep 17 00:00:00 2001 From: oilboi <47129783+oilboi@users.noreply.github.com> Date: Fri, 19 Jun 2020 17:51:14 -0400 Subject: [PATCH] disable swimming --- mods/player_api/init.lua | 59 +++++++++++----------- mods/player_mechanics/player_mechanics.lua | 32 +++++++----- 2 files changed, 49 insertions(+), 42 deletions(-) diff --git a/mods/player_api/init.lua b/mods/player_api/init.lua index 6c90d93..b2559c2 100644 --- a/mods/player_api/init.lua +++ b/mods/player_api/init.lua @@ -12,7 +12,7 @@ local player_constant = { "blank_skin.png", }, current_animation = "stand", - swimming = false, + --swimming = false, collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}, old_controls = {}, stepheight = 0.6 , @@ -187,15 +187,15 @@ end -- controls head bone local state -local swimming +--local swimming local pitch local pitch_look = function(player,sneak) state = get_player_state(player) - swimming = is_player_swimming(player) + --swimming = is_player_swimming(player) pitch = degrees(player:get_look_vertical()) * -1 - if swimming then - pitch = pitch + 90 - elseif sneak then + --if swimming then + --pitch = pitch + 90 + if sneak then pitch = pitch + 15 end @@ -299,7 +299,7 @@ local translation_table = { local name local temp_pool local state -local swimming +--local swimming local mouse local translated local control_translation = function(player,control) @@ -307,10 +307,10 @@ local control_translation = function(player,control) temp_pool = pool[name] state = get_player_state(player) - swimming = is_player_swimming(player) + --swimming = is_player_swimming(player) mouse = (control.LMB or control.RMB) - + --[[ if swimming then for k,i in pairs(control) do if i and translation_table.swim.keys[k] then @@ -323,32 +323,33 @@ local control_translation = function(player,control) set_animation(player, translated.animation, translated.speed) return else - if control.sneak then - for k,i in pairs(control) do - if i and translation_table.sneak.keys[k] then - translated = translation_table.sneak.states[true][mouse] + ]]-- + if control.sneak then + for k,i in pairs(control) do + if i and translation_table.sneak.keys[k] then + translated = translation_table.sneak.states[true][mouse] + set_animation(player, translated.animation, translated.speed) + return + end + end + translated = translation_table.sneak.states[false][mouse] + set_animation(player, translated.animation, translated.speed) + return + else + for k,i in pairs(control) do + if i and translation_table.walk.keys[k] then + translated = translation_table.walk.states[mouse][state] + if translated then set_animation(player, translated.animation, translated.speed) return end end - translated = translation_table.sneak.states[false][mouse] - set_animation(player, translated.animation, translated.speed) - return - else - for k,i in pairs(control) do - if i and translation_table.walk.keys[k] then - translated = translation_table.walk.states[mouse][state] - if translated then - set_animation(player, translated.animation, translated.speed) - return - end - end - end end - - translated = translation_table.stand[mouse] - set_animation(player, translated.animation, translated.speed) end + + translated = translation_table.stand[mouse] + set_animation(player, translated.animation, translated.speed) + --end end -- translates player movement to animation diff --git a/mods/player_mechanics/player_mechanics.lua b/mods/player_mechanics/player_mechanics.lua index bfe9c4f..d0fec7c 100644 --- a/mods/player_mechanics/player_mechanics.lua +++ b/mods/player_mechanics/player_mechanics.lua @@ -20,7 +20,7 @@ minetest.register_on_joinplayer(function(player) temp_pool.state = 0 temp_pool.old_state = 0 temp_pool.was_in_water = false - temp_pool.swimming = false + --temp_pool.swimming = false temp_pool.swim_bumped = false end) @@ -30,7 +30,7 @@ minetest.register_on_respawnplayer(function(player) name = player:get_player_name() pool[name].state = 0 pool[name].was_in_water = false - pool[name].swim_bumped = false + --pool[name].swim_bumped = false send_running_cancellation(player,false) end) @@ -96,6 +96,7 @@ local control_state = function(player) name = player:get_player_name() temp_pool = pool[name] + --[[ -- water movement data head = minetest.get_item_group(get_player_head_env(player),"water") > 0 legs = minetest.get_item_group(get_player_legs_env(player),"water") > 0 @@ -116,11 +117,12 @@ local control_state = function(player) end end end - - if (in_water ~= temp_pool.was_in_water) or + ]]-- + if --(in_water ~= temp_pool.was_in_water) or (temp_pool.state ~= temp_pool.old_state) or ((temp_pool.state == 1 or temp_pool.state == 2) and hunger <= 6) then + --[[ if (not in_water and temp_pool.was_in_water) then player:set_physics_override({ sneak = true, @@ -144,6 +146,7 @@ local control_state = function(player) }) player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0}) end + ]]-- -- running/swimming fov modifier if hunger > 6 and (temp_pool.state == 1 or temp_pool.state == 2) then @@ -155,10 +158,10 @@ local control_state = function(player) player:set_physics_override({speed=1.5}) end - elseif (not in_water and temp_pool.state ~= 1 and temp_pool.state ~= 2 and - (temp_pool.old_state == 1 or temp_pool.old_state == 2)) or - (in_water and temp_pool.state ~= 1 and temp_pool.state ~= 2 and temp_pool.state ~= 3 and - (temp_pool.old_state == 1 or temp_pool.old_state == 2 or temp_pool.old_state == 3))then + elseif (temp_pool.state ~= 1 and temp_pool.state ~= 2 and + (temp_pool.old_state == 1 or temp_pool.old_state == 2)) then--or + --(in_water and temp_pool.state ~= 1 and temp_pool.state ~= 2 and temp_pool.state ~= 3 and + --(temp_pool.old_state == 1 or temp_pool.old_state == 2 or temp_pool.old_state == 3))then player:set_fov(1, true,0.15) player:set_physics_override({speed=1}) @@ -172,18 +175,19 @@ local control_state = function(player) end --sneaking - if temp_pool.state == 3 and in_water then - send_running_cancellation(player,false) - elseif not in_water and temp_pool.state == 3 and temp_pool.old_state ~= 3 then + --if temp_pool.state == 3 and in_water then + -- send_running_cancellation(player,false) + if temp_pool.state == 3 and temp_pool.old_state ~= 3 then player:set_eye_offset({x=0,y=-1,z=0},{x=0,y=0,z=0}) - elseif not in_water and temp_pool.old_state == 3 and temp_pool.state ~= 3 then + elseif temp_pool.old_state == 3 and temp_pool.state ~= 3 then player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0}) end temp_pool.old_state = state - temp_pool.was_in_water = in_water + --temp_pool.was_in_water = in_water -- water movement + --[[] elseif in_water then if not temp_pool.was_in_water then player:set_physics_override({ @@ -192,7 +196,9 @@ local control_state = function(player) end temp_pool.old_state = temp_pool.old_state temp_pool.was_in_water = in_water + ]]-- end + end minetest.register_globalstep(function(dtime) -- 2.44.0