Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

2 Pages V  < 1 2  
Reply to this topicStart new topic
> [Series][Scripting]Windows, A tutorial from the Script Builders
Amnesiah
post Dec 18 2009, 03:07 PM
Post #21


Level 1
Group Icon

Group: Member
Posts: 11
Type: Mapper
RM Skill: Intermediate




I'm getting a syntax error now when starting it with an edited code law gave me,
And I really don't know how to fix a syntax error,, ;o

This post has been edited by Amnesiah: Dec 18 2009, 03:11 PM
Go to the top of the page
 
+Quote Post
   
The Law G14
post Dec 18 2009, 05:56 PM
Post #22


Scripter FTW
Group Icon

Group: Local Mod
Posts: 1,346
Type: Scripter
RM Skill: Skilled
Rev Points: 5




Sorry about that, this should hopefully work:

CODE
#==============================================================================
# ** Window_Command_Icons
#------------------------------------------------------------------------------
# This class deals with command window icons processing.  
#==============================================================================

class Window_Command_Icons < Window_Selectable
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
      draw_icon(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(38, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
  end
  #--------------------------------------------------------------------------
  # * Draw Icon
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_icon(index)
    case index
    when 0
      icon = '001-Weapon01'
    when 1
      icon = '001-Weapon01'
    when 2
      icon = '001-Weapon01'
    when 3
      icon = '001-Weapon01'
    when 4
      icon = '001-Weapon01'
    when 5
      icon = '001-Weapon01'
     else
      icon = ''
    end
    bitmap = RPG::Cache.icon(icon)
    src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    self.contents.blt(4, 32*index+5, bitmap, src_rect)
  end
end

#==============================================================================
# ** Window_attr_points
#------------------------------------------------------------------------------
#  This window displays a variable.
#==============================================================================

class Window_attr_points < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
  super(0, 250, 200, 70)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 120, 32, "Points left:")
    self.contents.font.color = normal_color
    self.contents.draw_text(120, 0, 50, 32, $game_variables[3].to_s)
  end
end


#==============================================================================
# ** Scene_Attr
#------------------------------------------------------------------------------
# This class performs attr screen processing.
#==============================================================================

class Scene_Attr
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make command window
    s1 = "Hp"
    s2 = "Sp"
    s3 = "Str"
    s4 = "Dex"
    s5 = "Agi"
    s6 = "Int"
    s7 = "close"
    @command_window = Window_Command_Icons.new(200, [s1, s2, s3, s4, s5, s6, s7])
    @command_window.index = 0
    @command_window.height = 250
    @command_window.x = 0
    # Make attribute window
    @attr_points = Window_attr_points.new
    @attr_points.x = 0
    @attr_points.y = 250
    # 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
    @attr_points.dispose
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def update
      # Update windows
      @command_window.update
      @attr_points.update
      # If command window is active: call update_command
      if Input.trigger?(Input::C)
        # Branch by command window cursor position
        case @command_window.index
        when 0 # hp
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          @hp = @hp + 10
        when 1 # sp
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          @sp = @sp + 10
        when 2 # str
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          @str = @str + 10
        when 3 # dex
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          @dex = @dex + 10
        when 4 # agi
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          @agi = @agi + 10
        when 5 # int
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          @int = @int + 10
        when 6 # close
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          @command_window.dispose
        end
        return
      end
      $game_variables[3] = @command_window.index
    end
  end
end


__________________________

To put in sig, copy this link:
CODE
[url="http://www.rpgrevolution.com/forums/index.php?showtopic=51540"][img]http://img40.imageshack.us/img40/6504/conceptthelawbanner.png[/img][/url]


Sig Stuff


"When you first come, no one knows you. When help them out, they all know you. When you leave, they all love you. When you come back, they've already forgotten you." -- copy into your sig if you think this quote speaks true!

If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others. -Exiled One

My Project Thread: Gai's Hunters


Go to the top of the page
 
+Quote Post
   
Amnesiah
post Dec 19 2009, 01:27 AM
Post #23


Level 1
Group Icon

Group: Member
Posts: 11
Type: Mapper
RM Skill: Intermediate




Still getting the error,
What does a syntax error mean actually ?
Go to the top of the page
 
+Quote Post
   
The Law G14
post Dec 19 2009, 06:39 AM
Post #24


Scripter FTW
Group Icon

Group: Local Mod
Posts: 1,346
Type: Scripter
RM Skill: Skilled
Rev Points: 5




Oops, my mistake:

CODE
#==============================================================================
# ** Window_Command_Icons
#------------------------------------------------------------------------------
# This class deals with command window icons processing.  
#==============================================================================

class Window_Command_Icons < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width    : window width
  #     commands : command text string array
  #--------------------------------------------------------------------------
  def initialize(width, commands)
    # Compute window height from command quantity
    super(0, 0, width, commands.size * 32 + 32)
    @item_max = commands.size
    @commands = commands
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
      draw_icon(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(38, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
  end
  #--------------------------------------------------------------------------
  # * Draw Icon
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_icon(index)
    case index
    when 0
      icon = '001-Weapon01'
    when 1
      icon = '001-Weapon01'
    when 2
      icon = '001-Weapon01'
    when 3
      icon = '001-Weapon01'
    when 4
      icon = '001-Weapon01'
    when 5
      icon = '001-Weapon01'
     else
      icon = ''
    end
    bitmap = RPG::Cache.icon(icon)
    src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    self.contents.blt(4, 32*index+5, bitmap, src_rect)
  end
end

#==============================================================================
# ** Window_attr_points
#------------------------------------------------------------------------------
#  This window displays a variable.
#==============================================================================

class Window_attr_points < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
  super(0, 250, 200, 70)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 120, 32, "Points left:")
    self.contents.font.color = normal_color
    self.contents.draw_text(120, 0, 50, 32, $game_variables[3].to_s)
  end
end


#==============================================================================
# ** Scene_Attr
#------------------------------------------------------------------------------
# This class performs attr screen processing.
#==============================================================================

class Scene_Attr
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make command window
    s1 = "Hp"
    s2 = "Sp"
    s3 = "Str"
    s4 = "Dex"
    s5 = "Agi"
    s6 = "Int"
    s7 = "close"
    @command_window = Window_Command_Icons.new(200, [s1, s2, s3, s4, s5, s6, s7])
    @command_window.index = 0
    @command_window.height = 250
    @command_window.x = 0
    # Make attribute window
    @attr_points = Window_attr_points.new
    @attr_points.x = 0
    @attr_points.y = 250
    # 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
    @attr_points.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @command_window.update
    @attr_points.update
    # If command window is active: call update_command
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 0 # hp
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @hp = @hp + 10
      when 1 # sp
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @sp = @sp + 10
      when 2 # str
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @str = @str + 10
      when 3 # dex
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @dex = @dex + 10
      when 4 # agi
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @agi = @agi + 10
      when 5 # int
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @int = @int + 10
      when 6 # close
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new
      end
      return
    end
    $game_variables[3] = @command_window.index
  end
end


Also, to get more info about syntax errors, NightShade has written two tutorials about them:

http://www.rpgrevolution.com/forums/index....showtopic=36295

http://www.rpgrevolution.com/forums/index....showtopic=37834


__________________________

To put in sig, copy this link:
CODE
[url="http://www.rpgrevolution.com/forums/index.php?showtopic=51540"][img]http://img40.imageshack.us/img40/6504/conceptthelawbanner.png[/img][/url]


Sig Stuff


"When you first come, no one knows you. When help them out, they all know you. When you leave, they all love you. When you come back, they've already forgotten you." -- copy into your sig if you think this quote speaks true!

If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others. -Exiled One

My Project Thread: Gai's Hunters


Go to the top of the page
 
+Quote Post
   
Amnesiah
post Dec 20 2009, 09:47 AM
Post #25


Level 1
Group Icon

Group: Member
Posts: 11
Type: Mapper
RM Skill: Intermediate




Still having the error sad.gif

I really want this to work !
Go to the top of the page
 
+Quote Post
   
Litchi
post Dec 20 2009, 11:35 AM
Post #26


Level 3
Group Icon

Group: Member
Posts: 40
Type: None
RM Skill: Undisclosed




Are the Script Builders like a little club here?
Go to the top of the page
 
+Quote Post
   
The Law G14
post Dec 20 2009, 12:04 PM
Post #27


Scripter FTW
Group Icon

Group: Local Mod
Posts: 1,346
Type: Scripter
RM Skill: Skilled
Rev Points: 5




@Amnesiah: Sorry sad.gif This should definetly work, at least I know it works for me:

CODE
#==============================================================================
# ** Window_Command_Icons
#------------------------------------------------------------------------------
# This class deals with command window icons processing.  
#==============================================================================

class Window_Command_Icons < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width    : window width
  #     commands : command text string array
  #--------------------------------------------------------------------------
  def initialize(width, commands)
    # Compute window height from command quantity
    super(0, 0, width, commands.size * 32 + 32)
    @item_max = commands.size
    @commands = commands
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
      draw_icon(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(38, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
  end
  #--------------------------------------------------------------------------
  # * Draw Icon
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_icon(index)
    case index
    when 0
      icon = '001-Weapon01'
    when 1
      icon = '001-Weapon01'
    when 2
      icon = '001-Weapon01'
    when 3
      icon = '001-Weapon01'
    when 4
      icon = '001-Weapon01'
    when 5
      icon = '001-Weapon01'
     else
      icon = ''
    end
    bitmap = RPG::Cache.icon(icon)
    src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    self.contents.blt(4, 32*index+5, bitmap, src_rect)
  end
  #--------------------------------------------------------------------------
  # * Disable Item
  #     index : item number
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
end

#==============================================================================
# ** Window_attr_points
#------------------------------------------------------------------------------
#  This window displays a variable.
#==============================================================================

class Window_attr_points < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
  super(0, 250, 200, 70)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 120, 32, "Points left:")
    self.contents.font.color = normal_color
    self.contents.draw_text(120, 0, 50, 32, $game_variables[3].to_s)
  end
end


#==============================================================================
# ** Scene_Attr
#------------------------------------------------------------------------------
# This class performs attr screen processing.
#==============================================================================

class Scene_Attr
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make command window
    s1 = "Hp"
    s2 = "Sp"
    s3 = "Str"
    s4 = "Dex"
    s5 = "Agi"
    s6 = "Int"
    s7 = "close"
    @command_window = Window_Command_Icons.new(200, [s1, s2, s3, s4, s5, s6, s7])
    @command_window.index = 0
    @command_window.height = 260
    @command_window.x = 0
    if $game_variables[3] == 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)
      @command_window.disable_item(5)
    end
    @spriteset = Spriteset_Map.new
    # Make attribute window
    @attr_points = Window_attr_points.new
    @attr_points.x = 0
    @attr_points.y = 260
    # 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
    @attr_points.dispose
    @spriteset.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @command_window.update
    @attr_points.update
    @spriteset.update
    # If command window is active: call update_command
    if Input.trigger?(Input::C)
      @actor = $game_party.actors[1]
      # Branch by command window cursor position
      case @command_window.index
      when 0 # hp
        $game_system.se_play($data_system.decision_se)
        if $game_variables[3] != 0
          @actor.maxhp + 10
        end
      when 1 # sp
        $game_system.se_play($data_system.decision_se)
        if $game_variables[3] != 0
          @actor.maxsp + 10
        end
      when 2 # str
        $game_system.se_play($data_system.decision_se)
        if $game_variables[3] != 0
          @actor.str + 10
        end
      when 3 # dex
        $game_system.se_play($data_system.decision_se)
        if $game_variables[3] != 0
          @actor.dex + 10
        end
      when 4 # agi
        $game_system.se_play($data_system.decision_se)
        if $game_variables[3] != 0
          @actor.agi + 10
        end
      when 5 # int
        $game_system.se_play($data_system.decision_se)
        if $game_variables[3] != 0
          @actor.int + 10
        end
      when 6 # close
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new
      end
      return
    end
  end
end


@Litchi: We're basically a scripting club that help people learn how to script. You can find our main topic over here:

http://www.rpgrevolution.com/forums/index....showtopic=35685


__________________________

To put in sig, copy this link:
CODE
[url="http://www.rpgrevolution.com/forums/index.php?showtopic=51540"][img]http://img40.imageshack.us/img40/6504/conceptthelawbanner.png[/img][/url]


Sig Stuff


"When you first come, no one knows you. When help them out, they all know you. When you leave, they all love you. When you come back, they've already forgotten you." -- copy into your sig if you think this quote speaks true!

If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others. -Exiled One

My Project Thread: Gai's Hunters


Go to the top of the page
 
+Quote Post
   
Amnesiah
post Dec 20 2009, 12:05 PM
Post #28


Level 1
Group Icon

Group: Member
Posts: 11
Type: Mapper
RM Skill: Intermediate




QUOTE (Litchi @ Dec 20 2009, 11:35 AM) *
Are the Script Builders like a little club here?


Something like that,
they help people to learn scripting,
giving advice and solving problems.

To be honest,
they're awesome biggrin.gif
Go to the top of the page
 
+Quote Post
   

2 Pages V  < 1 2
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 25th May 2013 - 02:31 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker