Add lifetime limit
This commit is contained in:
parent
969cac3860
commit
d741261156
2
TODO.txt
2
TODO.txt
@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
- add lifetime limit
|
- add option to remove mobs that aren't near any players
|
||||||
|
15
init.lua
15
init.lua
@ -114,6 +114,8 @@ def.on_activate = function(self, staticdata)
|
|||||||
self.knockback = false
|
self.knockback = false
|
||||||
self.state = math.random(1, 2)
|
self.state = math.random(1, 2)
|
||||||
self.old_y = self.object:get_pos().y
|
self.old_y = self.object:get_pos().y
|
||||||
|
self.lifetime = sneeker.lifetime
|
||||||
|
self.lifetimer = 0
|
||||||
|
|
||||||
local data = core.deserialize(staticdata)
|
local data = core.deserialize(staticdata)
|
||||||
if data and type(data) == "table" then
|
if data and type(data) == "table" then
|
||||||
@ -135,8 +137,17 @@ local function isnan(n)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def.on_step = function(self, dtime)
|
def.on_step = function(self, dtime)
|
||||||
|
-- update lifetime timer
|
||||||
|
-- FIXME: this is longer than realtime
|
||||||
|
self.lifetimer = self.lifetimer + dtime
|
||||||
|
if self.lifetimer >= self.lifetime then
|
||||||
|
-- TODO: should have a death animation
|
||||||
|
self.object:remove()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
if self.knockback then
|
if self.knockback then
|
||||||
return
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local ANIM_STAND = 1
|
local ANIM_STAND = 1
|
||||||
@ -339,6 +350,8 @@ def.on_step = function(self, dtime)
|
|||||||
else
|
else
|
||||||
self.object:set_acceleration({x=0, y=-10, z=0})
|
self.object:set_acceleration({x=0, y=-10, z=0})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
def.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
def.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||||
|
@ -3,6 +3,13 @@
|
|||||||
|
|
||||||
local time_min = 60
|
local time_min = 60
|
||||||
|
|
||||||
|
--- How long (in seconds) sneeker remains in world after spawn.
|
||||||
|
--
|
||||||
|
-- Default: 15 minutes
|
||||||
|
--
|
||||||
|
-- @setting sneeker.lifespan
|
||||||
|
sneeker.lifetime = tonumber(core.settings:get("sneeker.lifetime") or time_min * 15)
|
||||||
|
|
||||||
--- Loudness of explosion.
|
--- Loudness of explosion.
|
||||||
--
|
--
|
||||||
-- @setting sneeker.boom_gain
|
-- @setting sneeker.boom_gain
|
||||||
|
@ -2,6 +2,11 @@
|
|||||||
# Extra debugging messages.
|
# Extra debugging messages.
|
||||||
enable_debug_mods (Mod debugging) bool false
|
enable_debug_mods (Mod debugging) bool false
|
||||||
|
|
||||||
|
# How long (in seconds) sneeker remains in world after spawn.
|
||||||
|
#
|
||||||
|
# Default: 900 (15 minutes)
|
||||||
|
sneeker.lifetime (Sneeker lifetime) int 900
|
||||||
|
|
||||||
# Loudness of explosion.
|
# Loudness of explosion.
|
||||||
#
|
#
|
||||||
# Those with a weak heart might want to turn it down.
|
# Those with a weak heart might want to turn it down.
|
||||||
|
Loading…
Reference in New Issue
Block a user