Page 1 of 1

Follow vehicle/entity with zoom_to_world / open_map

Posted: Sat Jun 22, 2019 9:41 am
by Saevon
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

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

Re: Follow vehicle/entity with zoom_to_world / open_map

Posted: Sun Sep 18, 2022 1:46 am
by Gorfiend7
I'd like to second this request - some way for a mod to initiate a "follow entity" action that would work similar to the current "Open this location in the map" for trains. Ideally this would at least work for any vehicle (including spidertrons), and would be nice if it could work for any entity like other player characters, bots, or biters. A bonus would be if you can read what entity a player is currently following.

I tried emulating this with zoom_to_world/open_map on every tick, but that has issues. The issue in OP seems to mostly be fixed, but not completely - normally I can see changes to render mode from the user and act on it, but in a megabase where UPS drops below 60 I rarely saw the render mode change (reducing the game speed made it better, but would still fail sometimes). It also breaks any selection tools - looks like a zoom_to_world/open_map call cancels any active selection (which makes sense normally). It's also extra work to make sure the player can get out of this mode, since it can prevent them from opening the main menu.