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

A few scripting questions

ShadowFiendZX

Gym Leader
  • 59
    Posts
    12
    Years
    I've got a few questions about scripting, I'm not very comfortable with Ruby yet, so if there are simple answers, please forgive my ignorance.

    First off, I made an item that can be used that has a few functions. When used, a text box pops up and you get a choice. After some searching, I got the text box to have my windowskin, but I also want the choice box to use the windowskin as well, how would I do this? As a sidenote, this is all done in a new script section that is separate from everything.

    Here's how the dialogue is shown,
    Code:
    commands=[_INTL("Download information"),_INTL("View storage"),_INTL("Go online"),_INTL("View Daycare"),_INTL("Nothing")]
    
        choice=Kernel.pbMessage(_INTL("\\w[iiddskin]What do you want to do?"),commands)
    I want the whole thing to have the windowskin that's on the bottom of the screen. Obviously putting the \\w[iiddskin] in the command part did nothing.

    [PokeCommunity.com] A few scripting questions


    My second question is, when I use "pbDownloadToString" it takes multiple tries to have a successful download, I'm not sure if it's the code or just my computer, although my friends also had the issue. Does anybody know of a way to fix this, or if it's just a given?

    My third "question" is I decided I wanted the trainer card to have a back, so what I did was I made a new script section with a modified copy of the original trainer card script, the original trainer card script now has a bit of code that says:
    Code:
      def pbTrainerCard
        loop do
          Graphics.update
          Input.update
          self.update
          if Input.trigger?(Input::C)
         scene=PokemonTrainerCardBackScene.new
               screen=PokemonTrainerCardBack.new(scene)
               pbFadeOutIn(99999) { 
                  screen.pbStartScreen
                 @scene.pbRefresh
               }
    
         
             elsif Input.trigger?(Input::B)
              pbEndScene
              break
              end
        end 
      end

    and the trainer card back has a bit of code that says

    Code:
    if Input.trigger?(Input::C)
    
         
    break
          elsif Input.trigger?(Input::B)
    break
          end
        end 
      end
    Basically, what I want to happen is, when you press C on the front, the back shows, when you press C or X on the back, it returns to the front, and when you press X on the front, it goes back to the pause menu. What actually happens is, The back shows fine, and goes back to the front fine, but pressing X while viewing the front of the card after viewing the back at least once will unpause the game, but leave the trainer card in the view, you can walk and interact, and text will overlay the trainer card, after spamming X for a few seconds, the trainer card disappears. Can somebody tell me how to fix that?
     
    Last edited:
    For the trainer card thing, you must end the scene with one of 2, @scene.pbEndScene or just pbEndScene.
     
    I did, for the X key anyway, if I do it for the C key part it reloads the front of the trainer card instead of showing the back. This is quite strange.
     
    On the third question: I screwed around a little to see if I could get something like what you describe working which I managed. The code snippet you provided is almost correct. Just remove the call to @screen.pbRefresh and it should run as expected. (I've highlighted the line to remove below: )

    Code:
     def pbTrainerCard
      loop do
        Graphics.update
        Input.update
        self.update
        if Input.trigger?(Input::C)
         scene=PokemonTrainerCardBackScene.new
         screen=PokemonTrainerCardBack.new(scene)
         pbFadeOutIn(99999) { 
           screen.pbStartScreen
           [COLOR="Red"][S]@scene.pbRefresh[/S][/COLOR]
         }
        elsif Input.trigger?(Input::B)
          pbEndScene
          break
        end
      end 
    end

    I suspect what was happening was the game was getting (silently) hung up on the call to a non-existent method and preventing the loop from running correctly.

    I suppose I'll mention: it might be useful running the game with the $INTERNAL flag (and maybe the $DEBUG flag, too) set to true. The game will be less silent about these kinds of errors when it's on. (It'll also keep a log of errors under /Data/debuglog.txt which is always really handy.)
     
    On the third question: I screwed around a little to see if I could get something like what you describe working which I managed. The code snippet you provided is almost correct. Just remove the call to @screen.pbRefresh and it should run as expected. (I've highlighted the line to remove below: )

    Code:
     def pbTrainerCard
      loop do
        Graphics.update
        Input.update
        self.update
        if Input.trigger?(Input::C)
         scene=PokemonTrainerCardBackScene.new
         screen=PokemonTrainerCardBack.new(scene)
         pbFadeOutIn(99999) { 
           screen.pbStartScreen
           [COLOR="Red"][S]@scene.pbRefresh[/S][/COLOR]
         }
        elsif Input.trigger?(Input::B)
          pbEndScene
          break
        end
      end 
    end

    I suspect what was happening was the game was getting (silently) hung up on the call to a non-existent method and preventing the loop from running correctly.

    I suppose I'll mention: it might be useful running the game with the $INTERNAL flag (and maybe the $DEBUG flag, too) set to true. The game will be less silent about these kinds of errors when it's on. (It'll also keep a log of errors under /Data/debuglog.txt which is always really handy.)

    Oh my goodness! Thank you! It worked! I'll try that $internal flag, and continue to learn how to code in Ruby. Thanks for the help :)
     
    Back
    Top