tModLoader ERROR CS0103.

peachy

Skeletron Prime
Followed a 2018 tutorial on Youtube to make an ore and it's tile. Here is the error:

C:\whatevs\ModSources\ModName\Tiles\OreTile.cs(12,13) : error CS0103: The name 'Main' does not exist in the current context.

CODE:
Code:
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Packastrophy.Tiles
{
    public class EquibriumTile : ModItem
    {
        public override void SetDefaults()
        {
            Main.tileSolid[Type] = true;
            Main.tileMergeDirt[Type] = true;
            Main.tileLighted[Type] = true;
            Main.tileBlockLight[Type] = false;
            drop = mod.ItemType("EquibriumOre");
            MapTranslation name = CreatedMapEntryName();
            name.SetDefault("Equibrium Ore");
            AddMapEntry(new Color(76, 116, 72), name);
            minPick = 50;
        }
    }
}

VIDEO:

I followed exactly, and i don't know what i've done wrong. :(
 
Thanks, but now it's saying;
c:\Users\whatevs\Mod Sources\Packastrophy\Tiles\EquibriumTile.cs(13,28) : error CS0103: The name 'Type' does not exist in the current context
 
Thanks! I'm a bit stupid for not figuring that out haha :)
[doublepost=1560871276,1560871054][/doublepost]It made two errors this time...

c:\Users\whatevs\ModLoader\Mod Sources\Packastrophy\Tiles\EquibriumTile.cs(18,13) : error CS0246: The type or namespace name 'MapTranslation' could not be found (are you missing a using directive or an assembly reference?)

c:\Users\whatevs\Mod Sources\Packastrophy\Tiles\EquibriumTile.cs(18,35) : error CS0103: The name 'CreatedMapEntryName' does not exist in the current context
 
Thanks! I'm a bit stupid for not figuring that out haha :)
[doublepost=1560871276,1560871054][/doublepost]It made two errors this time...

c:\Users\whatevs\ModLoader\Mod Sources\Packastrophy\Tiles\EquibriumTile.cs(18,13) : error CS0246: The type or namespace name 'MapTranslation' could not be found (are you missing a using directive or an assembly reference?)

c:\Users\whatevs\Mod Sources\Packastrophy\Tiles\EquibriumTile.cs(18,35) : error CS0103: The name 'CreatedMapEntryName' does not exist in the current context
Change 'MapTranslation' to 'ModTranslation' and change 'CreatedMapEntryName' to 'CreateMapEntryName'.
 
Hi I'm having the same problem here is my code.

using Terraria.ID;
using Terraria.ModLoader;
namespace Frixum.Items //The directory for your .cs and .png; Example: Mod Sources/TutorialMOD/Items
{
public class theplucker : ModItem
{
public override void SetDefaults()
{

//the name displayed when hovering over the Weapon ingame.
item.damage = 50; //The damage stat for the Weapon.
item.melee = true; //This defines if it does Melee damage and if its effected by Melee increasing Armor/Accessories.
item.width = 60; //The size of the width of the hitbox in pixels.
item.height = 60; //The size of the height of the hitbox in pixels.
//The description of the Weapon shown when hovering over the Weapon ingame.
item.useTime = 20; //How fast the Weapon is used.
item.useAnimation = 20; //How long the Weapon is used for.
item.useStyle = 1; //The way your Weapon will be used, 1 is the regular sword swing for example
item.knockBack = 6; //The knockback stat of your Weapon.
item.value = Item.buyPrice(0, 2, 0, 0); // How much the item is worth, in copper coins, when you sell it to a merchant. It costs 1/5th of this to buy it back from them. An easy way to remember the value is platinum, gold, silver, copper or PPGGSSCC (so this item price is 10gold)
item.rare = 2; //The color the title of your Weapon when hovering over it ingame
item.UseSound = SoundID.Item1; //The sound played when using your Weapon
item.autoReuse = true; //Weather your Weapon will be used again after use while holding down, if false you will need to click again after use to use it again.
}
public override void AddRecipes()
{ //this is how to craft this item
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10); //this is how to add an ingredient from Terraria, so for crafting this item you need 10 Dirt Block
recipe.AddTile(TileID.WorkBenches); //this is where to craft the item ,WorkBenches = all WorkBenches Anvils = all anvils , MythrilAnvil = Mythril Anvil and Orichalcum Anvil, Furnaces = all furnaces , DemonAltar = Demon Altar and Crimson Altar , TinkerersWorkbench = Tinkerer's Workbench
recipe.SetResult(this);
recipe.AddRecipe();
}
public override void SetStaticDefaults()
{ DisplayName.SetDefault("The Plucker"); //the name displayed when hovering over the Weapon ingame.
Tooltip.SetDefault("Want to listen to some mikey toons?");}
}
}




The error massage is that the name 'item' does not exist.
 
Hi I'm having the same problem here is my code.

using Terraria.ID;
using Terraria.ModLoader;
namespace Frixum.Items //The directory for your .cs and .png; Example: Mod Sources/TutorialMOD/Items
{
public class theplucker : ModItem
{
public override void SetDefaults()
{

//the name displayed when hovering over the Weapon ingame.
item.damage = 50; //The damage stat for the Weapon.
item.melee = true; //This defines if it does Melee damage and if its effected by Melee increasing Armor/Accessories.
item.width = 60; //The size of the width of the hitbox in pixels.
item.height = 60; //The size of the height of the hitbox in pixels.
//The description of the Weapon shown when hovering over the Weapon ingame.
item.useTime = 20; //How fast the Weapon is used.
item.useAnimation = 20; //How long the Weapon is used for.
item.useStyle = 1; //The way your Weapon will be used, 1 is the regular sword swing for example
item.knockBack = 6; //The knockback stat of your Weapon.
item.value = Item.buyPrice(0, 2, 0, 0); // How much the item is worth, in copper coins, when you sell it to a merchant. It costs 1/5th of this to buy it back from them. An easy way to remember the value is platinum, gold, silver, copper or PPGGSSCC (so this item price is 10gold)
item.rare = 2; //The color the title of your Weapon when hovering over it ingame
item.UseSound = SoundID.Item1; //The sound played when using your Weapon
item.autoReuse = true; //Weather your Weapon will be used again after use while holding down, if false you will need to click again after use to use it again.
}
public override void AddRecipes()
{ //this is how to craft this item
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10); //this is how to add an ingredient from Terraria, so for crafting this item you need 10 Dirt Block
recipe.AddTile(TileID.WorkBenches); //this is where to craft the item ,WorkBenches = all WorkBenches Anvils = all anvils , MythrilAnvil = Mythril Anvil and Orichalcum Anvil, Furnaces = all furnaces , DemonAltar = Demon Altar and Crimson Altar , TinkerersWorkbench = Tinkerer's Workbench
recipe.SetResult(this);
recipe.AddRecipe();
}
public override void SetStaticDefaults()
{ DisplayName.SetDefault("The Plucker"); //the name displayed when hovering over the Weapon ingame.
Tooltip.SetDefault("Want to listen to some mikey toons?");}
}
}




The error massage is that the name 'item' does not exist.
Add ‘using Terraria;’ to the top of the file.
 
error CS0103: The name 'ItemType' does not exist in the current context warnings

Am i stupid?..

Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;

namespace tMod.Tiles
{
    public class IldraftOre_Tile : ModTile
    {
        public override void SetDefaults()
        {
            TileID.Sets.Ore[Type] = true;
            Main.tileSpelunker[Type] = true;
            Main.tileShine2[Type] = true;
            Main.tileShine[Type] = 900;
            Main.tileSolid[Type] = true;
            Main.tileMergeDirt[Type] = true;
            Main.tileBlockLight[Type] = true;

            drop = mod.ItemType("IldraftOre");

            ModTranslation name = CreateMapEntryName();
            name.SetDefault("Ildraft Ore");
            AddMapEntry(new Color(112, 181, 198), name);
        }
    };
}
 
error CS0103: The name 'ItemType' does not exist in the current context warnings

Am i stupid?..

Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;

namespace tMod.Tiles
{
    public class IldraftOre_Tile : ModTile
    {
        public override void SetDefaults()
        {
            TileID.Sets.Ore[Type] = true;
            Main.tileSpelunker[Type] = true;
            Main.tileShine2[Type] = true;
            Main.tileShine[Type] = 900;
            Main.tileSolid[Type] = true;
            Main.tileMergeDirt[Type] = true;
            Main.tileBlockLight[Type] = true;

            drop = mod.ItemType("IldraftOre");

            ModTranslation name = CreateMapEntryName();
            name.SetDefault("Ildraft Ore");
            AddMapEntry(new Color(112, 181, 198), name);
        }
    };
}
Depending on your version of tModLoader, ItemType(itemName) has been deprecated. The new version works like this:
C#:
drop = mod.ItemType<IldraftOre>();
 
Depending on your version of tModLoader, ItemType(itemName) has been deprecated. The new version works like this:
C#:
drop = mod.ItemType<IldraftOre>();

Erm... It's not working so due to same problem :D
Doesn't exist in the current bla-bla-bla

PS
Also he can't find my item, but with item all ok (might it helps understand problem)
 
Last edited:
Erm... It's not working so due to same problem :D
Doesn't exist in the current bla-bla-bla
Are you sure this is the script that's causing the error? "does not exist in the current context" is not the error I'd expect if member access goes awry.
 
Are you sure this is the script that's causing the error? "does not exist in the current context" is not the error I'd expect if member access goes awry.

Yep, i checked all one more time: these two errors are in this file

error CS0246: The type or namespace name 'IldraftOre' could not be found (are you missing a using directive or an assembly reference?)
error CS0103: The name 'ItemType' does not exist in the current context

Maybe i made new mistake?
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;

namespace tMod.Tiles
{
    public class IldraftOreTile:ModTile
    {
        public override void SetDefaults()
        {
            TileID.Sets.Ore[Type] = true;
            Main.tileSpelunker[Type] = true;
            Main.tileShine2[Type] = true;
            Main.tileShine[Type] = 900;
            Main.tileSolid[Type] = true;
            Main.tileMergeDirt[Type] = true;
            Main.tileBlockLight[Type] = true;
            drop = mod.ItemType<IldraftOre>();

            ModTranslation name = CreateMapEntryName();
            name.SetDefault("Ildraft Ore");
            AddMapEntry(new Color(152, 171, 198), name);
        }
    };
}
 
Last edited:
Yep, i checked all one more time: these two errors are in this file

error CS0246: The type or namespace name 'IldraftOre' could not be found (are you missing a using directive or an assembly reference?)
error CS0103: The name 'ItemType' does not exist in the current context

Maybe i made new mistake?
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;

namespace tMod.Tiles
{
    public class IldraftOreTile:ModTile
    {
        public override void SetDefaults()
        {
            TileID.Sets.Ore[Type] = true;
            Main.tileSpelunker[Type] = true;
            Main.tileShine2[Type] = true;
            Main.tileShine[Type] = 900;
            Main.tileSolid[Type] = true;
            Main.tileMergeDirt[Type] = true;
            Main.tileBlockLight[Type] = true;
            drop = mod.ItemType<IldraftOre>();

            ModTranslation name = CreateMapEntryName();
            name.SetDefault("Ildraft Ore");
            AddMapEntry(new Color(152, 171, 198), name);
        }
    };
}
Are you on the newest version of tModLoader? If not, what version are you on?
 
Hey guys im actually making a mod and i get the : error Csolo3: The name "recipe" does not exist in the current context. and i don't understant what i did wrong.
here's my code so far :
using System.Threading;
using System.Reflection;
using System.Net.Mail;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria;
namespace SpiritWalkers.item
{
public class VoidStone : ModItem
{
public override void AddRecipes()
{
CreateRecipe();
recipe.AddIngredient(ModContent.ItemType<Content.Items.NightShards>(20));
recipe.AddIngredient(ItemId.TrashCan, 1);
recipe.AddTile(ModContent.TileType<Content.Tiles.Furniture.ShadowSteelAnvil>());
recipe.SetResult(this);
recipe.AddRecipe();
recipe.register();
}
public override void SetDefaults()
{
item.width = 20;
item.height = 20;
item.value = 4000;
item.rare = 3;
item.accessory = true;
}
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Void Stone"); // by default capitalization in classnames will add spaces to the display name. you can customize the display name here by uncommenting this line.
Tooltip.SetDefault("Destroys all the ressources you don't need");
}
}

}
 
help
This is the code

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SkinsAndVanitys.Content.Skins.Body
{
[AutoloadEquip(EquipType.Body)]

public class LostGirlChest : ModItem
{
public override void SetStaticDefaults()
{
ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true;
ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true;
ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBodyAlt] = true;
ArmorIDs.Body.Sets.HidesArms[equipSlotBodyAlt] = true;
}

public override void SetDefaults()
{
Item.defense = 0;
Item.value = 950;
Item.rare = ItemRarityID.White;
Item.hasVanityEffects = true;
}
}
}
 

Attachments

  • Screenshot (24).png
    Screenshot (24).png
    166.6 KB · Views: 30
Back
Top Bottom