good days
i have this impresion of mine that there is not posible to know how much time player has been pressing left or rigth click on minetest
i been looking inside the "projectiles mod" code and this guy has to press to times click to shoot and arrow
i show an example to better understand what i wanna achive coz english is not mi native languague and become a little hard to express complex meanings
https://www.youtube.com/watch?v=zi5hZE8 ... e=youtu.be
for this chainsaw i need a on_use = function() to start the actions and animations
but also a i need something like while_on_use = function() to update the animation frames
and lastly i need some off_use() = function() to finalize the animation and destroy the afected blocks consume the combustible etc etc
items now, how long the player has presset leftClick
-
- New member
- Posts: 5
- Joined: Wed Nov 04, 2020 00:06
- In-game: perromercenario
Re: items now, how long the player has presset leftClick
you need something like this
Code: Select all
saw={
users={},
}
on_use=function(itemstack, user, pointed_thing)
local name=player:get_player_name()
saw.users[name] = saw.users[name] or {user=user}
saw.users[name].left = true
saw.users[name].left_time = 0
end
on_place=function(itemstack, user, pointed_thing)
local name=player:get_player_name()
saw.users[name] = saw.users[name] or {user=user}
saw.users[name].right = true
saw.users[name].right_time = 0
end
minetest.register_globalstep(function(dtime)
for name, u in pairs(saw.users) do
local key=u.user:get_player_control()
if not key then --player is offline
saw.users[name] = nil
return
end
if key.left then
u.left = key.LMB
u.left_time = u.left_time + dtime
if u.left_time >= 10 then
-- ...
end
end
if u.right then
u.right = key.RMB
u.right_time = u.right_time + dtime
if u.right_time >= 10 then
-- ...
end
end
end
end)
Who is online
Users browsing this forum: No registered users and 5 guests