• 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!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • 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

  • 281
    Posts
    16
    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