Can't find vanilla red-wire / green-wire entity definitions

Place to get help with not working mods / modding interface.
Post Reply
DasNasu
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun Jan 13, 2019 4:55 pm
Contact:

Can't find vanilla red-wire / green-wire entity definitions

Post by DasNasu »

Hi, i'm currently working on a mod for more flexibility with circuit networks, namely more cables, other cables, machines to work with those cables etc. So far so good.

I created the the prototypes files / declarations / definitions (however you would like to call them, my java brain loves definitions, but i'm not sure if these files actually are definitions or more like declarations) for items, technologies and recipes, started the game and tried if everything works as expected. Technologies are listed and researchable with correct effects etc, everything working fine except for connecting the wires with anything. Holding a wire and left-clicking it to machines, electric poles etc just opens their menu respectively. Makes sense, since i haven't defined an entity file for the wires so far and this is where it kinda went downhill. For every other file so far i searched the basegame files, looked at other mods, rushed through the modding tutorial etc, but i'm not able to find ANY entity definition for the red-wire and the green-wire. I would appreciate any hint or help where to find the entity definitions of the vanilla circuit cables, thanks in advance c:
Every good story ends with System.exit(0);

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

Re: Can't find vanilla red-wire / green-wire entity definitions

Post by Deadlock989 »

Wires are not entities. Machines which can connect to wires must have certain properties set up, e.g. circuit_wire_connection_point, circuit_wire_max_distance etc. See transport belts for an example.

But many entities cannot be connected to circuit wires, e.g. assembling machines. If their prototype on the wiki doesn't list the circuit connection properties, the entity can't ever be connected to wire.

The core lualib (Factorio/data/core/lualib) provides some handy public functions for getting hold of the specific circuit point connector sprites, see circuit-connector-sprites.lua and circuit-connector-generated-definitions.lua.
Image

DasNasu
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun Jan 13, 2019 4:55 pm
Contact:

Re: Can't find vanilla red-wire / green-wire entity definitions

Post by DasNasu »

Thanks for the response, that machinery need connection points makes sense and i stumbled across this on belts and chests but couldn't wrap my head around it for now. But then still my main question stays left open: Why am i not able to connect the wires to the vanilla electric pole and inserters for example? i mean i basically copy pasted the wire stuff from the base game since i'm not a fan of deepcopying and modifying everything, when its easier and probably cleaner to create a new protoype. So i must've missed something right?

Just for clarification for my mind: why aren't wires entities aswell? I mean everything in the game is some kind of thing. For clarification purposes i'll take assembling machines as example:

If the machine is not craftet yet, its just a recipe, as soon as i craft it and it pops in my inventory its an item. i could throw this item into a chest or the ground and it would still be an item. as soon as i place it down it becomes an entity, if my understanding is correct so far. Applying this to wires in my mind means that they become entities aswell as soon as they become a "physical object" of the game world and thus need a definition right?

[Edit]: what makes me think is: if i basically copy pasted the "new" wires basing of the vanilla wires, why the game won't let me connect my wires to poles and inserters, but the vanilla wires are fine?
Every good story ends with System.exit(0);

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

Re: Can't find vanilla red-wire / green-wire entity definitions

Post by Deadlock989 »

DasNasu wrote:
Tue Sep 13, 2022 12:02 pm
So i must've missed something right?
Maybe? We can't see your code.
[Edit]: what makes me think is: if i basically copy pasted the "new" wires basing of the vanilla wires, why the game won't let me connect my wires to poles and inserters, but the vanilla wires are fine?
The connection behaviour of wires is hard-coded as far as I know. Modders have pretty limited access to it compared to most other things. From memory I don't think you can define new control circuit wires; "copper-cable", "red-wire" and "green-wire" items are treated as a special case by the game engine and items with those names have to exist (i.e. your mod has to provide them if the base mod is disabled).
Image

DasNasu
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun Jan 13, 2019 4:55 pm
Contact:

Re: Can't find vanilla red-wire / green-wire entity definitions

Post by DasNasu »

Deadlock989 wrote:
Tue Sep 13, 2022 12:31 pm
Maybe? We can't see your code.

Code: Select all

-- prototypes/item/bundled-wire.lua

data:extend(
	{
		{
			type = "item",
			name = "tn-white-bundled-wire",
			icon = "__base__/graphics/icons/green-wire.png",
			icon_size = 32,
			flags = {
				"goes-to-quickbar"
			},
			subgroup = "circuit-network",
			stack_size = 200
		},
		{
			type = "item",
			name = "tn-black-bundled-wire",
			icon = "__base__/graphics/icons/green-wire.png",
			icon_size = 32,
			flags = {
				"goes-to-quickbar"
			},
			subgroup = "circuit-network",
			stack_size = 200
		}
	}
)

Code: Select all

-- prototypes/recipe/bundled-wire.lua

data:extend(
	{
		{
			type = "recipe",
			name = "tn-white-bundled-wire",
			enabled = true,
			ingredients = {
				{"tn-white-network-wire", 1},
				{"tn-orange-network-wire", 1},
				{"tn-magenta-network-wire", 1},
				{"tn-ice-network-wire", 1},
				{"tn-yellow-network-wire", 1},
				{"tn-lime-network-wire", 1},
				{"tn-pink-network-wire", 1},
				{"tn-anthracite-network-wire", 1},
				{"tn-gray-network-wire", 1},
				{"tn-cyan-network-wire", 1},
				{"tn-purple-network-wire", 1},
				{"tn-blue-network-wire", 1},
				{"tn-brown-network-wire", 1},
				{"tn-green-network-wire", 1},
				{"tn-red-network-wire", 1},
				{"tn-black-network-wire", 1}
			},
			result = "tn-white-bundled-wire"
		},
		{
			type = "recipe",
			name = "tn-black-bundled-wire",
			enabled = true,
			ingredients = {
				{"tn-white-network-wire", 1},
				{"tn-orange-network-wire", 1},
				{"tn-magenta-network-wire", 1},
				{"tn-ice-network-wire", 1},
				{"tn-yellow-network-wire", 1},
				{"tn-lime-network-wire", 1},
				{"tn-pink-network-wire", 1},
				{"tn-anthracite-network-wire", 1},
				{"tn-gray-network-wire", 1},
				{"tn-cyan-network-wire", 1},
				{"tn-purple-network-wire", 1},
				{"tn-blue-network-wire", 1},
				{"tn-brown-network-wire", 1},
				{"tn-green-network-wire", 1},
				{"tn-red-network-wire", 1},
				{"tn-black-network-wire", 1}
			},
			result = "tn-black-bundled-wire"
		}
	}
)

Code: Select all

--prototypes/technology/bundled-wire.lua

data:extend (
	{
		{
			type = "technology",
			name = "NasuNetwork Bundeling",
			icon_size = 128,
			icon = "__base__/graphics/technology/steel-processing.png",
			effects = {
				{
					type = "unlock-recipe",
					recipe = "tn-white-bundled-wire"
				},
				{
					type = "unlock-recipe",
					recipe = "tn-black-bundled-wire"
				}
			},
			prerequisites = {
				"NasuNetwork 1", "NasuNetwork 2", "NasuNetwork 3", "NasuNetwork 4"
			},
			unit = {
				count = 250,
				ingredients = {
					{"science-pack-1", 2},
					{"science-pack-2", 2},
					{"science-pack-3", 1}
				},
				time = 30
			}
		}
	}
)
pretty basic so far, the code for the single wires looks similar, but i thought it would be quite messy to post like 600 lines of code which are basically copy paste and change the itemname.
Deadlock989 wrote:
Tue Sep 13, 2022 12:31 pm
The connection behaviour of wires is hard-coded as far as I know. Modders have pretty limited access to it compared to most other things. From memory I don't think you can define new control circuit wires; "copper-cable", "red-wire" and "green-wire" items are treated as a special case by the game engine and items with those names have to exist (i.e. your mod has to provide them if the base mod is disabled).
So what i'm taking from this is: for me there is currently no other way than copying the raw data of the vanilla cables and after modifying them (like color, recipe and such stuff) reinsert them back into the game, so its basically the same wire, but with a different name, coloring etc.

I'll try to override the vanilla cables and see if it helps c: Thanks for your effort so far c:
Every good story ends with System.exit(0);

Post Reply

Return to “Modding help”