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

[Custom Feature Question] Berry Tree From Galar... Help!

#Not Important

All hail the wishmaker
  • 910
    Posts
    5
    Years
    So, I am creating a script for a Berry Tree From Galar
    It is this (It doesn't work yet) :
    Code:
    ################################################################################
    #                                                                              #
    #                       Berry Tree From Galar Script                           #
    #                            By #Not Imortant                                  #
    #                          For Essentials v17.2                                #
    #                                 v 1.0.0                                      #
    #                                                                              #
    ################################################################################
    =begin
    USAGE:
     Call with pbBerry tree
     Remember to credit me!
    =end
    #Cherubi is added by default
    #Change this to "true" give encounters for:
    #Skwovet and Greedent
    #Set to "false" if you don't have the Gen 8 PBS files
    GEN8ENCOUNTERS = true 
    #In turn, switch this to the opposite of that
    NOGEN8ENCOUNTERS = false
    =begin
    Set this to true to add:
    
    Bellsprout
    Pidgey
    Spearow
    Applin (But only with Gen 8)
    Burmy (But no Gen 8 only)
    
    To the encounters available from tree-shaking
    =end
    REMADEENCOUNTERS = false
    #Same here as before
    REGULARENCOUNTERS = true
    #If you don't want new encounters or Gen 8, you'll be left with Cherubi ...
    #DONT TOUCH
    DONTTOUCH = true
    ################################################################################
    #                       Here I define the Script                               #
    ################################################################################
    def pbshake
      if DONTTOUCH
        if DONTTOUCH
          result=rand(10)
          if result = 1
            Kernel.pbReceiveItem(berry,PBItems,:ORANBERRY) #Gives oran berry
            Kernel.pbMessage("There are berries on the ground, keep shaking?")
            loop do
              command=Kernel.pbShowCommands(nil,[
              _INTL("Yes"),
              _INTL("No")
              ],command)
              case command
              when 0
              when 1
                break
              end
          end
          if result = 2
            Kernel.pbReceiveItem(berry,PBItems,:ORANBERRY,2) #Gives two oran berries
            Kernel.pbMessage("There are berries on the ground, keep shaking?")
            loop do
              command=Kernel.pbShowCommands(nil,[
              _INTL("Yes"),
              _INTL("No")
              ],command)
              case command
              when 0
              when 1
                break
              end
            end
          end
          if result = 3
            Kernel.pbReceiveItem(berry,PBItems,:ORANBERRY,3) #You get it now
            Kernel.pbMessage("There are berries on the ground, keep shaking?")
            loop do
              command=Kernel.pbShowCommands(nil,[
              _INTL("Yes"),
              _INTL("No")
              ],command)
              case command
              when 0
              when 1
                break
              end
            end
          end
          if result = 4
            Kernel.pbReceiveItem(berry,PBItems,:PECHABERRY) #Same but with pecha berries
            Kernel.pbMessage("There are berries on the ground, keep shaking?")
            loop do
              command=Kernel.pbShowCommands(nil,[
              _INTL("Yes"),
              _INTL("No")
              ],command)
              case command
              when 0
              when 1
                break
              end
            end  
          end
          if result = 5
            Kernel.pbReceiveItem(berry,PBItems,:PECHABERRY,2) #...
            Kernel.pbMessage("There are berries on the ground, keep shaking?")
            loop do
              command=Kernel.pbShowCommands(nil,[
              _INTL("Yes"),
              _INTL("No")
              ],command)
              case command
              when 0
              when 1
                break
              end
            end  
          end
          if result = 6
            Kernel.pbReceiveItem(berry,PBItems,:PECHABERRY,3)
            Kernel.pbMessage("There are berries on the ground, keep shaking?")
            loop do
              command=Kernel.pbShowCommands(nil,[
              _INTL("Yes"),
              _INTL("No")
              ],command)
              case command
              when 0
              when 1
                break
              end
            end  
          end
          if result = 7
            Kernel.pbReceiveItem(berry,PBItems,:CHERIBERRY)
            Kernel.pbMessage("There are berries on the ground, keep shaking?")
            loop do
              command=Kernel.pbShowCommands(nil,[
              _INTL("Yes"),
              _INTL("No")
              ],command)
              case command
              when 0
              when 1
                break
              end
            end  
          end
          if result = 8
            Kernel.pbReceiveItem(berry,PBItems,:CHERIBERRY,2)
            Kernel.pbMessage("There are berries on the ground, keep shaking?")
            loop do
              command=Kernel.pbShowCommands(nil,[
              _INTL("Yes"),
              _INTL("No")
              ],command)
              case command
              when 0
              when 1
                break
              end
            end
          end
          if result = 9
            Kernel.pbReceiveItem(berry,PBItems,:CHERIBERRY,3)
            Kernel.pbMessage("There are berries on the ground, keep shaking?")
            loop do
              command=Kernel.pbShowCommands(nil,[
              _INTL("Yes"),
              _INTL("No")
              ],command)
              case command
              when 0
              when 1
                break
              end
            end
          end
          if result = 10 #Encounters 1/10 of the time
            if GEN8ENCOUNTERS #Gives encounters if remade & gen 8 are on
              if REMADEENCOUNTERS
                encounter=rand(7) #I mean you could also randomize the levels
                if encounter = 1      #But I think it could lag the game
                  pbWildBattle(CHERUBI,7,1)
                end
                if encounter = 2
                  pbWildBattle(SKWOVET,7,1)
                end
                if encounter = 3
                  pbWildBattle(GREEDUNT,7,1)
                end
                if encounter = 4
                  pbWildBattle(BELLSPROUT,7,1)
                end
                if encounter = 5
                  pbWildBattle(PIDGEY,7,1)
                end
                if encounter = 6
                  pbWildBattle(SPEAROW,7,1)
                end
                if encounter = 7
                  pbWildBattle(APPLIN,7,1)
                end
              end
            end
            if GEN8ENCOUNTERS && REGULARENCOUNTERS #Gives the regular encounters for Galar
              encounter=rand(3)
              if encounter = 1      #I created my username because what you put a 
                pbWildBattle(CHERUBI,7,1)#hashtag in front of is
              end                    #Not Important in Ruby   
              if encounter = 2
                pbWildBattle(SKWOVET,7,1)
              end
              if encounter = 3
                pbWildBattle(GREEDUNT,7,1)
              end
            end
            if NOGEN8ENCOUNTERS && REMADEENCOUNTERS
              encounter=rand(5)
              if encounter = 1
                pbWildBattle(CHERUBI,7,1)
              end
              if encounter = 2
                pbWildBattle(BELLSPROUT,7,1)
              end
              if encounter = 3
                pbWildBattle(PIDGEY,7,1)
              end
              if encounter = 4
                pbWildBattle(SPEAROW,7,1)
              end
              if encounter = 5
                pbWildBattle(BURMY,7,1)
              end
            end
            else
              pbWildBattle(CHERUBI,7,1)
            end
            Kernel.pbMessage("Other pokemon took the berries left on the tree away...")
          end
        end
      end
    end
    def pbTreeOfBerries
      for i in 0...16
        if i = 1
          pbshake
        end
        if i = 2
          pbshake
        end
        if i = 3
          pbshake
        end
        if i = 4
          pbshake
        end
        if i = 5
          pbshake
        end
        if i = 6
          pbshake
        end
        if i = 7
          pbshake
        end
        if i = 8
          pbshake
        end
        if i = 9
          pbshake
        end
        if i = 10
          pbshake
        end
        if i = 11
          pbshake
        end
        if i = 12
          pbshake
        end
        if i = 13
          pbshake
        end
        if i = 14
          pbshake
        end
        if i = 15
          pbshake
        end
      end
    end
    And it gives this error:
    Code:
    ---------------------------
    Pokemon Meteor
    ---------------------------
    Script 'Berrytree' line 46: NameError occurred.
    
    undefined local variable or method `berry' for nil:NilClass
    ---------------------------
    OK   
    ---------------------------
    If I remove the 'berry' part of giving the items it gives this error:
    Code:
    ---------------------------
    Pokemon Metal Might
    ---------------------------
    Script 'PField_Field' line 1406: TypeError occurred.
    
    compared with non class/module
    ---------------------------
    OK   
    ---------------------------
    Which is:
    Code:
      return false if !item || item<=0 || quantity<1
      itemname = (quantity>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
      pocket = pbGetPocket(item)
      if isConst?(item,PBItems,:LEFTOVERS)
        Kernel.pbMessage(_INTL("\\me[Item get]You obtained some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
      elsif pbIsMachine?(item)   # TM or HM
        Kernel.pbMessage(_INTL("\\me[Item get]You obtained \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(pbGetMachine(item))))
      elsif quantity>1
        Kernel.pbMessage(_INTL("\\me[Item get]You obtained {1} \\c[1]{2}\\c[0]!\\wtnp[30]",quantity,itemname))
      elsif ['a','e','i','o','u'].include?(itemname[0,1].downcase)
        Kernel.pbMessage(_INTL("\\me[Item get]You obtained an \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
      else
        Kernel.pbMessage(_INTL("\\me[Item get]You obtained a \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
      end
      if $PokemonBag.pbStoreItem(item,quantity)   # If item can be added
        Kernel.pbMessage(_INTL("You put the {1} away\\nin the <icon=bagPocket{2}>\\c[1]{3} Pocket\\c[0].",
           itemname,pocket,PokemonBag.pocketNames()[pocket]))
        return true
      end
      return false   # Can't add the item
    end
    Pls help
     
    Kernel.pbItemBall(:BERRYNAME)

    I don't have access to a PC to test this, but you can replace the problematic item script with this. And as a plus point, when you use this, it will say "(PLAYER) has found a (BERRYNAME)" instead of "(PLAYER) has received a (BERRYNAME)" . Great script btw. Hope you post it as a resource soon.
     
    :(
    Code:
    ---------------------------
    Pokemon Metal Might
    ---------------------------
    Script 'Berrytree' line 46: NoMethodError occurred.
    
    undefined method `pbReceiveItemBall' for Kernel:Module
    ---------------------------
    OK   
    ---------------------------
     
    I believe I have fixed the first error but now there is another:
    Code:
    ---------------------------
    Pokemon Metal Might
    ---------------------------
    Script 'PItem_Items' line 16: NoMethodError occurred.
    
    undefined method `[]' for nil:NilClass
    ---------------------------
    OK   
    ---------------------------
     
    :(
    Code:
    ---------------------------
    Pokemon Metal Might
    ---------------------------
    Script 'Berrytree' line 46: NoMethodError occurred.
    
    undefined method `pbReceiveItemBall' for Kernel:Module
    ---------------------------
    OK   
    ---------------------------

    Its Kernel.pbItemBall not Kernel.pbReceiveItemBall.
     
    Back
    Top