Hide upgraded tiers (higher MKs)

Place to get help with not working mods / modding interface.
Post Reply
Dellamonikus
Inserter
Inserter
Posts: 23
Joined: Fri Nov 07, 2014 2:22 pm
Contact:

Hide upgraded tiers (higher MKs)

Post by Dellamonikus »

Hi, so i know just very little lua, but about 10 different programming languages, so the basic understandings are not a problem.
A problem is however, that for some mods i can edit the tech(nology).lua so that the upgraded tiers (higher MKs) of technologies are hidden until the prerequisites have been researched.

For one mod I figured out, that I would have to set "upgrade = true", which I did and it worked.
The .lua where it works:

Code: Select all

data:extend({
  {
    type = "technology",
    name = "wind-turbine-2",
    icon = "__Wind_Turbine__/graphics/wind_turbine_icon-mk2.png",
    effects =
    {
      {
        type = "unlock-recipe",
        recipe = "wind-turbine-mk2"
      }
    },
    prerequisites = {},
    upgrade = true,
    unit =
    {
      count = 50,
      ingredients =
      {
        {"science-pack-1", 1}
      },
      time = 5
    },
    order = "a-h-d",
  },
  {
    type = "technology",
    name = "wind-turbine-3",
    icon = "__Wind_Turbine__/graphics/wind_turbine_icon-mk3.png",
    effects =
    {
      {
        type = "unlock-recipe",
        recipe = "wind-turbine-mk3"
      }
    },
    prerequisites = {"wind-turbine-2"},
    upgrade = true,
    unit =
    {
      count = 50,
      ingredients =
      {
        {"science-pack-1", 1},
		{"science-pack-2", 1}
      },
      time = 5
    },
    order = "a-h-d",
  },
  {
    type = "technology",
    name = "wind-turbine-4",
    icon = "__Wind_Turbine__/graphics/wind_turbine_icon-mk4.png",
    effects =
    {
      {
        type = "unlock-recipe",
        recipe = "wind-turbine-mk4"
      }
    },
    prerequisites = {"wind-turbine-3"},
    upgrade = true,
    unit =
    {
      count = 50,
      ingredients =
      {
        {"science-pack-1", 1},
		{"science-pack-2", 1},
		{"science-pack-3", 1}
      },
      time = 5
    },
    order = "a-h-d",
  },
  {
    type = "technology",
    name = "wind-turbine-5",
    icon = "__Wind_Turbine__/graphics/wind_turbine_icon-mk5.png",
    effects =
    {
      {
        type = "unlock-recipe",
        recipe = "wind-turbine-mk5"
      }
    },
    prerequisites = {"wind-turbine-4"},
    upgrade = true,
    unit =
    {
      count = 50,
      ingredients =
      {
		{"science-pack-1", 1},
		{"science-pack-2", 1},
		{"science-pack-3", 1},
		{"alien-science-pack", 1}
      },
      time = 5
    },
    order = "a-h-d",
  }
})
When doing the same thing for another mod however, it didn't work:

Code: Select all

data:extend({
    {
      type = "technology",
      name = "force-fields",
      icon = "__Force Fields__/graphics/forcefields.png",
      prerequisites = {"alien-technology", "battery", "advanced-electronics", "optics"},
      effects =
      {
        {
          type = "unlock-recipe",
          recipe = "forcefield-emitter"
        },
        {
          type = "unlock-recipe",
          recipe = "forcefield-tool"
        }
      },
      unit =
      {
        count = 300,
        ingredients =
        {
          {"science-pack-1", 1},
          {"science-pack-2", 1}
        },
        time = 35,
        
      },
      order = "a-h-d"
    },
    {
      type = "technology",
      name = "green-fields",
      icon = "__Force Fields__/graphics/green-forcefields.png",
      prerequisites = {"force-fields"},
      unit =
      {
        count = 150,
        ingredients =
        {
          {"science-pack-1", 1},
          {"science-pack-2", 1}
        },
        time = 30,
      },
	  upgrade=true,
      order = "a-h-d"
    },
    {
      type = "technology",
      name = "purple-fields",
      icon = "__Force Fields__/graphics/purple-forcefields.png",
      prerequisites = {"green-fields"},
      unit =
      {
        count = 200,
        ingredients =
        {
          {"science-pack-1", 1},
          {"science-pack-2", 1}
        },
        time = 30,
      },
      upgrade = true,
	  order = "a-h-d"
    },
    {
      type = "technology",
      name = "red-fields",
      icon = "__Force Fields__/graphics/red-forcefields.png",
      prerequisites = {"purple-fields"},
      unit =
      {
        count = 200,
        ingredients =
        {
          {"science-pack-1", 1},
          {"science-pack-2", 1},
          {"science-pack-3", 1}
        },
        time = 30,
      },
      upgrade = true,
	  order = "a-h-d"
    }
  }
)
The only difference I notice in these are the order. I've looked up its meaning in wiki, but I didn't give too much information about it. I think it is a class (with subclasses) like clustering, so that an "a" prefix will put things higher the techtree while a "z" suffix would put it at the last position of its parent class.

What am I doing wrong, trying to make those force-field upgrades only visible when the previous one has been researched?

User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

Re: Hide upgraded tiers (higher MKs)

Post by Arch666Angel »

As far as I know the upgrade = true will only hide upgrades for another tech, so lvl 1 of that tech is always visible, but not the successive upgrades. Upgraded techs are marked by the number suffix in their name, in your example the "-2".

Dellamonikus
Inserter
Inserter
Posts: 23
Joined: Fri Nov 07, 2014 2:22 pm
Contact:

Re: Hide upgraded tiers (higher MKs)

Post by Dellamonikus »

Oh, yea, that works, thanks!
I didn't know about that name convention.

User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

Re: Hide upgraded tiers (higher MKs)

Post by Arch666Angel »

Glad to help. Had to figure that out myself by looking at bobmods code, don't know if it is documented anywhere in that way.

Post Reply

Return to “Modding help”