Advertisement
AFRLme

Save Screenshot to a Folder [VS] (working)

Nov 6th, 2012
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 KB | None | 0 0
  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. -- syntax: "createScreenshot(path)" or "createScreenshot(path, {flags=1, clear = true|false})"
  4. -- ref: http://wiki.visionaire2d.net/index.php?title=CreateScreenshot
  5.      
  6. -- declare an incrementing variable (increment the variable by 1 with "count = count +1")
  7. local count = 0
  8.      
  9. -- check if any screenshots already exist + set count value
  10. function get_screen_amt()
  11.  local filename = 'screen_' .. count .. '.png'
  12.  local f = io.open('screenshots/' .. filename, 'r')
  13.  -- * --
  14.  if f then
  15.   count = count +1
  16.   check_cond() -- loops the query until file does not exist!
  17.   f:close()
  18.  else
  19.   if count == 1 then local screen_amt = count -1
  20.    print('-- * --')
  21.    print('there are currently ' .. screen_amt  .. ' saved screenshots!')
  22.    print('next screenshot will be screen_' .. count .. '.png')
  23.   end
  24.   if count > 1 then local screen_amt = count +1
  25.    print('-- * --')
  26.    print('there are currently ' .. screen_amt  .. ' saved screenshots!')
  27.    print('next screenshot will be screen_' .. count .. '.png')
  28.   end
  29.  end
  30. end
  31.  
  32. -- execute this in "Game properties" > "At begin  start following action" > "Start Action" -- starts loop to check if any screenshots exist & returns amount!
  33. function check_cond()
  34.   get_screen_amt()
  35. end
  36.  
  37. -- saves a png screenshot to the screenshot folder with a numer amended to the end based on current count value!
  38. function save_screenie_to_path()
  39. local filename = 'screen_' .. count .. '.png'
  40.   createScreenshot('screenshots/' .. filename)
  41.   print(filename .. ' has been saved to the screenshots folder!')
  42.   count = count +1
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement