Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Sase on March 20, 2008, 07:34:15 am

Title: [RESOLVED] General Script Questions
Post by: Sase on March 20, 2008, 07:34:15 am
Ok, so here goes all the small questions about scripts (example, how to change variable inside a script or how to remove something small).

My question now:
What syntax should I use to draw a variable number into a menu.
Title: Re: General Script Questions
Post by: Fantasist on March 20, 2008, 07:53:22 am
variables are stored in $game_variables, which is an array (like this: [1, 45, 34, 3, ...])
you refer to a variable of ID like this:
$game_variables[ID]


Next, in the menu, in a window, you might have observed 'self.contents.draw_text(....'

You'll need to do this:
self.contents.draw_text(x, y, w, h, $game_variables[ID].to_s)


x, y are the position od drawing the text. w is how much space the text is given horizontally. h is generally 32 (how much space text is given vertically). The last argument should be a string. But since $game_variable[ID] is a number, we  use '.to_s' to convert it into a string. Hope I was clear :)
Title: Re: General Script Questions
Post by: Sase on March 20, 2008, 08:45:02 am
Thanks a bunch. ^^,
Title: Re: General Script Questions
Post by: Fantasist on March 20, 2008, 10:35:49 am
no problem ^_^
Title: Re: General Script Questions
Post by: Sase on March 22, 2008, 02:41:57 am
Well again I need your assistance :F
This script (should?) needs to exort character faces from Characters/*charname*_face
If it's not there by default, I'd need to know where it is. So, in other words, it would draw faces instead of Characters. (btw its edited by me)
#==============================================================================
# ** Universal Customizable Men?
#==============================================================================
# The Sleeping Leonhart
# Version 1.0
# 24.05.07
#==============================================================================
# With this script you can customize your main men?.
# Feature:
# * Possibility to create a Menu with pictures(when the picture is active the opacity of the window is automatically setted to 0)
# * Windows animtion In and Out
# * Enable disable the windows animation
# * Setup the windows position, opacity and animation direction
# * You can hide a window
# * 3 different status window
# * You can set the command horizzontally or vertically
# * You can show the face of hero instead the character (The face go in Charcters/Face and name the picture like the character)
# * You can add/remove command
#==============================================================================
# Configuration
#==============================================================================
BG_MAP = true #make the map visible on the background
BG_PICTURE = "" #the name of the background picture
STATUS_PICTURE = "" #the name of the status picture
STEP_PICTURE = "" #the name of the steps picture
LOCATION_PICTURE = "" #the name of the location picture
GOLD_PICTURE = "" #the name of the gold picture
TIME_PICTURE = "" #the name of the steps picture
COMMAND_PICTURE = ""  #the name of the command picture
COMMAND_ITEM = "Items" #the name of the command item
COMMAND_SKILL = "Ability" #the name of the command skill
COMMAND_EQUIP = "Equipment" #the name of the command equipment
COMMAND_STATUS = "Status" #the name of the command status
COMMAND_BEAST = "Bestiary" #the name of the command save
COMMAND_SAVE = "Save Game" #Real save
COMMAND_EXIT = "Quit Game" #the name of the command exit
COMMAND_JRNL = "Journal"
COMMAND_OPT = "Options"
COMMAND_PARTY = "Change Party"
ANIMATION = true #enable the window animation
#PARTYSWITCH_ALLOWED = false

# REMEMBER TO SET $game_system.PARTYSWITCH_ALLOWED = true !!!
#===============================================================================
# Window Setup
#===============================================================================
# COMMAND_WINDOW Syntax: [Type of command Window, x, y, opacity, animation]
# LOCATION_WINDOW, STEP_WINDOW, GOLD_WINDOW, TIME_WINDOW Syntax: [Visible?, x, y, opacity, animation]
# STATUS_WINDOW Syntax: [Type of status Window, x, y, opacity, graphic, animation]
#-------------------------------------------------------------------------------
# Type of command Window = Set the Command Window in "Horizzontal" or "Vertical"
# Visible? = set to true if the window is visible
# x = Set the x position of the window
# y = Set the y position of the window
# opacity = Set the opacity of the window
# animation = Set the anmation side. "Down", "Up", "Left" or "Right"
# Type of status Window = Choose the type of the status window
# graphic = choose if show the face or the charcter in the status menu
#==============================================================================
COMMAND_WINDOW = ["Vertical", 0, 0, 160, "Right"]
STEP_WINDOW = [true, 0, 320, 160, "Down"]
LOCATION_WINDOW = [true, 480, 0, 320, "Down"]
GOLD_WINDOW = [true, 160, 0, 160, 160, "Down"]
TIME_WINDOW = [true, 0, 400, 320, "Right"]
STATUS_WINDOW = [2, 160, 64, 160, "Character", "Left"]
COMMAND_SETUP = [COMMAND_ITEM, COMMAND_SKILL, COMMAND_EQUIP, COMMAND_STATUS,COMMAND_JRNL, COMMAND_BEAST, COMMAND_PARTY, COMMAND_SAVE, COMMAND_EXIT]

class Game_Actor < Game_Battler
  def now_exp
    return @exp - @exp_list[@level]
  end
  def next_exp
    return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  end
end

class Window_Base < Window
  def draw_actor_face(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name + "_face", actor.character_hue)
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end
  def draw_actor_battler(actor, x, y)
    bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x, y, bitmap, src_rect)
  end
  def draw_actor_battler_trunc(actor, x, y)
    bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0+cw/8, 0, 80, ch)
    self.contents.blt(x, y, bitmap, src_rect)
  end
  def draw_actor_exps(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 28, 32, "EXP")
    self.contents.font.color = normal_color
    if actor.now_exp != 0
      text = (actor.now_exp.to_f / actor.next_exp.to_f)*100.00
      text = text.round
    else
      text = 0
    end
    self.contents.draw_text(x + 40, y, 84, 32, text.to_s+"%")
  end
  def draw_actor_parameter(actor, x, y, type)
    case type
    when 0
      parameter_name = "Attack"#$data_system.words.atk
      parameter_value = actor.atk
    when 1
      parameter_name = "Defence"#$data_system.words.pdef
      parameter_value = actor.pdef
    when 2
      parameter_name = "Resistance"#$data_system.words.mdef
      parameter_value = actor.mdef
    when 3
      parameter_name = "Strenght"#$data_system.words.str
      parameter_value = actor.str
    when 4
      parameter_name = "Dexterity"#$data_system.words.dex
      parameter_value = actor.dex
    when 5
      parameter_name = "Agility"#$data_system.words.agi
      parameter_value = actor.agi
    when 6
      parameter_name = "Intelligence"#$data_system.words.int
      parameter_value = actor.int
    end
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 120, 32, parameter_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 88, y, 36, 32, parameter_value.to_s, 2)
  end
end

class Window_Command < Window_Selectable
  attr_reader :commands
  def command(index = self.index)
    return @commands[index]
  end
  def commands=(commands)
    return if @commands == commands
    @commands = commands
    item_max = @item_max
    @item_max = @commands.size
    unless item_max == @item_max
      unless self.contents.nil?
        self.contents.dispose
        self.contents = nil
      end
      self.contents = Bitmap.new(width - 32, @item_max * 32)
    end
    refresh
  end
end

class Window_Selectable < Window_Base
  def command(index = self.index)
    return @commands[index]
  end
  def commands=(commands)
    return if @commands == commands
    @commands = commands
    item_max    = @item_max
    @item_max   = @commands.size
    @column_max = @item_max
    unless item_max == @item_max
      unless self.contents.nil?
        self.contents.dispose
        self.contents = nil
      end
    self.contents = Bitmap.new(@item_max * (width - 32), height - 32)
    end
    refresh
  end
end

class Window_MenuCommand < Window_Selectable
  def initialize
    if COMMAND_SETUP.size > 6
      super(COMMAND_WINDOW[1], COMMAND_WINDOW[2], 640, 96)
    else
      super(COMMAND_WINDOW[1], COMMAND_WINDOW[2], 640, 64)
    end
    self.contents = Bitmap.new(width - 32, height - 32)
    @item_max = COMMAND_SETUP.size
    if COMMAND_SETUP.size > 6
      @column_max = 6
      @row_max = 2
    else
      @column_max = COMMAND_SETUP.size
      @row_max = 1
    end
    @commands = COMMAND_SETUP
    @c_spacing    = (640 - 32)
    if COMMAND_PICTURE != ""
      @picture = Sprite.new
      @picture.bitmap = RPG::Cache.picture("Menu/" + COMMAND_PICTURE)
      @picture.x = 480
      @picture.y = 640
      self.opacity = 0
    else
      self.opacity = COMMAND_WINDOW[3]
    end
    refresh
    self.index = 0
  end
  alias tslums_menucmd_update update
  def update
    if COMMAND_PICTURE != ""
      @picture.x = self.x
      @picture.y = self.y
    end
    tslums_menucmd_update
  end
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, system_color)
    end
  end
  def draw_item(index, color)
    cursor_width = self.width / @column_max - 32
    x = 4 + index % @column_max * (cursor_width + 32)
    y = index / @column_max * 32
    self.contents.draw_text(x, y, cursor_width, 32, @commands[index], 0)
  end
  def disable_item(index)
    draw_item(index, disabled_color)
  end
end

class Window_Steps < Window_Base
  def initialize
    super(STEP_WINDOW[1], STEP_WINDOW[2], 160, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    if STEP_PICTURE != ""
      @picture = Sprite.new
      @picture.bitmap = RPG::Cache.picture("Menu/" + STEP_PICTURE)
      @picture.x = 640
      @picture.y = 480
      self.opacity = 0
    else
      self.opacity = STEP_WINDOW[3]
    end
    refresh
  end
  alias tslums_step_update update
  def update
    if STEP_PICTURE != ""
      @picture.x = self.x
      @picture.y = self.y
    end
    tslums_step_update
  end
end

class Game_Map
  def name
  $map_infos[@map_id]
  end
end
class Scene_Title
  $map_infos = load_data("Data/MapInfos.rxdata")
  for key in $map_infos.keys
    $map_infos[key] = $map_infos[key].name
  end
end
class Window_Location < Window_Base
  def initialize
    super(LOCATION_WINDOW[1], LOCATION_WINDOW[2], 160, 64)
    self.contents = Bitmap.new(width - 52, height - 32)
    if LOCATION_PICTURE != ""
      @picture = Sprite.new
      @picture.bitmap = RPG::Cache.picture("Menu/" + LOCATION_PICTURE)
      @picture.x = 640
      @picture.y = 480
      self.opacity = 0
    else
      self.opacity = LOCATION_WINDOW[3]
    end
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(0 , 0, 640, 32, $game_map.name)
  end
  alias tslums_loc_update update
  def update
    if LOCATION_PICTURE != ""
      @picture.x = self.x
      @picture.y = self.y
    end
    tslums_loc_update
  end
end

class Window_Gold < Window_Base
  def initialize
    super(GOLD_WINDOW[1], GOLD_WINDOW[2], 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    if GOLD_PICTURE != ""
      @picture = Sprite.new
      @picture.bitmap = RPG::Cache.picture("Menu/" + GOLD_PICTURE)
      @picture.x = 640
      @picture.y = 480
      self.opacity = 0
    else
      self.opacity = GOLD_WINDOW[3]
    end
    refresh
  end
  alias tslums_gold_update update
  def update
    if GOLD_PICTURE != ""
      @picture.x = self.x
      @picture.y = self.y
    end
    tslums_gold_update
  end
end

class Window_PlayTime < Window_Base
  def initialize
    super(TIME_WINDOW[1], TIME_WINDOW[2], 160, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    if TIME_PICTURE != ""
      @picture = Sprite.new
      @picture.bitmap = RPG::Cache.picture("Menu/" + TIME_PICTURE)
      @picture.x = 480
      @picture.y = 640
      self.opacity = 0
    else
      self.opacity = TIME_WINDOW[3]
    end
    refresh
  end
  alias tslums_time_update update
  def update
    if TIME_PICTURE != ""
      @picture.x = self.x
      @picture.y = self.y
    end
    tslums_time_update
  end
end

class Window_MenuStatus < Window_Selectable
  def initialize
    super(STATUS_WINDOW[1], STATUS_WINDOW[2], 480, 480-64)
    self.contents = Bitmap.new(width - 32, height - 32)
    if STATUS_PICTURE != ""
      @picture = Sprite.new
      @picture.bitmap = RPG::Cache.picture("Menu/" + STATUS_PICTURE)
      @picture.x = 640
      @picture.y = 480
      self.opacity = 0
    else
      self.opacity = STATUS_WINDOW[3]
    end
    refresh
    self.active = false
    self.index = -1
  end
  alias tslums_stat_update update
  def update
    if STATUS_PICTURE != ""
      @picture.x = self.x
      @picture.y = self.y
    end
    tslums_stat_update
  end
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      x = 64
      y = i * 98
      actor = $game_party.actors[i]
      if STATUS_WINDOW[4] == "Character"
        draw_actor_graphic(actor, x - 40, y + 80)
      elsif STATUS_WINDOW[4] == "Face"
        draw_actor_face(actor, x-20, y + 80)
      end
      draw_actor_name(actor, x, y)
      draw_actor_class(actor, x + 144, y)
      draw_actor_level(actor, x, y + 32)
      draw_actor_state(actor, x + 90, y + 32)
      draw_actor_exp(actor, x, y + 64)
      draw_actor_hp(actor, x + 236, y + 32)
      draw_actor_sp(actor, x + 236, y + 64)
    end
  end
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(0, @index * 98, self.width - 32, 96)
    end
  end
end

class Window_MenuStatus2 < Window_Selectable
  def initialize
    super(STATUS_WINDOW[1], STATUS_WINDOW[2], 480, 480-64)
    self.contents = Bitmap.new(width - 32, height - 32)
    if STATUS_PICTURE != ""
      @picture = Sprite.new
      @picture.bitmap = RPG::Cache.picture("Menu/" + STATUS_PICTURE)
      @picture.x = 640
      @picture.y = 480
      self.opacity = 0
    else
      self.opacity = STATUS_WINDOW[3]
    end
    refresh
    self.active = false
    self.index = -1
  end
  alias tslums_stat2_update update
  def update
    if STATUS_PICTURE != ""
      @picture.x = self.x
      @picture.y = self.y
    end
    tslums_stat2_update
  end
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      x = 64
      y = i * 98
      actor = $game_party.actors[i]
      if STATUS_WINDOW[4] == "Character"
        draw_actor_graphic(actor, x - 40, y + 80)
      elsif STATUS_WINDOW[4] == "Face"
        draw_actor_face(actor, x-10, y + 80)
      end
      self.contents.font.size = 18
      draw_actor_name(actor, x, y)
      draw_actor_hp(actor, x + 92, y)
      draw_actor_sp(actor, x + 236, y)
      draw_actor_state(actor, x, y + 18)
      draw_actor_level(actor, x, y + 36)
      draw_actor_exps(actor, x, y + 54)
      draw_actor_parameter(actor, x + 92, y + 18, 0)
      draw_actor_parameter(actor, x + 92, y + 36, 1)
      draw_actor_parameter(actor, x + 92, y + 54, 2)
      draw_actor_parameter(actor, x + 236, y + 18, 3)
      draw_actor_parameter(actor, x + 236, y + 36, 4)
      draw_actor_parameter(actor, x + 236, y + 54, 5)
    end
  end
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(0, @index * 98, self.width - 32, 96)
    end
  end
end

class Window_MenuStatus3 < Window_Selectable
  def initialize
    super(STATUS_WINDOW[1], STATUS_WINDOW[2], 480, 416)
    if STATUS_PICTURE != ""
      @picture = Sprite.new
      @picture.bitmap = RPG::Cache.picture("Menu/" + STATUS_PICTURE)
      @picture.x = 640
      @picture.y = 480
      self.opacity = 0
    else
      self.opacity = STATUS_WINDOW[3]
    end
    @column_max = 1
    refresh
    self.index = -1
  end
  alias tslums_stat2_update update
  def update
    if STATUS_PICTURE != ""
      @picture.x = self.x
      @picture.y = self.y
    end
    if self.index == -1
      self.oy = 0
    else
      self.oy = self.index*416
    end
    tslums_stat2_update
  end
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @item_max = $game_party.actors.size
    if @item_max > 0
      self.contents = Bitmap.new(448, 416*@item_max)
      for i in 0...@item_max
        y = i * 416
        actor = $game_party.actors[i]
        if STATUS_WINDOW[4] == "Character"
          draw_actor_graphic(actor, x - 40, y + 80)
        elsif STATUS_WINDOW[4] == "Face"
          draw_actor_face(actor, x-80, y+80)
        end
        draw_actor_name(actor, 4, y + 0)
        draw_actor_class(actor, 4 + 144, y + 0)
        draw_actor_level(actor, 0, y + 32)
        draw_actor_state(actor, 0, y + 64)
        draw_actor_hp(actor, 0 + 144, y + 32, 172)
        draw_actor_sp(actor, 0 + 144, y + 64, 172)
        draw_actor_parameter(actor, 0, y + 160, 0)
        draw_actor_parameter(actor, 0, y + 192, 1)
        draw_actor_parameter(actor, 0, y + 224, 2)
        draw_actor_parameter(actor, 0, y + 256, 3)
        draw_actor_parameter(actor, 0, y + 288, 4)
        draw_actor_parameter(actor, 0, y + 320, 5)
        draw_actor_parameter(actor, 0, y + 352, 6)
        self.contents.font.color = system_color
        self.contents.draw_text(0, y + 96, 80, 32, "EXP")
        self.contents.draw_text(144, y + 96, 80, 32, "NEXT")
        self.contents.font.color = normal_color
        self.contents.draw_text(0 + 60, y + 96, 84, 32, actor.exp_s, 2)
        self.contents.draw_text(144 + 60, y + 96, 84, 32, actor.next_rest_exp_s, 2)
        self.contents.font.color = system_color
        self.contents.draw_text(192, y + 160, 96, 32, "Wearing")
        draw_item_name($data_weapons[actor.weapon_id], 192 + 16, y + 208)
        draw_item_name($data_armors[actor.armor1_id], 192 + 16, y + 256)
        draw_item_name($data_armors[actor.armor2_id], 192 + 16, y + 304)
        draw_item_name($data_armors[actor.armor3_id], 192 + 16, y + 352)
        draw_item_name($data_armors[actor.armor4_id], 192 + 16, y + 400)
      end
    end
  end
  def update_cursor_rect
    self.cursor_rect.empty
  end 
end

class Scene_Menu
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  def main
    if BG_MAP == true
      @spritesetmap = Spriteset_Map.new
    end
    if BG_PICTURE != ""
      @bg = Sprite.new
      @bg.bitmap = RPG::Cache.picture("Menu/" + BG_PICTURE)
    end
    if COMMAND_WINDOW[0] == "Vertical"
      @command_window = Window_Command.new(160, COMMAND_SETUP)
      if COMMAND_PICTURE != ""
        @picture = Sprite.new
        @picture.bitmap = RPG::Cache.picture("Menu/" + COMMAND_PICTURE)
        @picture.x = 480
        @picture.y = 640
        @command_window.opacity = 0
      else
        @command_window.opacity = COMMAND_WINDOW[3]
      end
    elsif COMMAND_WINDOW[0] == "Horizontal"
      @command_window = Window_MenuCommand.new
    end   
    @command_window.index = @menu_index
    if $game_party.actors.size == 0
      @command_window.disable_item(1)
    end
    #if $game_system.save_disabled
    #  @command_window.disable_item(COMMAND_SAVE)
    #end
    @location_window = Window_Location .new
    @playtime_window = Window_PlayTime.new
    @steps_window = Window_Steps.new
    @gold_window = Window_Gold.new
    case STATUS_WINDOW[0]
    when 2
      @status_window = Window_MenuStatus2.new
    when 3
      @status_window = Window_MenuStatus3.new
    else
      @status_window = Window_MenuStatus.new
    end
    @playtime_window.visible = TIME_WINDOW[0]
    @location_window.visible = LOCATION_WINDOW[0]
    @gold_window.visible = GOLD_WINDOW[0]
    @steps_window.visible = STEP_WINDOW[0]
    if ANIMATION == true
      case COMMAND_WINDOW[4]
      when "Up"
        @command_window.y = 480 + COMMAND_WINDOW[2]
      when "Down"
        @command_window.y = -COMMAND_WINDOW[2]
      when "Left"
        @command_window.x = 640 + COMMAND_WINDOW[1]
      when "Right"
        @command_window.x = -COMMAND_WINDOW[1].to_f
      end
      case TIME_WINDOW[4]
      when "Up"
        @playtime_window.y = 480 + TIME_WINDOW[2]
      when "Down"
        @playtime_window.y = -480 - TIME_WINDOW[2]
      when "Left"
        @playtime_window.x = 640 + TIME_WINDOW[1]
      when "Right"
        @playtime_window.x = -640 - TIME_WINDOW[1]
      end
      case LOCATION_WINDOW[4]
      when "Up"
        @location_window.y = 480 + LOCATION_WINDOW[2]
      when "Down"
        @location_window.y = -LOCATION_WINDOW[2]
      when "Left"
        @location_window.x = 640 + LOCATION_WINDOW[1]
      when "Right"
        @location_window.x = -LOCATION_WINDOW[1].to_f
      end
      case STEP_WINDOW[4]
      when "Up"
        @steps_window.y = 480 + STEP_WINDOW[2]
      when "Down"
        @steps_window.y = -480 - STEP_WINDOW[2]
      when "Left"
        @steps_window.x = 640 + STEP_WINDOW[1]
      when "Right"
        @steps_window.x = -640 - STEP_WINDOW[1]
      end
      case GOLD_WINDOW[4]
      when "Up"
        @gold_window.y = 480 + GOLD_WINDOW[2]
      when "Down"
        @gold_window.y =  - GOLD_WINDOW[2]
      when "Left"
        @gold_window.x = 640 + GOLD_WINDOW[1]
      when "Right"
        @gold_window.x =  - GOLD_WINDOW[1]
      end     
      case STATUS_WINDOW[5]
      when "Up"
        @status_window.y = 480 + STATUS_WINDOW[2]
      when "Down"
        @status_window.y = -480 - STATUS_WINDOW[2]
      when "Left"
        @status_window.x = 640 + STATUS_WINDOW[1]
      when "Right"
        @status_window.x = -640 - STATUS_WINDOW[1]
      end
    end
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    dispose
  end
  def dispose
    if BG_MAP == true
      @spritesetmap.dispose
    end
    @command_window.dispose
    if COMMAND_PICTURE != "" and COMMAND_WINDOW[0] == "Vertical"
      @picture.dispose
    end
    if BG_PICTURE != ""
      @bg.dispose
    end
    @location_window.dispose
    @playtime_window.dispose
    @steps_window.dispose
    @gold_window.dispose
    @status_window.dispose
  end
  def delay(seconds)
    for i in 0...(seconds * 1)
      sleep 0.01
      Graphics.update
    end
  end
  def update
    windows_update
    if ANIMATION == true
      animate_window
    end
    if @command_window.active
      update_command
      return
    end
    if @status_window.active
      update_status
      return
    end
  end
  def windows_update
    @command_window.update
    @location_window.update
    @playtime_window.update
    @steps_window.update
    @gold_window.update
    @status_window.update
    if COMMAND_PICTURE != "" and COMMAND_WINDOW[0] == "Vertical"
      @picture.x = @command_window.x
      @picture.y = @command_window.y
    end
  end
  def animate_window
    case COMMAND_WINDOW[4]
    when "Up"
      if @command_window.y > COMMAND_WINDOW[2]
        @command_window.y -= ((480 + COMMAND_WINDOW[2]) / 10).to_f
      end
      if @command_window.y < COMMAND_WINDOW[2]
        @command_window.y = COMMAND_WINDOW[2]
      end
    when "Down"
      if @command_window.y < COMMAND_WINDOW[2]
        @command_window.y += (COMMAND_WINDOW[2] / 10).to_f
      end
      if @command_window.y > COMMAND_WINDOW[2]
        @command_window.y = COMMAND_WINDOW[2]
      end
    when "Left"
      if @command_window.x > COMMAND_WINDOW[1]
        @command_window.x -= ((640 + COMMAND_WINDOW[1]) / 10).to_f
      end
      if @command_window.x < COMMAND_WINDOW[1]
        @command_window.x = COMMAND_WINDOW[1]
      end
    when "Right"
      if @command_window.x < COMMAND_WINDOW[1]
        @command_window.x += (COMMAND_WINDOW[1] / 10).to_f
      end
      if @command_window.x > COMMAND_WINDOW[1]
        @command_window.x= COMMAND_WINDOW[1]
      end
    end
    case TIME_WINDOW[4]
    when "Up"
      if @playtime_window.y > TIME_WINDOW[2]
        @playtime_window.y -= ((480 + TIME_WINDOW[2]) / 10).to_f
      end
      if @playtime_window.y < TIME_WINDOW[2]
        @playtime_window.y = TIME_WINDOW[2]
      end
    when "Down"
      if @playtime_window.y < TIME_WINDOW[2]
        @playtime_window.y += ((480 + TIME_WINDOW[2]) / 10).to_f
      end
      if @playtime_window.y > TIME_WINDOW[2]
        @playtime_window.y = TIME_WINDOW[2]
      end
    when "Left"
      if @playtime_window.x > TIME_WINDOW[1]
        @playtime_window.x -= ((640 + GOLD_WINDOW[1]) / 10).to_f
      end
      if @playtime_window.x < TIME_WINDOW[1]
        @playtime_window.x = TIME_WINDOW[1]
      end
    when "Right"
      if @playtime_window.x < TIME_WINDOW[1]
        @playtime_window.x += ((640 + TIME_WINDOW[1]) / 10).to_f
      end
      if @playtime_window.x > TIME_WINDOW[1]
        @playtime_window.x = TIME_WINDOW[1]
      end
    end
    case LOCATION_WINDOW[4]
    when "Up"
      if @location_window.y > LOCATION_WINDOW[2]
        @location_window.y -= ((480 + LOCATION_WINDOW[2]) / 10).to_f
      end
      if @location_window.y < LOCATION_WINDOW[2]
        @location_window.y = LOCATION_WINDOW[2]
      end
    when "Down"
      if @location_window.y < LOCATION_WINDOW[2]
        @location_window.y += (LOCATION_WINDOW[2] / 10).to_f
      end
      if @location_window.y > LOCATION_WINDOW[2]
        @location_window.y = LOCATION_WINDOW[2]
      end
    when "Left"
      if @location_window.x > LOCATION_WINDOW[1]
        @location_window.x -= ((640 + LOCATION_WINDOW[1]) / 10).to_f
      end
      if @location_window.x < LOCATION_WINDOW[1]
        @location_window.x = LOCATION_WINDOW[1]
      end
    when "Right"
      if @location_window.x < LOCATION_WINDOW[1]
        @location_window.x += (LOCATION_WINDOW[1] / 10).to_f
      end
      if @location_window.x > LOCATION_WINDOW[1]
        @location_window.x= LOCATION_WINDOW[1]
      end
    end
    case STEP_WINDOW[4]
    when "Up"
      if @steps_window.y > STEP_WINDOW[2]
        @steps_window.y -= ((480 + STEP_WINDOW[2]) / 10).to_f
      end
      if @steps_window.y < STEP_WINDOW[2]
        @steps_window.y = STEP_WINDOW[2]
      end
    when "Down"
      if @steps_window.y < STEP_WINDOW[2]
        @steps_window.y += ((480 + STEP_WINDOW[2]) / 10).to_f
      end
      if @steps_window.y > STEP_WINDOW[2]
        @steps_window.y = STEP_WINDOW[2]
      end
    when "Left"
      if @steps_window.x > STEP_WINDOW[1]
        @steps_window.x -= ((640 + GOLD_WINDOW[1]) / 10).to_f
      end
      if @steps_window.x < STEP_WINDOW[1]
        @steps_window.x = STEP_WINDOW[1]
      end
    when "Right"
      if @steps_window.x < STEP_WINDOW[1]
        @steps_window.x += ((640 + STEP_WINDOW[1]) / 10).to_f
      end
      if @steps_window.x > STEP_WINDOW[1]
        @steps_window.x = STEP_WINDOW[1]
      end
    end
    case GOLD_WINDOW[4]
    when "Up"
      if @gold_window.y > GOLD_WINDOW[2]
        @gold_window.y -= ((480 + GOLD_WINDOW[2]) / 10).to_f
      end
      if @gold_window.y < GOLD_WINDOW[2]
        @gold_window.y = GOLD_WINDOW[2]
      end
    when "Down"
      if @gold_window.y < GOLD_WINDOW[2]
        @gold_window.y += ((480 + GOLD_WINDOW[2]) / 10).to_f
      end
      if @gold_window.y > GOLD_WINDOW[2]
        @gold_window.y = GOLD_WINDOW[2]
      end
    when "Left"
      if @gold_window.x > GOLD_WINDOW[1]
        @gold_window.x -= ((640 + GOLD_WINDOW[1]) / 10).to_f
      end
      if @gold_window.x < GOLD_WINDOW[1]
        @gold_window.x = GOLD_WINDOW[1]
      end
    when "Right"
      if @gold_window.x < GOLD_WINDOW[1]
        @gold_window.x += ((640 + GOLD_WINDOW[1]) / 10).to_f
      end
      if @gold_window.x > GOLD_WINDOW[1]
        @gold_window.x = GOLD_WINDOW[1]
      end
    end
    case STATUS_WINDOW[5]
    when "Up"
      if @status_window.y > STATUS_WINDOW[2]
        @status_window.y -= ((480 + STATUS_WINDOW[2]) / 10).to_f
      end
      if @status_window.y < STATUS_WINDOW[2]
        @status_window.y = STATUS_WINDOW[2]
      end
    when "Down"
      if @status_window.y < STATUS_WINDOW[2]
        @status_window.y += ((480 + STATUS_WINDOW[2]) / 10).to_f
      end
      if @status_window.y > STATUS_WINDOW[2]
        @status_window.y = STATUS_WINDOW[2]
      end
    when "Left"
      if @status_window.x > STATUS_WINDOW[1]
        @status_window.x -= ((640 + STATUS_WINDOW[1]) / 10).to_f
      end
      if @status_window.x < STATUS_WINDOW[1]
        @status_window.x = STATUS_WINDOW[1]
      end
    when "Right"
      if @status_window.x < STATUS_WINDOW[1]
        @status_window.x += ((640 + STATUS_WINDOW[1]) / 10).to_f
      end
      if @status_window.x > STATUS_WINDOW[1]
        @status_window.x = STATUS_WINDOW[1]
      end
    end
  end
  def delete_window
    i=0
    loop do
      windows_update
      case COMMAND_WINDOW[4]
      when "Up"
        if @command_window.y < 480 + COMMAND_WINDOW[2]
          @command_window.y += ((480 + COMMAND_WINDOW[2]) / 10).to_f
        end
      when "Down"
        if @command_window.y > -480 - COMMAND_WINDOW[2]
          @command_window.y -= ((480 + COMMAND_WINDOW[2]) / 10).to_f
        end
      when "Left"
        if @command_window.x < 640 + COMMAND_WINDOW[1]
          @command_window.x += ((640 + COMMAND_WINDOW[1]) / 10).to_f
        end
      when "Right"
        if @command_window.x > -640 - COMMAND_WINDOW[1]
          @command_window.x -= ((640 + COMMAND_WINDOW[1]) / 10).to_f
        end
      end
      case LOCATION_WINDOW[4]
      when "Up"
        if @location_window.y < 480 + LOCATION_WINDOW[2]
          @location_window.y += ((480 + LOCATION_WINDOW[2]) / 10).to_f
        end
      when "Down"
        if @location_window.y > -480 - LOCATION_WINDOW[2]
          @location_window.y -= ((480 + LOCATION_WINDOW[2]) / 10).to_f
        end
      when "Left"
        if @location_window.x < 640 + LOCATION_WINDOW[1]
          @location_window.x += ((640 + LOCATION_WINDOW[1]) / 10).to_f
        end
      when "Right"
        if @location_window.x > -640 - LOCATION_WINDOW[1]
          @location_window.x -= ((640 + LOCATION_WINDOW[1]) / 10).to_f
        end
      end
      case TIME_WINDOW[4]
      when "Up"
        if @playtime_window.y < 480 + TIME_WINDOW[2]
          @playtime_window.y += ((480 + TIME_WINDOW[2]) / 10).to_f
        end
      when "Down"
        if @playtime_window.y > -480 - TIME_WINDOW[2]
          @playtime_window.y -= ((480 + TIME_WINDOW[2]) / 10).to_f
        end
      when "Left"
        if @playtime_window.x < 640 + TIME_WINDOW[1]
          @playtime_window.x += ((640 + TIME_WINDOW[1]) / 10).to_f
        end
      when "Right"
        if @playtime_window.x > -640 - TIME_WINDOW[1]
          @playtime_window.x -= ((640 + TIME_WINDOW[1]) / 10).to_f
        end
      end
      case STEP_WINDOW[4]
      when "Up"
        if @steps_window.y < 480 + STEP_WINDOW[2]
          @steps_window.y += ((480 + STEP_WINDOW[2]) / 10).to_f
        end
      when "Down"
        if @steps_window.y > -480 - STEP_WINDOW[2]
          @steps_window.y -= ((480 + STEP_WINDOW[2]) / 10).to_f
        end
      when "Left"
        if @steps_window.x < 640 + STEP_WINDOW[1]
          @steps_window.x += ((640 + STEP_WINDOW[1]) / 10).to_f
        end
      when "Right"
        if @steps_window.x > -640 - STEP_WINDOW[1]
          @steps_window.x -= ((640 + STEP_WINDOW[1]) / 10).to_f
        end
      end
      case GOLD_WINDOW[4]
      when "Up"
        if @gold_window.y < 480 + GOLD_WINDOW[2]
          @gold_window.y += ((480 + GOLD_WINDOW[2]) / 10).to_f
        end
      when "Down"
        if @gold_window.y > -480 - GOLD_WINDOW[2]
          @gold_window.y -= ((480 + GOLD_WINDOW[2]) / 10).to_f
        end
      when "Left"
        if @gold_window.x < 640 + GOLD_WINDOW[1]
          @gold_window.x += ((640 + GOLD_WINDOW[1]) / 10).to_f
        end
      when "Right"
        if @gold_window.x > -640 - GOLD_WINDOW[1]
          @gold_window.x -= ((640 + GOLD_WINDOW[1]) / 10).to_f
        end
      end
      case STATUS_WINDOW[5]
      when "Up"
        if @status_window.y < 480 + STATUS_WINDOW[2]
          @status_window.y += ((480 + STATUS_WINDOW[2]) / 10).to_f
        end
      when "Down"
        if @status_window.y > -480 - STATUS_WINDOW[2]
          @status_window.y -= ((480 + STATUS_WINDOW[2]) / 10).to_f
        end
      when "Left"
        if @status_window.x < 640 + STATUS_WINDOW[1]
          @status_window.x += ((640 + STATUS_WINDOW[1]) / 10).to_f
        end
      when "Right"
        if @status_window.x > -640 - STATUS_WINDOW[1]
          @status_window.x -= ((640 + STATUS_WINDOW[1]) / 10).to_f
        end
      end
      delay(1)
      i += 1
      if i == 10
        break
      end
    end
  end
  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      delete_window
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      if $game_party.actors.size == 0 and @command_window.index < 4
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @command_window.command
      when COMMAND_ITEM
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Item.new
      when COMMAND_SKILL
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when COMMAND_EQUIP
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when COMMAND_STATUS
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when COMMAND_JRNL
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Journal.new
      when COMMAND_OPT
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Option.new
      when COMMAND_BEAST
        #$game_system.se_play($data_system.buzzer_se)
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Bestiary.new
        #$scene = Scene_MonsterBook.new
      when COMMAND_SAVE
        if $game_system.save_disabled
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Save.new
      when COMMAND_PARTY
       if $game_switches[1000]
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_PartySwitcher.new
        return
      end
      $game_system.se_play($data_system.buzzer_se)
      when COMMAND_EXIT
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_End.new
        end
      return
    end
  end
  def update_status
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    if Input.trigger?(Input::C)
      case @command_window.command
      when COMMAND_SKILL
        if $game_party.actors[@status_window.index].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Skill.new(@status_window.index)
      when COMMAND_EQUIP
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Equip.new(@status_window.index)
      when COMMAND_STATUS
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Status.new(@status_window.index)
      end
      return
    end
  end
end
Title: Re: General Script Questions
Post by: Fantasist on March 23, 2008, 12:44:22 am
Quote# * You can show the face of hero instead the character (The face go in Charcters/Face and name the picture like the character)


def draw_actor_face(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name + "_face", actor.character_hue)


The above two lines conflict. The instruction says to name the face graphics exactly as the charset and place the pics in Characters/Faces folder. But it actually works in this way:
in Characters/ put the face pics, whoce names are <charset_pic_name>_face.

And then,
STATUS_WINDOW = [2, 160, 64, 160, "Character", "Left"]


set that "Character" to "Face".