How can I get the zoom ratio of the current screen?

Place to get help with not working mods / modding interface.
Post Reply
sdgmlj
Fast Inserter
Fast Inserter
Posts: 127
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

How can I get the zoom ratio of the current screen?

Post by sdgmlj »

I want to add a screen zoom function, but it seems that "player. Zoom" only supports writing, but does not support reading. Is there a way to obtain the current zoom ratio? Because only in this way can smooth scaling be achieved

I've tried to record with variables, but if the player adjusts with the scroll wheel, this variable is not accurate,

User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 310
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: How can I get the zoom ratio of the current screen?

Post by Stringweasel »

sdgmlj wrote:
Fri Mar 18, 2022 12:14 pm
I want to add a screen zoom function, but it seems that "player. Zoom" only supports writing, but does not support reading. Is there a way to obtain the current zoom ratio? Because only in this way can smooth scaling be achieved

I've tried to record with variables, but if the player adjusts with the scroll wheel, this variable is not accurate,
This is not possible unfortunately. It's not part of the game state, since it's specific to you and other players don't need to know about it. Similar to the location of your mouse pointer. And if it's not part of the game state it means that, in multiplayer for example, my game won't know the zoom level of your game. This can create desyncs between game instances if the mod does something depending on the zoom level. Or that's how I understand it at least :)
Alt-F4 Author | Factorio Modder
Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby

sdgmlj
Fast Inserter
Fast Inserter
Posts: 127
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Re: How can I get the zoom ratio of the current screen?

Post by sdgmlj »

Stringweasel wrote:
Fri Mar 18, 2022 12:33 pm
sdgmlj wrote:
Fri Mar 18, 2022 12:14 pm
I want to add a screen zoom function, but it seems that "player. Zoom" only supports writing, but does not support reading. Is there a way to obtain the current zoom ratio? Because only in this way can smooth scaling be achieved

I've tried to record with variables, but if the player adjusts with the scroll wheel, this variable is not accurate,
This is not possible unfortunately. It's not part of the game state, since it's specific to you and other players don't need to know about it. Similar to the location of your mouse pointer. And if it's not part of the game state it means that, in multiplayer for example, my game won't know the zoom level of your game. This can create desyncs between game instances if the mod does something depending on the zoom level. Or that's how I understand it at least :)
Thank you. It seems that there is no way to solve this problem

Qon
Smart Inserter
Smart Inserter
Posts: 2091
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: How can I get the zoom ratio of the current screen?

Post by Qon »

You can disable the normal zoom controls to avoid that problem. You would have to do all zoom controls with your mod then though.

Post Reply

Return to “Modding help”