Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> Having a problem when I use
Ignasis
post Mar 17 2012, 08:29 PM
Post #1


Level 4
Group Icon

Group: Member
Posts: 52
Type: None
RM Skill: Intermediate




I keep getting an error message that pops up when I try even a simple battle test stating Game_Crafting line 259:ArgumentError wrong number of arguments (12 of 13) Anyone know what I can do to fix this?

Here is the code segment.
def createNewRecipe(stringToParse)
#first check for nil and comments
return nil if stringToParse == nil
return nil if stringToParse.strip.empty?
return nil if stringToParse.lstrip.index("#") != nil

#first parse out the text info
#split at the whitespace
attributes = stringToParse.split

name = attributes[0].gsub("_", " ") #the first position is name
itemType = attributes[1].to_i #2nd is item type
numOfIngs = attributes[2].to_i #3nd position is the num of ingredients
x = 0
ingreds = [] #ingredients start at the 3rd position
while x < numOfIngs
number = attributes[x + 3]
ingredientType = number[0,1].to_i
index = number[1,number.length - 1].to_i
case ingredientType #switch for ingredients
when 0
ingreds.push($data_items[index])
when 1
ingreds.push($data_weapons[index])
when 2
ingreds.push($data_armors[index])
end
x += 1
end
y = 0
amounts = [] #amounts start after the ingredients
while y < numOfIngs
amounts.push(attributes[x + y + 3].to_i)
y += 1
end
currentIndex = x + y + 3
case itemType #switch for resulting items
when 0
normalItem = $data_items[attributes[currentIndex].to_i]
criticalItem = $data_items[attributes[currentIndex + 2].to_i]
when 1
normalItem = $data_weapons[attributes[currentIndex].to_i]
criticalItem = $data_weapons[attributes[currentIndex + 2].to_i]
when 2
normalItem = $data_armors[attributes[currentIndex].to_i]
criticalItem = $data_armors[attributes[currentIndex + 2].to_i]
end
normalAmount = attributes[currentIndex + 1].to_i
critAmount = attributes[currentIndex + 3].to_i
critChance = attributes[currentIndex + 4].to_i
difficulty = attributes[currentIndex + 5].to_i
bonusStat = attributes[currentIndex + 6].to_i
bonusInterval = attributes[currentIndex + 7].to_i
category = attributes[currentIndex + 8].to_i

#next, create the Recipe object, initialize it and return it!
thisRecipe = Recipe.new(name, ingreds, amounts, normalItem, normalAmount, <===This is line 259
criticalItem, critAmount, critChance, difficulty,
bonusStat, bonusInterval, category)
return thisRecipe
end

#----------------------------------------------------------------------------
# Returns the array of recipes that are available
#----------------------------------------------------------------------------
def recipeList
return @recipes
end

#----------------------------------------------------------------------------
# Discovers the recipe at recipeIndex
#----------------------------------------------------------------------------
def discover(recipeIndex)
@recipes[recipeIndex].setDiscovered
end

#----------------------------------------------------------------------------
# Returns the difficulties of the specified stat
#----------------------------------------------------------------------------
def difficulties(stat)
case stat
when 0
return @atkThresholds
when 1
return @defThresholds
when 2
return @spiThresholds
when 3
return @agiThresholds
end
end


__________________________
Go to the top of the page
 
+Quote Post
   
 
Start new topic
Replies
Pacman
post Mar 17 2012, 08:40 PM
Post #2


Level 3
Group Icon

Group: Member
Posts: 34
Type: Scripter
RM Skill: Advanced




This error is caused by a line of code calling a method with a specific number of arguments, but the call provides the wrong number of arguments. In this case, the code is calling Recipe.new which specifies 13 arguments, but the code is only giving 12. I can't tell you how to fix this, as I don't have the script in question, but at least now you know why the error's happening.


__________________________
Go to the top of the page
 
+Quote Post
   
Ignasis
post Mar 17 2012, 08:45 PM
Post #3


Level 4
Group Icon

Group: Member
Posts: 52
Type: None
RM Skill: Intermediate




QUOTE (Pacman @ Mar 17 2012, 08:40 PM) *
This error is caused by a line of code calling a method with a specific number of arguments, but the call provides the wrong number of arguments. In this case, the code is calling Recipe.new which specifies 13 arguments, but the code is only giving 12. I can't tell you how to fix this, as I don't have the script in question, but at least now you know why the error's happening.


Thanks for confirming my beliefs... I just started trying to learn ruby so some of this stuff is still a little confusing to me at times... I tried looking through the code.. to find if there is something missing from the array...I'm not entirely sure what to look for.


__________________________
Go to the top of the page
 
+Quote Post
   

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 05:27 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker