Detect if player view the map

Place to get help with not working mods / modding interface.
Yemto
Burner Inserter
Burner Inserter
Posts: 16
Joined: Sun Aug 28, 2016 1:52 pm
Contact:

Detect if player view the map

Post by Yemto »

Is there an event, or some other way to see if the player is looking at the map?
MostlyNumbers
Inserter
Inserter
Posts: 26
Joined: Fri Apr 13, 2018 10:07 pm
Contact:

Re: Detect if player view the map

Post by MostlyNumbers »

You can define a custom input to fire an event when they toggle map view. Something like:

In data.lua

Code: Select all

local custom_input={
    type = "custom-input",
    name = "my-custom-input",
    key_sequence = "",
    linked_game_control = "toggle-map",
    consuming = "none"
}
data:extend{custom_input}
In control.lua

Code: Select all

script.on_event("my-custom-input", function(event)
    -- Do something here
end)
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Detect if player view the map

Post by eradicator »

Not sure if input actions trigger when clicking the minimap instead of pressing a button (they probably do). But, apart from that the map-open status doesn't seem to be part of the game state (i just tested) and thus you can't use it for anything that affects the game state without causing multiplayer desyncs.
MostlyNumbers
Inserter
Inserter
Posts: 26
Joined: Fri Apr 13, 2018 10:07 pm
Contact:

Re: Detect if player view the map

Post by MostlyNumbers »

when clicking the minimap
Didn't even know that was an option!
Post Reply

Return to “Modding help”