Turning off electric-grid overlay in map view for selected entities

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1742
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Turning off electric-grid overlay in map view for selected entities

Post by Pi-C »

I'd like to be able to turn off the electric-grid overlay in map view for individual entities.

Use case: It's about Bio Industries. The mod provides so-called musk-floor, which basically is a ground tile with a hidden electric pole and a hidden solar panel placed on top of it. The hidden power poles have wire_reach set to 1, so adjoining tiles are connected. However, in map view this can result in huge areas of blue because all hidden poles are connected to their neighbors, and there has been a bug report about it.

This is what my testing setup looks in normal view:
nomap.png
nomap.png (955.44 KiB) Viewed 1651 times
This is what people expect to see in map view:
want_this.png
want_this.png (40.99 KiB) Viewed 1651 times
This is what they now get:
have_that.png
have_that.png (43.21 KiB) Viewed 1651 times
Actually, the current behavior is not a bug, but the normal thing in a normal game. It is perceived as a bug, however, because it worked differently for so long. Musk floor is created by placing a tile. If the script sees that the correct tile has been created, it does this:

Code: Select all

      local solar_mat = surface.get_tile(position.x, position.y)
      local sm_pole_name = "bi-musk-mat-pole"
      local sm_panel_name = "bi-musk-mat-solar-panel"
      
      local create_sm_pole = surface.create_entity({
        name = sm_pole_name,
        position = {position.x + 0.5, position.y + 0.5},
        force = force
      })
      local create_sm_panel = surface.create_entity({
        name = sm_panel_name,
        position = {position.x + 0.5, position.y + 0.5},
        force = force
      })
The bug was that the variable "force" used to be assigned outside of the scope of this block. So, "force = force" didn't amount to "force = event.player.force", but to "force = nil" -- and if "force = nil" is used with create_entity, it will default to "force = 'enemy'". In effect, people didn't get to see the electric overlay in map view because the musk floor didn't belong to them!

I probably could declare the original bug a feature and use create_entity with "force = 'enemy'" again, but I imagine this could be problematic if there are players with player.force = "enemy" because they would get to see the power grids of all players (including their own) in map view. So, unless you can guarantee that no human player will ever be able to be part of the force "enemy" (or any other new force I could make up), I'd like to be able to set a flag or option that turns off the electric overlay in map view for just selected entities. Would that be possible?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Pi-C
Smart Inserter
Smart Inserter
Posts: 1742
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Turning off electric-grid overlay in map view for selected entities

Post by Pi-C »

Pi-C wrote: Wed Apr 08, 2020 1:01 pm I probably could declare the original bug a feature and use create_entity with "force = 'enemy'" again, but I imagine this could be problematic if there are players with player.force = "enemy" because they would get to see the power grids of all players (including their own) in map view.
So I made up my mind to fix this by creating a new force for the musk floor. Then I saw the new Alliance mod which exposes forces to players so they can declare alliance with it. This is what I get on starting a new game and setting my player as independent force:
alliance.png
alliance.png (38.96 KiB) Viewed 1620 times
All of the forces shown are created by other mods for special purposes -- they clearly aren't meant to be joined by other players, but are shown nevertheless. So even if I create a force with an overly complicated name to minimize the chance that somebody will create a force of the same name to make sure that nobody will see the electric grid of other players, there are ways to get around this.

If exempting entities from being shown in the map view electric-grid overlay isn't possible for whatever reason, perhaps there is a way to add a setting to forces making them special by not allowing players to join them? Something like "force.players_may_join"?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Rseding91
Factorio Staff
Factorio Staff
Posts: 14616
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Turning off electric-grid overlay in map view for selected entities

Post by Rseding91 »

I don't want to slow down the map rendering for electric poles by having to check each ones prototype to see if it's configured to not show in the electric network rendering.
If you want to get ahold of me I'm almost always on Discord.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1742
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Turning off electric-grid overlay in map view for selected entities

Post by Pi-C »

Rseding91 wrote: Fri Apr 10, 2020 4:15 pm I don't want to slow down the map rendering for electric poles by having to check each ones prototype to see if it's configured to not show in the electric network rendering.
Thanks for answering -- especially on a holiday! Yes, it's reasonable that this may slow things down. How about my other suggestion then, would there be any chance for a flag/setting to prevent players from joining a certain force?

By the way, I don't expect an answer over the weekend. Take some days off, please, and have a happy Easter time! :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Rseding91
Factorio Staff
Factorio Staff
Posts: 14616
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Turning off electric-grid overlay in map view for selected entities

Post by Rseding91 »

There are only 2 ways for a player to join a force: console commands or the map editor. Both ways are functionally the same: a mod, or admin saying "put this player on that force" and so there's no "joining" to block. Just don't put a player on a force if you don't want them on the force.

If a player manually puts himself on a force, well the player is the "head admin" for a save so he can do what he wants.
If you want to get ahold of me I'm almost always on Discord.
mooman219
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Apr 10, 2020 10:28 pm
Contact:

Re: Turning off electric-grid overlay in map view for selected entities

Post by mooman219 »

@Pi-c

Apologies if my mod caused you some trouble, it's my first one and I added a warning on the description page in response. I'll work on improving the interactions with other mods such that it doesn't step on their toes as much as it does now. Force management is really an administrator level action and I didn't fix up all the corners yet with letting players manage it on a smaller scale.
Last edited by mooman219 on Fri Apr 10, 2020 10:34 pm, edited 2 times in total.
Post Reply

Return to “Modding interface requests”