Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Zooming in DFHack Lua scripts  (Read 1196 times)

bliantfive

  • Bay Watcher
    • View Profile
Zooming in DFHack Lua scripts
« on: July 13, 2016, 08:14:28 am »

So, im working on a basic lua spotlight script that follows a dwarf from time to time and then gets back to its position.

Its working great, but i need a way to set the zoom level of the game.

I found the other window values (df.global.window_x etc.) but i can't, for the love of armok, find the value of the zoom level.

Since im navigating through the whole df object now and cant find it I need some help.

Thank you.
« Last Edit: July 13, 2016, 11:51:27 am by bliantfive »
Logged
Dwarf247 - a 24/7 Dwarf Fortress stream online!

check out this thread

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Zooming in DFHack Lua scripts
« Reply #1 on: July 13, 2016, 06:47:14 pm »

I'm pretty sure df.global.gps.dimx and df.global.gps.dimy show the exact amount of tiles on screen at the moment. Not exactly zoom level, but close enough.

bliantfive

  • Bay Watcher
    • View Profile
Re: Zooming in DFHack Lua scripts
« Reply #2 on: July 14, 2016, 01:22:41 am »

I'm pretty sure df.global.gps.dimx and df.global.gps.dimy show the exact amount of tiles on screen at the moment. Not exactly zoom level, but close enough.

When zoomed these dont change and changing them has no effect (in fact they are changed back at the next tick). Seem to have no relation to zooming other than beeing an informative value of the baseline.

There is a parameter df.zoom_commands but I have no hint how to use it or if even if it is to be used(or just a mere collection of flags or anything) There is also nothing to read out other than the type (which is "zoom_commands").

I still need help people.

Isnt there any form of documentation? I mean all the other script writers have done it before. I cant imagine they were browsing through the whole object mess like I do now.
Logged
Dwarf247 - a 24/7 Dwarf Fortress stream online!

check out this thread

bliantfive

  • Bay Watcher
    • View Profile
Re: Zooming in DFHack Lua scripts
« Reply #3 on: July 14, 2016, 04:03:43 am »

Im using dfhack.screen.zoom() now.
This is working, but i would like it better to have a constant value i could edit(or at least read out)

I also cant come up with a way to use gui.simulateInput() with the ZOOM_RESET key.
gui.simulateInput('ZOOM_RESET') does not work while gui.simulateInput('D_LOOK') for example does.

This would be a workaround to have a baseline to zoom from.
Logged
Dwarf247 - a 24/7 Dwarf Fortress stream online!

check out this thread

bliantfive

  • Bay Watcher
    • View Profile
Re: Zooming in DFHack Lua scripts
« Reply #4 on: July 14, 2016, 04:09:46 am »

OK, got my head around it and have a workaround that should work for anyone interested:
dfhack.screen.zoom(0) - zoom out
dfhack.screen.zoom(1) - zoom in
dfhack.screen.zoom(2) - reset zoom
Logged
Dwarf247 - a 24/7 Dwarf Fortress stream online!

check out this thread

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: Zooming in DFHack Lua scripts
« Reply #5 on: July 14, 2016, 09:30:05 pm »

I also cant come up with a way to use gui.simulateInput() with the ZOOM_RESET key.
gui.simulateInput('ZOOM_RESET') does not work while gui.simulateInput('D_LOOK') for example does.
The reason that doesn't work is because screen zooming is handled by the global viewscreen logic, and gui.simulateInput is only capable of sending input to the current viewscreen. This is also why you cannot control Macros or Movie recording in this way.
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.