Take into account machine ioConfig when transferring power
This commit is contained in:
parent
174798262b
commit
319d3102f6
2
api.lua
2
api.lua
@ -64,7 +64,7 @@ industrialtest.api.powerFlow=function(pos)
|
|||||||
end
|
end
|
||||||
local neighboursContainingPower=0
|
local neighboursContainingPower=0
|
||||||
for key,value in ipairs(neighbours) do
|
for key,value in ipairs(neighbours) do
|
||||||
if industrialtest.api.hasPowerStorage(value) then
|
if industrialtest.api.hasPowerStorage(value) and value:get_string("industrialtest.ioConfig")[key%2==0 and key+1 or key-1]=="i" then
|
||||||
neighboursContainingPower=neighboursContainingPower+1
|
neighboursContainingPower=neighboursContainingPower+1
|
||||||
else
|
else
|
||||||
neighbourPositions[key]=nil
|
neighbourPositions[key]=nil
|
||||||
|
@ -18,7 +18,6 @@ local S=minetest.get_translator("industrialtest")
|
|||||||
|
|
||||||
-- Generators
|
-- Generators
|
||||||
local function generatorFormspec(fuelPercent,charged)
|
local function generatorFormspec(fuelPercent,charged)
|
||||||
minetest.chat_send_all(charged)
|
|
||||||
local formspec={
|
local formspec={
|
||||||
industrialtest.formspecVersion(),
|
industrialtest.formspecVersion(),
|
||||||
"size[10.8,12]",
|
"size[10.8,12]",
|
||||||
@ -89,6 +88,7 @@ local definition={
|
|||||||
meta:set_int("fuelTime",fuelTime)
|
meta:set_int("fuelTime",fuelTime)
|
||||||
industrialtest.api.addPower(meta,100)
|
industrialtest.api.addPower(meta,100)
|
||||||
meta:set_string("formspec",generatorFormspec(fuelTime/meta:get_int("maxFuelTime")*100,meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")))
|
meta:set_string("formspec",generatorFormspec(fuelTime/meta:get_int("maxFuelTime")*100,meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")))
|
||||||
|
industrialtest.api.powerFlow(pos)
|
||||||
if fuelTime>0 or fuelList[1]:get_count()>0 then
|
if fuelTime>0 or fuelList[1]:get_count()>0 then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user