Page 1 of 1
Access neighbour bonus of nuclear reactor
Posted: Mon Jan 01, 2018 9:43 pm
by IngoKnieto
Does anybody know how I can access (and then change) the current neighbour bonus of a nuclear reactor?
I tried: my_reactor_entity.neighbour_bonus but this doesn't work: "LuaEntity doesn't contain key neighbour_bonus."
Re: Access neighbour bonus of nuclear reactor
Posted: Mon Jan 01, 2018 10:15 pm
by 321freddy
You can only changes it at startup in the data.lua files (not in control.lua).
This is the prototype definition of the nuclear reactor:
Code: Select all
{
type = "reactor",
name = "nuclear-reactor",
icon = "__base__/graphics/icons/nuclear-reactor.png",
icon_size = 32,
flags = {"placeable-neutral", "player-creation"},
minable = {mining_time = 1.5, result = "nuclear-reactor"},
max_health = 500,
corpse = "big-remnants",
consumption = "40MW",
neighbour_bonus = 1,
[...]
}
So to change it do
Code: Select all
data.raw.reactor["nuclear-reactor"].neighbour_bonus = 1
Re: Access neighbour bonus of nuclear reactor
Posted: Mon Jan 01, 2018 11:20 pm
by IngoKnieto
But I want to access the current neighbour bonus value of an already build reactor. Is there a way I can get this like for example the reactor temperature?
I found entity.temperature in the Lua API, but there doesn't seem to be any property for the current neighbour bonus of a nuclear reactor.
Re: Access neighbour bonus of nuclear reactor
Posted: Mon Jan 01, 2018 11:34 pm
by 321freddy
Yes it seems to be missing. The only way I see to change it would be, to create a new reactor type with a different neighbor bonus and replace the old one with it.
Or you could try
asking here and maybe they'll add the property if you're lucky.
Re: Access neighbour bonus of nuclear reactor
Posted: Tue Jan 02, 2018 7:28 pm
by IngoKnieto
Thanks for the tip with the property request thread, I'll try that.
I actually did create my own reactor type, but I have no idea how to do the neighbour bonus. I think the base game neighbour bonus just doubles the heat a reactor produces (not sure though...).
But how can I access the heat? There is the "heat_buffer" in the reactor prototype, I suppose that is where these values are configured:
Code: Select all
heat_buffer =
{
max_temperature = 1000,
specific_heat = "10MJ",
max_transfer = "10GW",
connections = [...]
}
But again same problem: how do you access it from control.lua? I know about entity.burner, but (afaik) there's no entity.heat_buffer. So I'm right where I started with entity.neighbour_bonus
Or did you have anything different in mind?
Re: Access neighbour bonus of nuclear reactor
Posted: Wed Jan 03, 2018 5:06 pm
by 321freddy
In data.lua you can just set neighbour_bonus to whatever you like, you don't need to change the heat thing.
The vanilla reactor does it like this:
Code: Select all
{
type = "reactor",
name = "nuclear-reactor",
[...]
neighbour_bonus = 1,
[...]
}
I guess 1 means a neighbour bonus of +100% (1 * 100 = 100%), so set it to 2 to get +200%, 1.5 to get +150% etc.
+100% bonus means the reactor has 100% + 100% = 200% efficiency, so I think it is just as efficient as two standalone reactors combined.
You wont be able to easily read the neighbour bonus in control.lua without the property but you could just hardcode it for now.
Re: Access neighbour bonus of nuclear reactor
Posted: Wed Jan 03, 2018 9:39 pm
by IngoKnieto
Ok, I think I get what you mean. Although the default neighbour_bonus is 1, which results in +0% efficiency (I suppose that is the state when the reactor standing alone), so I think I would have to set it to 2 to get +100%.
However this has no effect. I created a test reactor prototype and I set the neighbour_bonus to 2, all other settings are like in the vanilla reactor. When you build this reactor it still has +0% bonus, it looks like the bonus is never applied (Or maybe it is applied when the reactor is build, and one tick later reset to the default value by some in-game script, which checks and sets the neighbour bonus for all entities with type = "reactor"? (btw if there is such a script I would really like a look at it)).
I then tried to change the values of the heat_buffer, I thought I could modify the performance there, but specific_heat = "10MJ" just controls the time in which the reactor heats up (if you set it to 5 MJ it'll heat up twice as fast), and max_transfer = "10GW" didn't have any effect at all - or at least I couldn't find one.
Too bad, I would really like to build a custom reactor, which can produce heat for more than the default 4 heat exchangers...
Anyway, thanks for the help

Re: Access neighbour bonus of nuclear reactor
Posted: Thu Jan 04, 2018 3:18 am
by Nexela
Neighbor bonus only has affect when there are neighbors

Re: Access neighbour bonus of nuclear reactor
Posted: Thu Jan 04, 2018 5:42 am
by chrisgbk
IngoKnieto wrote:Ok, I think I get what you mean. Although the default neighbour_bonus is 1, which results in +0% efficiency (I suppose that is the state when the reactor standing alone), so I think I would have to set it to 2 to get +100%.
However this has no effect. I created a test reactor prototype and I set the neighbour_bonus to 2, all other settings are like in the vanilla reactor. When you build this reactor it still has +0% bonus, it looks like the bonus is never applied (Or maybe it is applied when the reactor is build, and one tick later reset to the default value by some in-game script, which checks and sets the neighbour bonus for all entities with type = "reactor"? (btw if there is such a script I would really like a look at it)).
I then tried to change the values of the heat_buffer, I thought I could modify the performance there, but specific_heat = "10MJ" just controls the time in which the reactor heats up (if you set it to 5 MJ it'll heat up twice as fast), and max_transfer = "10GW" didn't have any effect at all - or at least I couldn't find one.
Too bad, I would really like to build a custom reactor, which can produce heat for more than the default 4 heat exchangers...
Anyway, thanks for the help

Output of a reactor is controlled by "consumption" in the prototype, which is how much heat the reactor generates from fuel. Doubling it means the reactor consumes fuel twice as fast, but outputs twice the heat. Vanilla is 40MW which corresponds to supporting 4 10MW heat exchangers.
Re: Access neighbour bonus of nuclear reactor
Posted: Thu Jan 04, 2018 8:01 pm
by IngoKnieto
Nexela wrote:Neighbor bonus only has affect when there are neighbors

Yeah, I get it now, and I probably didn't make myself 100% clear. I think you can say that there are two "neighbour bonus variables":
a) how big is the bonus -> that's the value in the prototype
b) how many times is it applied to the reactor -> that's the value depending on the number of neighbour reactors.
And I wanted to modify the second thing. Have a neighbour bonus without any neighbour reactor. But I think it's controlled by some inner game logic and can't be modified.
chrisgbk wrote:IngoKnieto wrote:Ok, I think I get what you mean. Although the default neighbour_bonus is 1, which results in +0% efficiency (I suppose that is the state when the reactor standing alone), so I think I would have to set it to 2 to get +100%.
However this has no effect. I created a test reactor prototype and I set the neighbour_bonus to 2, all other settings are like in the vanilla reactor. When you build this reactor it still has +0% bonus, it looks like the bonus is never applied (Or maybe it is applied when the reactor is build, and one tick later reset to the default value by some in-game script, which checks and sets the neighbour bonus for all entities with type = "reactor"? (btw if there is such a script I would really like a look at it)).
I then tried to change the values of the heat_buffer, I thought I could modify the performance there, but specific_heat = "10MJ" just controls the time in which the reactor heats up (if you set it to 5 MJ it'll heat up twice as fast), and max_transfer = "10GW" didn't have any effect at all - or at least I couldn't find one.
Too bad, I would really like to build a custom reactor, which can produce heat for more than the default 4 heat exchangers...
Anyway, thanks for the help

Output of a reactor is controlled by "consumption" in the prototype, which is how much heat the reactor generates from fuel. Doubling it means the reactor consumes fuel twice as fast, but outputs twice the heat. Vanilla is 40MW which corresponds to supporting 4 10MW heat exchangers.
So consumption = production, aahhhh....

Thanks, that was kinda what I was looking for.
I set it to 80 MW and I set burner.efficiency to 2 to counter the faster fuel burning. I think that must be about what the vanilla neighbour_bonus is doing, right? I mean for two reactors next to each other...