tModLoader Official tModLoader Help Thread

When I try to name the weapon, I get this error:
Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)
Here is the code:
Code:
 using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Moreweapons.Projectile_Weapons
{
   public class MoonThrowingKnife : ModItem
    {
        public override void SetDefaults()
        {
         item.name = "Moon Throwing Knife";
            item.damage = 52;
            item.useStyle = 5;
            item.useAnimation = 18;
            item.useTime = 25;
            item.shootSpeed = 3.75f;
            item.knockBack = 4.5f;
            item.width = 24;
            item.height = 40;
            item.scale = 1f;
            item.rare = 9;
            item.UseSound = SoundID.Item1;
            item.value = 10000;
            item.melee = true;
            item.autoReuse = true;

            item.noMelee = true;
            item.noUseGraphic = true;
            item.shoot = mod.ProjectileType<Projectiles.MoonThrowingKnife>();
        }
        public override bool CanUseItem(Player player)
        {
            return player.ownedProjectileCounts[item.shoot] < 1;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.LunarBar, 2);
            recipe.AddTile(TileID.MythrilAnvil);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
 
When I try to name the weapon, I get this error:
Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)
item.name isn't a thing for what you're trying to do. Download Example Mod here and take some time to explore it, get a feel for the folder structure, where documents are placed, and the syntax of the code. Also, consider switching to Visual Studio; if you type "item." then VS will tell you what options you can put there based on your references, which is both useful and educational.
 
How do i make my gun shoot onyx, just like the Onyx Blaster.

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

namespace UltimaRise.Items.Weapons
{
    public class OnyxGun : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Onyx Gun");
            Tooltip.SetDefault("Shoot out onyx");
        }
        public override void SetDefaults()
        {
            item.damage = 50;
            item.ranged = true;
            item.width = 40;
            item.height = 20;
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 5;
            item.noMelee = true;
            item.knockBack = 4;
            item.value = 10000000;
            item.rare = 8;
            item.UseSound = SoundID.Item36;
            item.autoReuse = true;
            item.shoot = 6;
            item.shootSpeed = 6;
            item.useAmmo = AmmoID.Bullet;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.FlareGun);
            recipe.AddIngredient(ItemID.HallowedBar, 15);
            recipe.AddIngredient(ItemID.SoulofNight, 15);
            recipe.AddIngredient(ItemID.SoulofMight, 15);
            recipe.AddTile(TileID.MythrilAnvil);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage,ref float knockBack)
        {
            if (type == ProjectileID.Bullet);
            {
                type = ProjectileID.
            }
        }
    }
}
 
Hey, I was wondering... Does anyone know how to make dust provide light?
I've tried setting dust.noLight to true and false, nothing happened. I can also give you the weapon code that i want the dust to be applied to.

Dust code:

using Terraria;
using Terraria.ModLoader;

namespace ShanksMod.Items
{
public class VendetiteToolDust : ModDust
{
public override void OnSpawn(Dust dust)
{
dust.velocity *= 0.6f;
dust.noGravity = true;
dust.noLight = false;
dust.scale *= 1f;
}

public override bool Update(Dust dust)
{
dust.position += dust.velocity;
dust.rotation += dust.velocity.X * 0.2f;
dust.scale *= 0.90f;
if (dust.scale < 0.5f)
{
dust.active = false;
}
return false;
}

}
}



Weapon Code:


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

namespace ShanksMod.Items
{
public class Vendetta : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Vendetta");
Tooltip.SetDefault("Forged specially for someone...");
}
public override void SetDefaults()
{
item.damage = 60;
item.melee = true;
item.width = 40;
item.height = 40;
item.useTime = 10;
item.useAnimation = 10;
item.useStyle = 1;
item.knockBack = 6;
item.value = 10000;
item.rare = 8;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.useTurn = true;

}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.HellstoneBar, 20);
recipe.AddIngredient(ItemID.SoulofMight, 10);
recipe.AddIngredient(ItemID.SoulofSight, 10);
recipe.AddIngredient(ItemID.SoulofFright, 10);
recipe.AddIngredient(ItemID.HallowedBar, 15);
recipe.AddIngredient(null, "VendetiteBar", 10);
recipe.AddTile(TileID.MythrilAnvil);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override void MeleeEffects(Player player, Rectangle hitbox)
{
if (Main.rand.Next(3) == 0)
{
//Emit dusts when swing the sword
Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, mod.DustType("VendetiteToolDust"));
}
}
}
}
 
Recently came back to Terraria and decided to play with a few mods. However, over the course of my game play on multiple occasions I would click (left and right) an item and it would completely disappear. It happens randomly but not often but it can be frustrating if you lose an important item. Below are the mods I am playing with, if anybody can maybe assist with my issue that would be appropriated thank you.
  • WorldGen Previewer v0.1.5.1
  • Which Mod Is This From? v2.4
  • Yet Another Boss Health Bar v1.2.1
  • Boss Checklist v.0.1.4.2
  • AlchemistNPC v5.5
  • Tremor Mod Remastered v1.3.2.7
  • Spirit Mod v1.3.3.0
  • The Antiaris v0.1.0.3
  • imkSushi's Mod v4.3.1
  • Reduced Grinding v4.23
  • Calamity Mod v.1.2.3.8
  • More Accessories+ v2.1
  • MaxStackPlus v3.2
 
upload_2017-12-30_17-2-20.png

[doublepost=1514671369,1514671352][/doublepost]
anyone know this error??
 
I'm trying to make a helmet which provides the night owl buff/effect while it is being worn. For some reason, there is no night owl effect taking place. Even if I unequip and re-equip the helmet again, I don't see a difference in the lighting. What am I doing wrong?


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

namespace moreyes.Items.Armor
{
[AutoloadEquip(EquipType.Head)]
public class LensHelmet : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Lens Helmet");
Tooltip.SetDefault("Lens may be small, but they can still be used to craft with. The glass lens you used to craft this refracts light you see, making light seem brighter.");
}

public override void SetDefaults()
{
item.width = 18;
item.height = 18;
item.value = 1000;
item.rare = 0;
item.defense = 1;
}

public virtual void UpdateEquip(Item item, Player player)
{
player.AddBuff(BuffID.NightOwl, 2);
}

public override bool IsArmorSet(Item head, Item body, Item legs)
{
return body.type == mod.ItemType("LensChestplate") && legs.type == mod.ItemType("LensLeggings");
}

public override void UpdateArmorSet(Player player)
{
player.setBonus = "With maximum light refraction from having full lens armor, you now also give off light!";
player.AddBuff(BuffID.Shine, 2);
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Lens, 30);
recipe.AddTile(TileID.Anvils);
recipe.needLava = true;
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
Top of spoiler

Edit: The shine buff works fine once I have the full set of associated armor, so I don't know if I have the wrong buff ID or if it's something else that is causing this.
 
Last edited:
I have just now started to get this error when it says "Resetting Game Objects". It happens now every time I try to join a world, and I changed nothing but update tModLoader to the latest version from the one before it, although it did let me join a world once right after updating.
sxedctrftvbgyh.PNG
 
I have just now started to get this error when it says "Resetting Game Objects". It happens now every time I try to join a world, and I changed nothing but update tModLoader to the latest version from the one before it, although it did let me join a world once right after updating.View attachment 190696
As I understand it, memory stuff is usually too many mods. Terraria is 32-bit, so only utilizes ~3GB (in practice) of your RAM regardless of how much RAM you have. Universally, tModLoader and all mods are perpetually in beta and varying level of unoptimized, so enough mods will eat up your available memory for Terraria and BAM, memory exceptions.

Edit: Also, because of this, when you need to reload mods, just exit Terraria and restart. Reloading doesn't cleanly reset memory, and you'll end up running out after a reload or two, depending on your mods. Especially if you're using any big mods like Calamity or Thorium.
 
As I understand it, memory stuff is usually too many mods. Terraria is 32-bit, so only utilizes ~3GB (in practice) of your RAM regardless of how much RAM you have. Universally, tModLoader and all mods are perpetually in beta and varying level of unoptimized, so enough mods will eat up your available memory for Terraria and BAM, memory exceptions.

Edit: Also, because of this, when you need to reload mods, just exit Terraria and restart. Reloading doesn't cleanly reset memory, and you'll end up running out after a reload or two, depending on your mods. Especially if you're using any big mods like Calamity or Thorium.
The weird thing is, however, that everything went by smoothly the first time I joined a world after updating, so I'm guessing it's just a problem with too many other programs open.
 
Maybe, but only if you're running a lot of memory-demanding 32-bit programs.
I did that and I disabled some mods I realized I had enabled just before the crashing started. That didn't work, so I guess I'll have to downgrade some mods.
 
I did that and I disabled some mods I realized I had enabled just before the crashing started. That didn't work, so I guess I'll have to downgrade some mods.
The big ones are usually the troublemakers... if I recall correctly, they include Calamity, Tremor, Thorium, and Spirit, for example. A big infraction tends to be sound... if a mod has a lot of music and environmental sound, it's going to eat resources. Mods like the above, introducing new boss fight music, biome music, and the like, will chew up memory when loaded.

If you're using multiple big mods, your quickest fix will be to trim those down. If it helps: Calamity is balanced around itself, not other content, so doesn't play well with others, and Tremor is still in the middle of re-development since it changed hands... if you're going to play Tremor, consider using it as the only big mod, and helping the dev with feedback and bug reports.
 
Could you copy + paste the code from BatonVI.cs here?
using Terraria.ID;
using Terraria.ModLoader;

using Terraria.ID;
using Terraria.ModLoader;

namespace MilitaryMod.Items.Weapons
{
public class BatonV1 : ModItem
{
public override void SetStaticDefaults()
}
public override void SetDefaults()
{
item.damage = 50;
item.melee = true;
item.width = 40;
item.height = 40;
item.toolTip = AIT Baton For Infantry;
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 6;
item.value = 10000;
item.rare = 2;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
 
Last edited:
The Class can't have spaces. By default, the game will take the displayed name from the Class and just auto-insert spaces before each capital letter after the first (HamSandwichOnRye gets displayed as "Ham Sandwich On Rye"), but, in case it doesn't work (I'm not sure how it'll respond to the "V1"), you'll probably want to put something like
Code:
DisplayName.SetDefault("Baton V1");
in SetStaticDefaults. You also might want to try attaching a description to appear in the tooltip, which would be putting
Code:
Tooltip.SetDefault("Good for fending off attacking Ham Sandwiches.");
also under SetStaticDefaults.
I'm putting a link to Example Mod in my signature, in case you haven't seen it, and because I refer to it so much. You should get Visual Studio and take some time to just explore Example Mod and see the format it uses for both folder structure and file layout. You'll find a LOT of answers there!
 
The Class can't have spaces. By default, the game will take the displayed name from the Class and just auto-insert spaces before each capital letter after the first (HamSandwichOnRye gets displayed as "Ham Sandwich On Rye"), but, in case it doesn't work (I'm not sure how it'll respond to the "V1"), you'll probably want to put something like
Code:
DisplayName.SetDefault("Baton V1");
in SetStaticDefaults. You also might want to try attaching a description to appear in the tooltip, which would be putting
Code:
Tooltip.SetDefault("Good for fending off attacking Ham Sandwiches.");
also under SetStaticDefaults.
I'm putting a link to Example Mod in my signature, in case you haven't seen it, and because I refer to it so much. You should get Visual Studio and take some time to just explore Example Mod and see the format it uses for both folder structure and file layout. You'll find a LOT of answers there!

i tried this and it still wont work..

using Terraria.ID;
using Terraria.ModLoader;

namespace MilitaryMod.Items.Weapons
{
public class BatonV1 : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("BatonV1");
Tooltip.SetDefault("AIT Baton For Infantry");
}
public override void SetDefaults()
{
item.name = "BatonV1";
item.damage = 50;
item.melee = true;
item.width = 32;
item.height = 32;
item.toolTip = AIT Baton For Infantry;
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 6;
item.value = 10000;
item.rare = 2;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
 
Back
Top Bottom