Storage tank max size info
Storage tank max size info
Hi, i was trying to reach Storage tank max size (fluid_box.base_area) from code but without success. I know that i can get to prorotype of entity, but it seem that i need to cast it somehow to specific entityType to be able reach fluid_box.
Am i right and is it possible in lua? Or am i doing it wrong. please help, I hate using hardcoded magic numbers.
BTW isnt here something like Modders irc where i could ask about simple problem like this and dont spam forum?
Am i right and is it possible in lua? Or am i doing it wrong. please help, I hate using hardcoded magic numbers.
BTW isnt here something like Modders irc where i could ask about simple problem like this and dont spam forum?
Re: Storage tank max size info
That would require people to regularly log into something, something I find relatively rare, even when the whole process can be automated.Kexík wrote:BTW isnt here something like Modders irc where i could ask about simple problem like this and dont spam forum?
Re: Storage tank max size info
Me too.Kexík wrote: I hate using hardcoded magic numbers.
According to what I understand, you want ask "base_area" of an tank entity or pipe in your control.lua
This theoretically is entity.prototype.fluid_box.base_area, but can't be get some properties, i think you need hardcode magic numbers :/
Re: Storage tank max size info
If what L0771 said don't work, then I'm pretty sure that there is no way to do it.
However maybe you want to explain why you need it, there might be other solutions.
However maybe you want to explain why you need it, there might be other solutions.
Re: Storage tank max size info
I need exactly what L0771 said entity.prototype.fluid_box.base_area, but problem is that entity.prototype give me Prototype/Entity and that dont have fluid_box so i would need to recast it somehow to Prototype/PipeConnectable that have fluid box so i can reach it. Thats what i think is the problem.
Re: Storage tank max size info
Well yes, but that isn't working, right?! There is nothing like casting in this context, so if you can't access it that means that you can't access it
Anyway, there still exist workarounds like "meta-items". Basically you create generic items in the loading phase which store the values in which you are intrested, in keys that are accesible via the prototype.
Anyway, there still exist workarounds like "meta-items". Basically you create generic items in the loading phase which store the values in which you are intrested, in keys that are accesible via the prototype.
Re: Storage tank max size info
Hmm thanks, about that workaround, you mean like, when prototypes are loaded i will save their base_area for example like myTable[prototype.name] = prototype.liquid_box.base_area (with all necessary checks of course), but where can i do it? Do you have any example or link where is mentioned how to do it?
BTW i want this because of compatibility with other mod if they create storage-tank type entity with different base_area
BTW i want this because of compatibility with other mod if they create storage-tank type entity with different base_area
Re: Storage tank max size info
What drs9999 sais is.......Kexík wrote:Hmm thanks, about that workaround, you mean like, when prototypes are loaded i will save their base_area for example like myTable[prototype.name] = prototype.liquid_box.base_area (with all necessary checks of course), but where can i do it? Do you have any example or link where is mentioned how to do it?
improvised
Code: Select all
for k,tank pairs(data.raw["storage-tank"]) do
data:extend(
{
{
type = "item",
name = "fluid-"..tank.name,
icon = "__mod__/graphics/generic.png",
flags = {"goes-to-main-inventory"},
fuel_value = v.fluid_box.base_area.."J",
subgroup = "a",
order = "a",
stack_size = 1
},
}
)
end
or ["entity"].prototype.fuelvalue
Re: Storage tank max size info
Oh cool, thanks.
One question I have to use this in data.lua? Or can i use it in control.lua because i though that data is not modifiable in scripts?
One question I have to use this in data.lua? Or can i use it in control.lua because i though that data is not modifiable in scripts?
Last edited by Kexík on Fri Dec 19, 2014 4:39 pm, edited 2 times in total.
Re: Storage tank max size info
Dammit I was to slow
Yes I meant what L0771 said.
Yes I meant what L0771 said.
Yes, you have to create the items in data.lua. It's like you said prototypes are read-only once loading is done.Kexík wrote:Oh cool, thanks.
One question I have to use this in data.lua? Or can i use it in control.lua because i though that data is not modifiable in scripts?
Re: Storage tank max size info
I hate this, i have like 1300 items and 400 entities for this... with only an mining-tool.speed editable i can save above 300 itemsdrs9999 wrote:Yes, you have to create the items in data.lua. It's like you said prototypes are read-only once loading is done.
Re: Storage tank max size info
Thanks,
i will use it, but i guess it will not work with others mod like i hoped. When my mod will be loaded before another, i will have no other oprion then use magic number because meta-item will not exist
i will use it, but i guess it will not work with others mod like i hoped. When my mod will be loaded before another, i will have no other oprion then use magic number because meta-item will not exist
Re: Storage tank max size info
Can add dependencies like scrapmod, and i think don't need the versionKexík wrote:Thanks,
i will use it, but i guess it will not work with others mod like i hoped. When my mod will be loaded before another, i will have no other oprion then use magic number because meta-item will not exist
+
Re: Storage tank max size info
A couple of Bob's mods also have this optional dependencies setup, changing the recipes and such if the optional mods are active. Bob's Assemblers is the one I have personal experience with.
Re: Storage tank max size info
Oh, if dependenci have ? before name it mean i dont have to have it, but if i have it will load it before my?
Thank you guys, a learned a lot and fixed more problems than only the one mention at first post :]
Thank you guys, a learned a lot and fixed more problems than only the one mention at first post :]
Re: Storage tank max size info
yep, is optional dependency.Kexík wrote:Oh, if dependenci have ? before name it mean i dont have to have it, but if i have it will load it before my?
Re: Storage tank max size info
That's what we're here for
Glad you've solved that problem.
Glad you've solved that problem.
Re: Storage tank max size info
Ok last question (i hope) when making meta-items, can i use some group that will not be visible when seting conditions from smart-inserters ?
Re: Storage tank max size info
Code: Select all
data:extend(
{
{
type = "item-group",
name = "nombre",
order = "a",
inventory_order = "z",
icon="__icon-mod__/icons/icon/reicon/iconicon/icon.png"
}
}
)
in factorio by default only can see what can you craft, if this group have no one recipe, you can't see. Only can see by smart inserter and logistic slots.
* All my names are generic
Re: Storage tank max size info
Oh, ok thx