Page 1 of 1

How to interpret the "fuel_value" property?

Posted: Wed Aug 09, 2017 8:23 pm
by MrFreohr
Hello,
I am currently working on a fix for Autofill to include modded items in its fuel detection and insertion logic, but I have hit a fairly major roadblock.
I can retrieve all the item prototypes with a fuel value (coal, wood, wooden chest, crushed coal from Angel's addons, etc.) and the value is stored as a string, e.g. "8MJ".
What I don't understand is that the type of this value is not the one described in the official API (fuel_value property), which is typed as a float.

I used the data-raw-protoypes to filter the properties I need.

Code: Select all

wood
{
  fuel_category = "chemical",
  fuel_value = "2MJ",
  name = "wood",
  type = "item"
}
wooden-chest
{
  fuel_category = "chemical",
  fuel_value = "4MJ",
  name = "wooden-chest",
  type = "item"
}
So my questions are:
  • What is the correct way to store this fuel value ? As a string with the absolute energy value and the unit (used in every mod and the base game item prototypes), or as a float value, which the wiki explains that it represents the energy value relative to coal's energy value?
  • If this value is supposed to be stored as a string, is there any way to compare 2 fuel values (beside writing my own string->int converter function)?

Re: How to interpret the "fuel_value" property?

Posted: Wed Aug 09, 2017 8:59 pm
by DaveMcW
Is your file named data.lua? Use the string value.

Is your file named control.lua? Use the official API (float value).

data-raw-protoypes mod is an ugly hack, you should report any use case that requires it in Modding interface requests

Re: How to interpret the "fuel_value" property?

Posted: Wed Aug 09, 2017 9:59 pm
by Nexela
If time wasn't such a constraint I would have finished autofill 2.0

It currently has much better ammo and fuel logic in it, You can check out some of the branches on github to see how it I do it.

Getting the ammo and fuel stuff from the data stage is not the way to go.

Re: How to interpret the "fuel_value" property?

Posted: Wed Aug 09, 2017 10:08 pm
by MrFreohr
I understand your time problem, I can help with some parts of the developpement if you have some specifications lying around :)

I found my solution in the end, it wasn't a prototype problem, the logic was already working, but the fuel I was trying to insert was the omnite ore (with a 3MJ value) from the omniconvertion modpack, and it didn't make it into the fuel-high array (needed by the burner drill, furnaces, etc.)...

Re: How to interpret the "fuel_value" property?

Posted: Wed Aug 09, 2017 10:08 pm
by d3x0r
The wiki is wrong... and should be corrected... that is describing data.lua entries..

The other reference in lua api is right; once you get it in game control script it's a double without units, but not as a data definition...

It's a floating point value with a unit suffix, kJ, MJ etc work, and because it has other things than numbers it has to be a string.
"6.3kJ" is a valid value though....

it's not actually Joules though; it's watts per tick it supplies.
Not a big deal; just use relative scale based on other fuel types...


If you specify J where it's expecting Watts it multiplies the value by 60.
if you use W where its expecting joules it divides the value by 60.

m,c,d,D don't work... (/1000,/100,/10,*10)
Units that work
[J/W] * 1
k[J/W] * 1000
M[J/W] *1,000,000
G[J/W] * 1,000,000,000
T[J/W] * 1,000,000,000,000
P[J/W] * 1,000,000,000,000,000
Z[J/W] (another thousand)
Y[J/W] (another thousand) (highest unit apparently)

(not sure about higher values)