forked from mrkubax10/industrialtest
Rotary Macerator fixes
This commit is contained in:
parent
1e9a2e645e
commit
21d4a3a014
@ -150,10 +150,12 @@ rotaryMacerator.activeOnTimer=function(pos,elapsed,meta,inv)
|
|||||||
local dstSlot=inv:get_stack("dst",1)
|
local dstSlot=inv:get_stack("dst",1)
|
||||||
local powerAmount=meta:get_int("industrialtest.powerAmount")
|
local powerAmount=meta:get_int("industrialtest.powerAmount")
|
||||||
local rpm=meta:get_int("rpm")
|
local rpm=meta:get_int("rpm")
|
||||||
|
local speed=industrialtest.api.getMachineSpeed(meta)
|
||||||
|
local requiredPower=elapsed*rotaryMacerator.opPower*speed
|
||||||
|
|
||||||
industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
|
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("srcTime",0)
|
||||||
meta:set_float("maxSrcTime",0)
|
meta:set_float("maxSrcTime",0)
|
||||||
minetest.swap_node(pos,{
|
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)
|
local srcTime=meta:get_float("srcTime")+elapsed*(1+rpm/7500)
|
||||||
if srcTime>=meta:get_float("maxSrcTime") then
|
if srcTime>=meta:get_float("maxSrcTime") then
|
||||||
local speed=industrialtest.api.getMachineSpeed(meta)
|
local multiplier=math.min(srcSlot:get_count(),speed)
|
||||||
local multiplier=1
|
local prevCount=resultStack:get_count()
|
||||||
if srcSlot:get_count()>=speed then
|
|
||||||
multiplier=speed
|
|
||||||
end
|
|
||||||
resultStack:set_count(resultStack:get_count()*multiplier)
|
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("srcTime",0)
|
||||||
meta:set_float("maxSrcTime",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)
|
inv:set_stack("src",1,srcSlot)
|
||||||
meta:set_int("rpm",math.min(rpm+750*elapsed,7500))
|
meta:set_int("rpm",math.min(rpm+750*elapsed,7500))
|
||||||
if modified then
|
if modified then
|
||||||
@ -225,6 +224,8 @@ rotaryMacerator.activeOnTimer=function(pos,elapsed,meta,inv)
|
|||||||
meta:set_float("srcTime",srcTime)
|
meta:set_float("srcTime",srcTime)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
industrialtest.api.addPower(meta,-requiredPower)
|
||||||
|
|
||||||
return true,true
|
return true,true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user