Pokémon Essentials All questions and discussion about Pokémon Essentials, the Pokémon game kit for RPG Maker XP, go in here. Also contains links to the latest downloads and the Essentials Wiki.

Ad Content
Reply
 
Thread Tools
  #1   Link to this post, but load the entire thread.  
Old 5 Days Ago (5:59 PM).
clawort's Avatar
clawort clawort is offline
     
    Join Date: Mar 2019
    Location: Australia
    Gender: Male
    Posts: 20
    [Pokémon Essentials version 17.2]
    Exception: NoMethodError
    Message: undefined method `<' for nil:NilClass
    Pokemon_Forms:483
    Pokemon_Forms:482:in `call'
    Pokemon_Forms:95:in `call'
    Pokemon_Forms:7:in `form'
    Pokemon_Forms:28:in `fSpecies'
    PokeBattle_Pokemon:850:in `baseStats'
    PokeBattle_Pokemon:886:in `calcStats'
    PokeBattle_Pokemon:967:in `__mf_initialize'
    Pokemon_Forms:43:in `initialize'
    PSystem_PokemonUtilities:79:in `new'
    Reply With Quote
      #2   Link to this post, but load the entire thread.  
    Old 4 Days Ago (8:11 AM).
    Vendily's Avatar
    Vendily Vendily is online now
     
    Join Date: Aug 2015
    Gender: Female
    Nature: Calm
    Posts: 841
    Given the fact that line 483 does not exist in a clean v17.2 project, It appears that you have added some new code, probably a new form.
    The error itself is saying you tried to check if nil is less than a number or variable but you should really post the code if you want more help than that.
    __________________

    Reply With Quote
      #3   Link to this post, but load the entire thread.  
    Old 4 Days Ago (6:26 PM).
    clawort's Avatar
    clawort clawort is offline
       
      Join Date: Mar 2019
      Location: Australia
      Gender: Male
      Posts: 20
      Quote:
      Originally Posted by Vendily View Post
      Given the fact that line 483 does not exist in a clean v17.2 project, It appears that you have added some new code, probably a new form.
      The error itself is saying you tried to check if nil is less than a number or variable but you should really post the code if you want more help than that.
      Yeah! But what do I do?
      Reply With Quote
        #4   Link to this post, but load the entire thread.  
      Old 4 Days Ago (6:29 PM).
      Poq's Avatar
      Poq Poq is online now
         
        Join Date: Aug 2017
        Posts: 119
        Quote:
        Originally Posted by clawort View Post
        Yeah! But what do I do?
        Quote:
        Originally Posted by Vendily View Post
        ... you should really post the code if you want more help than that.
        Copy the script that the error indicates and paste it in the thread.
        Reply With Quote
          #5   Link to this post, but load the entire thread.  
        Old 4 Days Ago (6:31 PM). Edited 4 Days Ago by clawort.
        clawort's Avatar
        clawort clawort is offline
           
          Join Date: Mar 2019
          Location: Australia
          Gender: Male
          Posts: 20
          Quote:
          Originally Posted by Poq View Post
          Copy the script that the error indicates and paste it in the thread.
          What script?! Help!
          Reply With Quote
            #6   Link to this post, but load the entire thread.  
          Old 4 Days Ago (7:05 PM). Edited 4 Days Ago by juliorain.
          juliorain's Avatar
          juliorain juliorain is offline
           
          Join Date: Aug 2016
          Location: USA
          Gender: Male
          Nature: Quirky
          Posts: 693
          Spoiler:


          this is the script editor. Each item on the left menu pulls of up a script that does something with the code. in the right half is where the code's text editor is. those little numbers in gray mean which line of the code youre on. You can copy, paste, the text into the code editor into any program that reads text like here.
          __________________
          Reply With Quote
            #7   Link to this post, but load the entire thread.  
          Old 4 Days Ago (7:20 PM).
          clawort's Avatar
          clawort clawort is offline
             
            Join Date: Mar 2019
            Location: Australia
            Gender: Male
            Posts: 20
            Quote:
            Originally Posted by juliorain View Post
            Spoiler:


            this is the script editor. Each item on the left menu pulls of up a script that does something with the code. in the right half is where the code's text editor is. those little numbers in gray mean which line of the code youre on. You can copy, paste, the text into the code editor into any program that reads text like here.
            Okay!
            Spoiler:
            MultipleForms.register(:EMOMOTH,{
            "getForm"=>proc{|pokemon|
            next 2 if pokemon.happiness<1
            next 1 if pokemon.happiness>254
            next 0
            }
            })

            That it?
            Reply With Quote
              #8   Link to this post, but load the entire thread.  
            Old 4 Days Ago (7:38 PM).
            juliorain's Avatar
            juliorain juliorain is offline
             
            Join Date: Aug 2016
            Location: USA
            Gender: Male
            Nature: Quirky
            Posts: 693
            that does appear to be the problem code, and ruby doesn't like "<" for some reason, which is the correct operator. does it return an error if you replace "<1" with "==0" and ">254" with "==255"?
            __________________
            Reply With Quote
              #9   Link to this post, but load the entire thread.  
            Old 3 Days Ago (11:30 AM). Edited 3 Days Ago by Poq.
            Poq's Avatar
            Poq Poq is online now
               
              Join Date: Aug 2017
              Posts: 119
              The problem seems to be that you are calling this method on a pokémon who's happiness has not yet been initialized and is thus nil. The < operator doesn't work for nil. Try changing your code to this:
              Code:
              MultipleForms.register(:EMOMOTH,{
              "getForm"=>proc{|pokemon|
              next 2 if !pokemon.happiness >=1
              next 1 if pokemon.happiness>254
              next 0 
              }
              })
              Reply With Quote
                #10   Link to this post, but load the entire thread.  
              Old 3 Days Ago (12:45 PM). Edited 3 Days Ago by mgriffin.
              mgriffin's Avatar
              mgriffin mgriffin is online now
               
              Join Date: Apr 2014
              Posts: 335
              Quote:
              Originally Posted by Poq View Post
              The problem seems to be that you are calling this method on a pokémon who's happiness has not yet been initialized and is thus nil. The < operator doesn't work for nil. Try changing your code to this:
              Code:
              MultipleForms.register(:EMOMOTH,{
              "getForm"=>proc{|pokemon|
              next 2 if !pokemon.happiness >=1
              next 1 if pokemon.happiness>254
              next 0 
              }
              })
              Hmm, doesn't that cause a "true has no >= operator" error, because !nil is true, and true can't be compared with numbers?

              I think you'd be better off with something like:
              Code:
              MultipleForms.register(:EMOMOTH,{
              "getForm"=>proc{|pokemon|
              next 0 if pokemon.happiness.nil?
              next 2 if pokemon.happiness<1
              next 1 if pokemon.happiness>254
              next 0 
              }
              })
              Or maybe that first next should be next 2? Not sure under what circumstances a Pokémon's happiness can be nil, and therefore what form is most appropriate.



              Quote:
              Originally Posted by juliorain View Post
              that does appear to be the problem code, and ruby doesn't like "<" for some reason, which is the correct operator. does it return an error if you replace "<1" with "==0" and ">254" with "==255"?
              Just to answer this question, you can compare nil with anything, so it will work fine, assuming that happiness cannot be less than 0 or more than 255 (which sounds right).
              I think this solution is cleaner than Poq's/my suggestion involving nil?, but YMMV.
              Reply With Quote
                #11   Link to this post, but load the entire thread.  
              Old 3 Days Ago (1:15 PM).
              juliorain's Avatar
              juliorain juliorain is offline
               
              Join Date: Aug 2016
              Location: USA
              Gender: Male
              Nature: Quirky
              Posts: 693
              Quote:
              Originally Posted by mgriffin View Post
              Hmm, doesn't that cause a "true has no >= operator" error, because !nil is true, and true can't be compared with numbers?

              I think you'd be better off with something like:
              Code:
              MultipleForms.register(:EMOMOTH,{
              "getForm"=>proc{|pokemon|
              next 0 if pokemon.happiness.nil?
              next 2 if pokemon.happiness<1
              next 1 if pokemon.happiness>254
              next 0 
              }
              })
              Or maybe that first next should be next 2? Not sure under what circumstances a Pokémon's happiness can be nil, and therefore what form is most appropriate.




              Just to answer this question, you can compare nil with anything, so it will work fine, assuming that happiness cannot be less than 0 or more than 255 (which sounds right).
              I think this solution is cleaner than Poq's/my suggestion involving nil?, but YMMV.
              perhaps they hould add a rescue their base happiness defined in the PBS?
              __________________
              Reply With Quote
                #12   Link to this post, but load the entire thread.  
              Old 3 Days Ago (7:49 PM).
              clawort's Avatar
              clawort clawort is offline
                 
                Join Date: Mar 2019
                Location: Australia
                Gender: Male
                Posts: 20
                Quote:
                Originally Posted by juliorain View Post
                that does appear to be the problem code, and ruby doesn't like "<" for some reason, which is the correct operator. does it return an error if you replace "<1" with "==0" and ">254" with "==255"?
                Idk but I might try...
                Reply With Quote
                  #13   Link to this post, but load the entire thread.  
                Old 3 Days Ago (12:05 AM).
                mgriffin's Avatar
                mgriffin mgriffin is online now
                 
                Join Date: Apr 2014
                Posts: 335
                Quote:
                Originally Posted by juliorain View Post
                perhaps they hould add a rescue their base happiness defined in the PBS?
                That sounds like a good idea. Although ideally you'd want to work out why it's nil before you do that, because I'd expect that happiness should always be initialized to the base happiness instead of nil.
                Reply With Quote
                  #14   Link to this post, but load the entire thread.  
                Old 2 Days Ago (3:15 PM).
                clawort's Avatar
                clawort clawort is offline
                   
                  Join Date: Mar 2019
                  Location: Australia
                  Gender: Male
                  Posts: 20
                  Will this work?
                  Spoiler:
                  MultipleForms.register(:EMOMOTH,{
                  "getForm"=>proc{|pokemon|
                  next 2 if pokemon.happiness<=1 #Sad Form
                  next 1 if pokemon.happiness>=254 #Happy Form
                  next 0 #Neutral Form
                  }
                  })
                  Reply With Quote
                    #15   Link to this post, but load the entire thread.  
                  Old 2 Days Ago (3:56 PM). Edited 2 Days Ago by WolfPP.
                  WolfPP's Avatar
                  WolfPP WolfPP is online now
                  Discord: Wolf#1235
                     
                    Join Date: Aug 2018
                    Location: Brazil
                    Gender: Male
                    Nature: Jolly
                    Posts: 423
                    Maybe he needs to add:

                    Code:
                    attr_accessor(:happiness)
                    Inside '_Forms' script. Like:
                    Code:
                    class PokeBattle_Pokemon
                      attr_accessor(:formTime)   # Time when Furfrou's/Hoopa's form was set
                      attr_accessor(:forcedForm)
                      attr_accessor(:happiness)
                    Because the code that i sent to him is correct, i guess lol. It was the same than i made to Lycanroc.
                    Reply With Quote
                      #16   Link to this post, but load the entire thread.  
                    Old 2 Days Ago (4:09 PM).
                    clawort's Avatar
                    clawort clawort is offline
                       
                      Join Date: Mar 2019
                      Location: Australia
                      Gender: Male
                      Posts: 20
                      Quote:
                      Originally Posted by WolfPP View Post
                      Maybe he needs to add:

                      Code:
                      attr_accessor(:happiness)
                      Inside '_Forms' script. Like:
                      Code:
                      class PokeBattle_Pokemon
                        attr_accessor(:formTime)   # Time when Furfrou's/Hoopa's form was set
                        attr_accessor(:forcedForm)
                        attr_accessor(:happiness)
                      Because the code that i sent to him is correct, i guess lol. It was the same than i made to Lycanroc.
                      Okay!
                      Reply With Quote
                        #17   Link to this post, but load the entire thread.  
                      Old 1 Day Ago (8:25 PM).
                      clawort's Avatar
                      clawort clawort is offline
                         
                        Join Date: Mar 2019
                        Location: Australia
                        Gender: Male
                        Posts: 20
                        Peeps! I fixed it! I did juliorain's method by using == instead of <!
                        Reply With Quote
                        Reply

                        Quick Reply

                        Join the conversation!

                        Create an account to post a reply in this thread, participate in other discussions, and more!

                        Create a PokéCommunity Account
                        Ad Content
                        Thread Tools

                        Posting Rules
                        You may not post new threads
                        You may not post replies
                        You may not post attachments
                        You may not edit your posts

                        BB code is On
                        Smilies are On
                        [IMG] code is On
                        HTML code is Off

                        Forum Jump


                        All times are GMT -8. The time now is 5:57 AM.