Page 1 of 1

LuaEntity::set_recipe(recipe)

Posted: Mon Sep 18, 2017 6:00 pm
by Bilka
Same as http://lua-api.factorio.com/latest/LuaE ... y_settings , but with a recipe being passed to it instead of an entity. I currently have to do

Code: Select all

local entity = game.surfaces["tas-surface"].create_entity{name = myplayer.selected.name, position = {0,0}, force="player", recipe=tokens[3]}
  local items = myplayer.selected.copy_settings(entity)
  entity.destroy()
  if items then
    for name, count in pairs(items) do
      myplayer.insert{name=name, count=count}
    end
  end
to find out which items a recipe switch to tokens[3] "spits out" so that I can insert them back into the player. Just changing LuaEntity::recipe doesn't give me that info.

Re: LuaEntity::set_recipe(recipe)

Posted: Thu Sep 28, 2017 7:52 pm
by Rseding91
I've changed it for 0.16 so instead of entity.recipe it will now be entity.get_recipe() and entity.set_recipe() with set returning the items the same as copy_settings does.

Re: LuaEntity::set_recipe(recipe)

Posted: Thu Sep 28, 2017 7:53 pm
by Bilka
Rseding91 wrote:I've changed it for 0.16 so instead of entity.recipe it will now be entity.get_recipe() and entity.set_recipe() with set returning the items the same as copy_settings does.
Thank you!