Insert blueprints into blueprint-book

Place to get help with not working mods / modding interface.
Post Reply
User avatar
OldVamp
Burner Inserter
Burner Inserter
Posts: 17
Joined: Fri May 27, 2016 12:41 am
Contact:

Insert blueprints into blueprint-book

Post by OldVamp »

I am setting up a custom quick start scenario and would like to start players off with a full (blank) blueprint book.
I cant seem to put together the right combination of words and functions to complete the task during the on_player_created event.
This is what I have:

Code: Select all

  player.insert{name="blueprint-book", count=1}

  local inventories = {player.get_inventory(defines.inventory.player_quickbar), player.get_inventory(defines.inventory.player_main)}
  for _, inv in pairs(inventories) do
    for i=1,#inv do
      local itemStack = inv[i]
      if itemStack.valid_for_read and itemStack.type == "blueprint-book" then
        --now what? I want to insert blueprint count 30 into blueprint-book
      end
    end
  end
Any help would be appreciated.
\|/;';\|/
It may be working as intended, but
what was intended is not working.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Insert blueprints into blueprint-book

Post by Nexela »

You need to get the equipment grid for the item http://lua-api.factorio.com/latest/LuaE ... tGrid.html
See Below
Last edited by Nexela on Thu Jan 05, 2017 5:53 am, edited 1 time in total.

User avatar
OldVamp
Burner Inserter
Burner Inserter
Posts: 17
Joined: Fri May 27, 2016 12:41 am
Contact:

Re: Insert blueprints into blueprint-book

Post by OldVamp »

Nexela wrote:You need to get the equipment grid for the item
That doesn't seem to work
Factorio 0.14.21 wrote:attempt to index field 'grid' (a nil value)
\|/;';\|/
It may be working as intended, but
what was intended is not working.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Insert blueprints into blueprint-book

Post by Nexela »

Ohhhhhhhhh wrong one I see now :) http://lua-api.factorio.com/latest/LuaI ... _inventory

Code: Select all

  if itemStack.valid_for_read and itemStack.type == "blueprint-book" then
    local itemInv = itemStack.get_inventory(defines.inventory.item_main)
    itemInv.insert("blueprint")
  end

User avatar
OldVamp
Burner Inserter
Burner Inserter
Posts: 17
Joined: Fri May 27, 2016 12:41 am
Contact:

Re: Insert blueprints into blueprint-book

Post by OldVamp »

That did the trick.
Thank you very much.

Code: Select all

  player.insert{name="blueprint-book", count=1}

  local inventories = {player.get_inventory(defines.inventory.player_quickbar), player.get_inventory(defines.inventory.player_main)}
  for _, inv in pairs(inventories) do
    for i=1,#inv do
      local itemStack = inv[i]
      if itemStack.valid_for_read and itemStack.type == "blueprint-book" then
        local itemInv = itemStack.get_inventory(defines.inventory.item_main)
        itemInv.insert{name="blueprint", count=30}
      end
    end
  end
\|/;';\|/
It may be working as intended, but
what was intended is not working.

Post Reply

Return to “Modding help”