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.

Watermark Script

Kaoii

Member

If I was a halfway decent scripter, I would probably try to do this myself because I'm sure it's pretty simple.

This is my request. I want a script that will put an image on the screen for about a split second any time you hit the print screen button, effectively making a watermark for your game. I think a lot of people would use this.

I need to be able to change the X and Y coordinates of the image shown on the screen, the size of the image, and the opacity of the image. I'd also prefer it be SDK compatible.

Thanks to anyone who does this ;)
 
Well, I'm not a scripter, but this can pretty much just be done with a common event. Just make a switch and turn it on. Then, make a common event that runs as a parallel process and requires that the switch be on. Then make a branch that says when whatever key you choose is pressed, show the picture you want to use as your watermark, else erase the picture.
 

Jason

Awesome Bro

I have an idea, but I don't know anything about scripting:

Make it so it's something like this:

if. button(PrtScn (It has a number on the keyboard, but I don't know which)) is pressed
show_picture "Watermark.png" (0, 0, 320, 100) #Can be anything you like.
wait_1_frame
erase_picture "Watermark.png"
end

Maybe something like that would work ?
 

Mac

Member

But jbchrist there are still many ways around people just being able to print screen, you would have to have it so that it would watermark if there is interference from other programmes too. It would generally have to keep running.
 

Jason

Awesome Bro

I did it in my game, It just shows up a textbox saying Watermark in it, You can change it to whatever you like.

First, you will need this Keyboard Input Script (I edited it to include PrtScn):
Code:
#==============================================================================
# Keyboard Input Module
#----------------------------------------------------------------------------
# Script by Cybersam
#==============================================================================

module Input
  @keys = []
  @pressed = []
  Mouse_Left = 1
  Mouse_Right = 2
  Mouse_Middle = 4
  Back= 8
  Tab = 9
  Enter = 13
  Shift = 16
  Ctrl = 17
  Alt = 18
  Esc = 27
  Space = 32
  Numberkeys = {}
  Numberkeys[0] = 48        # => 0
  Numberkeys[1] = 49        # => 1
  Numberkeys[2] = 50        # => 2
  Numberkeys[3] = 51        # => 3
  Numberkeys[4] = 52        # => 4
  Numberkeys[5] = 53        # => 5
  Numberkeys[6] = 54        # => 6
  Numberkeys[7] = 55        # => 7
  Numberkeys[8] = 56        # => 8
  Numberkeys[9] = 57        # => 9
  Numberpad = {}
  Numberpad[0] = 45
  Numberpad[1] = 35
  Numberpad[2] = 40
  Numberpad[3] = 34
  Numberpad[4] = 37
  Numberpad[5] = 12
  Numberpad[6] = 39
  Numberpad[7] = 36
  Numberpad[8] = 38
  Numberpad[9] = 33
  Letters = {}
  Letters["A"] = 65
  Letters["B"] = 66
  Letters["C"] = 67
  Letters["D"] = 68
  Letters["E"] = 69
  Letters["F"] = 70
  Letters["G"] = 71
  Letters["H"] = 72
  Letters["I"] = 73
  Letters["J"] = 74
  Letters["K"] = 75
  Letters["L"] = 76
  Letters["M"] = 77
  Letters["N"] = 78
  Letters["O"] = 79
  Letters["P"] = 80
  Letters["Q"] = 81
  Letters["R"] = 82
  Letters["S"] = 83
  Letters["T"] = 84
  Letters["U"] = 85
  Letters["V"] = 86
  Letters["W"] = 87
  Letters["X"] = 88
  Letters["Y"] = 89
  Letters["Z"] = 90
  Fkeys = {}
  Fkeys[1] = 112
  Fkeys[2] = 113
  Fkeys[3] = 114
  Fkeys[4] = 115
  Fkeys[5] = 116
  Fkeys[6] = 117
  Fkeys[7] = 118
  Fkeys[8] = 119
  Fkeys[9] = 120
  Fkeys[10] = 121
  Fkeys[11] = 122
  Fkeys[12] = 123
  PrtScn = 124
  Collon = 186        # => \ |
  Equal = 187         # => = +
  Comma = 188         # => , <
  Underscore = 189    # => - _
  Dot = 190           # => . >
  Backslash = 191     # => / ?
  Lb = 219
  Rb = 221
  Quote = 222         # => '"
  #-------------------------------------------------------------------------------
  USED_KEYS = [Mouse_Left, Mouse_Right, Mouse_Middle] 
  #-------------------------------------------------------------------------------
  
module_function
  #--------------------------------------------------------------------------
  def triggered?(key)
    Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1
  end
  #-------------------------------------------------------------------------- 
  def check(key)
    Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1
  end
  #--------------------------------------------------------------------------
  def pressed?(key)
    return true unless Win32API.new("user32","GetKeyState",['i'],'i').call(key).between?(0, 1)
    return false
  end
  #--------------------------------------------------------------------------
  def mouse_update
    @used_i = []
    for i in USED_KEYS
      x = check(i)
      if x == true
        @used_i.push(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  def self.C
    self.trigger?(C)
  end
  #-------------------------------------------------------------------------- 
  def self.B
    self.trigger?(B)
  end
  #-------------------------------------------------------------------------- 
  def self.A
    self.trigger?(A)
  end
  #-------------------------------------------------------------------------- 
  def self.Down
    self.trigger?(DOWN)
  end
  #-------------------------------------------------------------------------- 
  def self.Up
    self.trigger?(UP)
  end
  #-------------------------------------------------------------------------- 
  def self.Right
    self.trigger?(RIGHT)
  end
  #-------------------------------------------------------------------------- 
  def self.Left
    self.trigger?(LEFT)
  end
  #--------------------------------------------------------------------------
  def self.Anykey
    if A or B or C or Down or Up or Right or Left
      return true
    else
      return false
    end
  end
  #--------------------------------------------------------------------------
end
You put the Keyboard Input Script ABOVE every other Script in the editor.

This is the script for the Watermark:

Code:
#-------------------------------------------------------------------------------
#** Watermark Test
#-------------------------------------------------------------------------------
#This enables you to choose whether a Watermark comes on when you press PrtScn.
#I have tested it and it works perfectly for me.
#Please credit me if you use it !
#                                                          Jbrist
#-------------------------------------------------------------------------------

class Watermark_Test < Window_Base
    
    def initialize
      
      if Input.triggered? (124) #PrtScn
        super(0, 0, 190, 32)
        self.contents = Bitmap.new (width - 32, height - 32)
        self.contents.draw_text (1, 1, 190, 32, "Watermark")
        erase.draw_text
          elsif Input.triggered? (8) #Backspace
            @Watermark_Test.dispose
          end
        end
      end
    
#-------------------------------------------------------------------------------
#You must be in Full-Screen for it to work, or else you get the Watermark in
#the top left corner of your screen (With the editor etc. on it)
#-------------------------------------------------------------------------------

Or if you would like it in SDK, Heres the code:

Code:
#-------------------------------------------------------------------------------
#** Watermark Test
#-------------------------------------------------------------------------------
#This enables you to choose whether a Watermark comes on when you press PrtScn.
#I have tested it and it works perfectly for me.
#Please credit me if you use it !
#                                                          Jbrist
#-------------------------------------------------------------------------------

class Watermark_Test < Window_Base
  
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Watermark Test', 'Jbrist', 1, '2.12.07')

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------

if SDK.state('Watermark Test') == true

    def initialize
      
      if Input.triggered? (124) #PrtScn
        super(0, 0, 190, 32)
        self.contents = Bitmap.new (width - 32, height - 32)
        self.contents.draw_text (1, 1, 190, 32, "Watermark")
        erase.draw_text
          elsif Input.triggered? (8) #Backspace
            @Watermark_Test.dispose
          end
        end
      end
      
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end

    
#-------------------------------------------------------------------------------
#You must be in Full-Screen for it to work, or else you get the Watermark in
#the top left corner of your screen (With the editor etc. on it)
#-------------------------------------------------------------------------------

Then you just make an event/common event, and add this into Call script (Make sure it's parrallel proccess):
Code:
Watermark_Test.new
 
It's nice but there's something wrong with the window,
look :

Code:
#-------------------------------------------------------------------------------
#** Watermark Test
#-------------------------------------------------------------------------------
#This enables you to choose whether a Watermark comes on when you press PrtScn.
#I have tested it and it works perfectly for me.
#Please credit me if you use it !
#                                                          Jbrist
#-------------------------------------------------------------------------------

class Watermark_Test < Window_Base
    
    def initialize
      
      if Input.triggered? (124) #PrtScn
        super(0, 0, 190, 32)
        self.contents = Bitmap.new (width - 32, height - 32)
        self.contents.draw_text (1, 1, 190, 32, "Watermark")
        erase.draw_text
          elsif Input.triggered? (8) #Backspace
            @Watermark_Test.dispose
          end
        end
      end
    
#-------------------------------------------------------------------------------
#You must be in Full-Screen for it to work, or else you get the Watermark in
#the top left corner of your screen (With the editor etc. on it)
#-------------------------------------------------------------------------------

okay, when we're trying to check if something happens, we need to do that in the update method.

the initialize method is reserved for the object (and it's variables) creation.

instead, you can draw the text and the window, hide it with self.visible = false, and show it when Print Screen is pressed (and that, in the update method) :

Code:
class Watermark_Test < Window_Base
    
    def initialize
      super(0, 0, 192, 32)
      self.contents = Bitmap.new (width - 32, height - 32)
      self.contents.draw_text (1, 1, 190, 32, "Watermark")
      self.visible = false
    end
    def update
      if Input.triggered? (124) #PrtScn
        self.visible = true
      else
        self.visible = false
      end
    end
end

you could still improve it more by checking if the PrintScreen key is pressed down :
Code:
    def update
      self.visible = Input.pressed?(124) #PrtScn
    end

but it's a nice job for a wannabe scripter ;)
 

Kaoii

Member

I appreciate all of the support given, and what SephirothSpawn said is correct about when other people play it.

My game will be running full-screen at all times, so that isn't a problem. However, I'm not even a halfway decent subpar scripter. Jbrist, I'm assuming the script you posted is proper and I appreciate that, but what about Selwyn's comments? Also, how would I get it to show an image instead of text?
 

Jason

Awesome Bro

I haven't had much experience with Scripting yet, As I'm only a Wannabe Scripter, But I'm learning more difficult things, So I will edit my post when I find out how to display a picture, if thats okay with you.
And I'd say to go with Selwyn's, because he's a more experienced scripter than I am, But yeah, I've tested my script and it works fine for me.
 
Kaoii, try this script:
Code:
class Sprite_Watermark < Sprite
  def initialize
    super()
    self.bitmap = RPG::Cache.picture('Watermark')
    self.z = 9999999
    self.visible = false
  end
  def update
    super()
    self.visible = Input.press?(124)
  end
end
class Scene_Map
  alias watermark_main main
  alias watermark_update update
  def main
    @watermark = Sprite_Watermark.new
    water_main
    @watermark_mark.dispose
  end
  def update
    @watermark.update
    watermark_update
  end
end
Add a picture called Watermark into the picture folder.
It just shows the watermark picture on the map by default, but you can add it to any scene by copying the Scene_Map section and changing the name of the Scene (e.g. Scene_Menu, Scene_Battle, etc.)
 

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