Linked Belts


Quantum connection between belts; UPS-free, multiplayer, multiple forces and surfaces compatible

Content
15 days ago
1.1 - 2.0
4.28K
Cheats

i Mark linked belt for deconstruction if one got mined/destroyed

1 year, 9 months ago

Hi,

Really great mod. One suggestion - what if the linked belt got marked for deconstruction when it's pair got either mined or destroyed ?

That would make it easier to clean up.

Sample Code Here :

script.on_event(defines.events.on_player_mined_entity, function(event)
    local player_index = event.player_index
    local player = game.players[player_index]
    local entity = player.selected
    if entity and entity.valid then
        if entity.type == "linked-belt" then
            local lbn = entity.linked_belt_neighbour
            if lbn and lbn.surface == entity.surface then
                --Mark linked belt neighbour for deconstruction
                lbn.order_deconstruction(lbn.force, player)
            end
        end
    end

end)

Pastebin link - https://pastebin.com/cB3mNnrz

1 year, 9 months ago

Hi, thanks, you are invited to collab.

1 year, 8 months ago

Is it possible to make an option for the belt return to its previous state after destroying the linked one? Like remembering which belt it was linked to so we don't have to destroy the first one?

12 days ago
(updated 12 days ago)

@Heinwintoe Is there a reason why you check if the linked belts are on the same surface? I think it might be better to order the deconstruction even if the LBN is on another surface, otherwise you can be left with unlinked belts elsewhere. (I'm trying to implement your suggestion now.)

12 days ago

Maybe multisurface must be the mod setting.

5 days ago
(updated 5 days ago)

Yeah, I think it would be nice if (dis)allowing inter-surface linked belts was a mod setting. But I'm not quite sure how to handle it.

Say the player builds a linked belt on one surface, it will not be linked yet, and then the player goes to another surface to build a linked belt there. Should the unlinked belt on the first surface be marked for deconstruction? or should it be kept unlinked (with the warning)? or should it be saved in memory so that when the player goes back to that surface and builds a linked belt, it will link to the one he placed before changing surfaces? Or the player could be prevented from placing linked belts on other surfaces until the first has been linked or deconstructed, but this seems to drastic to me.

4 days ago

Easy solution: on the surface changing remove alone linked belt.

Other way: two entities: one entity for the same surface only, the second one for inter surface logistics.

New response