Guest User

Get/SetCameraState

a guest
Nov 29th, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1.  
  2. -- Press mouse button to print the current camera position
  3. -- Open infolog, copy paste a camera position into this widget:Initialize
  4. -- Then toggle widget to get back to that camera position
  5.  
  6. function widget:GetInfo()
  7.    return {
  8.       name      = "PrintCam",
  9.       desc      = "Print GetCameraState()",
  10.       author    = "zwzsg",
  11.       version   = "2",
  12.       date      = "Dec, 2009",
  13.       license   = "Free",
  14.       layer     = 1,
  15.       enabled   = false,
  16.    }
  17. end
  18.  
  19.  
  20. function widget:MousePress(mx, my, button)
  21.     local txt=nil
  22.     for k,v in pairs(Spring.GetCameraState()) do
  23.         if type(v)=="string" then
  24.             v="\""..v.."\""
  25.         end
  26.         txt=(txt and (txt..", ") or "")..tostring(k).."="..tostring(v)
  27.     end
  28.     txt="Spring.SetCameraState({"..txt.."},1)"
  29.     Spring.Echo(txt)
  30. end
  31.  
  32. function widget:Initialize()
  33.     Spring.SetCameraState({px=3176.9895019531, py=1271.5123291016, pz=1504.1774902344, dx=-0.79640448093414, dy=-0.60291218757629, name="fps", fov=45, mode=0, dz=0.047204066067934, oldHeight=290.76232910156},1)
  34. end
Advertisement
Add Comment
Please, Sign In to add comment