Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've been working on a game for awhile and I am developing it with RPG Maker VX. I came to a point where I needed to... I guess for lack of better explanation... Limit the key items to just 1. So I started looking through my scripts and found (in Game_Party):

  #--------------------------------------------------------------------------
  # * Get Maximum Number of Items Possessed
  #--------------------------------------------------------------------------
  def max_item_number(item)
    return 99
  end

and added below it:

  #--------------------------------------------------------------------------
  # * Get Maximum Number of Key Items Possessed
  #--------------------------------------------------------------------------
  def max_key_item_number(item)
    return 1
  end

and right below that is:

  #--------------------------------------------------------------------------
  # * Determine if Maximum Number of Items Are Possessed
  #--------------------------------------------------------------------------
  def item_max?(item)
    item_number(item) >= max_item_number(item)
  end

So I changed the last one too:

  #--------------------------------------------------------------------------
  # * Determine if Maximum Number of Items Are Possessed
  #--------------------------------------------------------------------------
  def item_max?(item)
    if key_item? == true
      item_number(item) >= max_key_item_number(item)
    end

    if key_item? == false
      item_number(item) >= max_item_number(item)
    end
  end

Now this seemed to not affect anything (that I could tell). I tested it and its still the same as before I touched anything. I am new to developing games and relatively new to scripting for them. Is this approach even close to what I want to do? Any help is greatly apprecieated!

share|improve this question
    
You'll probably have more luck over at the official RPG Maker forums. –  Vaughan Hilts Oct 10 '12 at 5:56
add comment

1 Answer

This is the correct way to do it. Figured it out after playing around for about 2 hours lol.

  #--------------------------------------------------------------------------
  # * Determine if Maximum Number of Items Are Possessed
  #--------------------------------------------------------------------------
  def item_max?(item)
    if item.key_item?
      item_number(item) >= max_key_item_number(item)
    else
      item_number(item) >= max_item_number(item)
    end
  end
share|improve this answer
    
Mark your answer as correct when you get the chance. :) –  Jonathan Hobbs Nov 9 '12 at 7:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.