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

Variable doesn't seem to be updating

  • 6
    Posts
    8
    Years
    • Seen Jul 2, 2019
    I'm a programmer who hasn't really fiddled around with Ruby before starting some Pokemon Essentials stuff as a fun side-project. But I'm having issues making the Trainer Card screen behave quite how I want.

    def pbStartScene
    @drawText=false
    #Do some stuff that takes some time, and all the other trainer card stuff
    @drawText = true
    def pbDrawTrainerCardFront
    #Do stuff as normal until...
    if @drawText==true
    pbDrawTextPositions(overlay,textPositions)
    end

    Rather than making it so that after the StartScene does its thing, the text shows up, the text just straight up doesn't appear at all. I seem to be seeing the same issue with other types of variable, such as float and int, where they simply don't update when I try to modify them, but stay at the value they were first set at. This goes for different operators, too, such as "+=".

    I figure you've got to do something different to update a variable in Ruby, but I can't seem to figure it out. Issues like this are always bound to crop up when you first start a new language, I suppose.
     
    You don't have to do anything special to change variables in Ruby. I can't tell from your snippets, but it's more about however your logic works.

    I'm not even sure why you're doing what you are here, pbDrawTrainerCardFront isn't even called until the end of pbStartScene, you can do whatever processes you need before the call.

    Also, you don't need to say
    Code:
     if @drawText==true
    you can just say
    Code:
    if @drawText
     
    "pbDrawTrainerCardFront isn't even called until the end of pbStartScene"

    Ahh, that'd do it. I made the adjustment to my script real quick to call it whenever it needs to update, and that seemed to do the trick. For some reason, I assumed pbDrawTrainerCardFront was called as part of the update routine.

    Kind of a hacky way to do things, but I'm still a noob at this and it works well enough. Thanks for the info. This is solved.
     
    Back
    Top