http://github.com/jastevenson303/sjcsm
Requires SSM part: viewtopic.php?f=9&t=22682
Code: Select all
-- sneakjump client-side mod
-- copyright 2019 james stevenson
-- gnu lgpl 2.1+
local sprinting = false
local step = 0.09
local player = minetest.localplayer
local channel = minetest.mod_channel_join("sprinting")
local function convert(decimal)
local binary = ""
while decimal > 0 do
binary = "" .. (decimal % 2) .. binary
decimal = math.floor(decimal / 2)
end
local length = binary:len()
local bits = {}
for i = length, 1, -1 do
local bit = tonumber(binary:sub(i, i))
table.insert(bits, bit)
end
for i = 1, 9 do
if not bits[i] then
bits[i] = 0
end
end
return bits
end
local function get_movement(player)
local keys = convert(player:get_key_pressed())
local aux1 = keys[6] == 1
if aux1 and not sprinting then
channel:send_all("t")
sprinting = true
elseif sprinting and not aux1 then
channel:send_all("f")
sprinting = false
end
minetest.after(step, function()
get_movement(player)
end)
end
minetest.after(step, function()
get_movement(player)
end)
Here's a video.