Double jump. Jump tuning. Changed deprecated functions.
parent
11c44f88d9
commit
606fb7a5ea
81
init.lua
81
init.lua
|
@ -31,7 +31,7 @@ climbing_pick.pick_on_use = function(itemstack, user, pointed_thing)
|
|||
return
|
||||
end
|
||||
if user and pt.type == "object" and pt.ref and pt.ref:is_player() then
|
||||
local pos = user:getpos()
|
||||
local pos = user:get_pos()
|
||||
local target_pos = pt.ref:get_pos()
|
||||
if pos and target_pos and vector.distance(pos, target_pos) < 3 then
|
||||
local tmp_dir = vector.direction(pos, target_pos)
|
||||
|
@ -58,7 +58,7 @@ climbing_pick.pick_on_use = function(itemstack, user, pointed_thing)
|
|||
end
|
||||
return
|
||||
elseif user and pt.type == "object" and pt.ref then
|
||||
local pos = user:getpos()
|
||||
local pos = user:get_pos()
|
||||
local target_pos = pt.ref:get_pos()
|
||||
if pos and target_pos and vector.distance(pos, target_pos) < 3 then
|
||||
local tmp_dir = vector.direction(pos, target_pos)
|
||||
|
@ -106,7 +106,7 @@ climbing_pick.pick_on_use = function(itemstack, user, pointed_thing)
|
|||
elseif pt.type == "node" then
|
||||
local under = minetest.get_node(pt.under)
|
||||
|
||||
local pos = user:getpos()
|
||||
local pos = user:get_pos()
|
||||
local target_pos = pt.under
|
||||
if pos and target_pos and vector.distance(pos, target_pos) > 3 then
|
||||
return
|
||||
|
@ -335,57 +335,56 @@ minetest.register_craft({
|
|||
|
||||
|
||||
local on_step = function (dtime)
|
||||
local players = minetest.get_connected_players()
|
||||
for i = 1, #players do
|
||||
local player_name = players[i]:get_player_name()
|
||||
local jump2 = climbing_pick.jump2[player_name] or 0
|
||||
local player_controls = players[i]:get_player_control_bits()
|
||||
local player_jump = math.floor(player_controls%32/16)
|
||||
local players = minetest.get_connected_players()
|
||||
for i, player in pairs(players) do
|
||||
local player_name = player:get_player_name()
|
||||
local jump2 = climbing_pick.jump2[player_name] or 0
|
||||
local player_controls = player:get_player_control_bits()
|
||||
local player_jump = math.floor(player_controls%32/16)
|
||||
|
||||
local itemstack = players[i]:get_wielded_item()
|
||||
local pick = minetest.get_item_group(itemstack:get_name(), "climbing") > 0
|
||||
local itemstack = player:get_wielded_item()
|
||||
local pick = minetest.get_item_group(itemstack:get_name(), "climbing") > 0
|
||||
|
||||
local current_jump_speed = players[i]:get_player_velocity()["y"]
|
||||
if pick then
|
||||
local current_jump_speed = player:get_player_velocity()["y"]
|
||||
|
||||
local standing = current_jump_speed == 0
|
||||
local falling = current_jump_speed < 0
|
||||
local standing = current_jump_speed == 0
|
||||
local falling = current_jump_speed < 0
|
||||
|
||||
if standing and jump2 > 0 then
|
||||
climbing_pick.jump2[player_name] = jump2 - 1
|
||||
elseif not standing and jump2 < 3 then
|
||||
climbing_pick.jump2[player_name] = jump2 + 1
|
||||
end
|
||||
if standing and jump2 > 0 then
|
||||
climbing_pick.jump2[player_name] = jump2 - 1
|
||||
elseif not standing and jump2 < 3 then
|
||||
climbing_pick.jump2[player_name] = jump2 + 1
|
||||
end
|
||||
|
||||
if player_jump == 1 and pick and jump2 == 3 and falling then
|
||||
climbing_pick.jump2[player_name] = 6
|
||||
if player_jump == 1 and jump2 == 3 and falling then
|
||||
climbing_pick.jump2[player_name] = 6
|
||||
|
||||
local pos = players[i]:get_pos()
|
||||
local pos = player:get_pos()
|
||||
|
||||
local tool_definition = itemstack:get_definition()
|
||||
local tool_capabilities = tool_definition.tool_capabilities
|
||||
local uses = tool_capabilities.groupcaps.climbing.uses
|
||||
itemstack:add_wear(65535/(uses-1))
|
||||
local tool_definition = itemstack:get_definition()
|
||||
local tool_capabilities = tool_definition.tool_capabilities
|
||||
local uses = tool_capabilities.groupcaps.climbing.uses
|
||||
itemstack:add_wear(65535/(uses-1))
|
||||
|
||||
players[i]:set_wielded_item(itemstack)
|
||||
player:set_wielded_item(itemstack)
|
||||
|
||||
minetest.sound_play("default_metal_footstep", {pos = pos, gain = 0.5, })
|
||||
climbing_pick.effect(pos)
|
||||
minetest.sound_play("default_metal_footstep", {pos = pos, gain = 0.5, })
|
||||
climbing_pick.effect(pos)
|
||||
|
||||
-- tool break sound
|
||||
if itemstack:get_count() == 0 and tool_definition.sound and tool_definition.sound.breaks then
|
||||
minetest.sound_play(tool_definition.sound.breaks, {pos = pos, gain = 0.5})
|
||||
end
|
||||
-- tool break sound
|
||||
if itemstack:get_count() == 0 and tool_definition.sound and tool_definition.sound.breaks then
|
||||
minetest.sound_play(tool_definition.sound.breaks, {pos = pos, gain = 0.5})
|
||||
end
|
||||
|
||||
|
||||
|
||||
local jump2_speed = 6.5 + tool_capabilities.groupcaps.climbing.maxlevel
|
||||
if (current_jump_speed + jump2_speed) > 6.5 then
|
||||
jump2_speed = 6.5 - current_jump_speed
|
||||
local jump2_speed = 6.5 + tool_capabilities.groupcaps.climbing.maxlevel
|
||||
if (current_jump_speed + jump2_speed) > 6.5 then
|
||||
jump2_speed = 6.5 - current_jump_speed
|
||||
end
|
||||
player:add_player_velocity({x=0, y=jump2_speed, z=0})
|
||||
end
|
||||
end
|
||||
players[i]:add_player_velocity({x=0, y=jump2_speed, z=0})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_globalstep(on_step)
|
||||
|
|
Loading…
Reference in New Issue