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.

Diamond Script

izze

Member

Diamond script
By Izze

Introduction

Hi everybody! This is my very first script, so don't be hars, ok?
This script adds a new scene called Scene_Dimonds and a new window in the menu. Scene_Diamonds shows the diamonds you have collected by a variable (Variable 1 in the script). The Window_Diamonds show how many diamonds you have.
Of course you can change diamonds to weathever you want.
Features
  • Shows how many diamonds you have.
  • Removes the "steps"-window
  • Adds "Diamonds" in the menu
  • Able to change diamonds to something else
Screenshots
http://img402.imageshack.us/img402/2739/screenshot01sb1.png[/IMG]
http://img401.imageshack.us/img401/1958 ... t02jd7.png[/IMG]
http://img401.imageshack.us/img401/7503 ... t03hw3.png[/IMG]

Demo

Here:
http://www.box.net/shared/4k07h4ryim

Script

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 = "Diamonds"
    s5 = "Status"
    s6 = "Save"
    s7 = "End Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
    @command_window.index = @menu_index
    # 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)
      @command_window.disable_item(4)
    end
    if $game_variables[1] == 0
      @command_window.disable_item(3)
    end
    # If save is forbidden
    if $game_system.save_disabled
      # Disable save
      @command_window.disable_item(4)
    end
    # Make play time window
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 0
    @playtime_window.y = 320
    # Make steps window
    @steps_window = Window_Variable.new
    @steps_window.x = 0
    @steps_window.y = 256
    # Make gold window
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = 416
    # Make status window
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0
    # 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  # Diamonds
        if $game_variables[1] > 0
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        #Switch to diamond scene
        $scene = Scene_Diamonds.new
      else
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      when 4  # 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 5  # 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 6  # 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
Code:
class Window_Variable < Window_Base
    def initialize
    super(32, 32, 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end

  def refresh
    self.contents.clear
    cx = contents.text_size($game_variables[1].to_s).width
    x = 4
    y = 0
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon("035-Item04")
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(32, 0, 10, 30, ":")
    self.contents.draw_text(45, 0, cx, 30, $game_variables[1].to_s)
  end
end

class Window_Diamonds < Window_Base
   def initialize
     super(0, 0, 640, 480)
     self.contents = Bitmap.new(width - 32, height - 32)
     refresh
   end
   
   def refresh
     self.contents.clear
     if $game_variables[1] == 1
       cx = contents.text_size("Diamond of fire").width
       bitmap = RPG::Cache.picture("diamond")
       self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 100, 100), 255)
       self.contents.draw_text(105, 50, cx, 30, "Diamond of fire")
     end
     if $game_variables[1] == 2
       cx = contents.text_size("Diamond of fire").width
       cxx = contents.text_size("Diamond of ice").width
       bitmap = RPG::Cache.picture("diamond")
       self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 100, 100), 255)
       self.contents.draw_text(105, 50, cx, 30, "Diamond of fire")
       bitmap = RPG::Cache.picture("diamond2")
       self.contents.blt(0, 104, bitmap, Rect.new(0, 0, 100, 100), 255)
       self.contents.draw_text(105, 150, cxx, 30, "Diamond of ice")
     end
     if $game_variables[1] == 3
       cx = contents.text_size("Diamond of fire").width
       cxx = contents.text_size("Diamond of ice").width
       cxxx = contents.text_size("Diamond of earth").width
       bitmap = RPG::Cache.picture("diamond")
       self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 100, 100), 255)
       self.contents.draw_text(105, 50, cx, 30, "Diamond of fire")
       bitmap = RPG::Cache.picture("diamond2")
       self.contents.blt(0, 104, bitmap, Rect.new(0, 0, 100, 100), 255)
       self.contents.draw_text(105, 150, cxx, 30, "Diamond of ice")
       bitmap = RPG::Cache.picture("diamond3")
       self.contents.blt(0, 208, bitmap, Rect.new(0, 0, 100, 100), 255)
       self.contents.draw_text(105, 250, cxxx, 30, "Diamond of earth")
     end
   end
 end


 
 class Scene_Diamonds
   def main
     #Create window
     @diamond_window = Window_Diamonds.new
     #Make the dimond windoe active
     @diamond_window.active = true
     # 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
    @diamond_window.dispose
  end
  #Update
  def update
    @diamond_window.update
    if @diamond_window.active
      update_diamond
    end
  end
  def update_diamond
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(0)
    return
  end
end
end

Instructions

Just to paste the scripts into the script editor and have three pictures (100X100 pixels) called "diamond", "diamond2" and "diamond3"


Credits and Thanks

If you want to use this (wich I think noone will ;) ) please credit Izze!
 
little Tip

Replace the $game_variables[1]

with $diamonds

so the variable is clear for other use.

Nice work ^^
 

Dokien

Sponsor

Sir Lord Biowulve;293218 said:
little Tip

Replace the $game_variables[1]
with $diamonds
so the variable is clear for other use.

So, are you saying to change it to $diamonds[1]? If so, there are 5 code changes that I can see.
 
Never use global variables, plus yeyinde will kill you if he see's that.
don?t interests me if he does...

I must use them, because i need all 5000 Varaibles for my Event operations ( the complete KS, Men?s, paralell operations... everything is done with events..
That eats varaibleas and switches.

so i use arrays, hash oder global variables/switches for Scripting things.
 
What is the object of these diamonds? Will it have some sort of effect, like Materia or some bollocks? Or is it just collectables?
 

OS

Sponsor

Oh, you could use them for anything.

It would probably be wiser to add to Game_System instead, Sir Lord Biowulve; I mean, alias Game_System to hold all your globals like this:

$game_system.diamonds[1] = etc.

I use this method, and I gotta tell you, it works pretty well. The new variables are even saved with Game_System in Scene_Save, and Loaded as well, so you don't have to alter other scripts.
 
In my games the Scripts Scene_Save and Scene_Load are deleted..
That?s because i save and load via Call_Script in a picture and event based Men?.. so the Game_System thing doesn?t matter there ^^
 

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