Rotary Macerator fixes

This commit is contained in:
mrkubax10 2024-03-11 19:43:40 +01:00
parent 1e9a2e645e
commit 21d4a3a014

View File

@ -150,10 +150,12 @@ rotaryMacerator.activeOnTimer=function(pos,elapsed,meta,inv)
local dstSlot=inv:get_stack("dst",1)
local powerAmount=meta:get_int("industrialtest.powerAmount")
local rpm=meta:get_int("rpm")
local speed=industrialtest.api.getMachineSpeed(meta)
local requiredPower=elapsed*rotaryMacerator.opPower*speed
industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
if srcSlot:is_empty() or powerAmount<rotaryMacerator.opPower then
if srcSlot:is_empty() or powerAmount<requiredPower then
meta:set_float("srcTime",0)
meta:set_float("maxSrcTime",0)
minetest.swap_node(pos,{
@ -189,16 +191,13 @@ rotaryMacerator.activeOnTimer=function(pos,elapsed,meta,inv)
local srcTime=meta:get_float("srcTime")+elapsed*(1+rpm/7500)
if srcTime>=meta:get_float("maxSrcTime") then
local speed=industrialtest.api.getMachineSpeed(meta)
local multiplier=1
if srcSlot:get_count()>=speed then
multiplier=speed
end
local multiplier=math.min(srcSlot:get_count(),speed)
local prevCount=resultStack:get_count()
resultStack:set_count(resultStack:get_count()*multiplier)
inv:add_item("dst",resultStack)
local leftover=inv:add_item("dst",resultStack)
meta:set_float("srcTime",0)
meta:set_float("maxSrcTime",0)
srcSlot:set_count(srcSlot:get_count()-multiplier)
srcSlot:take_item(multiplier-leftover:get_count()/prevCount)
inv:set_stack("src",1,srcSlot)
meta:set_int("rpm",math.min(rpm+750*elapsed,7500))
if modified then
@ -225,6 +224,8 @@ rotaryMacerator.activeOnTimer=function(pos,elapsed,meta,inv)
meta:set_float("srcTime",srcTime)
end
industrialtest.api.addPower(meta,-requiredPower)
return true,true
end