I'd like to change the color of rails on the map during the control stage. I know that map_color is set at the data stage, so my plan was to define one prototype for each color and switch them out as needed. However, rail entities ignore map_color properties and use the utility-constant chart.rail_color instead.
My next best idea is to create an invisible entity with no collision box and the map_colors I need. That entity would than be placed on top of rails that should be recolored. Before I get into that, two questions: Can an invisible entity without collision be visible on the map? And if so, which map color would be shown if two entities overlap?
I've not done much at all with entity prototypes so far, so maybe there is even a better solution I don't know about. Any help is appreciated.
Change color of rails on map
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Change color of rails on map
That sounds like you only want to recolor *some* rails? Because recoloring them all individually dynamically would clearly be unreasonable :p.
As for a solution i have no clue. Mass-replacing stuff would be ugly even if it worked. And i bet replacing rails makes the pathfinder grumpy. Depending on what exactly you need it might be realistic to request map support for LuaRendering.
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.
Re: Change color of rails on map
Yes, just some and in 3-4 different colors. I am aware that any attempt to recolor large numbers of rails dynamically would be a performance hog.eradicator wrote: ↑Thu Jun 06, 2019 4:39 pmThat sounds like you only want to recolor *some* rails? Because recoloring them all individually dynamically would clearly be unreasonable :p.
I am looking for a way to visualize train throughput on the map. Rendering on the map would probably work pretty well. But it seems like a big ask.eradicator wrote: ↑Thu Jun 06, 2019 4:39 pmDepending on what exactly you need it might be realistic to request map support for LuaRendering.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Change color of rails on map
You won't know if you don't ask. It does already work in zoom-to-world view just fine.
Ofc trying yourself how placing invisible entities works won't hurt either. The game doesn't know if anything is "invisible" so that shouldn't affect map color. Collosion_box size most certainly will though. You could try setting an empty collosion_mask so it doesn't actually collide with anything even if it has a box.
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.
Re: Change color of rails on map
Thanks, that works. Weirdly, my test entity can cover curved rails on the map, but not straight rails. No matter what I use as entity type, straight rails beat all of them. The only exception are vehicles, but they use a sprite instead of map_coloreradicator wrote: ↑Thu Jun 06, 2019 5:54 pmYou could try setting an empty collosion_mask so it doesn't actually collide with anything even if it has a box.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Change color of rails on map
Try shifting the center of your entity 1/256'th of a tile southwards. Not sure how "off grid" entities behave with map colors...eduran wrote: ↑Fri Jun 07, 2019 7:43 amThanks, that works. Weirdly, my test entity can cover curved rails on the map, but not straight rails. No matter what I use as entity type, straight rails beat all of them. The only exception are vehicles, but they use a sprite instead of map_color :roll:eradicator wrote: ↑Thu Jun 06, 2019 5:54 pmYou could try setting an empty collosion_mask so it doesn't actually collide with anything even if it has a box.
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.
Re: Change color of rails on map
Tried that, but to no effect. Now I am curious: why 1/256th of a tile?eradicator wrote: ↑Fri Jun 07, 2019 10:14 amTry shifting the center of your entity 1/256'th of a tile southwards. Not sure how "off grid" entities behave with map colors...
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Change color of rails on map
Because as far as i know that's the resolution of "position" (I'm probably wrong about that :P). And stuff further south should draw over stuff north of it. I.e. Doesn't really matter how much. I just thought 1/256 would be the minimum that sohuld work. Try something larger like 1/4th or so. If that doesn't work either than map-draw-order is just different.eduran wrote: ↑Fri Jun 07, 2019 5:15 pmTried that, but to no effect. Now I am curious: why 1/256th of a tile?eradicator wrote: ↑Fri Jun 07, 2019 10:14 amTry shifting the center of your entity 1/256'th of a tile southwards. Not sure how "off grid" entities behave with map colors...
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.
Re: Change color of rails on map
You are correct, everything except trains uses position at 1/256 resolution. Trains are weird, they have an internal 32-bit 1-dimensional position, but display as a 1/256 2-dimensional position.eradicator wrote: ↑Fri Jun 07, 2019 5:50 pmthat's the resolution of "position" (I'm probably wrong about that ).