Use appropriate item power exchange direction
This commit is contained in:
parent
fd45e58e9c
commit
09a0d9c855
@ -37,7 +37,12 @@ industrialtest.internal.unpackTableInto(industrialtest.CanningMachine,{
|
|||||||
"upgrades",
|
"upgrades",
|
||||||
"powerStorage"
|
"powerStorage"
|
||||||
},
|
},
|
||||||
powerLists={"powerStorage"},
|
powerLists={
|
||||||
|
{
|
||||||
|
list="powerStorage",
|
||||||
|
direction="i"
|
||||||
|
}
|
||||||
|
},
|
||||||
active={
|
active={
|
||||||
tiles={
|
tiles={
|
||||||
"industrialtest_machine_block.png",
|
"industrialtest_machine_block.png",
|
||||||
@ -184,7 +189,6 @@ function industrialtest.CanningMachine.shouldDeactivate(self,pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function industrialtest.CanningMachine.afterDeactivation(self,pos)
|
function industrialtest.CanningMachine.afterDeactivation(self,pos)
|
||||||
minetest.debug("deactivated")
|
|
||||||
local meta=minetest.get_meta(pos)
|
local meta=minetest.get_meta(pos)
|
||||||
local inv=meta:get_inventory()
|
local inv=meta:get_inventory()
|
||||||
local targetSlot=inv:get_stack("dst",1)
|
local targetSlot=inv:get_stack("dst",1)
|
||||||
|
@ -161,16 +161,31 @@ function industrialtest.ElectricMachine.powerExchange(self,pos)
|
|||||||
if self.powerLists then
|
if self.powerLists then
|
||||||
local inv=meta:get_inventory()
|
local inv=meta:get_inventory()
|
||||||
local powerFlow=meta:get_int("industrialtest.powerFlow")
|
local powerFlow=meta:get_int("industrialtest.powerFlow")
|
||||||
for _,list in ipairs(self.powerLists) do
|
for _,listDesc in ipairs(self.powerLists) do
|
||||||
if meta:get_int("industrialtest.powerAmount")<=0 then
|
local slot=inv:get_stack(listDesc.list,1)
|
||||||
break
|
if slot:get_count()>0 then
|
||||||
end
|
if listDesc.direction=="o" then
|
||||||
local slot=inv:get_stack(list,1)
|
if meta:get_int("industrialtest.powerAmount")<=0 then
|
||||||
if slot:get_count()>0 and not industrialtest.api.isFullyCharged(slot:get_meta()) then
|
break
|
||||||
industrialtest.api.transferPowerToItem(meta,slot,powerFlow)
|
end
|
||||||
inv:set_stack(list,1,slot)
|
if not industrialtest.api.isFullyCharged(slot:get_meta()) then
|
||||||
self:updateFormspec(pos)
|
industrialtest.api.transferPowerToItem(meta,slot,powerFlow)
|
||||||
shouldRerunTimer=shouldRerunTimer or (not industrialtest.api.isFullyCharged(slot:get_meta()) and meta:get_int("industrialtest.powerAmount")>0)
|
inv:set_stack(listDesc.list,1,slot)
|
||||||
|
self:updateFormspec(pos)
|
||||||
|
shouldRerunTimer=shouldRerunTimer or (not industrialtest.api.isFullyCharged(slot:get_meta()) and meta:get_int("industrialtest.powerAmount")>0)
|
||||||
|
end
|
||||||
|
elseif listDesc.direction=="i" then
|
||||||
|
if industrialtest.api.isFullyCharged(meta) then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
local slotMeta=slot:get_meta()
|
||||||
|
if slotMeta:get_int("industrialtest.powerAmount")>0 then
|
||||||
|
industrialtest.api.transferPowerFromItem(slot,meta,powerFlow)
|
||||||
|
inv:set_stack(listDesc.list,1,slot)
|
||||||
|
self:updateFormspec(pos)
|
||||||
|
shouldRerunTimer=shouldRerunTimer or (not industrialtest.api.isFullyCharged(meta) and slotMeta:get_int("industrialtest.powerAmount")>0)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -50,7 +50,12 @@ industrialtest.internal.unpackTableInto(industrialtest.Generator,{
|
|||||||
flow=industrialtest.api.lvPowerFlow,
|
flow=industrialtest.api.lvPowerFlow,
|
||||||
ioConfig="oooooo",
|
ioConfig="oooooo",
|
||||||
hasPowerOutput=true,
|
hasPowerOutput=true,
|
||||||
powerLists={"charged"}
|
powerLists={
|
||||||
|
{
|
||||||
|
list="charged",
|
||||||
|
direction="o"
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function industrialtest.Generator.onConstruct(self,pos)
|
function industrialtest.Generator.onConstruct(self,pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user