script 'skill learn by element' line 80: no method error occured undefined method '[]' for nil:class

glyth

Villager
Member
Joined
Mar 31, 2012
Messages
17
Reaction score
0
First Language
english
Primarily Uses
script 'skill learn by element' line 80: no method error occured undefined method '[]' for nil:class

 


Code:
=begin
Learn Skills by Element use
by Fomar0153
Version 1.1
----------------------
Notes
----------------------
No requirements
Allows you to learn new skills by using skills of the same element.
----------------------
Instructions
----------------------
You will need to edit module Fomar, further instructions
are located there.
----------------------
Change Log
----------------------
1.0 -> 1.1 Fixed a bug that could cause crashing.
----------------------
Known bugs
----------------------
None
=end
module Fomar

  ELEMENTS = []
  # Add/Edit lines like the ones below
  ELEMENTS[1] = {}
  ELEMENTS[2] = {}
  ELEMENTS[3] = {}
  ELEMENTS[4] = {}
  ELEMENTS[5] = {}
  ELEMENTS[6] = {}
  ELEMENTS[7] = {}
  ELEMENTS[8] = {}
  ELEMENTS[9] = {}
  ELEMENTS[10] = {}
  ELEMENTS[11] = {}
  ELEMENTS[12] = {}
  # ELEMENTS[id][uses] = [NEW_SKILL_ID, NEW_SKILL_ID...]
  ELEMENTS[3][50]  = [52]
  ELEMENTS[3][75]  = [53]
  ELEMENTS[3][100] = [54]
  ELEMENTS[11][10] = [27]
  ELEMENTS[11][15] = [28]
  ELEMENTS[11][20] = [29]
  ELEMENTS[11][25] = [30]
  ELEMENTS[11][30] = [31]
  ELEMENTS[11][35] = [32]
  ELEMENTS[11][40] = [33]
  ELEMENTS[11][100] = [34]
  ELEMENTS[4][25] = [56]
  ELEMENTS[4][50] = [57]
  ELEMENTS[4][100] = [58]
  ELEMENTS[4][100] = [63]
  ELEMENTS[5][25] = [60]
  ELEMENTS[5][50] = [61]
  ELEMENTS[5][100] = [62]
  ELEMENTS[6][100] = [64]
  ELEMENTS[5][100] = [65]
  ELEMENTS[7][100] = [66]
  ELEMENTS[11][100] = [67]
  ELEMENTS[8][100] = [68]
  end

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● Aliases setup
  #--------------------------------------------------------------------------
  alias seu_setup setup
  def setup(actor_id)
    seu_setup(actor_id)
    @element_uses = []
  end
  #--------------------------------------------------------------------------
  # ● New Method add_element_use
  #--------------------------------------------------------------------------
  def add_element_use(id)
    return if id == -1
    if @element_uses[id].nil?
      @element_uses[id] = 0
    end
    @element_uses[id] += 1
    return if Fomar::ELEMENTS[id].nil?
    unless Fomar::ELEMENTS[id][@element_uses[id]].nil?
      for skill in Fomar::ELEMENTS[id][@element_uses[id]]
        learn_skill(skill)
        $game_message.add(@name + ' learns ' + $data_skills[skill].name)
      end
    end
  end
end

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # ● Aliases item_apply
  #--------------------------------------------------------------------------
  alias seu_item_apply item_apply
  def item_apply(user, item)
    seu_item_apply(user, item)
    if user.is_a?(Game_Actor) and item.is_a?(RPG::Skill)
      user.add_element_use(item.damage.element_id)
    end
  end
end
 

so what am i doing wrong with Fomar0153's script?

any help please
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Please enclose your code in code tags so it's more readable, and all of that within spoiler tags for a long script. In this case, better to actually link to the original script.


Which line is line 80?


I bet you've added the script, then loaded a save file that was made before the script was added. Start a new game.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
are you trying it out on a saved game? if yes, try it out on a new game...


this is line 80: if @element_uses[id].nil?


so it seems like @element_uses wasn't set-up, which is what happens if you tested this out on a saved game
 
Last edited by a moderator:

glyth

Villager
Member
Joined
Mar 31, 2012
Messages
17
Reaction score
0
First Language
english
Primarily Uses
are you trying it out on a saved game? if yes, try it out on a new game...

this is line 80: if @element_uses[id].nil?

so it seems like @element_uses wasn't set-up, which is what happens if you tested this out on a saved game
ty you, il try new game
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,019
Members
137,564
Latest member
McFinnaPants
Top