Connecting two entities

Place to get help with not working mods / modding interface.
Post Reply
hreintke
Fast Inserter
Fast Inserter
Posts: 115
Joined: Mon Sep 04, 2017 6:52 pm
Contact:

Connecting two entities

Post by hreintke »

Hi,

I am planning to use linked_belts in my mod.
Placing them is no issue, the challenge is how to connect them.

Preferable I would like to connect them the same way as how the circuit network wires are made.

Pick an item (link_connector like a red/green wire) click one linked_belt, see the connection as a wire, click the other linked_belt : done.
There should be no "visible cable" between the two linked entities.

Question :

Is that possible at all ?
If so, is there some example code which I can use as starting point ?

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: Connecting two entities

Post by Deadlock989 »

The "see the connection as a wire" during the linking part is not possible as far as I know. You couldn't even fake it with an actual wire because the LinkedBelt entity doesn't have circuit network connection points like a TransportBelt does.

If I were going to do this I would probably have it act more like copy-pasting settings between entities with CTRL-click and SHIFT-click, so you link the "target" to the "source". You could do nice things with the rendering API on those events to indicate at least something visual about the "connection" you are making, but not literally a wire like circuit connector / copper wires, and not any kind of beam or line that tracks the mouse cursor AFAIK. But you could also do it with a special "linking item" as you suggest.

For code examples for linking items (or a "virtual" cursor item you get from a quickbar shortcut), look at any mod that involves things like extended spidertron remote functions, or selecting areas e.g. Power Grid Comb, or the Wire Shortcuts mod that replaces red/green wire inventory items with shortcuts and hotkeys.
Image

Xorimuth
Filter Inserter
Filter Inserter
Posts: 623
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: Connecting two entities

Post by Xorimuth »

Editor Extensions also contains functionality for linked belts usable in game.
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Connecting two entities

Post by darkfrei »

hreintke wrote:
Wed Jan 13, 2021 5:02 pm

If so, is there some example code which I can use as starting point ?
Maybe Linked Belts?
You can connect them with the selection tool or just by placing connect the second linked belt to first one.

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

Re: Connecting two entities

Post by eradicator »

Deadlock989 wrote:
Wed Jan 13, 2021 6:54 pm
You couldn't even fake it with an actual wire because the LinkedBelt entity doesn't have circuit network connection points like a TransportBelt does.
If it's possible to script connect a cable to the cursor from a connectable entity then, one could fake it by spawning in something else that can recieve wires for the duration of the connection-input though. But i'm not sure if the api allows creating those unfinished cursor connections. Hm...in which case one could spawn the fake entity when the player hovers with the "cable" over a linked belt thus having the engine create the cable link naturally if the player clicks.
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.

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: Connecting two entities

Post by Deadlock989 »

eradicator wrote:
Wed Jan 13, 2021 7:43 pm
If it's possible to script connect a cable to the cursor from a connectable entity then, one could fake it by spawning in something else that can recieve wires for the duration of the connection-input though. But i'm not sure if the api allows creating those unfinished cursor connections. Hm...in which case one could spawn the fake entity when the player hovers with the "cable" over a linked belt thus having the engine create the cable link naturally if the player clicks.
* sits in corner of shower, rocking back and forth *
Image

Post Reply

Return to “Modding help”