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

[Error] What does this mean?

163
Posts
5
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'
 
1,680
Posts
8
Years
  • Age 24
  • Seen yesterday
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.
 
163
Posts
5
Years
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?
 
1,805
Posts
7
Years
  • Age 30
  • USA
  • Seen Jan 15, 2024
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:
163
Posts
5
Years
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?
 
1,805
Posts
7
Years
  • Age 30
  • USA
  • Seen Jan 15, 2024
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"?
 

Poq

144
Posts
6
Years
  • Age 34
  • Seen Aug 28, 2021
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:
1,403
Posts
10
Years
  • Seen Apr 18, 2024
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:
1,805
Posts
7
Years
  • Age 30
  • USA
  • Seen Jan 15, 2024
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?
 
1,403
Posts
10
Years
  • Seen Apr 18, 2024
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.
 
163
Posts
5
Years
Will this work?
Spoiler:
 

WolfPP

Spriter/ Pixel Artist
1,309
Posts
5
Years
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:
163
Posts
5
Years
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