Page 1 of 1

Having difficulty changing the recipe of the T3 assembler

Posted: Wed Oct 28, 2015 9:37 pm
by UntouchedWagons
I want to make the tier 3 assembler use only one tier 2 assembler but I'm having a hell of a time doing it. If I put

Code: Select all

data.raw.recipe["assembling-machine-3"].ingredients[1][2] = 1
That changes to number of speed modules needed even though speed modules are the first thing defined as an ingredient in recipe.lua. If I change the [1][2] to [1][1] or [1][3] Factorio throws a fit. What gives?

Re: Having difficulty changing the recipe of the T3 assembler

Posted: Wed Oct 28, 2015 10:14 pm
by DaveMcW
You want [2][1].

Re: Having difficulty changing the recipe of the T3 assembler

Posted: Wed Oct 28, 2015 10:15 pm
by prg
DaveMcW wrote:You want [2][1].
No, [2][2].

Re: Having difficulty changing the recipe of the T3 assembler

Posted: Wed Oct 28, 2015 10:17 pm
by DaveMcW
Right. :P

If you want to be clearer/safer, you can do a loop:

Code: Select all

for _, ingredient in pairs (data.raw.recipe["assembling-machine-3"].ingredients) do
  if (ingredient[1] == "assembling-machine-2") then
    ingredient[2] = 1
  end
end

Re: Having difficulty changing the recipe of the T3 assembler

Posted: Wed Oct 28, 2015 10:22 pm
by keyboardhack

Code: Select all

data.raw.recipe["assembling-machine-3"]
returns

Code: Select all

{
    type = "recipe",
    name = "assembling-machine-3",
    enabled = false,
    ingredients =
    {
      {"speed-module", 4},
      {"assembling-machine-2", 2}
    },
    result = "assembling-machine-3"
}

Code: Select all

data.raw.recipe["assembling-machine-3"].ingredients
returns

Code: Select all

{
      {"speed-module", 4},
      {"assembling-machine-2", 2}
}

Code: Select all

data.raw.recipe["assembling-machine-3"].ingredients[1]
returns

Code: Select all

 {
      "speed-module",
      4
}

Code: Select all

data.raw.recipe["assembling-machine-3"].ingredients[1][2]
returns

Code: Select all

4
so

Code: Select all

data.raw.recipe["assembling-machine-3"].ingredients[1]
gets you the first ingredients name and the amount of them used

Code: Select all

data.raw.recipe["assembling-machine-3"].ingredients[2]
gives you the second ingredients name and amount.

so you probably want to do

Code: Select all

data.raw.recipe["assembling-machine-3"].ingredients[2][2]

Re: Having difficulty changing the recipe of the T3 assembler

Posted: Thu Oct 29, 2015 1:21 am
by UntouchedWagons
prg wrote:
DaveMcW wrote:You want [2][1].
No, [2][2].
Thanks
keyboardhack wrote:All that stuff
How do you make the game print that stuff? I tried

Code: Select all

/c print(data.raw.recipe["assembling-machine-3"])
and it said that data didn't exist or something.

Re: Having difficulty changing the recipe of the T3 assembler

Posted: Thu Oct 29, 2015 3:16 am
by oLaudix
You can't print it like that.

You need to use something like this.

Code: Select all

/c game.player.print(game.player.force.recipes["assembling-machine-3"].ingredients[1].name)
/c game.player.print(game.player.force.recipes["assembling-machine-3"].ingredients[1].amount)
Moreover:

Code: Select all

/c game.player.print(game.player.force.recipes["assembling-machine-3"]
nor

Code: Select all

/c game.player.print(game.player.force.recipes["assembling-machine-3"].ingredients[1]
can be printed since you cant print userdata nor table.
If you want to print recipe ingredients do smth like this:

Code: Select all

/c 
for i,ingredient in pairs(game.player.force.recipes["assembling-machine-3"].ingredients) do
	  game.player.print(ingredient.name .. " - " .. ingredient.amount)
end

Re: Having difficulty changing the recipe of the T3 assembler

Posted: Thu Oct 29, 2015 9:47 am
by prg
oLaudix wrote:You can't print it like that.
Not from the console in a running game, but from data*.lua.

Code: Select all

print(serpent.block(data.raw.recipe["assembling-machine-3"].ingredients))

Code: Select all

{
  {
    "speed-module",
    4
  } --[[table: 0x2c28580]],
  {
    "assembling-machine-2",
    2
  } --[[table: 0x2c28610]]
} --[[table: 0x2c284f0]]

Re: Having difficulty changing the recipe of the T3 assembler

Posted: Thu Oct 29, 2015 6:52 pm
by orzelek
Where do you get output from print thats running in data phase?

You can also use serpent.block from console to print whole recipe.

Re: Having difficulty changing the recipe of the T3 assembler

Posted: Thu Oct 29, 2015 7:12 pm
by prg
orzelek wrote:Where do you get output from print thats running in data phase?
That's going to stdout, so you can see it nicely formatted in the terminal you're running Factorio in. (Or if it's too much output, like when you're dumping all of data.raw, redirect it to a file or pipe it to less or something)