[0.17.25] modding - consuming zoom-in event also consumes alt-zoom-in and vice versa

Bugs that are actually features.
Post Reply
jarcionek
Fast Inserter
Fast Inserter
Posts: 137
Joined: Thu Mar 10, 2016 11:26 am
Contact:

[0.17.25] modding - consuming zoom-in event also consumes alt-zoom-in and vice versa

Post by jarcionek »

Controls.PNG
Controls.PNG (26.81 KiB) Viewed 1756 times

Firstly, I find it weird that there two almost identical controls that by default are assigned the same keys, but ok. It seems like it should be a check box in the Interface or Graphics Settings whether zooming to world is enabled. In regards to zooming out - there is absolutely no difference between the two and I don't know why the alt-zoom-out even exists.

If user assigns both keys to the same button (e.g. mouse-wheel-up) it doesn't zoom up twice as fast. So the user can assign a key to the "normal" action, to the "alternative" action, or to both and there will be no difference.

However, things are much different when it comes to the modding API. Consider the following in the data.lua:

Code: Select all

data:extend {
    {
        type = "custom-input",
        name = "ZoomingReinvented_zoom-in",
        key_sequence = "",
        linked_game_control = "zoom-in",
        consuming = "game-only"
    },
    {
        type = "custom-input",
        name = "ZoomingReinvented_alt-zoom-in",
        key_sequence = "",
        linked_game_control = "alt-zoom-in",
        consuming = "none"
    }
}
If user presses the key assigned to the action, the associated event is fired - that's logical. If user assigned the same key to both actions, both events are fired and that's already when things get complicated - because game zoomed in/out by only a single step, not two.

Now, let's assume that the mod does nothing with these custom-inputs - consider that control.lua is empty.

If with the above data.lua, user assigned the same key to both actions, they will not be able to zoom in at all. consuming = "game-only" will consume the only event that the game has internally, no matter that alt-zoom-in is not consumed.

Here is the analysis of different setups and what happens in game. Problematic cases in bold, everything else makes sense:

Table.PNG
Table.PNG (24.16 KiB) Viewed 1756 times

Rseding91
Factorio Staff
Factorio Staff
Posts: 13201
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.17.25] modding - consuming zoom-in event also consumes alt-zoom-in and vice versa

Post by Rseding91 »

Note that as of one of the minor 0.17 versions "consuming" for mod hotkeys does nothing.

As for why there are 2 hotkeys with the same keybindings: because they do 2 different things.

Zoom is just normal map view zoom. Alt zoom is the zoom-to-world logic. If you're in one you won't transition to the other without using the other hotkey. Since they're the same by default it means you just transition between them as you hit the zoom level.
If you want to get ahold of me I'm almost always on Discord.

jarcionek
Fast Inserter
Fast Inserter
Posts: 137
Joined: Thu Mar 10, 2016 11:26 am
Contact:

Re: [0.17.25] modding - consuming zoom-in event also consumes alt-zoom-in and vice versa

Post by jarcionek »

Rseding91 wrote:
Mon Apr 08, 2019 12:00 pm
Note that as of one of the minor 0.17 versions "consuming" for mod hotkeys does nothing.
Nope. That still works in 0.17.25. Setting it to game-only makes the base game do nothing. See also viewtopic.php?f=23&t=68926#p419456

Rseding91 wrote:
Mon Apr 08, 2019 12:00 pm
As for why there are 2 hotkeys with the same keybindings: because they do 2 different things.

Zoom is just normal map view zoom. Alt zoom is the zoom-to-world logic. If you're in one you won't transition to the other without using the other hotkey. Since they're the same by default it means you just transition between them as you hit the zoom level.
And what about zoom out?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13201
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.17.25] modding - consuming zoom-in event also consumes alt-zoom-in and vice versa

Post by Rseding91 »

jarcionek wrote:
Mon Apr 08, 2019 12:06 pm
And what about zoom out?
It's the same. If you're in zoomed-to-world and you use the normal zoom-to-world zoom out it won't switch to the map overview.
If you want to get ahold of me I'm almost always on Discord.

jarcionek
Fast Inserter
Fast Inserter
Posts: 137
Joined: Thu Mar 10, 2016 11:26 am
Contact:

Re: [0.17.25] modding - consuming zoom-in event also consumes alt-zoom-in and vice versa

Post by jarcionek »

Rseding91 wrote:
Mon Apr 08, 2019 2:26 pm
jarcionek wrote:
Mon Apr 08, 2019 12:06 pm
And what about zoom out?
It's the same. If you're in zoomed-to-world and you use the normal zoom-to-world zoom out it won't switch to the map overview.
I could swear that normal zoom out switches back to map. Maybe I just remember it wrong (can't access the game right now).

Post Reply

Return to “Not a bug”