Page 1 of 1

How get or calculate value?

Posted: Fri Feb 11, 2022 11:46 pm
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.

Re: How get or calculate value?

Posted: Sat Feb 12, 2022 2:02 am
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.

Re: How get or calculate value?

Posted: Sat Feb 12, 2022 2:08 am
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.