Getting bounds immediately after setting zoom doesn’t work, because set_zoom sends a message and is therefore actioned next frame:
local zoom = 0.25
camera.set_zoom(camera_id, zoom)
local bounds = camera.screen_to_world_bounds(camera_id)
I tried to delay triggering the screen_to_world_bounds() with a message, but it doesn’t work (the zoom still isn’t changed when the “get_camera_bounds” message is received):
local zoom = 0.25
camera.set_zoom(camera_id, zoom)
msg.post(".", "get_camera_bounds") -- Triggering screen_to_world_bounds()
What’s the best way to accomplish this? I was going to use a timer, but then a thousand warning bells went off in my mind.