for _, force in pairs(game.forces) do
  force.reset_recipes()
  force.reset_technologies()
end

local ord={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r"}
for i, force in pairs(game.forces) do 
	for _,tech in pairs(force.technologies) do
		local prefix = "omni-sorting-"
		if string.sub(tech.name,1,string.len(prefix))==prefix and force.technologies[tech.name].researched then 
			local lvl = string.sub(tech.name,string.len(tech.name)-1,string.len(tech.name))
			local ore = string.sub(tech.name,string.len(prefix)+1,string.len(tech.name)-3)
			if string.sub(lvl,1,1) == "-" then
				lvl = string.sub(tech.name,string.len(tech.name),string.len(tech.name))
				ore = string.sub(tech.name,string.len(prefix)+1,string.len(tech.name)-2)
			end
			if ore ~= "electric" then
				if not force.technologies[prefix..ore.."-"..lvl+1] or not force.technologies[prefix..ore.."-"..lvl+1].researched then
					force.recipes[ore.."-extraction-"..ord[tonumber(lvl)]].enabled = true
					log(ore.."-extraction-"..ord[tonumber(lvl)].." is enabled")
				else
					for k = 1, lvl-1 do
						force.recipes[ore.."-extraction-"..ord[tonumber(k)]].enabled = false
						log(ore.."-extraction-"..ord[tonumber(k)].." is being disabled")
					end					
				end
			end
		end
		prefix = "omniston-solvation-"
		if string.sub(tech.name,1,string.len(prefix))==prefix and force.technologies[tech.name].researched then 
			local lvl = string.sub(tech.name,string.len(tech.name)-1,string.len(tech.name))
			if string.sub(lvl,1,1) == "-" then
				lvl = string.sub(tech.name,string.len(tech.name),string.len(tech.name))
			end
			if not force.technologies[prefix..lvl+1] or not force.technologies[prefix..lvl+1].researched then
				force.recipes[prefix..ord[tonumber(lvl)]].enabled = true
			else
				force.recipes[prefix..ord[tonumber(lvl)]].enabled = false				
			end
		end
		prefix = "omnic-hydrolyzation-"
		if string.sub(tech.name,1,string.len(prefix))==prefix and force.technologies[tech.name].researched then 
			local lvl = string.sub(tech.name,string.len(tech.name)-1,string.len(tech.name))
			if string.sub(lvl,1,1) == "-" then
				lvl = string.sub(tech.name,string.len(tech.name),string.len(tech.name))
			end
			if not force.technologies[prefix..lvl+1] or not force.technologies[prefix..lvl+1].researched then
				force.recipes[prefix..ord[tonumber(lvl)]].enabled = true
			else
				force.recipes[prefix..ord[tonumber(lvl)]].enabled = false				
			end
		end
		prefix = "distillation-"
		if string.sub(tech.name,1,string.len(prefix))==prefix and force.technologies[tech.name].researched then 
			local lvl = string.sub(tech.name,string.len(tech.name)-1,string.len(tech.name))
			local ore = string.sub(tech.name,string.len(prefix)+1,string.len(tech.name)-3)
			if string.sub(lvl,1,1) == "-" then
				lvl = string.sub(tech.name,string.len(tech.name),string.len(tech.name))
				ore = string.sub(tech.name,string.len(prefix)+1,string.len(tech.name)-2)
			end
			log("check this: "..prefix..ore.."-"..lvl+1)
			if not force.technologies[prefix..ore.."-"..lvl+1] or not force.technologies[prefix..ore.."-"..lvl+1].researched then
				force.recipes[prefix..ore.."-"..ord[tonumber(lvl)]].enabled = true
			else
				force.recipes[prefix..ore.."-"..ord[tonumber(lvl)]].enabled = false				
			end
		end
	end
end


if tonumber(a) ~= nil then
   --it's a number
end;