Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Initializing Constants?

Okay guys, I'm having a scripting error with an addon for an item mixing script. Whenever I try to start my game, I get this error:

Script 'Crafting List' line 26: NameError occoured.
uninitialized constant Game_Temp::Cooking

Line 26 is "category = Cooking". I'm afraid as a 100% RGSS illiterate, I have no idea how to initialize a constant. Obviously the problem likes in a constant that needs to be initialized. Unfortunately, I don't know how to do that. Can someone gimme a hand with this?
 

Jared

Member

class Game_Temp
Cooking = 1
end

But I don´t know the value which this constant needs. So you musst post the whole script for better help.
 
Actually, that seems to work just fine! But in any case, just for proof reading, here's my item list for the crafting script:

Code:
#================================
# master list for crafting script
#----------------------------------------------------------------
#-written by Deke
#----------------------------------------------------------------
#================================

class Game_Temp
 attr_reader :recipe_list
 Cooking = 1
 Herbalism = 1
 
 alias crafting_temp_initialize initialize

 def initialize
   crafting_temp_initialize
   @recipe_list=[]
   get_recipe_list
 end
 
 def get_recipe_list
   
   ingredients = [30,31,32]
   ingredient_types = [0,0,0]
   quantities = [1,1,1]
   result = 4
   result_type = 0
   category = Cooking
   @recipe_list.push(Game_Recipe.new(ingredients,ingredient_types,quantities,result,result_type,category))
   
   ingredients = [29,30]
   ingredient_types = [0,0]
   quantities = [1,2]
   result = 8
   result_type = 0
   category = Cooking
   @recipe_list.push(Game_Recipe.new(ingredients,ingredient_types,quantities,result,result_type,category))
   
   ingredients = [30,31,1]
   ingredient_types = [0,0,1]
   quantities = [1,1,3]
   result = 4
   result_type = 0
   category = Herbalism
   @recipe_list.push(Game_Recipe.new(ingredients,ingredient_types,quantities,result,result_type,category))
   
 end # of get_recipe_list method
end # of updates to Game_Temp Class
 

Jared

Member

change the value of Herbalism to 2, else Cooking and Herbalism is the same.
Cooking = 1
Herbalism = 2

There musst be another script, but when your code works, I think you don´t need to check it.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top