Making belt prototype consume power

Place to get help with not working mods / modding interface.
wahming
Fast Inserter
Fast Inserter
Posts: 192
Joined: Sun May 17, 2015 8:30 pm
Contact:

Making belt prototype consume power

Post by wahming »

Hi!

I'm trying to create a custom transport belt entity that will draw power from the grid. But I've had no luck so far with getting the belt to connect to the grid. Can anybody advise?
Incinirate
Burner Inserter
Burner Inserter
Posts: 18
Joined: Sun May 03, 2015 9:50 pm
Contact:

Re: Making belt prototype consume power

Post by Incinirate »

wahming wrote:Hi!

I'm trying to create a custom transport belt entity that will draw power from the grid. But I've had no luck so far with getting the belt to connect to the grid. Can anybody advise?
Possibly something like this in the entity code, not tested though so I can't say for certain:

Code: Select all

energy_source = {
  type = "electric",
  -- will produce this much * energy pollution units per tick
  emissions = 0.15 / 1.5,
  usage_priority = "secondary-input"
},
energy_usage = "90kW",
wahming
Fast Inserter
Fast Inserter
Posts: 192
Joined: Sun May 17, 2015 8:30 pm
Contact:

Re: Making belt prototype consume power

Post by wahming »

Incinirate wrote:
wahming wrote:Hi!

I'm trying to create a custom transport belt entity that will draw power from the grid. But I've had no luck so far with getting the belt to connect to the grid. Can anybody advise?
Possibly something like this in the entity code, not tested though so I can't say for certain:

Code: Select all

energy_source = {
  type = "electric",
  -- will produce this much * energy pollution units per tick
  emissions = 0.15 / 1.5,
  usage_priority = "secondary-input"
},
energy_usage = "90kW",
I thought so too. Sadly no, I already tried that.
User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Making belt prototype consume power

Post by L0771 »

wahming wrote:I'm trying to create a custom transport belt entity that will draw power from the grid. But I've had no luck so far with getting the belt to connect to the grid. Can anybody advise?
I don't understand, yours belts are using electricity but you need connect eeeevery belt with a pole?
Incinirate
Burner Inserter
Burner Inserter
Posts: 18
Joined: Sun May 03, 2015 9:50 pm
Contact:

Re: Making belt prototype consume power

Post by Incinirate »

wahming wrote:--snip--

I thought so too. Sadly no, I already tried that.
I'm sorry, maybe I am not understanding correctly, do the poles connect to the belts with that code and they just don't stop when you remove power or do they not connect alltogether?
wahming
Fast Inserter
Fast Inserter
Posts: 192
Joined: Sun May 17, 2015 8:30 pm
Contact:

Re: Making belt prototype consume power

Post by wahming »

L0771 wrote:
wahming wrote:I'm trying to create a custom transport belt entity that will draw power from the grid. But I've had no luck so far with getting the belt to connect to the grid. Can anybody advise?
I don't understand, yours belts are using electricity but you need connect eeeevery belt with a pole?
Incinirate wrote:
wahming wrote:--snip--

I thought so too. Sadly no, I already tried that.
I'm sorry, maybe I am not understanding correctly, do the poles connect to the belts with that code and they just don't stop when you remove power or do they not connect alltogether?
No, my belts are not using electricity, and they are not connecting at all.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14594
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Making belt prototype consume power

Post by Rseding91 »

It's not currently possible to make belts use power through the prototype - the belt entity doesn't support it.

You could possibly do it through scripting but it wouldn't be efficient by any means.
If you want to get ahold of me I'm almost always on Discord.
wahming
Fast Inserter
Fast Inserter
Posts: 192
Joined: Sun May 17, 2015 8:30 pm
Contact:

Re: Making belt prototype consume power

Post by wahming »

Rseding91 wrote:It's not currently possible to make belts use power through the prototype - the belt entity doesn't support it.
Yeah, I thought so. Thanks anyway for confirming.
Rseding91 wrote:You could possibly do it through scripting but it wouldn't be efficient by any means.
Just for me to learn - how would I do that?
Incinirate
Burner Inserter
Burner Inserter
Posts: 18
Joined: Sun May 03, 2015 9:50 pm
Contact:

Re: Making belt prototype consume power

Post by Incinirate »

wahming wrote:
Rseding91 wrote:It's not currently possible to make belts use power through the prototype - the belt entity doesn't support it.
Yeah, I thought so. Thanks anyway for confirming.
Rseding91 wrote:You could possibly do it through scripting but it wouldn't be efficient by any means.
Just for me to learn - how would I do that?
You could check it the belt was in range of any pole that was connected to power, if so, drain power, and if not set the belts speed to 0. Possibly
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Making belt prototype consume power

Post by orzelek »

Incinirate wrote:
wahming wrote:
Rseding91 wrote:It's not currently possible to make belts use power through the prototype - the belt entity doesn't support it.
Yeah, I thought so. Thanks anyway for confirming.
Rseding91 wrote:You could possibly do it through scripting but it wouldn't be efficient by any means.
Just for me to learn - how would I do that?
You could check it the belt was in range of any pole that was connected to power, if so, drain power, and if not set the belts speed to 0. Possibly
You can't set belts speed to 0 - entity prototype can't be modified.

You could consume power per belt in pole range but you couldn't stop the belt itself from working.
wahming
Fast Inserter
Fast Inserter
Posts: 192
Joined: Sun May 17, 2015 8:30 pm
Contact:

Re: Making belt prototype consume power

Post by wahming »

orzelek wrote:
Incinirate wrote:
wahming wrote:
Rseding91 wrote:It's not currently possible to make belts use power through the prototype - the belt entity doesn't support it.
Yeah, I thought so. Thanks anyway for confirming.
Rseding91 wrote:You could possibly do it through scripting but it wouldn't be efficient by any means.
Just for me to learn - how would I do that?
You could check it the belt was in range of any pole that was connected to power, if so, drain power, and if not set the belts speed to 0. Possibly
You can't set belts speed to 0 - entity prototype can't be modified.

You could consume power per belt in pole range but you couldn't stop the belt itself from working.
Belts can be deactivated - I've already got that working in my proof of concept. My major headache is with getting them to consume power.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14594
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Making belt prototype consume power

Post by Rseding91 »

wahming wrote: ... Belts can be deactivated - I've already got that working in my proof of concept. My major headache is with getting them to consume power.
You could look at how I implemented power usage for the chests in my "Compression Chests" mod - it's not perfect but it works great for the purposes of that mod. https://github.com/Rseding91/Compression-Chests
If you want to get ahold of me I'm almost always on Discord.
wahming
Fast Inserter
Fast Inserter
Posts: 192
Joined: Sun May 17, 2015 8:30 pm
Contact:

Re: Making belt prototype consume power

Post by wahming »

Rseding91 wrote:
wahming wrote: ... Belts can be deactivated - I've already got that working in my proof of concept. My major headache is with getting them to consume power.
You could look at how I implemented power usage for the chests in my "Compression Chests" mod - it's not perfect but it works great for the purposes of that mod. https://github.com/Rseding91/Compression-Chests
Glancing through your code - so you create a custom pole that has to be placed near your chest, and drain power from that? Good idea. I can see how to modify it for my own use.

Edit: Does the power usage show up in the electrical overview?
Edit 2: Nvm, I realised it's based on the accumulator prototype, not electric pole as I thought.
Post Reply

Return to “Modding help”