tModLoader Official tModLoader Help Thread

I am writing code to make the slime staff craft able with 25 gel and 30 wood, but for some reason I keep getting errors no matter what I change. Here is the code currently,
C#:
using Terraria.ID;
using Terraria.ModLoader;

namespace Xtreme
{
    public class XTreme : Mod
    {
    public ModRecipe Recipe { get; private set; }

    public override void AddRecipes()
    {
        ModRecipe recipe = new ModRecipe(this);
        recipe.AddIngredient(ItemID.Gel, 20);
        recipe.AddIngredient(ItemID.Wood, 15);
        recipe.AddTile(TileID.WorkBenches);
        recipe.SetResult(ItemID.SlimeStaff, 1);
        recipe.AddRecipe();
    }
  }
}

When I go to build and reload the mod it says that “Sequence contains more than one matching element” I got this from example mod, just tweaking things for the recipe and for my mods Namespace. I have no Idea what’s going on, and I have tried basically everything. If you need a list of the full error I can post it.
 
Last edited:
Is there a way to increase damage for only a specific weapon rather than a damage class? For example, wearing a set of copper armor, the set bonus would be +10% damage to only the copper shortsword.
 
I am writing code to make the slime staff craft able with 25 gel and 30 wood, but for some reason I keep getting errors no matter what I change. Here is the code currently,
C#:
using Terraria.ID;
using Terraria.ModLoader;

namespace Xtreme
{
    public class XTreme : Mod
    {
    public ModRecipe Recipe { get; private set; }

    public override void AddRecipes()
    {
        ModRecipe recipe = new ModRecipe(this);
        recipe.AddIngredient(ItemID.Gel, 20);
        recipe.AddIngredient(ItemID.Wood, 15);
        recipe.AddTile(TileID.WorkBenches);
        recipe.SetResult(ItemID.SlimeStaff, 1);
        recipe.AddRecipe();
    }
  }
}

When I go to build and reload the mod it says that “Sequence contains more than one matching element” I got this from example mod, just tweaking things for the recipe and for my mods Namespace. I have no Idea what’s going on, and I have tried basically everything. If you need a list of the full error I can post it.
That public ModRecipe Recipe { get; private set; } part is something ive never seen before, probably for something extremely complex.
so just
C#:
using Terraria.ID;
using Terraria.ModLoader;

namespace Xtreme
{
    public class XTreme : Mod
    {
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(this);
            recipe.AddIngredient(ItemID.Gel, 20);
            recipe.AddIngredient(ItemID.Wood, 15);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(ItemID.SlimeStaff, 1);
            recipe.AddRecipe();
        }
    }
}
should work, btw, i would recommend making the slime staff much, MUCH more expensive, as it is insanely good for that recipe, but im not here to tell you how to make your mod.
 
When I try to launch Tmodloader on steam this error message pops up, can anyone help me, please?
 

Attachments

  • error.PNG
    error.PNG
    8.8 KB · Views: 142
That public ModRecipe Recipe { get; private set; } part is something ive never seen before, probably for something extremely complex.
so just
C#:
using Terraria.ID;
using Terraria.ModLoader;

namespace Xtreme
{
    public class XTreme : Mod
    {
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(this);
            recipe.AddIngredient(ItemID.Gel, 20);
            recipe.AddIngredient(ItemID.Wood, 15);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(ItemID.SlimeStaff, 1);
            recipe.AddRecipe();
        }
    }
}
should work, btw, i would recommend making the slime staff much, MUCH more expensive, as it is insanely good for that recipe, but im not here to tell you how to make your mod.
It keeps giving me the same error,

“System.InvalidOperationException: Sequence contains more than one matching element”
 
So i’m making a gigashark mod and everytime I build+reload it says *invalid expression term ‘/‘ and the error is next to { and I don’t know how to remove it pls help
 
I'm trying to make a prefix that gives the weapon lifesteal
I want a weapon that has this prefix to have lifesteal.
I tried things like writing OnHitNPC in the file but it gives error.
Can anyone tell me what change to make to the code so it works as intended please.
Code:
using Terraria;
using Terraria.ModLoader;


namespace d.Prefixes
{
    public class Lifesteal : ModPrefix
    {
        public override float RollChance(Item item)
            => 50f;

        public override bool CanRoll(Item item)
            => true;

        public override PrefixCategory Category
            => PrefixCategory.AnyWeapon;

        public override void SetStats(ref float damageMult, ref float knockbackMult, ref float useTimeMult, ref float scaleMult, ref float shootSpeedMult, ref float manaMult, ref int critBonus)
        {
            damageMult = 0.6f;
        }
    }
}
 
Im making a new class where you can draw cards, which are consumable weapons from a deck of cards, im having issues with it, though, i want to make it so that if you have a total of ten cards in your inventory, you cannot draw any cards. But i cant figure out how to count the number of cards in the inventory, especially since they stack.

clearly its either gonna be buggy as heck (yes I censored it) or were gonna be able to count the amount of cards in the inventory.

basically what i have is an int (cardCount) that increases by one every time you draw a card from a deck, and decreases by one every time you "play" a card, the problem is, people can trash the cards without lowering the cardCount, then you can only have 9 cards, then 8, until eventually you just cant have cards which, surprisingly, isn't very fun.
 
Last edited:
In a mod I'm making, I have an item that is basically an upgrade to the snowman cannon. It (is supposed to) fire 4 rockets at once that like the snowman cannon home in on enemies and don't deal damage to the player who fired them but it would have a different sprite to the snowman cannon's. However I am having some problems with it:

First - When making the rocket projectile, I tried to clone projectile defaults and ai from the snowman rockets but just change the sprite and name (since it just need to be a resprite anyway) however when I did that it resulted in it having an invisible explosion that still hurts the player and for some reason the rocket bounces off walls now??? So after that failure I tried to make one from scratch but I couldn't find any documentation on making a rocket projectile so after looking through the source and copying some defaults and stuff for the snowman rockets from the base game, I still couldn't work out how to make a rocket work and also I'm not sure how to give it the special type of homing they have if making it from scratch.

Second - For some reason whilst item.useAmmo is AmmoID.Rocket if I make item.shoot anything except ProjectileID.RocketI (including modded projectiles) it will either shoot nothing at all or fire the entirely wrong projectile. And even after checking both the electrosphere launcher and snowman cannon I couldn't find how to fix that and make a rocket launcher convert a rocket to a non-standard rocket. So I couldn't even test the above problem unless I set the rocket launcher to not have an ammo. I have fixed this problem now thanks to penumbra gaming.

Any help with either of these problems would be greatly appreciated. Thanks in advance :guidesmile:
 
Last edited:
Ey, i wonder if tmodloader is coming on terraria 1.4 (terraria journey's end) soon, I cant seem to find any info around it and wonder how the progress around it is going
 
I'm trying to make a shield what am I doing wrong?
Code:
using Terraria;
using Terraria.Localization;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
using Terraria.ID;

namespace LunaBlade.Items.Accessories
{
    [AutoloadEquip(EquipType.Shield)]
    public class 0WoodenShield : ModItem
    {
        public override void SetStaticDefaults()
        {
            Tooltip.SetDefault("A wooden shield.");
        }
        public override void SetDefaults()
        {
            item.width = 24;
            item.height = 28;
            item.value = 3000;
            item.rare = 2;
            item.accessory = true;
            item.defense = 1;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(9, 25);
            recipe.AddTile(18);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
 
I'm trying to make a shield what am I doing wrong?
Code:
using Terraria;
using Terraria.Localization;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
using Terraria.ID;

namespace LunaBlade.Items.Accessories
{
    [AutoloadEquip(EquipType.Shield)]
    public class 0WoodenShield : ModItem
    {
        public override void SetStaticDefaults()
        {
            Tooltip.SetDefault("A wooden shield.");
        }
        public override void SetDefaults()
        {
            item.width = 24;
            item.height = 28;
            item.value = 3000;
            item.rare = 2;
            item.accessory = true;
            item.defense = 1;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(9, 25);
            recipe.AddTile(18);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
did you mean to put the 0 in the
C#:
public class 0WoodenShield : ModItem
?
if it wasn't a typo, the name cant start with a 0, and a better way to do it would be to make it WoodenShield0
 
How do I make it so that the set bonus for an armour set makes enemies take damage when they touch the player? (Like thorns). Any help is appreciated greatly.
 
Does anyone know how to give tmodloader more memory? since I don't have many mods, and the program crashes ... and I really have a good pc
 
Back
Top Bottom