autoeat: timed eat when certain things are happening
This commit is contained in:
parent
d47ce9b310
commit
307883157d
@ -1,10 +1,12 @@
|
||||
autoeat = {}
|
||||
|
||||
autoeat.last = 0
|
||||
local last_step_eating = false
|
||||
local interval = 1
|
||||
|
||||
function autoeat.eat()
|
||||
local player = minetest.localplayer
|
||||
local owx=player:get_wield_index()
|
||||
autoeat.eating = true
|
||||
player:set_wield_index(8)
|
||||
minetest.place_node(player:get_pos())
|
||||
minetest.after("0.2",function()
|
||||
@ -12,10 +14,15 @@ function autoeat.eat()
|
||||
end)
|
||||
end
|
||||
|
||||
function autoeat.conditional()
|
||||
if os.time() < autoeat.last + ( interval * 60 ) then return end
|
||||
autoeat.last = os.time()
|
||||
autoeat.eat()
|
||||
end
|
||||
|
||||
minetest.register_on_damage_taken(function()
|
||||
if not minetest.settings:get_bool("autoeat") then return end
|
||||
autoeat.eat()
|
||||
autoeat.eating = true
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function()
|
||||
@ -24,6 +31,12 @@ minetest.register_globalstep(function()
|
||||
elseif autoeat.eating then
|
||||
last_step_eating = true
|
||||
end
|
||||
if ( autofly.speed ~= 0 and minetest.settings:get_bool("autosprint") )
|
||||
or (minetest.settings:get_bool("autosprintfsprint") and minetest.settings:get_bool("continuous_forward") )
|
||||
or (minetest.settings:get_bool("killaura")) then
|
||||
autoeat.conditional()
|
||||
end
|
||||
|
||||
|
||||
end)
|
||||
|
||||
|
@ -54,6 +54,7 @@ local storage = minetest.get_mod_storage()
|
||||
local wpr=false;
|
||||
local twpname=nil
|
||||
local oldpm=false
|
||||
local lpos={x=0,y=0,z=0}
|
||||
local info=minetest.get_server_info()
|
||||
local stprefix="autofly-".. info['address'] .. '-'
|
||||
|
||||
@ -117,6 +118,7 @@ minetest.register_globalstep(function()
|
||||
if lpos then
|
||||
local dst=vector.distance(minetest.localplayer:get_pos(),lpos)
|
||||
speed=round2(dst,1)
|
||||
autofly.speed=speed
|
||||
end
|
||||
lpos=minetest.localplayer:get_pos()
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user