Chained belts and pipes

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
donlac
Burner Inserter
Burner Inserter
Posts: 6
Joined: Tue Jun 01, 2021 1:51 am
Contact:

Chained belts and pipes

Post by donlac »

I am making a mod to make chain actions to assist in non-linear deconstruction and upgrade (e.g. your belt isn't perfectly vertical or horizontal). I have two issues with this.
1) order_deconstruction and order_upgrade do not create undo orders, so my deconstruction and upgrade actions cannot be undone unlike the vanilla ones.
2) neighbours works fine for pipe, but not belt and splitter, so that lead me to belt_neighbours, but that doesn't seem to do anything I can see...is there an easier way than just checking the direction of all neighboring belt entities to see if they connect?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Chained belts and pipes

Post by DaveMcW »

1. Correct, that is not supported.
2. How to use belt_neighbours:

Code: Select all

/c
local result = game.player.selected.belt_neighbours
for _, belt in pairs(result.inputs) do
  rendering.draw_circle{surface=belt.surface, target=belt, color={r=1,g=1,b=0,a=1}, radius=0.4, width=5, time_to_live=300}
end
for _, belt in pairs(result.outputs) do
  rendering.draw_circle{surface=belt.surface, target=belt, color={r=1,g=0,b=0,a=1}, radius=0.4, width=5, time_to_live=300}
end

donlac
Burner Inserter
Burner Inserter
Posts: 6
Joined: Tue Jun 01, 2021 1:51 am
Contact:

Re: Chained belts and pipes

Post by donlac »

1. Guess its time for a request then.
2. Apparently I was referencing the inputs and outputs incorrectly...awesome, so much cleaner than the crazy facing code I wrote.

Thanks for the help!

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2530
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Chained belts and pipes

Post by FuryoftheStars »

donlac wrote:
Sat Dec 18, 2021 3:15 pm
1. Guess its time for a request then.
I believe there already is one.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

donlac
Burner Inserter
Burner Inserter
Posts: 6
Joined: Tue Jun 01, 2021 1:51 am
Contact:

Re: Chained belts and pipes

Post by donlac »

I was trying to get my mod to work on ghosted entities and I think I found a bug. When I added code to check the ghost_type to confirm a belt on an entity-ghost, it marks everything for deconstruction if you start on a belt, even the ghosts get marked for deconstruction, which then causes a crash if a robot tries to deconstruct the ghost.

I put back my code to find neighbour belts by position and facing and that worked fine on ghosts (the whole chain gets deconstructed when entity.order_deconstruction is called), but the second the chain hits a real belt, it switches back to ghosts marked for deconstruction for the rest of the chain.

Am I doing something wrong?
Attachments
chain-action_0.4.0.zip
(8.51 KiB) Downloaded 71 times

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Chained belts and pipes

Post by DaveMcW »

Good catch. I filed a bug report for you.

To work around it, you will have to check for ghosts and destroy them instead of deconstructing them.

Post Reply

Return to “Modding discussion”