Storage tank max size info

Place to get help with not working mods / modding interface.
Kexík
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Mon Dec 01, 2014 12:52 pm
Contact:

Storage tank max size info

Post by Kexík »

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?

n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: Storage tank max size info

Post by n9103 »

Kexík wrote:BTW isnt here something like Modders irc where i could ask about simple problem like this and dont spam forum?
That would require people to regularly log into something, something I find relatively rare, even when the whole process can be automated.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Storage tank max size info

Post by L0771 »

Kexík wrote: I hate using hardcoded magic numbers.
Me too.

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 :/

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: Storage tank max size info

Post by drs9999 »

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.

Kexík
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Mon Dec 01, 2014 12:52 pm
Contact:

Re: Storage tank max size info

Post by Kexík »

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.

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: Storage tank max size info

Post by drs9999 »

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.

Kexík
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Mon Dec 01, 2014 12:52 pm
Contact:

Re: Storage tank max size info

Post by Kexík »

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

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Storage tank max size info

Post by L0771 »

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?
What drs9999 sais is.......
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
and game.itemprototypes["fluid-storage-tank"].fuelvalue can get the fluid_box...
or ["entity"].prototype.fuelvalue

Kexík
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Mon Dec 01, 2014 12:52 pm
Contact:

Re: Storage tank max size info

Post by Kexík »

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?
Last edited by Kexík on Fri Dec 19, 2014 4:39 pm, edited 2 times in total.

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: Storage tank max size info

Post by drs9999 »

Dammit I was to slow :D
Yes I meant what L0771 said.
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?
Yes, you have to create the items in data.lua. It's like you said prototypes are read-only once loading is done.

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Storage tank max size info

Post by L0771 »

drs9999 wrote:Yes, you have to create the items in data.lua. It's like you said prototypes are read-only once loading is done.
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 items :cry:

Kexík
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Mon Dec 01, 2014 12:52 pm
Contact:

Re: Storage tank max size info

Post by Kexík »

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

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Storage tank max size info

Post by L0771 »

Kexí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
Can add dependencies like scrapmod, and i think don't need the version
+

n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: Storage tank max size info

Post by n9103 »

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.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.

Kexík
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Mon Dec 01, 2014 12:52 pm
Contact:

Re: Storage tank max size info

Post by Kexík »

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 :]

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Storage tank max size info

Post by L0771 »

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?
yep, is optional dependency.

n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: Storage tank max size info

Post by n9103 »

That's what we're here for :)
Glad you've solved that problem.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.

Kexík
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Mon Dec 01, 2014 12:52 pm
Contact:

Re: Storage tank max size info

Post by Kexík »

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 ?

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Storage tank max size info

Post by L0771 »

Code: Select all

data:extend(
{
    {
    type = "item-group",
    name = "nombre",
    order = "a",
    inventory_order = "z",
    icon="__icon-mod__/icons/icon/reicon/iconicon/icon.png"
    }
}
)
and set this name in subgroup.
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

Kexík
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Mon Dec 01, 2014 12:52 pm
Contact:

Re: Storage tank max size info

Post by Kexík »

Oh, ok thx

Post Reply

Return to “Modding help”