Page 1 of 1

Changing research requirements on # of science-pack

Posted: Tue Jul 01, 2014 12:45 pm
by hoho
I'm an absolute noob in Lua and in Factorio modding but I have been proramming for living for over a decade. I'm fairly certain once I get the very basics figured out I should be good to go with my bit of modding :)

Having said that I have a bit of problems figuring out how to change the number of science packs required per research. I've tried a few things but nothing has worked. Am I correct to assume that I should do something like this in my data.lua:

Code: Select all

data.raw.technology["fluid-handling"].unit.ingredients["science-pack-1"] = 100
When I do that I get "error while loading prototype "fluid-handling": no such node (name). I'm not sure why is that since I tried to copy it roughly off from liquid-station mod that had code like this:

Code: Select all

local effects = data.raw.technology["fluid-handling"].effects
effects[#effects + 1] = {type="unlock-recipe", recipe="fill-water-barrel"}

If someone could tell me how to set the number of science packs required for some specific research then that'd be pretty much all I need to get going.

Re: Changing research requirements on # of science-pack

Posted: Tue Jul 01, 2014 1:40 pm
by YuokiTani
i only know the easy way ...

make a technology-prototype and set it like this
counts are the numbers of science-packs, ingredients-number the factor

Code: Select all

  {
    type = "technology",
    name = "y-gunturret-compatible-dmg2-tech",
    icon = "__base__/graphics/technology/gun-turret-damage.png",
    effects =
    {
      {
        type = "turret-attack",
		turret_id = "gun-turret-mk2",
        modifier = "0.4"
      },	  
      {
        type = "turret-attack",
		turret_id = "gun-turret-mk3",
        modifier = "0.35"
      }	 	  	  
    },
    prerequisites = {"gun-turret-damage-3"},
    unit =
    {
      count = 75,
      ingredients =
      {
        {"science-pack-1", 1},    
        {"science-pack-2", 1}
      },
      time = 20
    },
    upgrade = "true",
    order = "e-o-b"
  },  
no more text needed ... don't forget to load your prototype and that's it
you should see base-technology-prototypes for more examples

-name is name of tech, but you give this tech your name in the locale/en/technology-names.cfg-file if you wish a different (with description)
-to change a existing, make sure your mod loaded later, and set a technology with the same name and different science-pack-setup (copy & paste ^^)

- hard way - i think it's possible to do this with real code, and insert all this with tables and data.raw -lines.

Re: Changing research requirements on # of science-pack

Posted: Tue Jul 01, 2014 1:45 pm
by hoho
I know how to add new tech, I want to change what is already there. Eventually I'd like to have my mod load last and modify the requirements for ALL researches so re-defining them one by one isn't a viable option.

Re: Changing research requirements on # of science-pack

Posted: Tue Jul 01, 2014 3:05 pm
by Rahjital
Untested as I can't play Factorio right now, but thisa here should work:

Code: Select all

data.raw.technology["fluid-handling"].unit.ingredients[1] = {"science-pack-1", 666}
If you look closely at the prototype, you'll see that "science-pack-1" is not a key of the ingredients table but the first part of the value. :)

Re: Changing research requirements on # of science-pack

Posted: Tue Jul 01, 2014 3:19 pm
by hoho
Awesome, that worked perfectly. Thanks :)