LuaGame.tile_prototypes

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

LuaGame.tile_prototypes

Post by Choumiko »

I'd like something like item_prototypes for tiles (for ones that can be placed by an item should be fine), it should have at least items_to_place_this, walking_speed_modifier as readably values

In addition to this, i think there's no way to find out whether an LuaItemPrototype can be placed as a tile, so maybe add place_as_tile with the resulting tile there?
Right now i have to do some pretty ugly stuff to try and dynamically find tiles and the corresponding item in data-final-fixes (to get modded concrete):

Code: Select all

local meta_concrete = copyPrototype("recipe", "deconstruction-planner", "farl-meta-concrete")
meta_concrete.ingredients = {}
meta_concrete.enabled = true
meta_concrete.hidden = false

for _, ent in pairs(data.raw["item"]) do
  if ent.place_as_tile and ent.place_as_tile.result and type(ent.place_as_tile.result) == "string" then
    local item_name = false
    local amount = 1
    local tile = data.raw["tile"][ent.place_as_tile.result] 
    if tile and tile.minable and tile.minable.result then
      item_name = ent.name
      if ent.place_as_tile.result ~= item_name then
        amount = 2
      end
    else
      item_name = false
      log("FARL: No item found for tile: "..ent.name)
    end
    if item_name then
      table.insert(meta_concrete.ingredients, {item_name, amount})
    end
  end
end
And in control.lua i read the ingredients of that fake recipe just to build a table that has the "tile to item" relation.
If i'm missing something that would make this easier please let me know :D
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: LuaGame.tile_prototypes

Post by daniel34 »

Implemented in 0.13.12.
quick links: log file | graphical issues | wiki
Post Reply

Return to “Implemented mod requests”