From 0b7097cb28869d36a251c7ded32cfa7c6c0b03f8 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 21 Sep 2021 20:45:08 +0200 Subject: [PATCH 1/2] add a burning animation fps setting --- mods/ENTITIES/mcl_burning/api.lua | 2 +- mods/ENTITIES/mcl_burning/init.lua | 3 ++- settingtypes.txt | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index bf721414..402835d7 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -285,7 +285,7 @@ function mcl_burning.fire_entity_step(self, dtime) end local animation_timer = self.animation_timer + dtime - if animation_timer >= 0.015 then + if animation_timer >= ( 1 / mcl_burning.animation_fps ) then animation_timer = 0 local animation_frame = self.animation_frame + 1 if animation_frame > mcl_burning.animation_frames - 1 then diff --git a/mods/ENTITIES/mcl_burning/init.lua b/mods/ENTITIES/mcl_burning/init.lua index 61ed1283..a1e3fe5c 100644 --- a/mods/ENTITIES/mcl_burning/init.lua +++ b/mods/ENTITIES/mcl_burning/init.lua @@ -2,7 +2,8 @@ local S = minetest.get_translator("mcl_burning") local modpath = minetest.get_modpath("mcl_burning") mcl_burning = { - animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8 + animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8, + animation_fps = tonumber(minetest.settings:get("fire_animation_fps")) or 30 } dofile(modpath .. "/api.lua") diff --git a/settingtypes.txt b/settingtypes.txt index 96e7d5f5..3f90c986 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -91,6 +91,11 @@ flame_sound (Flame sound) bool true # Form: Image height / Image width fire_animation_frames (Fire Animation Frames) int 8 +# How long to wait between frames of the fire animation in frames per second. +# A higher number means it looks better but also results in a lot of additional network traffic. A low single digit value is recommended for multiplayer. +#(default: 30) +fire_animation_fps (Fire Animation FPS) int 30 0 60 + # Whether to animate chests when open / close animated_chests (Animated chests) bool true From 84194b71e65207493a3773ce742aec05c81d5d1e Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 21 Sep 2021 21:34:24 +0200 Subject: [PATCH 2/2] burning: prevent adding multiple entities+huds --- mods/ENTITIES/mcl_burning/api.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index 402835d7..0d8e3d15 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -155,6 +155,16 @@ function mcl_burning.set_on_fire(obj, burn_time, reason) }) + 1 end + local already_burning = mcl_burning.is_burning(obj) + + + mcl_burning.set(obj, "float", "burn_time", burn_time) + mcl_burning.set(obj, "string", "reason", reason) + + if already_burning then + return + end + local hud_id if obj:is_player() then hud_id = mcl_burning.get(obj, "int", "hud_id") @@ -168,8 +178,7 @@ function mcl_burning.set_on_fire(obj, burn_time, reason) }) + 1 end end - mcl_burning.set(obj, "float", "burn_time", burn_time) - mcl_burning.set(obj, "string", "reason", reason) + mcl_burning.set(obj, "int", "hud_id", hud_id) mcl_burning.set(obj, "int", "sound_id", sound_id)