Car energy readings?

Place to get help with not working mods / modding interface.
Post Reply
sillyfly
Smart Inserter
Smart Inserter
Posts: 1099
Joined: Sun May 04, 2014 11:29 am
Contact:

Car energy readings?

Post by sillyfly »

I'm trying to get car energy readings (i.e. the amount of fuel), but I get weird results, namely player.vehicle.energy seems to contain only three possible values depending on the driving direction - when not moving it always contains the value 2666.666, when going forward it's 166.666 and when going backwards it's 1416.666

Is this a bug? Could I be doing something wrong? (I only print the value of energy every 60 ticks, nothing else) Is there an alternative way of reading the energy buffer of a car?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Car energy readings?

Post by Rseding91 »

Burner energy sources don't store the full buffer of energy in the property you're reading. There's a "remaining part of fuel being burnt" that gets transferred into the main energy buffer each tick. That's the progress bar you see when you open the car up.

I added LuaBurner for 0.15 that lets you read/write those properties in addition to the normal energy value.
If you want to get ahold of me I'm almost always on Discord.

sillyfly
Smart Inserter
Smart Inserter
Posts: 1099
Joined: Sun May 04, 2014 11:29 am
Contact:

Re: Car energy readings?

Post by sillyfly »

Thanks.
So if I understand correctly, the values I was seeing were energy consumed per tick? Why would it be larger when standing still or going backwards?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Car energy readings?

Post by Rseding91 »

sillyfly wrote:Thanks.
So if I understand correctly, the values I was seeing were energy consumed per tick? Why would it be larger when standing still or going backwards?
Cars only consume power when moving based off how fast they're trying to move. Cars move slowly going backwards and not at all when not moving.
If you want to get ahold of me I'm almost always on Discord.

sillyfly
Smart Inserter
Smart Inserter
Posts: 1099
Joined: Sun May 04, 2014 11:29 am
Contact:

Re: Car energy readings?

Post by sillyfly »

Ok, makes sense.

Post Reply

Return to “Modding help”