This should work, this time it checks if the icon exists, and if it doesn't - it moves on to the icons property. If it exists (which it should for all valid technologies which don't have icon property) it copies that to the new AMS technology. It also deletes the irrelevant property.
if data.raw["technology"][Prerequisite].icon ~= nil and data.raw["technology"][Prerequisite].icon ~= "" then
AMSMachineTechnology.icon = data.raw["technology"][Prerequisite].icon
AMSMachineTechnology.icon_size = data.raw["technology"][Prerequisite].icon_size
AMSMachineTechnology.icons = nil
elseif data.raw["technology"][Prerequisite].icons ~= nil and data.raw["technology"][Prerequisite].icons ~= {} then
AMSMachineTechnology.icons = data.raw["technology"][Prerequisite].icons
AMSMachineTechnology.icon = nil
AMSMachineTechnology.icon_size = nil
end
I have one more question, can you tell me how to make it so that the material is only legendary?
I don't know what you mean, can you please elaborate?