Access neighbour bonus of nuclear reactor

Place to get help with not working mods / modding interface.
Post Reply
User avatar
IngoKnieto
Fast Inserter
Fast Inserter
Posts: 106
Joined: Mon Oct 03, 2016 9:29 am
Contact:

Access neighbour bonus of nuclear reactor

Post 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."

321freddy
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Sep 23, 2016 10:16 pm
Contact:

Re: Access neighbour bonus of nuclear reactor

Post 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

User avatar
IngoKnieto
Fast Inserter
Fast Inserter
Posts: 106
Joined: Mon Oct 03, 2016 9:29 am
Contact:

Re: Access neighbour bonus of nuclear reactor

Post 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.

321freddy
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Sep 23, 2016 10:16 pm
Contact:

Re: Access neighbour bonus of nuclear reactor

Post 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.

User avatar
IngoKnieto
Fast Inserter
Fast Inserter
Posts: 106
Joined: Mon Oct 03, 2016 9:29 am
Contact:

Re: Access neighbour bonus of nuclear reactor

Post 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 8-)

Or did you have anything different in mind?

321freddy
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Sep 23, 2016 10:16 pm
Contact:

Re: Access neighbour bonus of nuclear reactor

Post 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.

User avatar
IngoKnieto
Fast Inserter
Fast Inserter
Posts: 106
Joined: Mon Oct 03, 2016 9:29 am
Contact:

Re: Access neighbour bonus of nuclear reactor

Post 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 :)

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Access neighbour bonus of nuclear reactor

Post by Nexela »

Neighbor bonus only has affect when there are neighbors :)

chrisgbk
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Mon Jan 02, 2017 4:31 am
Contact:

Re: Access neighbour bonus of nuclear reactor

Post 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.

User avatar
IngoKnieto
Fast Inserter
Fast Inserter
Posts: 106
Joined: Mon Oct 03, 2016 9:29 am
Contact:

Re: Access neighbour bonus of nuclear reactor

Post 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.... :D
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...

Post Reply

Return to “Modding help”