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

[Error] What does this mean?

  • 163
    Posts
    6
    Years
    [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'
     
    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.
     
    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?
     
    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.
     
    Last edited:
    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:

    That it?
     
    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"?
     
    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 
    }
    })
     
    Last edited:
    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.


    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.
     
    Last edited:
    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?
     
    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.
     
    Will this work?
    Spoiler:
     
    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.
     
    Last edited:
    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!
     
    Back
    Top