[RMXP] HELP WITH 'SCOPE' FOR NIL:NILCLASS

Posts

Pages: 1
Hey! First post on here and first time making a game in RPG Maker. I'm using XP, making a game for my senior project, and when I try to do a test battle against troops, when I use the 'Attack' command, I will very often get an error that is as follows:

Script 'Game_BattleAction' line 62: NoMethodError occurred.

undefined metho 'scope' for nil:NilClass

I have no idea how to fix this. My line 62 code in the Game_BattleAction section is as follows:

.include?($data_skills.scope)
return true
end

Can somebody please help me out? Thanks if you do!
author=kyatonipu
Hey! First post on here and first time making a game in RPG Maker. I'm using XP, making a game for my senior project, and when I try to do a test battle against troops, when I use the 'Attack' command, I will very often get an error that is as follows:

Script 'Game_BattleAction' line 62: NoMethodError occurred.

undefined metho 'scope' for nil:NilClass

I have no idea how to fix this. My line 62 code in the Game_BattleAction section is as follows:

if @kind == 1 and [5].include?($data_skills[@skill_id].scope)
  return true
end


Can somebody please help me out? Thanks if you do!



This is because the $data_skills at index @skill_id doesn't exist. nil / NilClass is basically the "does not exist" value in ruby. For some reason the game is looking up a skill from the $data_skills array but not finding anything, hence a nil object, then trying to get the scope of the nil object which causes an exception.

My first guess would be you created a skill, gave it to an enemy, then deleted the skill by changing the size of the skill database. I don't know why it's doing that on a regular attack action though. I'm not familiar with RMXP to help out much more though, and it might be a script you added to your game that has a bug that's causing this too.
author=GreatRedSpirit
author=kyatonipu
Hey! First post on here and first time making a game in RPG Maker. I'm using XP, making a game for my senior project, and when I try to do a test battle against troops, when I use the 'Attack' command, I will very often get an error that is as follows:

Script 'Game_BattleAction' line 62: NoMethodError occurred.

undefined metho 'scope' for nil:NilClass

I have no idea how to fix this. My line 62 code in the Game_BattleAction section is as follows:

if @kind == 1 and [5].include?($data_skills[@skill_id].scope)
  return true
end


Can somebody please help me out? Thanks if you do!
This is because the $data_skills at index @skill_id doesn't exist. nil / NilClass is basically the "does not exist" value in ruby. For some reason the game is looking up a skill from the $data_skills array but not finding anything, hence a nil object, then trying to get the scope of the nil object which causes an exception.

My first guess would be you created a skill, gave it to an enemy, then deleted the skill by changing the size of the skill database. I don't know why it's doing that on a regular attack action though. I'm not familiar with RMXP to help out much more though, and it might be a script you added to your game that has a bug that's causing this too.


I looked into it and turns out the enemy 'zombie' troop had a skill they were supposed to have that didn't exist. Thanks!
Glad to hear you found and fixed the problem! :)
Pages: 1