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

Variable doesn't seem to be updating

6
Posts
7
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.
     
    1,224
    Posts
    10
    Years
  • 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
     
    6
    Posts
    7
    Years
    • Seen Jul 2, 2019
    "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