[0.17.25] modding - consuming zoom-in event also consumes alt-zoom-in and vice versa
Posted: Sun Apr 07, 2019 3:26 pm
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"
}
}
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: