Better delay

This commit is contained in:
Duane Robertson 2016-05-26 01:49:08 -05:00
parent 234b71064c
commit 58ed1a5e1c
14 changed files with 29 additions and 42 deletions

View file

@ -70,10 +70,7 @@ mobs:register_mob("fun_caves:dangler", {
--replace_with = "air",
--replace_offset = -1,
do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
if not fun_caves.custom_ready(self) then
return
end

View file

@ -108,10 +108,7 @@ mobs:register_mob("fun_caves:goblin_coal", {
end,
do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
if not fun_caves.custom_ready(self) then
return
end

View file

@ -112,10 +112,7 @@ mobs:register_mob("fun_caves:goblin_cobble", {
end,
do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
if not fun_caves.custom_ready(self) then
return
end

View file

@ -108,10 +108,7 @@ mobs:register_mob("fun_caves:goblin_copper", {
end,
do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
if not fun_caves.custom_ready(self) then
return
end

View file

@ -110,10 +110,7 @@ mobs:register_mob("fun_caves:goblin_diamond", {
end,
do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
if not fun_caves.custom_ready(self) then
return
end

View file

@ -204,10 +204,7 @@ mobs:register_mob("fun_caves:goblin_digger", {
end,
do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
if not fun_caves.custom_ready(self) then
return
end

View file

@ -108,10 +108,7 @@ mobs:register_mob("fun_caves:goblin_gold", {
end,
do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
if not fun_caves.custom_ready(self) then
return
end

View file

@ -107,10 +107,7 @@ mobs:register_mob("fun_caves:goblin_ice", {
end,
do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
if not fun_caves.custom_ready(self) then
return
end

View file

@ -110,10 +110,7 @@ mobs:register_mob("fun_caves:goblin_iron", {
end,
do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
if not fun_caves.custom_ready(self) then
return
end

View file

@ -109,10 +109,7 @@ mobs:register_mob("fun_caves:goblin_king", {
end,
do_custom = function(self)
if not self.custom_time or self.custom_time % fun_caves.custom_delay == 0 then
self.custom_time = fun_caves.custom_delay - 1
else
self.custom_time = self.custom_time - 1
if not fun_caves.custom_ready(self) then
return
end

View file

@ -1,4 +1,4 @@
local DEBUG = true
local DEBUG = false
local cave_noise_1 = {offset = 0, scale = 1, seed = 3901, spread = {x = 40, y = 10, z = 40}, octaves = 3, persist = 1, lacunarity = 2}
local cave_noise_2 = {offset = 0, scale = 1, seed = -8402, spread = {x = 40, y = 20, z = 40}, octaves = 3, persist = 1, lacunarity = 2}

View file

@ -48,7 +48,16 @@ fun_caves.surface_damage = function(self, cold_natured)
end
fun_caves.custom_delay = 50
local custom_delay = 1000000
fun_caves.custom_ready = function(self)
local time = minetest.get_us_time()
if not self.custom_time or time - self.custom_time > custom_delay then
self.custom_time = time
return true
else
return false
end
end
local path = minetest.get_modpath(minetest.get_current_modname())
dofile(path .. "/danglers.lua")

View file

@ -48,6 +48,10 @@ mobs:register_mob("fun_caves:spider", {
punch_end = 90,
},
do_custom = function(self)
if not fun_caves.custom_ready(self) then
return
end
fun_caves.surface_damage(self)
end,
})

View file

@ -49,6 +49,10 @@ mobs:register_mob("fun_caves:spider_ice", {
punch_end = 90,
},
do_custom = function(self)
if not fun_caves.custom_ready(self) then
return
end
fun_caves.surface_damage(self, true)
end,
})