Refactor Recycler
This commit is contained in:
parent
ef88c5cd6b
commit
d247060c2e
@ -15,18 +15,49 @@
|
|||||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
local S=minetest.get_translator("industrialtest")
|
local S=minetest.get_translator("industrialtest")
|
||||||
|
industrialtest.Recycler=table.copy(industrialtest.SimpleElectricItemProcessor)
|
||||||
industrialtest.internal.registerSimpleElectricItemProcessor({
|
industrialtest.internal.unpackTableInto(industrialtest.Recycler,{
|
||||||
name="recycler",
|
name="industrialtest:recycler",
|
||||||
displayName=S("Recycler"),
|
description=S("Recycler"),
|
||||||
customTopTexture=true,
|
tiles={
|
||||||
|
"industrialtest_machine_block.png",
|
||||||
|
"industrialtest_machine_block.png",
|
||||||
|
"industrialtest_machine_block.png",
|
||||||
|
"industrialtest_machine_block.png",
|
||||||
|
"industrialtest_machine_block.png",
|
||||||
|
"industrialtest_machine_block.png^industrialtest_recycler_front.png",
|
||||||
|
"industrialtest_machine_block.png"
|
||||||
|
},
|
||||||
requiresWrench=true,
|
requiresWrench=true,
|
||||||
|
active={
|
||||||
|
tiles={
|
||||||
|
"industrialtest_machine_block.png",
|
||||||
|
"industrialtest_machine_block.png",
|
||||||
|
"industrialtest_machine_block.png",
|
||||||
|
"industrialtest_machine_block.png",
|
||||||
|
"industrialtest_machine_block.png",
|
||||||
|
"industrialtest_machine_block.png^industrialtest_recycler_front_active.png",
|
||||||
|
"industrialtest_machine_block.png"
|
||||||
|
}
|
||||||
|
},
|
||||||
capacity=80,
|
capacity=80,
|
||||||
flow=industrialtest.api.lvPowerFlow,
|
flow=industrialtest.api.lvPowerFlow,
|
||||||
opPower=40,
|
opPower=40,
|
||||||
method="industrialtest.recycling",
|
|
||||||
efficiency=1
|
efficiency=1
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function industrialtest.Recycler.getCraftResult(self,itemstack)
|
||||||
|
local srcAfter=ItemStack(itemstack:get_name())
|
||||||
|
srcAfter:set_count(itemstack:get_count()-1)
|
||||||
|
return {
|
||||||
|
item=ItemStack(industrialtest.random:next(1,8)==1 and "industrialtest:scrap" or ""),
|
||||||
|
time=2,
|
||||||
|
src=srcAfter
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
industrialtest.Recycler:register()
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type="shaped",
|
type="shaped",
|
||||||
output="industrialtest:recycler",
|
output="industrialtest:recycler",
|
||||||
|
@ -201,9 +201,9 @@ function industrialtest.SimpleElectricItemProcessor.activeUpdate(self,pos,elapse
|
|||||||
if output.item:get_count()>0 then
|
if output.item:get_count()>0 then
|
||||||
output.item:set_count(output.item:get_count()*multiplier)
|
output.item:set_count(output.item:get_count()*multiplier)
|
||||||
inv:add_item("dst",output.item)
|
inv:add_item("dst",output.item)
|
||||||
|
end
|
||||||
meta:set_float("srcTime",-1)
|
meta:set_float("srcTime",-1)
|
||||||
meta:set_float("maxSrcTime",0)
|
meta:set_float("maxSrcTime",0)
|
||||||
end
|
|
||||||
srcSlot:set_count(srcSlot:get_count()-multiplier*usedItems)
|
srcSlot:set_count(srcSlot:get_count()-multiplier*usedItems)
|
||||||
inv:set_stack("src",1,srcSlot)
|
inv:set_stack("src",1,srcSlot)
|
||||||
end
|
end
|
||||||
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Loading…
x
Reference in New Issue
Block a user