Page 1 of 1
Making belt prototype consume power
Posted: Tue May 19, 2015 7:35 pm
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?
Re: Making belt prototype consume power
Posted: Tue May 19, 2015 11:46 pm
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",
Re: Making belt prototype consume power
Posted: Tue May 19, 2015 11:50 pm
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.
Re: Making belt prototype consume power
Posted: Wed May 20, 2015 12:13 am
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?
Re: Making belt prototype consume power
Posted: Wed May 20, 2015 2:59 am
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?
Re: Making belt prototype consume power
Posted: Wed May 20, 2015 7:01 am
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.
Re: Making belt prototype consume power
Posted: Wed May 20, 2015 9:43 am
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.
Re: Making belt prototype consume power
Posted: Wed May 20, 2015 9:49 am
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?
Re: Making belt prototype consume power
Posted: Wed May 20, 2015 3:32 pm
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
Re: Making belt prototype consume power
Posted: Wed May 20, 2015 5:14 pm
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.
Re: Making belt prototype consume power
Posted: Wed May 20, 2015 5:16 pm
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.
Re: Making belt prototype consume power
Posted: Wed May 20, 2015 6:05 pm
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
Re: Making belt prototype consume power
Posted: Wed May 20, 2015 6:38 pm
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.