Balance nuclear reactor

This commit is contained in:
mrkubax10 2023-11-21 12:47:02 +01:00
parent c56c0a9c5c
commit f3d05ac5bb

View File

@ -70,7 +70,7 @@ local function findMaxFuelCluster(fuelList)
for y=1,4 do for y=1,4 do
for x=1,5 do for x=1,5 do
local iy=y-1 local iy=y-1
local stack=fuelList[iy*4+x] local stack=fuelList[iy*5+x]
local def=minetest.registered_tools[stack:get_name()] local def=minetest.registered_tools[stack:get_name()]
if def and def.groups._industrialtest_nuclearReactorFuel then if def and def.groups._industrialtest_nuclearReactorFuel then
local cluster={ local cluster={
@ -79,60 +79,60 @@ local function findMaxFuelCluster(fuelList)
y=iy y=iy
} }
} }
if x>1 and fuelList[iy*4+x-1]:get_name()==stack:get_name() then if x>1 and fuelList[iy*5+x-1]:get_name()==stack:get_name() then
table.insert(cluster,{ table.insert(cluster,{
x=x-1, x=x-1,
y=iy y=iy
}) })
end end
if x<5 and fuelList[iy*4+x+1]:get_name()==stack:get_name() then if x<5 and fuelList[iy*5+x+1]:get_name()==stack:get_name() then
table.insert(cluster,{ table.insert(cluster,{
x=x+1, x=x+1,
y=iy y=iy
}) })
end end
if y>1 and fuelList[(iy-1)*4+x]:get_name()==stack:get_name() then if y>1 and fuelList[(iy-1)*5+x]:get_name()==stack:get_name() then
table.insert(cluster,{ table.insert(cluster,{
x=x, x=x,
i=iy-1 y=iy-1
}) })
end end
if y<4 and fuelList[(iy+1)*4+x]:get_name()==stack:get_name() then if y<4 and fuelList[(iy+1)*5+x]:get_name()==stack:get_name() then
table.insert(cluster,{ table.insert(cluster,{
x=x, x=x,
y=iy+1 y=iy+1
}) })
end end
if x>1 and y>1 and fuelList[(iy-1)*4+x-1]:get_name()==stack:get_name() then if x>1 and y>1 and fuelList[(iy-1)*5+x-1]:get_name()==stack:get_name() then
table.insert(cluster,{ table.insert(cluster,{
x=x-1, x=x-1,
y=iy-1 y=iy-1
}) })
end end
if x<5 and y>1 and fuelList[(iy-1)*4+x+1]:get_name()==stack:get_name() then if x<5 and y>1 and fuelList[(iy-1)*5+x+1]:get_name()==stack:get_name() then
table.insert(cluster,{ table.insert(cluster,{
x=x+1, x=x+1,
y=iy-1 y=iy-1
}) })
end end
if x>1 and y<4 and fuelList[(iy+1)*4+x-1]:get_name()==stack:get_name() then if x>1 and y<4 and fuelList[(iy+1)*5+x-1]:get_name()==stack:get_name() then
table.insert(cluster,{ table.insert(cluster,{
x=x-1, x=x-1,
y=iy+1 y=iy+1
}) })
end end
if x<5 and y<4 and fuelList[(iy+1)*4+x+1]:get_name()==stack:get_name() then if x<5 and y<4 and fuelList[(iy+1)*5+x+1]:get_name()==stack:get_name() then
table.insert(cluster,{ table.insert(cluster,{
x=x+1, x=x+1,
y=iy+1 y=iy+1
}) })
end end
if #cluster==9 then
return cluster
end
if #cluster>#maxCluster then if #cluster>#maxCluster then
maxCluster=cluster maxCluster=cluster
end end
if #cluster==4 then
return maxCluster
end
end end
end end
end end
@ -224,11 +224,11 @@ reactor.activeOnTimer=function(pos,elapsed,meta,inv)
local maxCluster=findMaxFuelCluster(fuelList) local maxCluster=findMaxFuelCluster(fuelList)
for _,stack in ipairs(maxCluster) do for _,stack in ipairs(maxCluster) do
local index=stack.y*4+stack.x local index=stack.y*5+stack.x
local usedStack,_=useFuel(fuelList[index],5) local usedStack,_=useFuel(fuelList[index],5)
inv:set_stack("fuel",index,usedStack) inv:set_stack("fuel",index,usedStack)
end end
local generatedPowerAmount=math.pow(20,#maxCluster) local generatedPowerAmount=math.pow(3,#maxCluster)
if industrialtest.api.addPower(meta,generatedPowerAmount)>0 then if industrialtest.api.addPower(meta,generatedPowerAmount)>0 then
shouldUpdateFormspec=true shouldUpdateFormspec=true
end end
@ -325,8 +325,8 @@ industrialtest.internal.registerMachine({
name="nuclear_reactor", name="nuclear_reactor",
displayName=S("Nuclear Reactor"), displayName=S("Nuclear Reactor"),
getFormspec=reactor.getFormspec, getFormspec=reactor.getFormspec,
capacity=industrialtest.api.ivPowerFlow*2, capacity=industrialtest.api.evPowerFlow,
flow=industrialtest.api.ivPowerFlow, flow=industrialtest.api.evPowerFlow,
ioConfig="oooooo", ioConfig="oooooo",
requiresWrench=true, requiresWrench=true,
registerActiveVariant=true, registerActiveVariant=true,