Script to remove decorations on already placed concrete

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
JackGruff
Fast Inserter
Fast Inserter
Posts: 134
Joined: Tue Oct 15, 2013 4:44 pm
Contact:

Script to remove decorations on already placed concrete

Post by JackGruff »

Hi.

May someone please give me an up-to-date version of this script: viewtopic.php?p=117691#p117691

Please :)
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Script to remove decorations on already placed concrete

Post by eradicator »

The one in the link looks like it should still work if you replace "local_player" by just "player".
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
cbhj1
Fast Inserter
Fast Inserter
Posts: 172
Joined: Tue Apr 25, 2017 2:53 pm
Contact:

Re: Script to remove decorations on already placed concrete

Post by cbhj1 »

might need to adjust the tile specification depending on what concrete is being used in the base
JackGruff
Fast Inserter
Fast Inserter
Posts: 134
Joined: Tue Oct 15, 2013 4:44 pm
Contact:

Re: Script to remove decorations on already placed concrete

Post by JackGruff »

eradicator wrote: Tue May 25, 2021 6:49 pm The one in the link looks like it should still work if you replace "local_player" by just "player".
It doesn't. This is a multiplayer game if that matters. I've disabled all the mods but RSO. I changed the item name to 'refined-concrete'.

Script so far:

Code: Select all

/c for coord in game.player.surface.get_chunks() do
  for key, e in pairs(game.player.surface.find_entities_filtered({area={{coord.x * 32, coord.y * 32}, {coord.x * 32 + 32, coord.y * 32 + 32}}, type="decorative"})) do
    if game.player.surface.get_tile(e.position.x, e.position.y).name == "refined-concrete" then
      e.destroy()
    end
  end
end
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Script to remove decorations on already placed concrete

Post by eradicator »

Oh right, decoratives stopped to be entities at some point. It all works differently now. This cleans with half a tile radius, without radius the result isn't quite what I expected. Feel free to add in any other tile types you want cleaned.

Code: Select all

/c
local s = game.player.surface
local f = s.destroy_decoratives
local r = 0.5
for _, tile in pairs(s.find_tiles_filtered{name = {'concrete', 'refined-concrete'}}) do
  local pos = tile.position
  f{area = {{pos.x-r, pos.y-r}, {pos.x+r,pos.y+r}}}
  end
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
JackGruff
Fast Inserter
Fast Inserter
Posts: 134
Joined: Tue Oct 15, 2013 4:44 pm
Contact:

Re: Script to remove decorations on already placed concrete

Post by JackGruff »

eradicator wrote: Wed May 26, 2021 4:30 pm Oh right, decoratives stopped to be entities at some point. It all works differently now. This cleans with half a tile radius, without radius the result isn't quite what I expected. Feel free to add in any other tile types you want cleaned.

Code: Select all

/c
local s = game.player.surface
local f = s.destroy_decoratives
local r = 0.5
for _, tile in pairs(s.find_tiles_filtered{name = {'concrete', 'refined-concrete'}}) do
  local pos = tile.position
  f{area = {{pos.x-r, pos.y-r}, {pos.x+r,pos.y+r}}}
  end
Thank you!
Post Reply

Return to “Gameplay Help”