change push timeout to use a global table instead of metadata, which seems buggy
This commit is contained in:
parent
74f95581b7
commit
6f1fda2150
17
items.lua
17
items.lua
@ -4,6 +4,8 @@ local stick_vault_timeout = sumo.stick_vault_timeout -- int timer for how long t
|
||||
local allow_swap_distance = sumo.allow_swap_distance -- if an opponent is within this distance, then if the player uses the pushstick with the shift key pressed, the players switch positions.
|
||||
local stick_pointing_distance = sumo.stick_pointing_distance
|
||||
local stick_push_timeout = sumo.stick_push_timeout --(float)--in seconds
|
||||
sumo.timeouts={}
|
||||
|
||||
|
||||
|
||||
minetest.register_craftitem("sumo:pushstick", {
|
||||
@ -17,13 +19,14 @@ minetest.register_craftitem("sumo:pushstick", {
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
|
||||
|
||||
local imeta = itemstack:get_meta()
|
||||
local last_push_time = imeta:get_float('push_time')
|
||||
--local imeta = itemstack:get_meta()
|
||||
local p_name = user:get_player_name()
|
||||
local last_push_time = sumo.timeouts[p_name] or 0.0
|
||||
local current_time = minetest.get_us_time()/1000000.0
|
||||
|
||||
if last_push_time == nil then
|
||||
last_push_time = 0.0
|
||||
end
|
||||
-- if last_push_time == nil then
|
||||
-- last_push_time = 0.0
|
||||
-- end
|
||||
--minetest.chat_send_all('difference = '..current_time-last_push_time)
|
||||
local time_from_last_push = current_time-last_push_time
|
||||
|
||||
@ -109,8 +112,8 @@ minetest.register_craftitem("sumo:pushstick", {
|
||||
|
||||
end
|
||||
end
|
||||
imeta:set_float('push_time',current_time)
|
||||
return itemstack
|
||||
sumo.timeouts[p_name] = current_time
|
||||
|
||||
|
||||
end,
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user