Having difficulty changing the recipe of the T3 assembler

Place to get help with not working mods / modding interface.
Post Reply
User avatar
UntouchedWagons
Long Handed Inserter
Long Handed Inserter
Posts: 60
Joined: Thu Jan 01, 2015 6:16 pm
Contact:

Having difficulty changing the recipe of the T3 assembler

Post 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?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Having difficulty changing the recipe of the T3 assembler

Post by DaveMcW »

You want [2][1].

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Having difficulty changing the recipe of the T3 assembler

Post by prg »

DaveMcW wrote:You want [2][1].
No, [2][2].
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Having difficulty changing the recipe of the T3 assembler

Post 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

keyboardhack
Filter Inserter
Filter Inserter
Posts: 478
Joined: Sat Aug 23, 2014 11:43 pm
Contact:

Re: Having difficulty changing the recipe of the T3 assembler

Post 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]
Waste of bytes : P

User avatar
UntouchedWagons
Long Handed Inserter
Long Handed Inserter
Posts: 60
Joined: Thu Jan 01, 2015 6:16 pm
Contact:

Re: Having difficulty changing the recipe of the T3 assembler

Post 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.

User avatar
oLaudix
Filter Inserter
Filter Inserter
Posts: 282
Joined: Sun Jun 14, 2015 3:24 pm
Contact:

Re: Having difficulty changing the recipe of the T3 assembler

Post 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
Image

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Having difficulty changing the recipe of the T3 assembler

Post 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]]
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Having difficulty changing the recipe of the T3 assembler

Post 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.

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Having difficulty changing the recipe of the T3 assembler

Post 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)
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Post Reply

Return to “Modding help”