Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Wouldnt let me ammend this to my old question about the same script

Error: c:\Users\Hailey\Documents\My Games\Terraria\ModLoader\Mod Sources\SaobiesMod\Items\Items\Suspicious Chunk.cs(35,26) : error CS0115: 'SaobiesMod.Items.ItemName.AddRecipe()': no suitable method found to override

Full script:

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SaobiesMod.Items
{
		public class ItemName : ModItem
		{
				public override void SetDefaults()
				{
					item.name = "Suspicious Chunk";
					item.width = 20;
					item.height = 20;
					item.maxStack = 20;
					AddTooltip("A weird hunk of various minerals.";
					item.value = 100;
					item.rare = 1;
					item.useAnimation = 30;
					item.useTime = 30;
					item.useStyle = 4;
					item.consumable = true;
				}
				public override bool CanUseItem(Player player)
				{
					return !NPC.AnyNPCs(mod.NPCType("Gouzibal"));  //you cant spawn this boss multiple times
					return !Main.dayTime; //can use only at night
				}
				public override bool UseItem(Player player)
				{
					NPC.SpawnOnPlayer(plaer.whoAmI, mod.NPCType("Gouzibal")); //boss spawn
					Main.PlayerSound(15, (int)player.position.X (int)player.position.Y, 0);
					
					return true;
				}
				public override void AddRecipe()
				{
					ModRecipe recipe = new ModRecipe(mod);
					recipe.AddIngredient(ItemID:MeteoriteBar, 10);
					recipe.AddIngredient(ItemID:Ruby, 3);
					recipe.AddIngredient(ItemID:StoneBlock, 250);
					recipe.SetResult(this);
					recipe.AddRecipe();
				}
		}
		
}		


What I have tried:

I tried removing the ; after AddRecipe(), and that lead to the game saying the same thing. Im brand new to coding, so i dont know what else i could do to fix it

EDIT: Iv also tried changing "public override void AddRecipe()" to "public class Addrecipe()". It returned by saying "{ expected". Even after adding one at the end of the line, it still said this. I added like 3 and after still getting that error returned the code back to how it was "public override void AddRecipe()"
Posted
Updated 21-Jul-17 15:48pm
v2
Comments
George Swan 21-Jul-17 23:55pm    
Make sure that the signature of the base class method that you are overriding, ModItem.SetDefaults(), is declared using either the virtual, abstract or override keyword.
Member 13322529 22-Jul-17 0:00am    
How, exactly, would i go about fixing this issue, given this information? Bare in mind this is my first time ever coding, a lot of the terms are lost to me
David_Wimbley 22-Jul-17 0:44am    
You need to post your code for the class titled ModItem.

You are trying to override a method called AddRecipe in class ItemName which inherits from your base class of ModItem. It appears that there is no method in class ModItem called AddRecipe, or if there is a method called AddRecipe then it is not an empty method. Meaning, if AddReceipe method does exist in your base class of ModItem that the method in this class has parameters of some sort.

Without seeing the code for class ModItem I won't know for sure and no one else will either. I would encourage you to use the Improve Question widget/link in your question to add the code I've mentioned so we can provide more meaningful assistance.
Member 13322529 22-Jul-17 1:08am    
Hm... see, a script for ModItem doesnt exist. Im following a tutorial for doing all this stuff and wrote down what it said, then changed what it said i could to my liking. From there iv tampered with things on codes that worked so i could figure out what does what and try my own thing

There is no ModItem code, but there is a Items folder, in my mods folder
David_Wimbley 22-Jul-17 1:19am    
Then it must be that ModItem is a class from a third party library (i know nothing about terraria.

Change public override void AddRecipe() to public void AddRecipe() where you remove the modifier override from the method itself. This is the root of your issue at least.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900