I am trying to setup some data using a for loop, but I keep getting this error:
Here is the script:
Can someone help me? I really appreciate it if someone can. Peace out!
~Broken
Script 'Game_NPC' line 80: NoMetodError occurred.
undefined method `each' for 2:Fixnum
Here is the script:
Code:
class Scene_Title
def command_new_game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Stop BGM
Audio.bgm_stop
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
$game_npc = Game_NPC.new #NEW LINE HERE*************************
# Set up initial party
$game_party.setup_starting_members
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
end
end
class NPC_Database
#NPC_COUNT = 2
def initialize
#item# = [five item ids]
item1 = [1, 1, 1, 2, 3]
#clothes# = [shield, helmit, body_armour, accessory]
clothes1 = [1, 10, 22, 32]
#var = [0last_name, 1middle_name, 2first_name, 3age, 4sex, 5marriage, 6disp, 7bounty, 8lvl, 9items, 10clothes, 11weapon]
n1 = ["Testons", "Testing", "Testy", 14, 1, [false, ], 50, 0, 16, item1, clothes1, 1]
n2 = ["Killer", "The", "Im", 17, 0, 0, 1000, 23, [1, 1, 1, 2, 3], [1, 10, 22, 32], 1]
@npcs = [n1, n2]
end
end
class Game_NPC < NPC_Database
attr_accessor :id
attr_accessor :surname
attr_accessor :middle
attr_accessor :name
attr_accessor :age #Used in same-sex marriages (Checked for oldest)
attr_accessor :sex #gender
attr_accessor :marriage
attr_accessor :disp #Explained later
attr_accessor :bounty #Explained later
attr_accessor :lvl #used in same-sex marriages and battles (Checked for highest)
attr_accessor :hp #used in battle
attr_accessor :items #an array that holds up to 5 items.
attr_accessor :clothes #an array that holds Body, Head, Hand, Feet, and Shield Equiped armour.
attr_accessor :weapon #a variable that holds 1 weapon
#attr_accessor :skills #an array holding any (5) skills/spells the NPC knows
#attr_accessor :mp
NPC_COUNT = 2
MARRIAGE_MIN = 18 #The youngest age an NPC can be to get married
def initialize
super()
$data_npc = []
setup(NPC_COUNT)
end
def setup(npc_count)
for i in 2 #npc_count
$data_npcs << @npcs[i]
npc = $data_npcs[i]
@npc_id = i
@surname = npc[i][0]
@middle = npc[i][1]
@name = npc[i][2]
@age = npc[i][3]
@sex = npc[i][4]
@disp = npc[i][5]
@bounty = npc[i][6]
@lvl = npc[i][7]
@hp = 100 #Percentages only
@items = npc[i][8]
@clothes = npc[i][9]
@weapon = npc[i][10]
end
end
def id
return @npc_id
end
end
Can someone help me? I really appreciate it if someone can. Peace out!
~Broken