• 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.

[Question] Getting comfortable typing scripts

277
Posts
15
Years
I am trying to get a better feel for coding so I thought the best way to do so would be trying to script out all of my events instead of using the "event command" buttons, however I am running into a few issues that I haven't been able to figure out and would love feed back on what I am doing wrong.

Code:
def gtChoice
    Kernel.pbMessage(_INTL("Select an option."))
loop do
    command=Kernel.pbShowCommandsWithHelp(nil,
       [_INTL("Show a Picture"),
       _INTL("Give a Magikarp"),
       _INTL("Give a Rare Candy"),
       _INTL("Change Gender"),
       _INTL("Exit")],
       [_INTL("Select an option."),
       _INTL("Select an option."),
       _INTL("Select an option."),
       _INTL("Select an option."),
       _INTL("Select an option.")],-1
    )
    if command==0 # Show a Picture
     viewport=Viewport.new(0,0,512,384)
   sprite=Sprite.new(viewport)
    sprite.bitmap=Bitmap.new("Graphics/Pictures/Test.png")
    break
    elsif command==1 # Give a Magikarp
      pbAddToParty(:MAGIKARP,5)
      break
    elsif command==2 # Give a Rare Candy
      Kernel.pbReceiveItem(:RARECANDY)
      break
    elsif command==3 # Change Gender
      if $Trainer.gender == 0
        pbChangePlayer(1)
        Kernel.pbMessage(_INTL("You are now Female"))
      else
        pbChangePlayer(0)
        Kernel.pbMessage(_INTL("You are now Male"))
        end
      break
    elsif command==4 # Exit
      break
    end
    break
    end
  end

in short, I am trying to show text and give choices.

The show image code is the one I am having the most problem with, it shows the image but doesn't exit the loop leaving me unable to move, and when I try to show the image outside of a loop the image disappears on its own after a few seconds, and while its up the player can walk around, open their menu and all of the other normal functions.

Give Magikarp works fine and so does giving the Rare Candy

Change gender works, but if I remove the message "You are now *gender*" it wont break the loop and I can not move.

Exit and just pressing "B" to close the choice box without preforming an action will also leave me stuck in the loop, despite having the break command.


I am not asking for you to just give me the answer, but rather if anyone here could help me understand why this isn't working as I expected.

Thank you :t192:
 
Last edited:
Back
Top