• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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.

[Eventing Question] Shopkeep that can change pokeballs of pokemon?

4
Posts
4
Years
    • Seen Nov 19, 2022
    Hey so I'm trying to make a shopkeep that can change the Poke Ball one of your pokemon is stored in. I've tried cannabalizing/looking through the script for the debug mode function but I just have no idea what pieces to use?

    This is what I've come up with so far:

    Shopkeep that can change pokeballs of pokemon?
     
    153
    Posts
    5
    Years
    • Seen Feb 4, 2020
    paste the definition of your function pbBallTypeToBall

    Edit: oh actually it's a intern function

    Code:
    def pbBallTypeToBall(balltype)
      if $BallTypes[balltype]
        ret=getID(PBItems,$BallTypes[balltype])
        return ret if ret!=0
      end
      if $BallTypes[0]
        ret=getID(PBItems,$BallTypes[0])
        return ret if ret!=0
      end
      return getID(PBItems,:POKEBALL)
    end
     
    Last edited:
    153
    Posts
    5
    Years
    • Seen Feb 4, 2020
    The first problem in your event is that your two script lines are separated so there is no way a variable is kept from one to the other. you need to keep the value of the variable. you could try something like this
    Code:
    value=pbChooseBallList
    pbBallTypeToBall(value)
    in a single script command

    I guess the choose pokemon should also be in the same script
     
    Last edited:
    4
    Posts
    4
    Years
    • Seen Nov 19, 2022
    uh, all right i did that

    Shopkeep that can change pokeballs of pokemon?


    and i suppose i could leave the other code too? this is how it shows up in the original script

    Code:
        when "setpokeball"
          commands = []; balls = []
          for key in $BallTypes.keys
            item = getID(PBItems,$BallTypes[key])
            balls.push([key.to_i,PBItems.getName(item)]) if item && item>0
          end
          balls.sort! {|a,b| a[1]<=>b[1]}
          cmd = 0
          for i in 0...balls.length
            if balls[i][0]==pkmn.ballused
              cmd = i; break
            end
          end
          for i in balls
            commands.push(i[1])
          end
          loop do
            oldball = PBItems.getName(pbBallTypeToBall(pkmn.ballused))
            cmd = @scene.pbShowCommands(_INTL("{1} used.",oldball),commands,cmd)
            break if cmd<0
            pkmn.ballused = balls[cmd][0]
          end
        #=========

    not really sure how to call it; pretty sure it isn't an issue with THIS code since it works fine when invoked via debug menu
     
    Last edited:
    153
    Posts
    5
    Years
    • Seen Feb 4, 2020
    I can't check the script now, but I checked the picture of your event and you also need a link between the chosen poke and the pokeball that needs to be changed. I dont know which arguments the method is taking but it could look like this:

    Code:
    poke=pbChooseNonEggPokemon(1,2)
    newballtogive=pbChooseBallList
    poke.ballused=newballtogive

    I'am not sure pbBallTypeToBall(newballtogive) is actually necessary you have to check with what kind of arguments are needed but in general to transfer values from a function to another in a non confusing way the best is to use variables. And it's also nice to give them obvious names so everyone understands what they are used for.

    I found this mother.ballused in the daycare script and mother refers as a pokemon so this might work
     
    Last edited:
    4
    Posts
    4
    Years
    • Seen Nov 19, 2022
    that code seems really solid but causes the game to crash?

    it gives me a NoMethodError which kind of confuses me - it works perfectly fine when i invoke it from the debug menu
     
    Back
    Top