Hey,
i'm new to programming with lua, especially combined with factorio, but I have a good knowledge about programming in general. Currently I don't really understand the way of adding custom behaviours to buildings right now.
For example, changing the behaviour of a copy of the Steam Engine to produce energy with cold water instead of hot water.. How do I do that? I did not find any value, allowing me to change this behaviour. Is it something I have to do with the control.lua or is there another way to create this?
Can someone point me in the right direction for a solution for this kind of problem?
Thanks in advance
Savi
Change Generator Behaviour
Re: Change Generator Behaviour
Look into the KSPower mod, particularly the diesel generator, which consumes an arbitrary fluid and generates electricity.
Re: Change Generator Behaviour
Thanks for the fast reply, I guess I found what you meant:
He is checking for the type of the fuel and then manipulates the temperature of the pot to indirectly manipulate the diesel generator. In my case there would only be one type of fluid allowed (water) and the incoming value would be inverted. Is it possible to turn the behaviour around like
I'm not sure if I can access this value of the generator like that. I guess I just have to try
Thanks for your hint BlakeMW
Code: Select all
function check_generators()
if global.petroleum_generator ~= nil then
for k,gen in pairs(global.petroleum_generator) do
--if k % 10 == game.tick % 10 then
if gen.valid then
if gen.fluidbox[1] ~= nil then
local pot = gen.fluidbox[1]
local p = gen.position
if pot.type == "petroleum-gas" then
pot["temperature"] = 80
gen.surface.pollute({p.x, p.y}, 0.8/60)
elseif pot.type == "light-oil" then
pot["temperature"] = 100
gen.surface.pollute({p.x, p.y}, 1/60)
elseif pot.type == "diesel-fuel" then
pot["temperature"] = 100
gen.surface.pollute({p.x, p.y}, 1.2/60)
elseif pot.type == "heavy-oil" then
pot["temperature"] = 60
gen.surface.pollute({p.x, p.y}, 0.6/60)
else pot["temperature"] = 15 end
gen.fluidbox[1] = pot
end
else table.remove(global.petroleum_generator, k)
--end
end
end
end
end
Code: Select all
myGenerator["temperature"] = 100 - pot["temperature"]

Thanks for your hint BlakeMW
Re: Change Generator Behaviour
The KSPower Burner Generator does something sneakier - it creates a hidden steam engine on top of the burner generator, and the script manipulates that hidden steam engine.
So in principle you could base the generator on the Storage Tank, then have a script remove X amount of water, and add X amount of water with the temperature inverted to the hidden steam engine.
So in principle you could base the generator on the Storage Tank, then have a script remove X amount of water, and add X amount of water with the temperature inverted to the hidden steam engine.
Re: Change Generator Behaviour
But all the information which are visible for a generator, like "performance" and "available performance" would not be shown on the storage tank based entity?
//Edit
I looked again into the game and tested it. It seems that it is like I said.. The normal values for a generator are not shown

The control over the game is not that high as I initially thought. To combine the feature of having to additionally add an item to the building, but also fluids to generate power with modified fluid behaviour seems not to be that easy.
//Edit
I looked again into the game and tested it. It seems that it is like I said.. The normal values for a generator are not shown


The control over the game is not that high as I initially thought. To combine the feature of having to additionally add an item to the building, but also fluids to generate power with modified fluid behaviour seems not to be that easy.
