Advertisement
AFRLme

Save Screenshot to a Folder [VS] (better method)

Nov 30th, 2012
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- [screenie] (name given to the definition script)
  2. -- saves a png screenshot if a path is specified else saves screenshot to be used for next save game image!
  3. -- checks if file exists before saving - loops check until file doesn't exist![better method]
  4. -- syntax: "createScreenshot(path)" or "createScreenshot(path, {flags=1, clear = true|false})"
  5. -- ref: http://wiki.visionaire2d.net/index.php?title=CreateScreenshot
  6.      
  7. -- declare an incrementing variable (increment the variable by 1 with "count = count +1")
  8. local count = 0
  9.      
  10. -- saves a png screenshot to the screenshot folder with a numer amended to the end based on current count value!
  11. function save_screenie_to_path()
  12.  local filename = 'screen_' .. count .. '.png'
  13.  local f = io.open('screenshots/' .. filename, 'r')
  14.  -- * --
  15.  if f then
  16.   print('-- * --') -- comment this out if you don't want it!
  17.   print(filename .. ' already exists!') -- comment this out if you don't want it!
  18.   count = count +1
  19.   f:close()
  20.   check_save_screenie()
  21. else
  22.   createScreenshot('screenshots/' .. filename)
  23.   print('-- * --')
  24.   print(filename .. ' has been saved to the screenshots folder!')
  25.   count = count +1
  26.  end
  27. end
  28.  
  29. -- loops to check if next screenshot_x.png exists else save screenshot to folder!
  30. function check_save_screenie()
  31.  save_screenie_to_path()
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement