tModLoader I'm trying to make a mod but it keeps on saying: error CS1010: Newline in constant. How do I fix it?

jaractus

Ice Queen
I'm trying to make a mod but it keeps on saying: error CS1010: Newline in constant. How do I fix it? Here's my code in the items folder of my mod.
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace LOZ_MasterSword.Items
{
    public class MasterSword : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Master Sword");
            Tooltip.SetDefault("The Bane of darkness, the Sword of Time and ressurection.
            Used to travel across time to demolish evil");
        }
        public override void SetDefaults()
        {
            item.damage = 252;
            item.melee = true;
            item.width = 64;
            item.height = 64;
            item.useTime = 5;
            item.useAnimation = 5;
            item.useStyle = 1;
            item.knockBack = 0;
            item.value = 100000;
            item.rare = 11;
            item.UseSound = SoundID.Item1;
            item.autoReuse = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Terra Blade, 757);
            recipe.AddIngredient(ItemID.Influx Waver, 2880);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe(true);
        }
    }
}
Here's what it says on Terraria

c:\Users\******************\Documents\My Games\Terraria\ModLoader\Mod Sources\LOZ_MasterSword\Items\MasterSword.cs(12,47) : error CS1010: Newline in constant

(* = my name on my PC)
 
Your problem is probably that you're changing lines in the middle of the constant expression for the tooltip. I'm not sure how to fix that as I haven't coded anything serious in C#, but Google tells me you could do this:
Code:
Tooltip.SetDefault("The Bane of darkness, the Sword of Time and ressurection. \n Used to travel across time to demolish evil");
 
If you want to fix the error without creating a new line like how \n does you would need to do this
Code:
Tooltip.SetDefault("The Bane of darkness, the Sword of Time and ressurection." +
                   "Used to travel across time to demolish evil");
 
If you want to fix the error without creating a new line like how \n does you would need to do this
Code:
Tooltip.SetDefault("The Bane of darkness, the Sword of Time and ressurection." +
                   "Used to travel across time to demolish evil");
Okay I did that but now it says
c:\Users\******************\Documents\My Games\Terraria\ModLoader\Mod Sources\LOZ_MasterSword\LOZ_MasterSword.cs(7,10) : error CS0246: The type or namespace name 'Master' could not be found (are you missing a using directive or an assembly reference?)
Now what do I do?
 
Did you put a space there or something? (show your new code. Also come to the tmodloader discord)
 
Did you put a space there or something? (show your new code. Also come to the tmodloader discord)
Ok. Here's my code.
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace LOZ_MasterSword.Items
{
    public class MasterSword : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Master Sword");
            Tooltip.SetDefault("The Bane of darkness, the Sword of Time and ressurection." +
            "Used to travel across time to demolish evil");
        }
        public override void SetDefaults()
        {
            item.damage = 252;
            item.melee = true;
            item.width = 64;
            item.height = 64;
            item.useTime = 5;
            item.useAnimation = 5;
            item.useStyle = 1;
            item.knockBack = 0;
            item.value = 100000;
            item.rare = 11;
            item.UseSound = SoundID.Item1;
            item.autoReuse = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.TerraBlade);
            recipe.AddIngredient(ItemID.InfluxWaver);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe(true);
        }
    }
}
Also I don't have a Discord (for classified reasons), but I would if I had it.
 
K, I opened your code in Visual Studio and it only complained about

recipe.AddRecipe(true);

which should be

recipe.AddRecipe();
 
Ok. I'll see if that works. Thanks!
Ok. I did that and fiddled around with some things and now I have this error: c:\Users\******************\Documents\My Games\Terraria\ModLoader\Mod Sources\LOZ_MasterSword\LOZ_MasterSword.cs(8,10) : error CS1520: Method must have a return type. Now what? Heres both codes of the LOZ_MasterSword file, and the MasterSword file.
LOZ_MasterSword.cs/Weapon Properties(?):
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace LOZ_MasterSword
{
    class LOZ_MasterSword : ModItem
    {
        public MasterSword()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
                AutoloadGores = true,
                AutoloadSounds = true
            };
        }
    }
}
I added the "using Terraria.ID, thinking that might help. Should I remove it?
MasterSword.cs/Weapon Details:
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace LOZ_MasterSword.Items
{
    public class MasterSword : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Master Sword");
            Tooltip.SetDefault("The Bane of darkness, the Sword of Time and ressurection." +
            "Used to travel across time to demolish evil");
        }
        public override void SetDefaults()
        {
            item.damage = 252;
            item.melee = true;
            item.width = 64;
            item.height = 64;
            item.useTime = 5;
            item.useAnimation = 5;
            item.useStyle = 1;
            item.knockBack = 0;
            item.value = 100000;
            item.rare = 11;
            item.UseSound = SoundID.Item1;
            item.autoReuse = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.TerraBlade);
            recipe.AddIngredient(ItemID.InfluxWaver);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
Sorry I have so much problems.
Thanks!
 
Ok. I did that and fiddled around with some things and now I have this error: c:\Users\******************\Documents\My Games\Terraria\ModLoader\Mod Sources\LOZ_MasterSword\LOZ_MasterSword.cs(8,10) : error CS1520: Method must have a return type. Now what? Heres both codes of the LOZ_MasterSword file, and the MasterSword file.
LOZ_MasterSword.cs/Weapon Properties(?):
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace LOZ_MasterSword
{
    class LOZ_MasterSword : ModItem
    {
        public MasterSword()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
                AutoloadGores = true,
                AutoloadSounds = true
            };
        }
    }
}
I added the "using Terraria.ID, thinking that might help. Should I remove it?
MasterSword.cs/Weapon Details:
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace LOZ_MasterSword.Items
{
    public class MasterSword : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Master Sword");
            Tooltip.SetDefault("The Bane of darkness, the Sword of Time and ressurection." +
            "Used to travel across time to demolish evil");
        }
        public override void SetDefaults()
        {
            item.damage = 252;
            item.melee = true;
            item.width = 64;
            item.height = 64;
            item.useTime = 5;
            item.useAnimation = 5;
            item.useStyle = 1;
            item.knockBack = 0;
            item.value = 100000;
            item.rare = 11;
            item.UseSound = SoundID.Item1;
            item.autoReuse = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.TerraBlade);
            recipe.AddIngredient(ItemID.InfluxWaver);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
Sorry I have so much problems.
Thanks!
Hm, you seem to be confusing ModItem and Mod classes, just delete all this:

public MasterSword()
{
Properties = new ModProperties()
{
Autoload = true,
AutoloadGores = true,
AutoloadSounds = true
};
}


Leaving unused using statements is fine.
 
Hm, you seem to be confusing ModItem and Mod classes, just delete all this:

public MasterSword()
{
Properties = new ModProperties()
{
Autoload = true,
AutoloadGores = true,
AutoloadSounds = true
};
}


Leaving unused using statements is fine.
Ok I'll try that
 
Ok I'll try that
Ok. It managed to build the mod, but now I have an error for reloading my mods when it tries to reload the mod. Here's the error:\

It looks like this mod doesn't have a class extending Mod. Mods need a Mod class to function.
at Terraria.ModLoader.AssemblyManager.InstantiateMods(List`1 modsToLoad)

And here's the code of LOZ_MasterSword
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace LOZ_MasterSword
{
    class LOZ_MasterSword : ModItem
    {
   
   
   
   
   
   
   
   
       
    }
}
 
Back
Top Bottom