1
0
Fork 0

Remove global_step from on_step

This commit is contained in:
Tuxilio 2023-10-01 10:30:09 +00:00
parent 7abffa8500
commit 65cab094b8
1 changed files with 37 additions and 51 deletions

View File

@ -231,64 +231,50 @@ function TRIDENT_ENTITY.on_step(self, dtime)
self._picked_up = false
-- Pickup trident if player is nearby (not in Creative Mode)
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer >= 0.3 then
local objects = minetest.get_objects_inside_radius(pos, 1)
for _,obj in ipairs(objects) do
if obj:is_player() then
if not minetest.is_creative_enabled(obj:get_player_name()) then
if obj:get_inventory():room_for_item("main", "mcl_tridents") and not self._picked_up then
obj:get_inventory():add_item("main", "mcl_tridents:trident")
minetest.sound_play("item_drop_pickup", {
pos = pos,
max_hear_distance = 16,
gain = 1.0,
}, true)
self._picked_up = true
end
end
mcl_burning.extinguish(self.object)
self.object:remove()
return
local objects = minetest.get_objects_inside_radius(pos, 1)
for _,obj in ipairs(objects) do
if obj:is_player() then
if not minetest.is_creative_enabled(obj:get_player_name()) then
if obj:get_inventory():room_for_item("main", "mcl_tridents") and not self._picked_up then
obj:get_inventory():add_item("main", "mcl_tridents:trident")
minetest.sound_play("item_drop_pickup", {
pos = pos,
max_hear_distance = 16,
gain = 1.0,
}, true)
self._picked_up = true
end
end
timer = 0
mcl_burning.extinguish(self.object)
self.object:remove()
return
end
end)
end
-- Check for object "collision". Done every tick (hopefully this is not too stressing)
else
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer >= 0.3 then
if self._damage >= 9 and self._in_player == false then
minetest.add_particlespawner({
amount = 10,
time = 0.1,
minpos = vector.subtract(pos, vector.new(0.5, 0.5, 0.5)),
maxpos = vector.add(pos, vector.new(0.5, 0.5, 0.5)),
minvel = vector.new(-1, -1, -1),
maxvel = vector.new(1, 1, 1),
minacc = vector.new(0, -3, 0),
maxacc = vector.new(0, -3, 0),
minexptime = 0.5,
maxexptime = 1,
minsize = 0.5,
maxsize = 1,
collisiondetection = true,
collision_removal = true,
object_collision = true,
texture = "mcl_tridents_trail.png",
playername = "",
})
end
timer = 0
end
end)
if self._damage >= 9 and self._in_player == false then
minetest.add_particlespawner({
amount = 10,
time = 0.1,
minpos = vector.subtract(pos, vector.new(0.5, 0.5, 0.5)),
maxpos = vector.add(pos, vector.new(0.5, 0.5, 0.5)),
minvel = vector.new(-1, -1, -1),
maxvel = vector.new(1, 1, 1),
minacc = vector.new(0, -3, 0),
maxacc = vector.new(0, -3, 0),
minexptime = 0.5,
maxexptime = 1,
minsize = 0.5,
maxsize = 1,
collisiondetection = true,
collision_removal = true,
object_collision = true,
texture = "mcl_tridents_trail.png",
playername = "",
})
end
local closest_object
local closest_distance