fix command failing on lag

This commit is contained in:
Alexsandro Percy 2024-02-04 10:10:28 -03:00
parent 0712b19f79
commit b6cdf89865
2 changed files with 7 additions and 2 deletions

View File

@ -141,8 +141,10 @@ function steampunk_blimp.buoyancy_auto_correction(self, dtime)
--minetest.chat_send_player(self.driver_name, "antes: " .. self._baloon_buoyancy)
if self._baloon_buoyancy > 0 then factor = -1 end
local time_correction = (dtime/steampunk_blimp.ideal_step)
if time_correction < 1 then time_correction = 1 end
local intensity = 0.2
local correction = (intensity*factor) * math.max(time_correction, steampunk_blimp.ideal_step)
local correction = (intensity*factor) * time_correction
if math.abs(correction) > 0.5 then correction = 0.5 * math.sign(correction) end
--minetest.chat_send_player(self.driver_name, correction)
local before_correction = self._baloon_buoyancy
local new_baloon_buoyancy = self._baloon_buoyancy + correction

View File

@ -66,7 +66,10 @@ end
local function furnace_step(self, accel)
if self._energy > 0 and self._engine_running then
local consumed_power = (1/steampunk_blimp.FUEL_CONSUMPTION)
self._boiler_pressure = self._boiler_pressure + gained_pressure --pressure for the boiler
local time_correction = (self.dtime/steampunk_blimp.ideal_step)
if time_correction < 1 then time_correction = 1 end
local dtimed_pressure = gained_pressure*time_correction
self._boiler_pressure = self._boiler_pressure + dtimed_pressure --pressure for the boiler
self._energy = self._energy - consumed_power; --removes energy
end
if self._energy <= 0 or self._water_level <= 0 then