How get or calculate value?

Place to get help with not working mods / modding interface.
User avatar
yaim904
Fast Inserter
Fast Inserter
Posts: 129
Joined: Wed Nov 17, 2021 11:26 pm
Contact:

How get or calculate value?

Post by yaim904 »

Is there any way to access data.raw from control.lua??

I want the value of technology > Any technology > unit > time

Code: Select all

[ 'technology' ] = {
	[ 'electronics' ] = {
		[ 'type' ] = 'technology',
		[ 'name' ] = 'electronics',
		[ 'icon_size' ] = 256,
		[ 'icon_mipmaps' ] = 4,
		[ 'icon' ] = '__base__/graphics/technology/electronics.png',
		[ 'prerequisites' ] = {
			[ 1 ] = 'automation',
		},
		[ 'unit' ] = {
			[ 'count' ] = 30,
			[ 'ingredients' ] = {
				[ 1 ] = {
					[ 1 ] = 'automation-science-pack',
					[ 2 ] = 1,
				},
			},
			[ 'time' ] = 15,  <--
		},
		[ 'order' ] = 'a-d-a',
	},
}
Or a way to calculate it from the property research_unit_energy

Code: Select all

for _, force in pairs( game.forces ) do
	for Technology, Details in pairs( force.technologies ) do
		-- Details.research_unit_energy
	end
end

Code: Select all

[ 'electronics' ] = {
	[ 'name' ] = 'electronics',
	[ 'localised_name' ] = {
		[ 1 ] = 'technology-name.electronics',
	},
	[ 'localised_description' ] = {
		[ 1 ] = 'technology-description.electronics',
	},
	[ 'enabled' ] = true,
	[ 'visible_when_disabled' ] = false,
	[ 'upgrade' ] = false,
	[ 'researched' ] = false,
	[ 'research_unit_count' ] = 30,
	[ 'research_unit_energy' ] = 900,
	[ 'order' ] = 'a-d-a',
	[ 'level' ] = 1,
	[ 'research_unit_ingredients' ] = {
		[ 1 ] = 'automation-science-pack',
	},
	[ 'prerequisites' ] = {
		[ 1 ] = 'automation',
	},
	[ 'effects' ] = { },
	[ 'prototype' ] = {
		[ 'name' ] = 'electronics',
		[ 'localised_description' ] = {
			[ 1 ] = 'technology-description.electronics',
		},
		[ 'enabled' ] = true,
		[ 'hidden' ] = false,
		[ 'visible_when_disabled' ] = false,
		[ 'ignore_tech_cost_multiplier' ] = false,
		[ 'upgrade' ] = false,
		[ 'research_unit_count' ] = 30,
		[ 'research_unit_energy' ] = 900,  <--
		[ 'order' ] = 'a-d-a',
		[ 'level' ] = 1,
		[ 'max_level' ] = 1,
		[ 'research_unit_ingredients' ] = {
			[ 1 ] = 'automation-science-pack',
		},
		[ 'prerequisites' ] = {
			[ 1 ] = 'automation',
		},
		[ 'effects' ] = { },
	},
},
What I want is to calculate the time it takes to carry out the investigation with a laboratory, which would be count * time, but if you know another way, tell me.
Solo entiendo español, pero si tu también lo entiendes, escríbeme
:D
Everything i write in English is translated by Deepl.
:D
User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 586
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: How get or calculate value?

Post by Silari »

data.raw only exists in the data stage, as a precursor to making all the game's prototypes. Once you're in game, what you want is the prototype dictionaries in gamescript, specifically https://lua-api.factorio.com/latest/Lua ... prototypes

I believe research_unit_energy is the time in ticks.
User avatar
yaim904
Fast Inserter
Fast Inserter
Posts: 129
Joined: Wed Nov 17, 2021 11:26 pm
Contact:

Re: How get or calculate value?

Post by yaim904 »

Silari wrote: Sat Feb 12, 2022 2:02 am
I understand, and thanks for the clarification.

I already found what I was looking for.

research_unit_energy is equal to the research time of a laboratory, without a module or other improvements.

Just what I was looking for.
Solo entiendo español, pero si tu también lo entiendes, escríbeme
:D
Everything i write in English is translated by Deepl.
:D
Post Reply

Return to “Modding help”