:global double craft_inventory
:local int tier
:local double count
:local double plates
:local double pipes
:local double rawplates
tier = global.int.get("craft_tier:2.2")
count = global.double.get("craft_count:2.2")
plates = count * 2.0 * floor((66555444331.0 / (10.0 ^ i2d(tier))) % 10.0)
gotoif(x, tier != 2) ; only 5 plates for T2
plates = plates - 1.0
x: pipes = count * ceil(i2d(tier) / 5.0)
rawplates = max(0.0, plates * 9.0 - craft_inventory * (count("plate.dense", tier) + count("plate.stack", tier))) + max(0.0, pipes - craft_inventory * count("pipe", tier))
gotoif(plates, rawplates <= craft_inventory * count("plate", tier))
waitwhile(active("presser"))
produce("ingot", tier, rawplates - craft_inventory * count("plate", tier), "presser")
waitwhile(active("presser"))
plates: gotoif(pipes, plates <= craft_inventory * count("plate.dense", tier))
craft("plate.stack", tier, plates - craft_inventory * (count("plate.stack", tier) + count("plate.dense", tier)))
waitwhile(active("presser"))
produce("plate.stack", tier, plates - craft_inventory * count("plate.dense", tier), "presser")
pipes: gotoif(end, pipes <= craft_inventory * count("pipe", tier))
waitwhile(active("shaper"))
produce("plate", tier, pipes - craft_inventory * count("pipe", tier), "shaper")
end: waituntil(count("plate.dense", tier) >= plates & count("pipe", tier) >= pipes)
wait(0.0)