Hi! Can anyone explain how to make custom technology with research trigger in proper way?
I've tried one, but trigger doesn't work, also rendered in tech tree gui... as correct tech
An another question, how to disable technology with research trigger? If you change it to nil & add unit to technology the whole list of other triggers don't work ....
			
			
													Research Triggers
Research Triggers
					Last edited by ldinc on Mon Nov 11, 2024 2:57 pm, edited 1 time in total.
									
			
									
						Re: Research Triggers
Example of new tech i've tried:
			
			
									
									
						Code: Select all
{
  effects = {
    { recipe = "apm_crusher_machine_0", type = "unlock-recipe" },
    { recipe = "apm_coal_crushed_1",    type = "unlock-recipe" },
    { recipe = "apm_stone_crushed_1",   type = "unlock-recipe" },
    { recipe = "apm_wood_pellets_1",    type = "unlock-recipe" }
  },
  essential = true,
  icon = "__apm_resource_pack_ldinc__/graphics/technologies/apm_crusher_machine_0.png",
  icon_size = 128,
  name = "apm_crusher_machine_0",
  order = "a-a-a",
  prerequisites = {},
  research_trigger = { count = 5, item = "copper-plate", type = "craft-item" },
  type = "technology",
}
Re: Research Triggers
The first approoach to disable existing technology was:
This code successfully hide from the tree technology, but trigger still active and popup with successfully researched tech will appear
			
			
									
									
						Code: Select all
---@param technology_name string
function apm.lib.utils.technology.delete(technology_name)
	if not apm.lib.utils.technology.exist(technology_name) then return end
	local technology = data.raw.technology[technology_name]
	technology.hidden_in_factoriopedia = true
	technology.visible_when_disabled = false
	technology.essential = false
	technology.enabled = false
	technology.hidden = true
	-- let us find who is linked to this technology and remove the prerequisites
	for technology, _ in pairs(data.raw.technology) do
		if technology ~= technology_name then
			if apm.lib.utils.technology.has.prerequisites(technology, technology_name) then
				apm.lib.utils.technology.remove.prerequisites(technology, technology_name)
			end
		end
	end
end
Re: Research Triggers
Then i've tried to disable research trigger by setting up with `nil`. After this change any other tech-s with researh triggers become unsearchable via crafting items or interact with ores/oil
			
			
									
									
						Code: Select all
---@param technology_name string
function apm.lib.utils.technology.delete(technology_name)
	if not apm.lib.utils.technology.exist(technology_name) then return end
	local technology = data.raw.technology[technology_name]
	technology.hidden_in_factoriopedia = true
	technology.visible_when_disabled = false
	technology.essential = false
	technology.enabled = false
	technology.hidden = true
	if technology.research_trigger then
		technology.research_trigger = nil
		technology.unit = {
			ingredients = {},
			time = 1,
			count = 1,
		}
	end
	-- let us find who is linked to this technology and remove the prerequisites
	for technology, _ in pairs(data.raw.technology) do
		if technology ~= technology_name then
			if apm.lib.utils.technology.has.prerequisites(technology, technology_name) then
				apm.lib.utils.technology.remove.prerequisites(technology, technology_name)
			end
		end
	end
end

