Should graphics for a multi-part entity contain all parts?

Place to get help with not working mods / modding interface.
Post Reply

Should graphics for a multi-part entity contain all parts?

Yes, show everything in the cursor as it will be after placement.
0
No votes
No, reusing the graphics from each element saves memory.
0
No votes
 
Total votes: 0

mrvn
Smart Inserter
Smart Inserter
Posts: 5703
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Should graphics for a multi-part entity contain all parts?

Post by mrvn »

I'm working on something like the LogisticTrainNetwork mod. Like it I have train stops made up of multiple entities: train-stop, small-lamp, constant-combinator, arithmetic-combinator. The end result looks like this:
lto.png
lto.png (81.97 KiB) Viewed 984 times
At the left the place compount entity is seen and at the right the cursor for placing a new one. As you can see the cursor only shows the master entity and the other elements are only added after placement.

I wonder if it wouldn't be better to include all the elements in main entities graphics and set the others to invisible. Doing that would involve a lot of work to re-create the graphics for the train stop. It's made out of multiple parts with blinking lights and such that require a lot of definitions for the prototype that would all have to be redone instead of depp-copying the train-stop.

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

Re: Should graphics for a multi-part entity contain all parts?

Post by DaveMcW »

You really have 2 questions:

1. Should the cursor preview contain all parts graphics?
Answer: Yes!

2. Should a single built entity contain all parts graphics?
Answer: Probably not. Most entities have hardcoded graphics logic to make them look better, you will lose this by squeezing everything into a single entity.

Which leads to the third question...
3. How can I make the cursor preview look different from the final entity?
Answer: Make an entity whose only job is to look good in the cursor. Swap it out in on_built.

The data.lua looks like this:

Code: Select all

cursor_entity.sprite.priority = "very-low"  -- Don't waste VRAM on this
item.place_result = cursor_entity.name
real_entity.placeable_by = item.name
real_entity.minable.result = item.name

mrvn
Smart Inserter
Smart Inserter
Posts: 5703
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Should graphics for a multi-part entity contain all parts?

Post by mrvn »

DaveMcW wrote:
Sat Sep 14, 2019 10:52 pm
You really have 2 questions:

1. Should the cursor preview contain all parts graphics?
Answer: Yes!

2. Should a single built entity contain all parts graphics?
Answer: Probably not. Most entities have hardcoded graphics logic to make them look better, you will lose this by squeezing everything into a single entity.

Which leads to the third question...
3. How can I make the cursor preview look different from the final entity?
Answer: Make an entity whose only job is to look good in the cursor. Swap it out in on_built.

The data.lua looks like this:

Code: Select all

cursor_entity.sprite.priority = "very-low"  -- Don't waste VRAM on this
item.place_result = cursor_entity.name
real_entity.placeable_by = item.name
real_entity.minable.result = item.name
I have to look at this again but it makes sense so far. The item graphics would have all entities simplified and merged while the item.place_result would retain the individual entities with all their special quirks. E.g. the item has no blinking lights.

"Swap it out in on_built" is something else though and it is imho the worst. You loose wire connections that way, undo breaks, blueprinting has to edit the blueprint, blueprints can't be placed over existing entities, wires's can't be pasted in via blueprints.

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

Re: Should graphics for a multi-part entity contain all parts?

Post by DaveMcW »

mrvn wrote:
Mon Sep 16, 2019 12:26 pm
You loose wire connections that way
Not if you fast_replace.
mrvn wrote:
Mon Sep 16, 2019 12:26 pm
blueprinting has to edit the blueprint
Not if you use placeable_by.

mrvn
Smart Inserter
Smart Inserter
Posts: 5703
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Should graphics for a multi-part entity contain all parts?

Post by mrvn »

DaveMcW wrote:
Mon Sep 16, 2019 12:57 pm
mrvn wrote:
Mon Sep 16, 2019 12:26 pm
You loose wire connections that way
Not if you fast_replace.
mrvn wrote:
Mon Sep 16, 2019 12:26 pm
blueprinting has to edit the blueprint
Not if you use placeable_by.
Thanks, I will test and forward that to the railloader mod. It has some ugly LUA code to work around these problems that would be far better ti avoid outright.

mrvn
Smart Inserter
Smart Inserter
Posts: 5703
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Should graphics for a multi-part entity contain all parts?

Post by mrvn »

Still not getting any of that to work. Lets start with blueprinting over placed entities to add wires:

Code: Select all

  {
    type = "item",
    name = "railloader",
    place_result = "railloader-placement-proxy",
  },
  {
    type = "pump",
    name = "railloader-placement-proxy",
    minable = { mining_time = 0.1, result = "railloader" },
    flags = {"player-creation", "placeable-neutral"},
    fast_replaceable_group = "railloader",
    circuit_wire_connection_points = circuitconnectors["railloader-placement-proxy"].points,
    circuit_connector_sprites = circuitconnectors["railloader-placement-proxy"].sprites,
    circuit_wire_max_distance = default_circuit_wire_max_distance + 1.5,
  },
  {
    type = "container",
    name = "railloader-chest",
    flags = {"player-creation"},
    minable = {mining_time = 4, result = "railloader"},
    placeable_by = {item = "railloader", count = 1},
    fast_replaceable_group = "railloader",
    circuit_wire_max_distance = default_circuit_wire_max_distance
  },
I checked with detailed infos on and the placed entity is a railloader-chest and the ghost from the blueprint is a railloader-placement-proxy. But holding the blueprint over the entity just shows red and doesn't add wires when shift+clicking.

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

Re: Should graphics for a multi-part entity contain all parts?

Post by DaveMcW »

Your placeholder entity must be the same type as the wires you want to connect.

Post Reply

Return to “Modding help”