tModLoader recipe help

Zman350x

Steampunker
I want to make it so you can turn 5 mushrooms into 5 glowing mushrooms. So I look up how to make a custom recipe for a vanilla item. I then go to an already existing modded item, head to the recipe section, and paste this code

ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Mushroom, 5);
recipe.SetResult(ItemID.GlowingMushroom, 5);
recipe.AddRecipe();

I load up the game and get this error

c:\Users\Zack\Documents\My Games\Terraria\ModLoader\Mod Sources\Ranged\Items\PokeyPokeyStick.cs(38,23) : error CS0128: A local variable named 'recipe' is already defined in this scope
 
I want to make it so you can turn 5 mushrooms into 5 glowing mushrooms. So I look up how to make a custom recipe for a vanilla item. I then go to an already existing modded item, head to the recipe section, and paste this code

ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Mushroom, 5);
recipe.SetResult(ItemID.GlowingMushroom, 5);
recipe.AddRecipe();

I load up the game and get this error

c:\Users\Zack\Documents\My Games\Terraria\ModLoader\Mod Sources\Ranged\Items\PokeyPokeyStick.cs(38,23) : error CS0128: A local variable named 'recipe' is already defined in this scope
Check your code again. You probably have ModRecipe recipe = new ModRecipe(mod); multiple times in your code. That line creates a new variable of the type ModRecipe called 'recipe'. Obviously, you can't do that a second time, because you can't have two variables with the same name. You should be assigning to the same variable, not declaring a new one.

Change every instance of:
Code:
ModRecipe recipe = new ModRecipe(mod);
...after the first one to:
Code:
recipe = new ModRecipe(mod);
 
Back
Top Bottom