Generating decoratives for one chunk

Place to get help with not working mods / modding interface.
sparr
Smart Inserter
Smart Inserter
Posts: 1521
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Generating decoratives for one chunk

Post by sparr »

Code: Select all

surface.regenerate_decorative{chunks={{math.floor(slave_pos.x/32),math.floor(slave_pos.y/32)}}}
slave_pos is a tile position, so I'm trying to produce a single chunk position, and pass that to regenerate_decorative. I also tried {x=foo,y=bar} for the chunk position just in case. either way, I get this:

Code: Select all

Error while running event world-mirror::on_chunk_generated (ID 12)
Value must be a string in property tree at ROOT.chunks
stack traceback:
	__world-mirror__/control.lua:123: in function 'mirror_chunk'
	__world-mirror__/control.lua:140: in function <__world-mirror__/control.lua:126>
This sounds like it wants the chunks parameter to be a string instead of an array of chunkpositions?
Rseding91
Factorio Staff
Factorio Staff
Posts: 16014
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Generating decoratives for one chunk

Post by Rseding91 »

You can't use the chunks parameter without also giving the decoratives to regenerate.
If you want to get ahold of me I'm almost always on Discord.
sparr
Smart Inserter
Smart Inserter
Posts: 1521
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: Generating decoratives for one chunk

Post by sparr »

Is there a quick way to enumerate all of the default decoratives?
Rseding91
Factorio Staff
Factorio Staff
Posts: 16014
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Generating decoratives for one chunk

Post by Rseding91 »

sparr wrote:Is there a quick way to enumerate all of the default decoratives?
http://lua-api.factorio.com/latest/LuaG ... prototypes
If you want to get ahold of me I'm almost always on Discord.
sparr
Smart Inserter
Smart Inserter
Posts: 1521
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: Generating decoratives for one chunk

Post by sparr »

For future reference, if anyone else finds this thread...

Code: Select all

  -- get a list of all known autoplace-able decorative names
  local decorative_names = {}
  for k,v in pairs(game.decorative_prototypes) do
    if v.autoplace_specification then
      decorative_names[#decorative_names+1] = k
    end
  end
  -- apply them all to this chunk
  surface.regenerate_decorative(decorative_names, {{x=math.floor(position.x/32),y=math.floor(position.y/32)}})
Post Reply

Return to “Modding help”