Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Ploblem of item "NOTE", I've create Window_Note that I cannot add string to this block
mazixzero
post Jan 24 2009, 11:41 PM
Post #1


Level 1
Group Icon

Group: Member
Posts: 5
Type: Developer
RM Skill: Beginner




Hey guys. I've this ploblem to create Window_Note that window of description note in RMVX. I've create string in item note and i want to show it in Window_Note but it's not does work!. Why can i add string of ItemNote to this block



this's script that I write it (so badly)

this Window_Note
CODE
#==============================================================================
# ** Window_Note
#==============================================================================

class Window_Note < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(272, 56, 272, 360)
  end
  #--------------------------------------------------------------------------
  # * Set Text
  #  text  : character string displayed in window
  #  align : alignment (0..flush left, 1..center, 2..flush right)
  #--------------------------------------------------------------------------
  def note_text(text, align = 5)
    if text != @text or align != @align
      self.contents.clear
      self.contents.font.color = system_color
      self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
      @text = text
      @align = align
    end
  end
end


And this my Scene_Item
CODE
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
#  This class performs the item screen processing.
#==============================================================================

class Scene_Item < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    @viewport = Viewport.new(0, 0, 544, 416)
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
    @item_window = Window_Item.new(0, 56, 272, 360)
    @item_window.viewport = @viewport
    @note_window = Window_Note.new
    @note_window.viewport = @viewport
    @item_window.help_window = @help_window
    @item_window.note_window = @note_window
    @item_window.active = false
    @target_window = Window_MenuStatus.new(0, 0)
    hide_target_window
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @viewport.dispose
    @help_window.dispose
    @item_window.dispose
    @note_window.dispose
    @target_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Return to Original Screen
  #--------------------------------------------------------------------------
  def return_scene
    $scene = Scene_Menu.new(0)
  end
  #--------------------------------------------------------------------------
  # * Update Frame
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @help_window.update
    @item_window.update
    @note_window.update
    @target_window.update
    if @item_window.active
      update_item_selection
      update_note
    elsif @target_window.active
      update_target_selection
    end
  end
  
  def update_note
    last_item_id = @item.id
    @note_window.note_text($data_items[last_item_id].note)
  end
  #--------------------------------------------------------------------------
  # * Update Item Selection
  #--------------------------------------------------------------------------
  def update_item_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::C)
      @item = @item_window.item
      if @item != nil
        $game_party.last_item_id = @item.id
      end
      if $game_party.item_can_use?(@item)
        Sound.play_decision
        determine_item
      else
        Sound.play_buzzer
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Confirm Item
  #--------------------------------------------------------------------------
  def determine_item
    if @item.for_friend?
      show_target_window(@item_window.index % 2 == 0)
      if @item.for_all?
        @target_window.index = 99
      else
        if $game_party.last_target_index < @target_window.item_max
          @target_window.index = $game_party.last_target_index
        else
          @target_window.index = 0
        end
      end
    else
      use_item_nontarget
    end
  end
  #--------------------------------------------------------------------------
  # * Update Target Selection
  #--------------------------------------------------------------------------
  def update_target_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      if $game_party.item_number(@item) == 0    # If item is used up
        @item_window.refresh                    # Recreate the window contents
      end
      hide_target_window
    elsif Input.trigger?(Input::C)
      if not $game_party.item_can_use?(@item)
        Sound.play_buzzer
      else
        determine_target
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Confirm Target
  #    If there is no effect (such as using a potion on an incapacitated
  #    character), play a buzzer SE.
  #--------------------------------------------------------------------------
  def determine_target
    used = false
    if @item.for_all?
      for target in $game_party.members
        target.item_effect(target, @item)
        used = true unless target.skipped
      end
    else
      $game_party.last_target_index = @target_window.index
      target = $game_party.members[@target_window.index]
      target.item_effect(target, @item)
      used = true unless target.skipped
    end
    if used
      use_item_nontarget
    else
      Sound.play_buzzer
    end
  end
  #--------------------------------------------------------------------------
  # * Show Target Window
  #     right : Right justification flag (if false, left justification)
  #--------------------------------------------------------------------------
  def show_target_window(right)
    @item_window.active = false
    width_remain = 544 - @target_window.width
    @target_window.x = right ? width_remain : 0
    @target_window.visible = true
    @target_window.active = true
    if right
      @viewport.rect.set(0, 0, width_remain, 416)
      @viewport.ox = 0
    else
      @viewport.rect.set(@target_window.width, 0, width_remain, 416)
      @viewport.ox = @target_window.width
    end
  end
  #--------------------------------------------------------------------------
  # * Hide Target Window
  #--------------------------------------------------------------------------
  def hide_target_window
    @item_window.active = true
    @target_window.visible = false
    @target_window.active = false
    @viewport.rect.set(0, 0, 544, 416)
    @viewport.ox = 0
  end
  #--------------------------------------------------------------------------
  # * Use Item (apply effects to non-ally targets)
  #--------------------------------------------------------------------------
  def use_item_nontarget
    Sound.play_use_item
    $game_party.consume_item(@item)
    @item_window.draw_item(@item_window.index)
    @target_window.refresh
    if $game_party.all_dead?
      $scene = Scene_Gameover.new
    elsif @item.common_event_id > 0
      $game_temp.common_event_id = @item.common_event_id
      $scene = Scene_Map.new
    end
  end
end


Window_Selectable
CODE
#==============================================================================
# ** Window_Selectable
#------------------------------------------------------------------------------
#  This window contains cursor movement and scroll functions.
#==============================================================================

class Window_Selectable < Window_Base
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :item_max                 # item count
  attr_reader   :column_max               # digit count
  attr_reader   :index                    # cursor position
  attr_reader   :help_window              # help window
  attr_reader   :note_window              # note window
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x       : window X coordinate
  #     y       : window Y coordinate
  #     width   : window width
  #     height  : window height
  #     spacing : width of empty space when items are arranged horizontally
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height, spacing = 32)
    @item_max = 1
    @column_max = 1
    @index = -1
    @spacing = spacing
    super(x, y, width, height)
  end
  #--------------------------------------------------------------------------
  # * Create Window Contents
  #--------------------------------------------------------------------------
  def create_contents
    self.contents.dispose
    self.contents = Bitmap.new(width - 32, [height - 32, row_max * WLH].max)
  end
  #--------------------------------------------------------------------------
  # * Set Cursor Position
  #     index : new cursor position
  #--------------------------------------------------------------------------
  def index=(index)
    @index = index
    update_cursor
    call_update_help
    call_update_note
  end
  #--------------------------------------------------------------------------
  # * Get Row Count
  #--------------------------------------------------------------------------
  def row_max
    return (@item_max + @column_max - 1) / @column_max
  end
  #--------------------------------------------------------------------------
  # * Get Top Row
  #--------------------------------------------------------------------------
  def top_row
    return self.oy / WLH
  end
  #--------------------------------------------------------------------------
  # * Set Top Row
  #     row : row shown on top
  #--------------------------------------------------------------------------
  def top_row=(row)
    row = 0 if row < 0
    row = row_max - 1 if row > row_max - 1
    self.oy = row * WLH
  end
  #--------------------------------------------------------------------------
  # * Get Number of Rows Displayable on 1 Page
  #--------------------------------------------------------------------------
  def page_row_max
    return (self.height - 32) / WLH
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items Displayable on 1 Page
  #--------------------------------------------------------------------------
  def page_item_max
    return page_row_max * @column_max
  end
  #--------------------------------------------------------------------------
  # * Get bottom row
  #--------------------------------------------------------------------------
  def bottom_row
    return top_row + page_row_max - 1
  end
  #--------------------------------------------------------------------------
  # * Set bottom row
  #     row : Row displayed at the bottom
  #--------------------------------------------------------------------------
  def bottom_row=(row)
    self.top_row = row - (page_row_max - 1)
  end
  #--------------------------------------------------------------------------
  # * Get rectangle for displaying items
  #     index : item number
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new(0, 0, 0, 0)
    rect.width = (contents.width + @spacing) / @column_max - @spacing
    rect.height = WLH
    rect.x = index % @column_max * (rect.width + @spacing)
    rect.y = index / @column_max * WLH
    return rect
  end
  #--------------------------------------------------------------------------
  # * Set Help Window
  #     help_window : new help window
  #--------------------------------------------------------------------------
  def help_window=(help_window)
    @help_window = help_window
    call_update_help
  end
  def note_window=(note_window)
    @note_window = note_window
    call_update_note
  end
  #--------------------------------------------------------------------------
  # * Determine if cursor is moveable
  #--------------------------------------------------------------------------
  def cursor_movable?
    return false if (not visible or not active)
    return false if (index < 0 or index > @item_max or @item_max == 0)
    return false if (@opening or @closing)
    return true
  end
  #--------------------------------------------------------------------------
  # * Move cursor down
  #     wrap : Wraparound allowed
  #--------------------------------------------------------------------------
  def cursor_down(wrap = false)
    if (@index < @item_max - @column_max) or (wrap and @column_max == 1)
      @index = (@index + @column_max) % @item_max
    end
  end
  #--------------------------------------------------------------------------
  # * Move cursor up
  #     wrap : Wraparound allowed
  #--------------------------------------------------------------------------
  def cursor_up(wrap = false)
    if (@index >= @column_max) or (wrap and @column_max == 1)
      @index = (@index - @column_max + @item_max) % @item_max
    end
  end
  #--------------------------------------------------------------------------
  # * Move cursor right
  #     wrap : Wraparound allowed
  #--------------------------------------------------------------------------
  def cursor_right(wrap = false)
    if (@column_max >= 2) and
       (@index < @item_max - 1 or (wrap and page_row_max == 1))
      @index = (@index + 1) % @item_max
    end
  end
  #--------------------------------------------------------------------------
  # * Move cursor left
  #     wrap : Wraparound allowed
  #--------------------------------------------------------------------------
  def cursor_left(wrap = false)
    if (@column_max >= 2) and
       (@index > 0 or (wrap and page_row_max == 1))
      @index = (@index - 1 + @item_max) % @item_max
    end
  end
  #--------------------------------------------------------------------------
  # * Move cursor one page down
  #--------------------------------------------------------------------------
  def cursor_pagedown
    if top_row + page_row_max < row_max
      @index = [@index + page_item_max, @item_max - 1].min
      self.top_row += page_row_max
    end
  end
  #--------------------------------------------------------------------------
  # * Move cursor one page up
  #--------------------------------------------------------------------------
  def cursor_pageup
    if top_row > 0
      @index = [@index - page_item_max, 0].max
      self.top_row -= page_row_max
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if cursor_movable?
      last_index = @index
      if Input.repeat?(Input::DOWN)
        cursor_down(Input.trigger?(Input::DOWN))
      end
      if Input.repeat?(Input::UP)
        cursor_up(Input.trigger?(Input::UP))
      end
      if Input.repeat?(Input::RIGHT)
        cursor_right(Input.trigger?(Input::RIGHT))
      end
      if Input.repeat?(Input::LEFT)
        cursor_left(Input.trigger?(Input::LEFT))
      end
      if Input.repeat?(Input::R)
        cursor_pagedown
      end
      if Input.repeat?(Input::L)
        cursor_pageup
      end
      if @index != last_index
        Sound.play_cursor
      end
    end
    update_cursor
    call_update_help
  end
  #--------------------------------------------------------------------------
  # * Update cursor
  #--------------------------------------------------------------------------
  def update_cursor
    if @index < 0                   # If the cursor position is less than 0
      self.cursor_rect.empty        # Empty cursor
    else                            # If the cursor position is 0 or more
      row = @index / @column_max    # Get current row
      if row < top_row              # If before the currently displayed
        self.top_row = row          # Scroll up
      end
      if row > bottom_row           # If after the currently displayed
        self.bottom_row = row       # Scroll down
      end
      rect = item_rect(@index)      # Get rectangle of selected item
      rect.y -= self.oy             # Match rectangle to scroll position
      self.cursor_rect = rect       # Refresh cursor rectangle
    end
  end
  #--------------------------------------------------------------------------
  # * Call help window update method
  #--------------------------------------------------------------------------
  def call_update_help
    if self.active and @help_window != nil
       update_help
    end
  end
  def call_update_note
    if self.active and @note_window != nil
       update_note
    end
  end
  #--------------------------------------------------------------------------
  # * Update help window (contents are defined by the subclasses)
  #--------------------------------------------------------------------------
  def update_help
  end
  def update_note
  end
end


OH! If you have any script that's like this script or more COOL! this script. please reply in this topic. Thank you!!

P.S.(I bad English. I'm sorry for write badly. = =')

This post has been edited by mazixzero: Jan 24 2009, 11:44 PM
Go to the top of the page
 
+Quote Post
   
SojaBird
post Jan 25 2009, 02:39 AM
Post #2


Level 51
Group Icon

Group: Revolutionary
Posts: 1,573
Type: Scripter
RM Skill: Advanced




Hey hey,

Use the next code:
CODE
def update_help
    @note_window.note_text(item == nil ? "" : item.note)
  end

Instead of yours:
CODE
def update_note
    last_item_id = @item.id
    @note_window.note_text($data_items[last_item_id].note)
  end


Greatzz,
SojaBird.


__________________________
Art from the highest shelf?

Scriptology, scripting podcast



HUD's Request Lobby (multiple hud-scripts)


------------------------------------------------------------------

Random Stuff
OMG, it's Hab!!


This is a crazy drawing application! (by me)

How did I learned to script
QUOTE
Hey pim! I'm the Law G14!

For the past couple of months I've been learning RGSS and I've got the basic stuff down such windows, variables, conditional statements, ect. But, I can't see myself making big scripts such as a jumping system or a side view battle system. I was wondering how you learned to script because I really want to know how to script really well.

Thanks in advance.


Hey there,

Well I don't make battle neither though I can still teach you some things :)...
The way I've learned to script is by reading other scripts for the most part.
I've allways been interested in other peoples work but this time I though I had to try to make something myself...and it worked!!
The most importand thing when you go scripting is (at least in my case) that you want to make something to help an other wich can't script.
You also need to feel the competition that's around in the scripting-community.
Cause, I have to say, if you get pushed to get a sertain request done before an other scripter does, you feel POWERFULL!! :P
So that's an other thing...
You also don't need to be afraid to learn from others or helpfiles.
When I write my scripts, I actualy always have the helpfiles open to look things up I don't know or remember.
Then, you must be calm, cause you need to try the script a lot of times.
When I write a script, I test it after almost every changes.
First I set up the major structure.
Like when I make a window-script or part of a script I start with something like this:
CODE
class Window_Name < Window_Base
def initialize(x,y,width,height)
super(x,y,width,height)
refresh
end

def refresh
self.contents.clear
draw_contents
end

def draw_contents
draw_something(with, some, parameters)
end

def update
refresh if @something != @what_it_should_be
end
end
So that's also very important.
Then, the biggest thing I learned scripting from is TRIAL AND ERROR.
That's the most irritating way to learn something, cause it's more ERROR than TRIAL, but it does the trick realy good.

So that's it how I did it.
Now it's up to you.
Do some requests (if I didn't do it allready :P) and learn from them.

Hope that helped you out a little.
If not, keep your eye on the Scriptology-topic (see my sig) where I'll be updating for my scripting(video)tutorials.
Perhaps they're going to be usefull for you one day ;)


Greatzz,
SojaBird.
Go to the top of the page
 
+Quote Post
   
mazixzero
post Jan 25 2009, 11:47 PM
Post #3


Level 1
Group Icon

Group: Member
Posts: 5
Type: Developer
RM Skill: Beginner




I've try this. it's doesn't work. sweat.gif
Go to the top of the page
 
+Quote Post
   
SojaBird
post Jan 26 2009, 01:04 AM
Post #4


Level 51
Group Icon

Group: Revolutionary
Posts: 1,573
Type: Scripter
RM Skill: Advanced




First of all I advise you to use the alias function so the script can work with others wich more ease.
Also, you didn't change the window_item class...there you'll set the def update_note thing. You don't seem to have it.


Greatzz,
SojaBird.


__________________________
Art from the highest shelf?

Scriptology, scripting podcast



HUD's Request Lobby (multiple hud-scripts)


------------------------------------------------------------------

Random Stuff
OMG, it's Hab!!


This is a crazy drawing application! (by me)

How did I learned to script
QUOTE
Hey pim! I'm the Law G14!

For the past couple of months I've been learning RGSS and I've got the basic stuff down such windows, variables, conditional statements, ect. But, I can't see myself making big scripts such as a jumping system or a side view battle system. I was wondering how you learned to script because I really want to know how to script really well.

Thanks in advance.


Hey there,

Well I don't make battle neither though I can still teach you some things :)...
The way I've learned to script is by reading other scripts for the most part.
I've allways been interested in other peoples work but this time I though I had to try to make something myself...and it worked!!
The most importand thing when you go scripting is (at least in my case) that you want to make something to help an other wich can't script.
You also need to feel the competition that's around in the scripting-community.
Cause, I have to say, if you get pushed to get a sertain request done before an other scripter does, you feel POWERFULL!! :P
So that's an other thing...
You also don't need to be afraid to learn from others or helpfiles.
When I write my scripts, I actualy always have the helpfiles open to look things up I don't know or remember.
Then, you must be calm, cause you need to try the script a lot of times.
When I write a script, I test it after almost every changes.
First I set up the major structure.
Like when I make a window-script or part of a script I start with something like this:
CODE
class Window_Name < Window_Base
def initialize(x,y,width,height)
super(x,y,width,height)
refresh
end

def refresh
self.contents.clear
draw_contents
end

def draw_contents
draw_something(with, some, parameters)
end

def update
refresh if @something != @what_it_should_be
end
end
So that's also very important.
Then, the biggest thing I learned scripting from is TRIAL AND ERROR.
That's the most irritating way to learn something, cause it's more ERROR than TRIAL, but it does the trick realy good.

So that's it how I did it.
Now it's up to you.
Do some requests (if I didn't do it allready :P) and learn from them.

Hope that helped you out a little.
If not, keep your eye on the Scriptology-topic (see my sig) where I'll be updating for my scripting(video)tutorials.
Perhaps they're going to be usefull for you one day ;)


Greatzz,
SojaBird.
Go to the top of the page
 
+Quote Post
   

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 - 09:54 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker