LuaEntity::set_recipe(recipe)

Post Reply
Bilka
Factorio Staff
Factorio Staff
Posts: 3129
Joined: Sat Aug 13, 2016 9:20 am
Contact:

LuaEntity::set_recipe(recipe)

Post 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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaEntity::set_recipe(recipe)

Post 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.
If you want to get ahold of me I'm almost always on Discord.

Bilka
Factorio Staff
Factorio Staff
Posts: 3129
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaEntity::set_recipe(recipe)

Post 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!
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Implemented mod requests”