Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

SephirothSpawn's Blur Screenshot

Taking Blur Screenshot:
Blur_Screenshot.shot(blur_settings, filename, type)

Calling Saved Screenshot:
bitmap = Blur_Screenshot.cache[filename]

What kind of values 'blur_settings', 'filename' and 'type' should be?
There's no further info in the script's instructions. I've searched the forums and tried giving different values.
Nothing works and it seems I can't figure it out by myself. Has anyone else used this script?

PS. I have SDK2.4, MACL2.3 & screenshot.dll correctly installed in the project.
 
Here it is:

Code:
#==============================================================================
# ** Blur Screenshot
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1
# 2007-04-02
# SDK : Version 2.0+, Part I
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1 ---------------------------------------------------- (2007-04-02)
#------------------------------------------------------------------------------
# * Requirements :
#
#   Method & Class Library (2.1+) (Requires Screenshot dll)
#------------------------------------------------------------------------------
# * Description :
#
#   This script was designed to take a screenshot of your game, and blur the
#   image. The image is saved in a Module cache, and can be refrence in later
#   scenes. However the cache is cleared whenever a game is closed.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#------------------------------------------------------------------------------
# * Syntax :
#
#   Taking Blur Screenshot
#    - Blur_Screenshot.shot(blur_settings, filename, type)
#
#   Calling Saved Screenshot
#    - bitmap = Blur_Screenshot.cache[filename]
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Blur Screenshot', 'SephirothSpawn', 1, '2007-04-02')
SDK.check_requirements(2.0, [], {'Method & Class Library' => 2.1}) 

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.enabled?('Blur Screenshot')

#==============================================================================
# ** Blur_Screenshot
#==============================================================================
  
module Blur_Screenshot
  #--------------------------------------------------------------------------
  # * Image Cache
  #--------------------------------------------------------------------------
  @cache = {}
  #--------------------------------------------------------------------------
  # * Shot
  #--------------------------------------------------------------------------
  def self.shot(blur_settings = {}, filename = 'screenshot', type = 2)
    # Captures Screen Image
    Screenshot.shot(filename, type)
    # Loads Image
    bitmap = RPG::Cache.picture(filename)
    # Blur Bitmap
    bitmap.blur_area(blur_settings)
    # Dispose Sprite if In Cache
    if @cache.has_key?(filename)
      @cache[filename].dispose
    end
    # Save Cache Image
    @cache[filename] = bitmap
  end
  #--------------------------------------------------------------------------
  # * Read Cache
  #--------------------------------------------------------------------------
  def self.cache
    return @cache
  end
  #--------------------------------------------------------------------------
  # * Clear Cache
  #--------------------------------------------------------------------------
  def self.clear_cache
    @cache = {}
  end
end
  
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
 
It seems blur_settings has something to do with the amount of blur, filename the name of the screenshot and type, I'm not sure, but it's linked to what type of screenshot is taken. However, you can leave out type, as it's 2 by standard. I don't have the dll so I can't try it in game.~~
 
I tried this:

    Blur_Screenshot.shot(1, menubg)
    bitmap = Blur_Screenshot.cache[menubg]

Setting blur_settings to 1 doesn't seem to cause an error, although I have no idea what it actually does.
But the filename causes a NameError: undefined local variable or method 'menubg'

I also tried this (added the single quotes to filename):

    Blur_Screenshot.shot(1, 'menubg')
    bitmap = Blur_Screenshot.cache['menubg']

This causes a NoMethodError: undefined method 'shot' for Screenshot:Module

I'm quite new to scripting, so this can be some simple thing that I just haven't realised yet. Any ideas?

And thanks for the replies!
 
blur_settings is exactly what's passed to blur_area of Trickster's MACL, as seen here:
Code:
  def blur_area(settings = {})
    # Set Defaults
    @blur_settings.each do |default, setting|
      settings[default] = setting unless settings.has_key?(default)
    end
    # Collects Keys
    keys = settings.keys
    # Rect Defined Flag
    rect_defined = keys.include?('rect')
    # Rect Positions Defined
    rect_p_defined = keys.include?('x') && keys.include?('y') && 
                     keys.include?('w') && keys.include?('h')
    # If Rect Defined
    if rect_defined
      # Gets Rect
      rect = settings['rect']
      # Set Position Arguments
      x, y, w, h = rect.x, rect.y, rect.width, rect.height
    # If Rect Positions Defined
    elsif rect_p_defined
      # Set Position Arguments
      x, y, w, h = settings['x'], settings['y'], settings['w'], settings['h']
    else
      # Set Entire Bitmap
      x, y, w, h = 0, 0, self.width, self.height
    end
    # Duplicated Bitmap
    dummy = self.dup
    # Gets Spacing & Max Opacity
    spacing = settings['spacing']
    opacity = settings['opacity']
    # Number of Offsets
    settings['offset'].times do |i|
      # Collects Src Rect
      src_rects = []
      src_rects << Rect.new(x + i * spacing, y + i * spacing, w, h)
      src_rects << Rect.new(x - i * spacing, y + i * spacing, w, h)
      src_rects << Rect.new(x + i * spacing, y - i * spacing, w, h)
      src_rects << Rect.new(x - i * spacing, y - i * spacing, w, h)
      # Gets Opacity
      o = Integer(opacity * (settings['offset'] - i) / (settings['offset']))
      # Draws Rects
      src_rects.each do |src_rect|
        blt(x, y, dummy, src_rect, o)
      end
    end
  end
That means, you can add certain flags to the blur, such as the area by for example giving {rect = Rect.new(x, y, width, height)} as an argument. If you don't want to do that, you can just leave it empty, or - in case you want to define the filename or the type values, you can use {} (passes an empty hash).
filename is easy, just pass a string (encircled with ' or ") which you want to be your screenshot's filename.
If I remember correctly, type changes the filetype of the image, 1 being JPG and 2 being PNG... there might be other values which I can't remember, but either way, you'll find all of those in your Screenshot module.

An important thing to notice: If you don't want either of the default settings changed, you can just use Blur_Screenshot.shot without any additional attributes, since they're all set to defaults.

Hope this helps you out.
 
Ok, thanks for clearing that up! Now I now what arguments I have to give.

However, I'm still getting a NoMethodError: undefined method 'shot' for Screenshot:Module

In the scripts editor, I have (below the standard scripts) SDK first, then MACL, then Blur_Screenshot, then my custom menu script and finally Main. I think this should be ok.

This is the CMS:
Code:
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs menu screen processing.
#==============================================================================

class Scene_Menu
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make command window
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Status"
    s5 = "Save"
    s6 = "End Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
    @command_window.index = @menu_index
    @command_window.opacity = 160
    # If number of party members is 0
    if $game_party.actors.size == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    # If save is forbidden
    if $game_system.save_disabled
      # Disable save
      @command_window.disable_item(4)
    end
    Blur_Screenshot.shot({}, "menubg", 2)
    bitmap = Blur_Screenshot.cache["menubg"]
    # Make play time window
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 0
    @playtime_window.y = 224
    @playtime_window.opacity = 160
    # Make steps window
    @steps_window = Window_Steps.new
    @steps_window.x = 0
    @steps_window.y = 320
    @steps_window.opacity = 160
    # Make gold window
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = 416
    @gold_window.opacity = 160
    # Make status window
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0
    @status_window.opacity = 160
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @command_window.dispose
    @playtime_window.dispose
    @steps_window.dispose
    @gold_window.dispose
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @command_window.update
    @playtime_window.update
    @steps_window.update
    @gold_window.update
    @status_window.update
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    end
    # If status window is active: call update_status
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If command other than save or end game, and party members = 0
      if $game_party.actors.size == 0 and @command_window.index < 4
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Branch by command window cursor position
      case @command_window.index
      when 0  # item
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to item screen
        $scene = Scene_Item.new
      when 1  # skill
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2  # equipment
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3  # status
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 4  # save
        # If saving is forbidden
        if $game_system.save_disabled
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to save screen
        $scene = Scene_Save.new
      when 5  # end game
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to end game screen
        $scene = Scene_End.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when status window is active)
  #--------------------------------------------------------------------------
  def update_status
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Make command window active
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 1  # skill
        # If this actor's action limit is 2 or more
        if $game_party.actors[@status_window.index].restriction >= 2
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to skill screen
        $scene = Scene_Skill.new(@status_window.index)
      when 2  # equipment
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to equipment screen
        $scene = Scene_Equip.new(@status_window.index)
      when 3  # status
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to status screen
        $scene = Scene_Status.new(@status_window.index)
      end
      return
    end
  end
end

Apart from the window opacity settings and the Blur_Screenshot, there is nothing different compared to the standard menu script.
What am I doing wrong here?
 
european_son":74g5s7v0 said:
However, I'm still getting a NoMethodError: undefined method 'shot' for Screenshot:Module
Guess you lack either MACL 2.1, or rather the included Screenshot module, or the required dll then... Seph's stuff works nice, as that error's caused from the following line pointing to that module:
Code:
Screenshot.shot(filename, type)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top