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

[Scripting Question] This Display Type code works, but it can't tell the first type apart from the second. How do I fix this?

429
Posts
4
Years
  • Code:
    if battler.pbHasType?(:GRASS)
          imagePos.push(["Graphics/Pictures/Types/Grass",@spriteBaseX+94,+42])
        end

    This code, when put in the "def refresh" section of PokeBattle_SceneElements, will display the Pokemon's type if it is Grass type.

    I've got code like this for every type. Problem is, it currently only checks for if the Pokemon has the designated type, and not whether it's type 1 or type 2.
    So multi-typed Pokemon get their multiple types overlapping one another.
    I need a way to differentiate Type 1 from Type 2 in this code, so Type 2's image can be displayed next to Type 1's image correctly, rather than overlaying one right on top of the other.

    Code:
    if battler.pbType1?(:GRASS)
          imagePos.push(["Graphics/Pictures/Types/Grass",@spriteBaseX+94,+42])
        end
    if battler.pbType2?(:WATER)
          imagePos.push(["Graphics/Pictures/Types/Water",@spriteBaseX+126,+42])
        end

    Something like could work but I don't know how to code "If Type1=Grass" into Essentials-ese.
     
    429
    Posts
    4
    Years
  • Is there even a function for checking whether a type is Type1 or Type2? Copying things from the Pokemon Status screen that seem to check that don't work.
     
    429
    Posts
    4
    Years
  • Update: This attempt at the code just slaps a Grass type icon onto every Pokemon whether it's Grass type or not.

    Code:
        if battler.type1=:GRASS
          imagePos.push(["Graphics/Pictures/Types/GRASS",@spriteBaseX+94,+42])
        end

    My game is almost done. It is pretty much ready to be released. But a working version of this code should be a part of it, so fans know what Pokemon were changed in what ways and what types the new Pokemon are.
     
    Last edited:
    429
    Posts
    4
    Years
  • Update: I have discovered something in this language through experimentation.

    Code:
    if battler.type1=battler.type2
    if battler.pbHasType?(:GRASS)
          imagePos.push(["Graphics/Pictures/Types/Grass",@spriteBaseX+94,+42])
        end
      end

    Still no way to detect whether a chosen type is type 1 or type 2. It just checks whether a Pokemon is single-typed or not.

    And this just slaps a Grass icon onto everyone no matter what their type is.

    Code:
    if battler.type1=(:GRASS)
          imagePos.push(["Graphics/Pictures/Types/Grass",@spriteBaseX+94,+42])
        end
     
    429
    Posts
    4
    Years
  • Update: This does not work.

    Code:
    if battler.type1=battler.type2
    if battler.pbHasType?(:GRASS)
          imagePos.push(["Graphics/Pictures/Types/Grass",@spriteBaseX+94,+42])
        end
      end 
          if battler.pbHasType?(:GRASS) && battler.pbHasType?(:POISON)
          imagePos.push(["Graphics/Pictures/Types/GrassPoison",@spriteBaseX+94,+42])
        end

    I had assumed the code would let me check for single-types first, and then check if a Pokemon has a certain set of types. Then I could display one larger sprite that combines two Pokemon types together, one after the other. It would be unable to tell Flying/Fighting Pokemon apart from Fighting/Flying Pokemon and display two different sprites for the two different situations, but it would be something. In theory. If only.

    At this point, if the engine really is physically incapable of telling Type1 apart from Type2 in this context, my options are to either have each single Pokemon Type icon show up in a different place depending on the type, so that dual-types will not have their types overlap one another, or to give up on this concept entirely.
     
    1,408
    Posts
    10
    Years
    • Seen today
    You can just look at the dozens of places in the game's code that already do this. Like the Summary and Pokedex, for example.
     
    429
    Posts
    4
    Years
  • I have tried getting the Type1 and Type2 variables used by the Summary and Pokedex. They don't work. They either crash the game when it tries to run, or when a battle starts.

    When I try this:

    Code:
    if battler.pbType1 == :GRASS
          imagePos.push(["Graphics/Pictures/Types/Grass",@spriteBaseX+94,+42])
    end

    I get this:
    Code:
    [Pokémon Essentials version 19.1]
    [Generation 8 Project v1.1.0]
    [v19.1 Hotfixes 1.0.7]
    
    Exception: NoMethodError
    Message: undefined method `pbType1' for #<PokeBattle_Battler>
    
    Backtrace:
    196:PokeBattle_SceneElements:260:in `refresh'
    196:PokeBattle_SceneElements:38:in `initialize'
    199:Scene_Initialize:79:in `new'
    199:Scene_Initialize:79:in `block in pbInitSprites'
    199:Scene_Initialize:77:in `each'
    199:Scene_Initialize:77:in `each_with_index'
    199:Scene_Initialize:77:in `pbInitSprites'
    206:PokeBattle_BugContest:8:in `pbInitSprites'
    199:Scene_Initialize:21:in `pbStartBattle'
    173:Battle_StartAndEnd:270:in `pbStartBattleCore'
     
    Last edited:
    429
    Posts
    4
    Years
  • I could do this.

    Code:
    if battler.pbHasType?(:BUG) && !battler.pbHasType?(:DARK) && !battler.pbHasType?(:DRAGON) && !battler.pbHasType?(:ELECTRIC) && !battler.pbHasType?(:FAIRY) && !battler.pbHasType?(:FIGHTING) && !battler.pbHasType?(:FIRE) && !battler.pbHasType?(:FLYING) && !battler.pbHasType?(:GHOST) && !battler.pbHasType?(:GRASS) && !battler.pbHasType?(:GROUND) && !battler.pbHasType?(:ICE) && !battler.pbHasType?(:POISON) && !battler.pbHasType?(:PSYCHIC) && !battler.pbHasType?(:ROCK) && !battler.pbHasType?(:STEEL) && !battler.pbHasType?(:WATER)
    imagePos.push(["Graphics/Pictures/Types/Bug",@spriteBaseX+92,+42])
    end
    
    if battler.pbHasType?(:WATER) && battler.pbHasType?(:FIRE)
          imagePos.push(["Graphics/Pictures/Types/Water",@spriteBaseX+92,+42])
          imagePos.push(["Graphics/Pictures/Types/FIRE",@spriteBaseX+124,+42])
        end

    I could do one of the above for every single individual type. And every single double type and triple type combination possible. That's what this feature would take if the engine truly has no super secret password command that lets it tell Type1 from Type2 in this part of the code.
     
    429
    Posts
    4
    Years
  • Never mind, this code works.

    Code:
    if battler.type1 == :BUG
    imagePos.push(["Graphics/Pictures/Types/BUG",@spriteBaseX+110,+12])
    end
    if battler.type1 == :DARK
    imagePos.push(["Graphics/Pictures/Types/DARK",@spriteBaseX+110,+12])
    end
    if battler.type1 == :DRAGON
    imagePos.push(["Graphics/Pictures/Types/DRAGON",@spriteBaseX+110,+12])
    end
    if battler.type1 == :ELECTRIC
    imagePos.push(["Graphics/Pictures/Types/ELECTRIC",@spriteBaseX+110,+12])
    end
    if battler.type1 == :FAIRY
    imagePos.push(["Graphics/Pictures/Types/FAIRY",@spriteBaseX+110,+12])
    end
    if battler.type1 == :FIGHTING
    imagePos.push(["Graphics/Pictures/Types/FIGHT",@spriteBaseX+110,+12])
    end
    if battler.type1 == :FIRE
    imagePos.push(["Graphics/Pictures/Types/FIRE",@spriteBaseX+110,+12])
    end
    if battler.type1 == :FLYING
    imagePos.push(["Graphics/Pictures/Types/FLYING",@spriteBaseX+110,+12])
    end
    if battler.type1 == :GHOST
    imagePos.push(["Graphics/Pictures/Types/GHOST",@spriteBaseX+110,+12])
    end
    if battler.type1 == :GRASS
    imagePos.push(["Graphics/Pictures/Types/Grass",@spriteBaseX+110,+12])
    end
    if battler.type1 == :GROUND
    imagePos.push(["Graphics/Pictures/Types/GROUND",@spriteBaseX+110,+12])
    end
    if battler.type1 == :ICE
    imagePos.push(["Graphics/Pictures/Types/ICE",@spriteBaseX+110,+12])
    end
    if battler.type1 == :POISON
    imagePos.push(["Graphics/Pictures/Types/POISON",@spriteBaseX+110,+12])
    end
    if battler.type1 == :PSYCHIC
    imagePos.push(["Graphics/Pictures/Types/PSYCHIC",@spriteBaseX+110,+12])
    end
    if battler.type1 == :ROCK
    imagePos.push(["Graphics/Pictures/Types/ROCK",@spriteBaseX+110,+12])
    end
    if battler.type1 == :STEEL
    imagePos.push(["Graphics/Pictures/Types/STEEL",@spriteBaseX+110,+12])
    end
    if battler.type1 == :WATER
    imagePos.push(["Graphics/Pictures/Types/WATER",@spriteBaseX+110,+12])
    end
    
    if battler.type2 == :BUG && !(battler.type1 == :BUG)
    imagePos.push(["Graphics/Pictures/Types/BUG",@spriteBaseX+110,+26])
    end
    if battler.type2 == :DARK && !(battler.type1 == :DARK)
    imagePos.push(["Graphics/Pictures/Types/DARK",@spriteBaseX+110,+26])
    end
    if battler.type2 == :DRAGON && !(battler.type1 == :DRAGON)
    imagePos.push(["Graphics/Pictures/Types/DRAGON",@spriteBaseX+110,+26])
    end
    if battler.type2 == :ELECTRIC && !(battler.type1 == :ELECTRIC)
    imagePos.push(["Graphics/Pictures/Types/ELECTRIC",@spriteBaseX+110,+26])
    end
    if battler.type2 == :FAIRY && !(battler.type1 == :FAIRY)
    imagePos.push(["Graphics/Pictures/Types/FAIRY",@spriteBaseX+110,+26])
    end
    if battler.type2 == :FIGHTING && !(battler.type1 == :FIGHTING)
    imagePos.push(["Graphics/Pictures/Types/FIGHT",@spriteBaseX+110,+26])
    end
    if battler.type2 == :FIRE && !(battler.type1 == :FIRE)
    imagePos.push(["Graphics/Pictures/Types/FIRE",@spriteBaseX+110,+26])
    end
    if battler.type2 == :FLYING && !(battler.type1 == :FLYING)
    imagePos.push(["Graphics/Pictures/Types/FLYING",@spriteBaseX+110,+26])
    end
    if battler.type2 == :GHOST && !(battler.type1 == :GHOST)
    imagePos.push(["Graphics/Pictures/Types/GHOST",@spriteBaseX+110,+26])
    end
    if battler.type2 == :GRASS && !(battler.type1 == :GRASS)
    imagePos.push(["Graphics/Pictures/Types/Grass",@spriteBaseX+110,+26])
    end
    if battler.type2 == :GROUND && !(battler.type1 == :GROUND)
    imagePos.push(["Graphics/Pictures/Types/GROUND",@spriteBaseX+110,+26])
    end
    if battler.type2 == :ICE && !(battler.type1 == :ICE)
    imagePos.push(["Graphics/Pictures/Types/ICE",@spriteBaseX+110,+26])
    end
    if battler.type2 == :POISON && !(battler.type1 == :POISON)
    imagePos.push(["Graphics/Pictures/Types/POISON",@spriteBaseX+110,+26])
    end
    if battler.type2 == :PSYCHIC && !(battler.type1 == :PSYCHIC)
    imagePos.push(["Graphics/Pictures/Types/PSYCHIC",@spriteBaseX+110,+26])
    end
    if battler.type2 == :ROCK && !(battler.type1 == :ROCK)
    imagePos.push(["Graphics/Pictures/Types/ROCK",@spriteBaseX+110,+26])
    end
    if battler.type2 == :STEEL && !(battler.type1 == :STEEL)
    imagePos.push(["Graphics/Pictures/Types/STEEL",@spriteBaseX+110,+26])
    end
    if battler.type2 == :WATER && !(battler.type1 == :WATER)
    imagePos.push(["Graphics/Pictures/Types/WATER",@spriteBaseX+110,+26])
    end
     
    1,408
    Posts
    10
    Years
    • Seen today
    Again, you can just look at how the Summary and Pokedex handle type displays. They both manage to display type1 and type 2 for every Pokemon without having to literally list out every possible type in the game.
     

    Luka S.J.

    Jealous Croatian
    1,270
    Posts
    15
    Years
  • Spoiler:

    Code:
    imagePos.push(["Graphics/Pictures/Types/#{battler.type1}", @spriteBaseX + 110, 12])
    imagePos.push(["Graphics/Pictures/Types/#{battler.type2}", @spriteBaseX + 110, 26]) if battler.type1 != battler.type2

    Work smart, not hard ;)
     
    Back
    Top