RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Using conditional branches to check for x amount of an item?

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 81
Using RMVX
Is there a way to do it(ex. needing 5 potions instead of 1)?
I tried doing control variable and setting it equal to an item and then c. branch the variable to be >= 5 but I get a game interpreter error.
« Last Edit: April 01, 2011, 01:16:48 AM by Ecut »
Spoiler for "My Project":
Project topic:


Project blog:

Spoiler for "I Support":


***
Rep:
Level 82
IT ALL ENDED.
Quote
I tried doing control variable and setting it equal to an item and then c. branch the variable to be >= 5 but I get a game interpreter error.
That's not supposed to happen. It should work fine unless you did something else or used a script somewhere- Could you give more details?

*
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Control Variable: [Variable] = 0
label: Item-check
Conditional Branch: if [ITEM] is in Inventory
  Control Variable: [Variable] =+ 1
  Remove item: [ITEM] - 1
  Conditional Branch: if [ITEM] is in Inventory
    Jump to Label: Item-check
  Branch end
Branch end
Conditional Branch: if Variable [Variable] >= 5
  Stuff you want to happen.
Branch end
it's like a metaphor or something i don't know

**
Rep:
Level 81
Control Variable: [Variable] = 0
label: Item-check
Conditional Branch: if [ITEM] is in Inventory
  Control Variable: [Variable] =+ 1
  Remove item: [ITEM] - 1
  Conditional Branch: if [ITEM] is in Inventory
    Jump to Label: Item-check
  Branch end
Branch end
Conditional Branch: if Variable [Variable] >= 5
  Stuff you want to happen.
Branch end
Thanks so much! It works.
However, the npc takes however many ITEM you have; you only need to collect 5 of ITEM but if you talk to the npc with < 5 she takes ITEM anyway and if you talk to her with >= 5 she takes all of them. Do you know how to fix that? I usually have no trouble with events and such but this is the first time I've tried this . :P
Spoiler for "My Project":
Project topic:


Project blog:

Spoiler for "I Support":


*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
You should just get the Game Interpreter fix. RMVX was released with an error when it came to operating variables.
Add the following in its own slot just below Materials but above any other custom scripts you might have.

Code: [Select]
class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Control Variables
  #--------------------------------------------------------------------------
  def command_122
    value = 0
    case @params[3]  # Operand
    when 0  # Constant
      value = @params[4]
    when 1  # Variable
      value = $game_variables[@params[4]]
    when 2  # Random
      value = @params[4] + rand(@params[5] - @params[4] + 1)
    when 3  # Item
      value = $game_party.item_number($data_items[@params[4]])
    when 4  # Actor
      actor = $game_actors[@params[4]]
      if actor != nil
        case @params[5]
        when 0  # Level
          value = actor.level
        when 1  # Experience
          value = actor.exp
        when 2  # HP
          value = actor.hp
        when 3  # MP
          value = actor.mp
        when 4  # Maximum HP
          value = actor.maxhp
        when 5  # Maximum MP
          value = actor.maxmp
        when 6  # Attack
          value = actor.atk
        when 7  # Defense
          value = actor.def
        when 8  # Spirit
          value = actor.spi
        when 9  # Agility
          value = actor.agi
        end
      end
    when 5  # Enemy
      enemy = $game_troop.members[@params[4]]
      if enemy != nil
        case @params[5]
        when 0  # HP
          value = enemy.hp
        when 1  # MP
          value = enemy.mp
        when 2  # Maximum HP
          value = enemy.maxhp
        when 3  # Maximum MP
          value = enemy.maxmp
        when 4  # Attack
          value = enemy.atk
        when 5  # Defense
          value = enemy.def
        when 6  # Spirit
          value = enemy.spi
        when 7  # Agility
          value = enemy.agi
        end
      end
    when 6  # Character
      character = get_character(@params[4])
      if character != nil
        case @params[5]
        when 0  # x-coordinate
          value = character.x
        when 1  # y-coordinate
          value = character.y
        when 2  # direction
          value = character.direction
        when 3  # screen x-coordinate
          value = character.screen_x
        when 4  # screen y-coordinate
          value = character.screen_y
        end
      end
    when 7  # Other
      case @params[4]
      when 0  # map ID
        value = $game_map.map_id
      when 1  # number of party members
        value = $game_party.members.size
      when 2  # gold
        value = $game_party.gold
      when 3  # steps
        value = $game_party.steps
      when 4  # play time
        value = Graphics.frame_count / Graphics.frame_rate
      when 5  # timer
        value = $game_system.timer / Graphics.frame_rate
      when 6  # save count
        value = $game_system.save_count
      end
    end
    for i in @params[0] .. @params[1]   # Batch control
      case @params[2]  # Operation
      when 0  # Set
        $game_variables[i] = value
      when 1  # Add
        $game_variables[i] += value
      when 2  # Sub
        $game_variables[i] -= value
      when 3  # Mul
        $game_variables[i] *= value
      when 4  # Div
        $game_variables[i] /= value if value != 0
      when 5  # Mod
        $game_variables[i] %= value if value != 0
      end
      if $game_variables[i] > 99999999    # Maximum limit check
        $game_variables[i] = 99999999
      end
      if $game_variables[i] < -99999999   # Minimum limit check
        $game_variables[i] = -99999999
      end
    end
    $game_map.need_refresh = true
    return true
  end
end

Once you do that, you will be able to use the Control Variable event to get exactly how many of the item you have.

**
Rep:
Level 81
Thanks yet again Modern Algebra! :)
It works perfectly!!
Spoiler for "My Project":
Project topic:


Project blog:

Spoiler for "I Support":


*
Rep: +0/-0Level 70
RMRK Junior
Try this out
   1. Go grab the Game_Interpreter Fix script in text file
   2. Create a new game. Go into the script editor (on the toolbar, it looks like a pencil and paper). On the left-hand side you will see Game_Interpreter in the list of scripts. Click it to bring it up.
   3. In another window, open the file you downloaded. Choose Edit > Select all and Edit > Copy to select the whole 1660 lines in notepad. Then select the 1660 lines of text the script editor (CTRL+A works well). Then paste. Save your game.
   4. Open the folder with the project (one you just created and added a script into), and find this: Scripts.rvdata in the Data folder
   5. Copy Scripts.rvdata
   6. Go to the RPGVX\Systems\Data
   7. Paste Scripts.rvdata in here. It'll ask you if it should be overwritten. Say yes.

all copyright of this tutorial goes to rpgmakervx.net(didnt know if i had to say that or not better safe than sorry ;_;)

*
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
...He already solved it.
Over half a month ago.
it's like a metaphor or something i don't know