diff --git a/mods/ITEMS/REDSTONE/mesecons_button/init.lua b/mods/ITEMS/REDSTONE/mesecons_button/init.lua index 726d1f5e7..34a8622a1 100644 --- a/mods/ITEMS/REDSTONE/mesecons_button/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_button/init.lua @@ -157,10 +157,6 @@ function mesecon.register_button(basename, description, texture, recipeitem, sou -- Push the button! Push, push, push the button! if node_def.groups.button_push_by_arrow == 1 then - minetest.log("hit"..dump({ - pos = pos, - node = node, - })) mesecon.push_button(pos, node) end end diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 766d19e31..5e7d6a6cb 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -7,12 +7,6 @@ local enable_pvp = minetest.settings:get_bool("enable_pvp") local math = math local vector = vector --- Time in seconds after which a stuck arrow is deleted -local ARROW_TIMEOUT = 60 - --- Time after which stuck arrow is rechecked for being stuck -local STUCK_RECHECK_TIME = 5 - local YAW_OFFSET = -math.pi/2 local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements") @@ -70,6 +64,7 @@ local arrow_entity = { survive_collision = true, sticks_in_players = true, damages_players = true, + maximum_time = 60, damage_groups = function(self) return { fleshy = self._damage } end, @@ -87,14 +82,6 @@ local arrow_entity = { local pos = self.object:get_pos() self._allow_punch = self._allow_punch or not self._owner or not self._startpos or pos and vector.distance(self._startpos, pos) > 1.5 - -- Give the arrows a maximum flight time - self._time_in_air = (self._time_in_air or 0) + dtime - if self._time_in_air > ARROW_TIMEOUT then - self._removed = true - self.object:remove() - return true - end - if self._deflection_cooloff > 0 then self._deflection_cooloff = self._deflection_cooloff - dtime end @@ -165,7 +152,7 @@ local arrow_entity = { -- Otherwise, punching has no effect. on_punch = function(self) if self._stuck then - self._stuckrechecktimer = STUCK_RECHECK_TIME + self._stuckrechecktimer = 5 end end, get_staticdata = function(self) @@ -176,14 +163,6 @@ local arrow_entity = { out[field] = self["_"..field] end - if self._stuck then - -- If _stucktimer is missing for some reason, assume the maximum - if not self._stucktimer then - self._stucktimer = ARROW_TIMEOUT - end - out.stuckstarttime = minetest.get_gametime() - self._stucktimer - end - if self._owner then out._owner = self._owner:get_player_name() end @@ -204,15 +183,6 @@ local arrow_entity = { self["_"..field] = data[field] end - if data.stuckstarttime then - -- First, check if the stuck arrow is aleady past its life timer. - -- If yes, delete it. - self._stucktimer = minetest.get_gametime() - data.stuckstarttime - end - - -- Perform a stuck recheck on the next step. - self._stuckrechecktimer = STUCK_RECHECK_TIME - local vl_projectile_data = {} if data._owner then vl_projectile_data.owner = minetest.get_player_by_name(data._owner) diff --git a/mods/ITEMS/vl_projectile/api.md b/mods/ITEMS/vl_projectile/api.md index 8ba8b9f56..7e5711f17 100644 --- a/mods/ITEMS/vl_projectile/api.md +++ b/mods/ITEMS/vl_projectile/api.md @@ -23,6 +23,7 @@ Arguments: * If `type` is "entity" then the additional parameter `objet` will be provided. * `behaviors`: a list of behavior callbacks that define the projectile's behavior. This mod provides the following behaviors: `vl_projectiles.collides_with_solids`, `vl_projectiles.collides_with_entities` and `vl_projectiles.raycast_collides_with_entities` + * `maximum_time`: number of seconds until projectiles are removed. * `sounds`: sounds for this projectile. All fields take a table with three parameters corresponding to the three parameters for `minetest.play_sound()`. Supported sounds are: * `on_collision`: played when no other more specific sound is defined. May be a function of type `function(projectile, entity_def, projectile_def, type, ...)` diff --git a/mods/ITEMS/vl_projectile/init.lua b/mods/ITEMS/vl_projectile/init.lua index f9dd45f49..b79ee57ab 100644 --- a/mods/ITEMS/vl_projectile/init.lua +++ b/mods/ITEMS/vl_projectile/init.lua @@ -78,8 +78,14 @@ function mod.update_projectile(self, dtime) local entity_def = minetest.registered_entities[entity_name] or {} local entity_vl_projectile = entity_def._vl_projectile or {} - -- Update entity timer + -- Update entity timer and remove expired projectiles self.timer = (self.timer or 0) + dtime + local maximum_flight_time = entity_vl_projectile.maximum_time + if self.timer > maximum_flight_time then + self.removed = true + self.object:remove() + return + end -- Run behaviors local behaviors = entity_vl_projectile.behaviors or {} @@ -259,7 +265,7 @@ local function stuck_on_step(self, dtime, entity_def, projectile_def) local pos = self.object:get_pos() if not pos then return true end - self._stucktimer = self._stucktimer + dtime + self._stucktimer = (self._stucktimer or 0) + dtime if self._stucktimer > STUCK_TIMEOUT then mcl_burning.extinguish(self.object) self._removed = true @@ -269,7 +275,7 @@ local function stuck_on_step(self, dtime, entity_def, projectile_def) -- Drop arrow as item when it is no longer stuck -- TODO: revist after observer rework - self._stuckrechecktimer = self._stuckrechecktimer + dtime + self._stuckrechecktimer = (self._stuckrechecktimer or 0) + dtime if self._stuckrechecktimer > 1 then self._stuckrechecktimer = 0 if self._stuckin then