Follow vehicle/entity with zoom_to_world / open_map
Posted: Sat Jun 22, 2019 9:41 am
Instead of passing in a position, I would like `zoom_to_world{entity, scale}` (or `zoom_to_entity{vehicle, scale}`), where the chart keeps the vehicle in the center until closed (or cancelled with another `zoom_to/open_map` command. (The train's "go-to-train" button could also use this in the base game)
I've been trying to get a train-like "follow vehicle" display, except using the chart view (where you can zoom in and out, switch to chart_zoomed_in, and perform other actions like selecting alternative vehicles, etc
Currently I was doing the following, but this revealed the following problem (bug?): "player closed follow view" doesn't ever trigger! Since you queue up a "render_mode" change, you always overwrite player actions, and this leaves the game in a UI-locked state (ESC, M, etc don't work, since they all cancel the map view, and this brings it back... you cannot even open the menu) And trying to scroll out/in doesn't work for the same reason (chart to chart_zoomed_in render_mode is overwritten before I can read that its changed)
So I've found no alternatives so far, and UI-locking feels like a bug
I've been trying to get a train-like "follow vehicle" display, except using the chart view (where you can zoom in and out, switch to chart_zoomed_in, and perform other actions like selecting alternative vehicles, etc
Currently I was doing the following, but this revealed the following problem (bug?): "player closed follow view" doesn't ever trigger! Since you queue up a "render_mode" change, you always overwrite player actions, and this leaves the game in a UI-locked state (ESC, M, etc don't work, since they all cancel the map view, and this brings it back... you cannot even open the menu) And trying to scroll out/in doesn't work for the same reason (chart to chart_zoomed_in render_mode is overwritten before I can read that its changed)
So I've found no alternatives so far, and UI-locking feels like a bug
Code: Select all
if player.render_mode == defines.render_mode.game then
-- Player closed follow view
global.follow_vehicle[player.index] = nil
elseif player.render_mode == defines.render_mode.chart then
-- Minimap view, stay in the same view + zoom level
player.open_map(vehicle.position)
elseif player.render_mode == defines.render_mode.chart_zoomed_in then
-- Minimap-Enhanced mode, stay in the same view + zoom level
player.zoom_to_world(vehicle.position)
end