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 ?
Connecting two entities
- Deadlock989
- Smart Inserter
- Posts: 2528
- Joined: Fri Nov 06, 2015 7:41 pm
Re: Connecting two entities
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.
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.
Re: Connecting two entities
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
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Re: Connecting two entities
Maybe Linked Belts?
You can connect them with the selection tool or just by placing connect the second linked belt to first one.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Connecting two entities
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.Deadlock989 wrote: ↑Wed Jan 13, 2021 6:54 pmYou couldn't even fake it with an actual wire because the LinkedBelt entity doesn't have circuit network connection points like a TransportBelt does.
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
- Deadlock989
- Smart Inserter
- Posts: 2528
- Joined: Fri Nov 06, 2015 7:41 pm
Re: Connecting two entities
* sits in corner of shower, rocking back and forth *eradicator wrote: ↑Wed Jan 13, 2021 7:43 pmIf 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.