diff --git a/mods/lord/Core/fuel_device/src/fuel_device/Device.lua b/mods/lord/Core/fuel_device/src/fuel_device/Device.lua index fd6d70cc1..d03a48f09 100644 --- a/mods/lord/Core/fuel_device/src/fuel_device/Device.lua +++ b/mods/lord/Core/fuel_device/src/fuel_device/Device.lua @@ -58,24 +58,6 @@ end -- ----------------------------------------------------------------------------------------------- -- Private functions: ---- @private ---- @param pos table ---- @return NodeMetaRef -local function get_initiated_meta(pos) - local meta = minetest.get_meta(pos) - for _, name in pairs({ - 'fuel_totaltime', - 'fuel_time', - 'src_totaltime', - 'src_time' - }) do - if not meta:get_float(name) then - meta:set_float(name, 0.0) - end - end - return meta -end - --- @param meta NodeMetaRef local function reset_meta_times(meta) for _, name in pairs({ @@ -84,7 +66,7 @@ local function reset_meta_times(meta) 'src_totaltime', 'src_time' }) do - meta:set_float(name, 0.0) + meta:set_int(name, 0) end end @@ -95,7 +77,7 @@ end --- @return NodeMetaRef function Device:get_meta() if not self.meta then - self.meta = get_initiated_meta(self.position) + self.meta = minetest.get_meta(self.position) end return self.meta @@ -124,8 +106,8 @@ end --- @param hint string text shown in `infotext` after `": "` function Device:activate(hint) local meta = self:get_meta() - local percent = math_floor(meta:get_float('fuel_time') / meta:get_float('fuel_totaltime') * 100) - local item_percent = math_floor(meta:get_float('src_time') / meta:get_float('src_totaltime') * 100) + local percent = math_floor(meta:get_int('fuel_time') / meta:get_int('fuel_totaltime') * 100) + local item_percent = math_floor(meta:get_int('src_time') / meta:get_int('src_totaltime') * 100) minetest.swap_node_if_not_same(self.position, self.node_name.active) self:get_meta():set_string('infotext', self.NAME .. ': ' .. hint .. ' (' .. percent .. '%)') self:get_meta():set_string('formspec', self.form.get_spec('active', percent, item_percent)) diff --git a/mods/lord/Core/fuel_device/src/fuel_device/Processor.lua b/mods/lord/Core/fuel_device/src/fuel_device/Processor.lua index 1f91b7813..f4c6deec4 100644 --- a/mods/lord/Core/fuel_device/src/fuel_device/Processor.lua +++ b/mods/lord/Core/fuel_device/src/fuel_device/Processor.lua @@ -65,13 +65,9 @@ end --- @param remaining_source RecipeInput --- @param result_source RecipeOutput --- @param time number -local function grind_source(meta, remaining_source, result_source) +local function process_source(meta, remaining_source, result_source) local src_time = meta:get_int('src_time') - local src_totaltime = meta:get_int('src_totaltime') - - if src_time == 0 or src_totaltime == 0 then - meta:set_int('src_totaltime', result_source.time) - end + local src_totaltime = result_source.time src_time = src_time + 1 @@ -154,7 +150,7 @@ function Processor:act(position) device:activate(S('Active')) burn_fuel(meta, remaining_fuel, result_fuel) - grind_source(meta, remaining_source, result_source) + process_source(meta, remaining_source, result_source) else device:deactivate(S('Out Of Fuel')) end diff --git a/util/mt-ide-helper/classes/MetaDataRef.lua b/util/mt-ide-helper/classes/MetaDataRef.lua index 4342e6bd3..24c0ccf0c 100644 --- a/util/mt-ide-helper/classes/MetaDataRef.lua +++ b/util/mt-ide-helper/classes/MetaDataRef.lua @@ -32,7 +32,7 @@ function MetaDataRef:get_string(key) end function MetaDataRef:set_int(key, value) end ---@param key string ----@return number +---@return number Returns `0` if `key` not present. function MetaDataRef:get_int(key) end ---@param key string