tModLoader [Modding Help] Accessories Coding

DraLUSAD

Skeletron Prime
Hi guys, i'm looking for a few ways on some of my accessories and how they should work, at the moment they are coded like this

Code:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Industrialization.Accessories
{
    public class itebattlestoken : ModItem
    {

        public override void SetDefaults()
        {
            item.name = "Battle's Token";
            item.width = 24;
            item.height = 28;
            item.toolTip = "Increases enemy spawn rate";
            item.value = 0;
            item.rare = 1;
            item.accessory = true;
        }
       
        public override void UpdateAccessory(Player player)
        {
            player.enemySpawns = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "itediskbattleset", 1);
            recipe.AddIngredient(null, "iteemptytoken", 1);
            recipe.AddIngredient(null, "itecredit", 250);
            recipe.AddIngredient(300, 30);
            recipe.AddTile(114);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

BUT, its not what i want, infact, i'm hoping if anyone can help me change the code to doing this:
  1. Doesn't work in the accessories slot, instead, works only in the Accessory vanity slot
  2. Works just like that of a "Compass", "Watch", "Rader" ect, just by sitting in your inventory
Thanks :)
 
Hi guys, i'm looking for a few ways on some of my accessories and how they should work, at the moment they are coded like this

Code:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Industrialization.Accessories
{
    public class itebattlestoken : ModItem
    {

        public override void SetDefaults()
        {
            item.name = "Battle's Token";
            item.width = 24;
            item.height = 28;
            item.toolTip = "Increases enemy spawn rate";
            item.value = 0;
            item.rare = 1;
            item.accessory = true;
        }
      
        public override void UpdateAccessory(Player player)
        {
            player.enemySpawns = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "itediskbattleset", 1);
            recipe.AddIngredient(null, "iteemptytoken", 1);
            recipe.AddIngredient(null, "itecredit", 250);
            recipe.AddIngredient(300, 30);
            recipe.AddTile(114);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

BUT, its not what i want, infact, i'm hoping if anyone can help me change the code to doing this:
  1. Doesn't work in the accessories slot, instead, works only in the Accessory vanity slot
  2. Works just like that of a "Compass", "Watch", "Rader" ect, just by sitting in your inventory
Thanks :)
1.
I'll look into that for you (weird that that code doesn't work...).
2.
That's actually pretty simple. Instead of putting code in the UpdateAccessory function, you can do something like this:
Code:
public override void UpdateInventory(Player player)
{
    player.enemySpawns = true;
}
Hope that works for you ;)

P.S.
Your other request is comming along nicely.
 
Is there anywhere i can find a list of codes like these ones:
Code:
            player.longInvince = true;    //Acts like the Cross Necklace
            player.waterWalk = true;    //can walk on water
            player.iceSkate = true;    //better control on ice

Looking for a one thats used for "Create Potions"
 
Is there anywhere i can find a list of codes like these ones:
Code:
            player.longInvince = true;    //Acts like the Cross Necklace
            player.waterWalk = true;    //can walk on water
            player.iceSkate = true;    //better control on ice

Looking for a one thats used for "Create Potions"
If you have decompiled Terraria, look in Player.UpdateBuffs(). Anyway, I assume you are talking about Crate Potions not Create Potions, so you'll want to set player.cratePotion to true.

An alternate to decompiling is using Visual Studio to code your mod and when you type "player." a window will pop up with suggestions. You can usually find what you want by guessing the name and as you type the field you want will show itself in the autocomplete window.
 
If you have decompiled Terraria, look in Player.UpdateBuffs(). Anyway, I assume you are talking about Crate Potions not Create Potions, so you'll want to set player.cratePotion to true.

An alternate to decompiling is using Visual Studio to code your mod and when you type "player." a window will pop up with suggestions. You can usually find what you want by guessing the name and as you type the field you want will show itself in the autocomplete window.

aye, i have a difficult time with some languages that sound the same, like Create and Crate, but yes, it was Crate Potions.

whats this, "Visual Studio" thing your talking about, plus i dont know how to decompile Terraria, so both would be nice to know ;)
 
aye, i have a difficult time with some languages that sound the same, like Create and Crate, but yes, it was Crate Potions.

whats this, "Visual Studio" thing your talking about, plus i dont know how to decompile Terraria, so both would be nice to know ;)
You can find Visual Studio here (this is the 2015 Community Edition). Visual Studio is basically a program with some 'advanced' programming tools (like the one @jopojelly mentioned and much, much more).

If you want to decompile Terraria, I'd suggest downloading IlSpy (google that and download the binaries). If you open the program, you can just drag and drop your Terraria.exe file (from your Steam folder) into the program and you're good to go.
 
Hey does anyone know how to make an accessory or item that prevents death, then heals you, like the Devil's Carapace or Phylactery from Thorium?
 
Is there anywhere i can find a list of codes like these ones:
Code:
            player.longInvince = true;    //Acts like the Cross Necklace
            player.waterWalk = true;    //can walk on water
            player.iceSkate = true;    //better control on ice

Looking for a one thats used for "Create Potions"
If you have decompiled Terraria, look in Player.UpdateBuffs(). Anyway, I assume you are talking about Crate Potions not Create Potions, so you'll want to set player.cratePotion to true.

An alternate to decompiling is using Visual Studio to code your mod and when you type "player." a window will pop up with suggestions. You can usually find what you want by guessing the name and as you type the field you want will show itself in the autocomplete window.

It doesn't explain what the things do tho.
I'm getting the hand of it, but there's one thing I don't understand, can you help me? I don't know how to make running boots like the hermes or lightning or spectre. My boots keep on running at 53 mph and stack with hermes, running at 57. What's happening and what do I change to control the speed and stop the stack effect?
 
Hi guys, i'm looking for a few ways on some of my accessories and how they should work, at the moment they are coded like this

Code:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Industrialization.Accessories
{
    public class itebattlestoken : ModItem
    {

        public override void SetDefaults()
        {
            item.name = "Battle's Token";
            item.width = 24;
            item.height = 28;
            item.toolTip = "Increases enemy spawn rate";
            item.value = 0;
            item.rare = 1;
            item.accessory = true;
        }
  
        public override void UpdateAccessory(Player player)
        {
            player.enemySpawns = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "itediskbattleset", 1);
            recipe.AddIngredient(null, "iteemptytoken", 1);
            recipe.AddIngredient(null, "itecredit", 250);
            recipe.AddIngredient(300, 30);
            recipe.AddTile(114);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

BUT, its not what i want, infact, i'm hoping if anyone can help me change the code to doing this:
  1. Doesn't work in the accessories slot, instead, works only in the Accessory vanity slot
  2. Works just like that of a "Compass", "Watch", "Rader" ect, just by sitting in your inventory
Thanks :)
So I'm new to the world of coding, and literally have no idea of what any term means.

- Why is there an "ite" before "diskbattleset" and the ingredients?
- Can you write "item.value" by using "(0, 50, 0, 0)?
- What does "itecredit, 250" mean?
- What does "(300, 30);" mean?
- What does "AddTile(114)" mean?

Sorry if I ask too many questions... [EDIT: I figured out what "AddTile(114)" means]
 
Last edited:
- Why is there an "ite" before "diskbattleset" and the ingredients?
- Can you write "item.value" by using "(0, 50, 0, 0)?
- What does "itecredit, 250" mean?
- What does "(300, 30);" mean?
- The "ite" may just be this person's way of signalling something is an item.
- item.value can either be written as a number of Copper coins (500000 in your example) or as Item.buyPrice(platinum, gold, silver, copper) / Item.sellPrice(platinum, gold, silver, copper).
- recipe.AddIngredient(null, "itecredit", 250) means that one of the ingredients for this recipe is 250 "itecredit"s.
- recipe.AddIngredient(300, 30) means that one of the ingredients for this recipe is 30 of whatever item Terraria assigns as ID 300 - in this case, 30 Battle Potions.

If you're new to modding, you should most likely start here: tModLoader/tModLoader
 
- The "ite" may just be this person's way of signalling something is an item.
- item.value can either be written as a number of Copper coins (500000 in your example) or as Item.buyPrice(platinum, gold, silver, copper) / Item.sellPrice(platinum, gold, silver, copper).
- recipe.AddIngredient(null, "itecredit", 250) means that one of the ingredients for this recipe is 250 "itecredit"s.
- recipe.AddIngredient(300, 30) means that one of the ingredients for this recipe is 30 of whatever item Terraria assigns as ID 300 - in this case, 30 Battle Potions.

If you're new to modding, you should most likely start here: tModLoader/tModLoader
Thank You!
 
How can I make a gadget using UpdateInventory that displays information? Also, how do I make an accessory visible on the character? How do I sense when the player wearing the accessory is pressing a specific key, like left movement key or f?
 
Last edited:
Code:
using Terraria.ID;
using Terraria;
using Terraria.ModLoader;

namespace Rngmod.Items
{
    public class Clawat : ModItem
    {
        public override void SetStaticDefaults()

        {
            Tooltip.SetDefault("The damage of these small, concealable blades should not be underestimated.");
            DisplayName.SetDefault("Blades of Attack");
        }

        public override void SetDefaults()
        {
            item.width = 24;
            item.height = 28;
            item.value = 3000;
            item.rare = 0;
            item.accessory = true;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.IronBar, 10);
            recipe.AddIngredient(ItemID.Wood, 10);
            recipe.anyIronBar = true;
            recipe.anyWood = true;
            recipe.AddTile(TileID.Anvils);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }

        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            {
                player.meleeDamage += 10;
            }
        }
    }
}
How do i make an accessory give you +9 damage Not multiply it
 
Back
Top Bottom