Page 1 of 1

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

Posted: Fri Mar 18, 2022 12:14 pm
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,

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

Posted: Fri Mar 18, 2022 12:33 pm
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 :)

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

Posted: Sat Mar 19, 2022 6:18 am
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

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

Posted: Sat Mar 19, 2022 9:53 am
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.