• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Script to remove item from the bag not working!

Status
Not open for further replies.
  • 7
    Posts
    9
    Years
    • Seen Sep 22, 2015
    I'm trying to remove an item from my bag using
    "Conditional Branch:
    Script:
    $PokemonBag.pbDeleteItem(:POTION)"
    And it keeps crashing my game.
    If you know the solution to this problem please let me know!
     
    Are you certain you have a Potion in your bag? You should find a way to check that (see the wiki for this).

    Why do you put the script in a Conditional Branch anyway? Try adding it as a simple script (last page, last button) instead.
     
    I do but even if I didn't the Wiki says that it should just return to FALSE instead of giving me the error.
    And I had no idea that option existed haha so thank you for that.
     
    This is the error I keep getting.
    It seems like me defining the item as "POTION" is throwing it off which makes no sense to me?
    ---------------------------
    Pokemon Essentials
    ---------------------------
    Exception: RuntimeError
    Message: Script error within event 6, map 2 (Lappet Town):
    Exception: NameError
    Message: (eval):1:in `pbExecuteScript'uninitialized constant Interpreter:POTION
    ***Full script:
    $PokemonBag.pbDeleteItem(POTION)

    Interpreter:243:in `pbExecuteScript'
    Interpreter:1600:in `eval'
    Interpreter:243:in `pbExecuteScript'
    Interpreter:1600:in `command_355'
    Interpreter:494:in `execute_command'
    Interpreter:193:in `update'
    Interpreter:106:in `loop'
    Interpreter:198:in `update'
    Scene_Map:103:in `update'
    Scene_Map:101:in `loop'


    Interpreter:276:in `pbExecuteScript'
    Interpreter:1600:in `command_355'
    Interpreter:494:in `execute_command'
    Interpreter:193:in `update'
    Interpreter:106:in `loop'
    Interpreter:198:in `update'
    Scene_Map:103:in `update'
    Scene_Map:101:in `loop'
    Scene_Map:114:in `update'
    Scene_Map:68:in `main'
     
    Last edited:
    No luck my friend.
    I've checked the editor and the internal name is definitely "POTION"
    I just don't understand it.
    It's not working with any item.
     
    Oh! I just retried your suggestions and "$PokemonBag.pbDeleteItem(PBItems::POTION) " works!!
    I must have accidently left out the period after "Bag" haha
    Thank you very much.
     
    No, your error was that you didn't include the colon before POTION. In the scripts, all internal names of things must be preceded by a colon. A colon denotes a symbol rather than a variable - your error occurred because the variable POTION was not defined yet you were using it.

    For this particular method, you could have used either :POTION or PBItems::POTION - it's been coded to work that way. The former saves a little space, but it may be harder to ensure that colon is there.
     
    Last edited:
    Status
    Not open for further replies.
    Back
    Top