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.

[Filled] Display a number on map using a variable.

Hi. I was wondering if someone would be able to make me a script or find something similar.
What I am looking for is a script that will show a number on the map in the top left corner. The number needs to be assigned to a variable. So when I change the variable to another number (like Variable 0050= 5 or Variable 0050=+1) the number of the variable will be displayed on the map in the Font that I am using.
My scripting knowledge is EXTREMELY limited, but I am assuming that this would be a fairly short and simple script for someone that knows what they are doing.

My requirements are that it displays in the Font I am using, being able to change Font size and adjust X and Y coordinates so I can position it as I please, also using Variable 0050 would be good.

I don't really have anything to offer in return, because someone that can do this is obviously better than me but I will of course not fail to credit you clearly.

I would be very grateful if somebody would do this for me and I hope I have explained my request clearly enough to understand.
 
here ya go...

Code:
 

#==============================================================================

# ** Sprite_Mapnum

#------------------------------------------------------------------------------

#  This sprite is used to display the number on the map.

#  It observes the $game_variables

#  class and automatically changes sprite conditions.

#==============================================================================

 

class Sprite_Mapnum < Sprite

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super

    self.bitmap = Bitmap.new(128, 32)

    #-----------------------------------------------

    #  Change Font, Position, & Variable Number here

    #-----------------------------------------------

    self.bitmap.font.name = "Arial"

    self.bitmap.font.size = 32

    self.bitmap.font.color.set(255, 255, 255)

    self.x = 0

    self.y = 0

    @use_variable = 50

    #-----------------------------------------------

    #

    #-----------------------------------------------

    self.z = 500

    @mapnum = 0

    update

  end

  #--------------------------------------------------------------------------

  # * Dispose

  #--------------------------------------------------------------------------

  def dispose

    if self.bitmap != nil

      self.bitmap.dispose

    end

    super

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    super

    # Set number to visible if value is greater than 0

    self.visible = $game_variables[@use_variable] > 0

    # If timer needs to be redrawn

    if $game_variables[@use_variable] != @mapnum

      @mapnum = $game_variables[@use_variable]

      # Clear window contents

      self.bitmap.clear

      # Draw mapnum

      self.bitmap.draw_text(0,0,128,32, @mapnum.to_s)

    end

  end

end

 

#==============================================================================

# ** Scene_Map

#------------------------------------------------------------------------------

#  Create the Sprite, and update it

#==============================================================================

class Scene_Map

  alias mapnum_main main

  alias mapnum_update update

  def main

    @map_num = Sprite_Mapnum.new

    mapnum_main

    @map_num.dispose

  end

  def update

    mapnum_update

    @map_num.update

  end

end

 

Ref: Project4
 
Wow, just like that!
I'm so grateful. Thanks Brewmeister for taking the time to help me out. I really appreciate it. That was really quick too. You've been a great help.
I will give you full credit as promised.
 

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