tModLoader Official tModLoader Help Thread

Hi,how can I adjust the position of a weapon? Every time I use my gun I was like holding the gunstock by superpower.
 
Hi,how can I adjust the position of a weapon? Every time I use my gun I was like holding the gunstock by superpower.

You should do this in your SetDefaults:
item.useStyle = 5;
That makes it be held like a gun :)

Also I have a question (not for you, just generally anyone who can help!) How do I make a projectile spawn the Inferno Fork explosion on hitting a block or NPC?
 
So, I've been working on coding a weapon, but no matter what I do, nothing works. I've tried video tutorials and copied the code from those and edited it for my mod and it still did nothing. Any help?
Here's the code:
Code:
Code:
using System;
using Terraria;
using Terraria.ModLoader;

namespace KnifeMod.items
{
public class WoodKnife : ModItem
{
public override void SetDefaults()
{
item.name = "Wood Knife";
item.damage = 4;
item.melee = true;
item.width = 26;
item.height = 26;
item.toolTip = "FYI I am spy";
item.useTime = 10;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 0;
item.value = 300;
item.rare = 1;
item.useSound = 1;
item.autoReuse = true;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Wood, 10);
recipe.AddTile(18);
recipe.SetResult(this, 1);
recipe.AddRecipe();
}


}
}
Thanks!
 
So, I've been working on coding a weapon, but no matter what I do, nothing works. I've tried video tutorials and copied the code from those and edited it for my mod and it still did nothing. Any help?
Thanks!
did you copy it in reg notepad or notepad++ or none of the above? cause it doesnt have the tabbed parts ima try to fix it real quick
 
Code:
using System;
using Terraria;
using Terraria.ModLoader;

namespace KnifeMod.items
{
    public class WoodKnife : ModItem
    {
        public override void SetDefaults()
        {
        item.name = "Wood Knife";
        item.damage = 4;
        item.melee = true;
        item.width = 26;
        item.height = 26;
        item.toolTip = "FYI I am spy";
        item.useTime = 10;
        item.useAnimation = 20;
        item.useStyle = 1;
        item.knockBack = 0;
        item.value = 300;
        item.rare = 1;
        item.useSound = 1;
        item.autoReuse = true;
        }

        public override void AddRecipes()
        {
        ModRecipe recipe = new ModRecipe(mod);
        recipe.AddIngredient(ItemID.Wood, 10);
        recipe.AddTile(18);
        recipe.SetResult(this, 1);
        recipe.AddRecipe();
        }
    }
}
Also if you dont have notepad++ or something recommended for coding terraria mods you should since notepad cant do this correctly with copying in
[doublepost=1459645894,1459645818][/doublepost]also
item.value = Item.buyPrice(0,1,10,0);
makes doing a value easier which in that you set the buy price which it goes (plat,gold,silver,copper)
 
Code:
using System;
using Terraria;
using Terraria.ModLoader;

namespace KnifeMod.items
{
    public class WoodKnife : ModItem
    {
        public override void SetDefaults()
        {
        item.name = "Wood Knife";
        item.damage = 4;
        item.melee = true;
        item.width = 26;
        item.height = 26;
        item.toolTip = "FYI I am spy";
        item.useTime = 10;
        item.useAnimation = 20;
        item.useStyle = 1;
        item.knockBack = 0;
        item.value = 300;
        item.rare = 1;
        item.useSound = 1;
        item.autoReuse = true;
        }

        public override void AddRecipes()
        {
        ModRecipe recipe = new ModRecipe(mod);
        recipe.AddIngredient(ItemID.Wood, 10);
        recipe.AddTile(18);
        recipe.SetResult(this, 1);
        recipe.AddRecipe();
        }
    }
}
Also if you dont have notepad++ or something recommended for coding terraria mods you should since notepad cant do this correctly with copying in
[doublepost=1459645894,1459645818][/doublepost]also
item.value = Item.buyPrice(0,1,10,0);
makes doing a value easier which in that you set the buy price which it goes (plat,gold,silver,copper)
Thanks! Is t all good to go?
 
It is not craftable
[doublepost=1459646524,1459646365][/doublepost]@BenGallegos I'm getting this error:
Code:
error CS0103: The name 'ItemID' does not exist in the current context

Add using Terraria.ID; to the top of your code.

Also, make sure that your mod class (probably KnifeMod.cs in your case) either has Autload set to true or manually loads the knife in the Load method.
 
Add using Terraria.ID; to the top of your code.

Also, make sure that your mod class (probably KnifeMod.cs in your case) either has Autload set to true or manually loads the knife in the Load method.
The mod cs file is what I'm having trouble with, any help on that? I have zero idea on how to code it
 
The mod cs file is what I'm having trouble with, any help on that? I have zero idea on how to code it

It's deceptively complicated in that it can contain about fifty methods, yet can work with only one. Try this:
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace KnifeMod
{
    public class KnifeMod : Mod
    {

        public override void SetModInfo(out string name, ref ModProperties properties)
        {
            name = "Knife Mod";
            properties.Autoload = true;
            properties.AutoloadGores = true;
            properties.AutoloadSounds = true;
        }

        public override void Load()
        {
         
        }

        public override void Unload()
        {
         
        }
    }
}

This should work for what you're trying to do. Load and Unload are just there in case you want to set Autoload to false (although I don't think you would want to in your case).
 
Back
Top Bottom