Tiger Festival
Terrarian
I'm trying to make a simple vanity mod for tml 1.4, the spriting and coding is done, but whenever I try to build and reload I get this error, I have no clue how to get past it, any help is appreciated.
Code for Body:You'd have to post the code for MioBody, something is wrong on line 44.
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
namespace FF6Mod.Items.Clothing.FF6
{
[AutoloadEquip(EquipType.Body)]
public class CelesBody : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Celes's Top");
int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body);
ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true;
ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true;
}
public override void SetDefaults()
{
Item.width = 32;
Item.height = 30;
Item.value = Item.buyPrice(0, 0, 10, 0);
Item.rare = ItemRarityID.White;
}
}
}
Ok I did what you said and now my mod loads and I can make the vanities, now I'm unable to equip them. Here's my code.Can I ask why you're trying to create your own equiptype and manually load the texture? If it's a standard armor texture, none of that would be needed. Here's an example of a vanity body item in my mod. The files CelesBody.png and CelesBody_Body.png are automatically loaded by TML.
Code:using Terraria; using Terraria.ModLoader; using Terraria.ID; namespace FF6Mod.Items.Clothing.FF6 { [AutoloadEquip(EquipType.Body)] public class CelesBody : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Celes's Top"); int equipSlotBody = EquipLoader.GetEquipSlot(Mod, Name, EquipType.Body); ArmorIDs.Body.Sets.HidesTopSkin[equipSlotBody] = true; ArmorIDs.Body.Sets.HidesArms[equipSlotBody] = true; } public override void SetDefaults() { Item.width = 32; Item.height = 30; Item.value = Item.buyPrice(0, 0, 10, 0); Item.rare = ItemRarityID.White; } } }
Body
using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;
namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000006 RID: 6
[AutoloadEquip(EquipType.Body)]
{
})]
internal class MioBody : ModItem
{
// Token: 0x0600000F RID: 15 RVA: 0x000023A9 File Offset: 0x000005A9
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mio's Baseball T-Shirt");
Tooltip.SetDefault("A Baseball T-shirt with fingerless gloves!");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId;
}
// Token: 0x06000010 RID: 16 RVA: 0x000023E4 File Offset: 0x000005E4
public override void SetDefaults()
{
Item.width = 30;
Item.height = 28;
Item.vanity = true;
Item.rare = 5;
}
// Token: 0x06000011 RID: 17 RVA: 0x00002444 File Offset: 0x00000644
}
}
Head
using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;
namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000007 RID: 7
[AutoloadEquip(EquipType.Head)]
{
})]
internal class MioHead : ModItem
{
// Token: 0x06000013 RID: 19 RVA: 0x0000249B File Offset: 0x0000069B
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId;
}
// Token: 0x06000014 RID: 20 RVA: 0x000024D4 File Offset: 0x000006D4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}
// Token: 0x06000015 RID: 21 RVA: 0x00002534 File Offset: 0x00000734
}
}
Legs
using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;
namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000008 RID: 8
[AutoloadEquip(EquipType.Legs)]
{
})]
internal class MioLegs : ModItem
{
// Token: 0x06000017 RID: 23 RVA: 0x0000258B File Offset: 0x0000078B
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mio's Denim skirt");
Tooltip.SetDefault("A Blue denim skirt with a plaid shirt wrapped around.");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId;
}
// Token: 0x06000018 RID: 24 RVA: 0x000025C4 File Offset: 0x000007C4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}
// Token: 0x06000019 RID: 25 RVA: 0x00002624 File Offset: 0x00000824
}
}
Ok I removed the extra brackets and tried to build and reload and now this error pops upThe only thing that looks off is the extra brackets after the AutoloadEquip line.
So delete this:
{
})]
Otherwise your code is fine. Here's another example - ExampleMask
using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;
namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000007 RID: 7
[AutoloadEquip(EquipType.Head)]
internal class MioHead : ModItem
{
// Token: 0x06000013 RID: 19 RVA: 0x0000249B File Offset: 0x0000069B
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId;
}
// Token: 0x06000014 RID: 20 RVA: 0x000024D4 File Offset: 0x000006D4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}
// Token: 0x06000015 RID: 21 RVA: 0x00002534 File Offset: 0x00000734
}
}
SacrificeTotal = 1;
Almost there! It's working now and I'm able to equip everything, but there is one problemThe line CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId; is the issue.
You can just replace it withSacrificeTotal = 1;
using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;
namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000007 RID: 7
[AutoloadEquip(EquipType.Head)]
internal class MioHead : ModItem
{
// Token: 0x06000013 RID: 19 RVA: 0x0000249B File Offset: 0x0000069B
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
SacrificeTotal = 1;
}
// Token: 0x06000014 RID: 20 RVA: 0x000024D4 File Offset: 0x000006D4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}
// Token: 0x06000015 RID: 21 RVA: 0x00002534 File Offset: 0x00000734
}
}
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
I added that and this came upThere are a few options for drawing hair, but I think you should be fine if you add this line into SetStaticDefaults() for the head piece:
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;
namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000007 RID: 7
[AutoloadEquip(EquipType.Head)]
internal class MioHead : ModItem
{
// Token: 0x06000013 RID: 19 RVA: 0x0000249B File Offset: 0x0000069B
public override void SetStaticDefaults(ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
SacrificeTotal = 1;
}
// Token: 0x06000014 RID: 20 RVA: 0x000024D4 File Offset: 0x000006D4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}
// Token: 0x06000015 RID: 21 RVA: 0x00002534 File Offset: 0x00000734
}
}
I tried it and ran into thisYou don't add it into the actual method parameters, it's a line within the method.
So
SetStaticDefaults() {
line 1
line 2
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
}
using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;
namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000007 RID: 7
[AutoloadEquip(EquipType.Head)]
internal class MioHead : ModItem
{
// Token: 0x06000013 RID: 19 RVA: 0x0000249B File Offset: 0x0000069B
public override void SetStaticDefaults(){
line 1
line 2
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
}
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
SacrificeTotal = 1;
}
// Token: 0x06000014 RID: 20 RVA: 0x000024D4 File Offset: 0x000006D4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}
// Token: 0x06000015 RID: 21 RVA: 0x00002534 File Offset: 0x00000734
}
}
Oh I see, I removed the line 1 and 2 and reloaded and got another error.No dude don't just paste that lol. When I wrote 'line 1' and 'line 2' those were just examples not actual code. Just put the DrawFullHair line with the rest of your static defaults.
using System;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.GameContent.Creative;
using Terraria.ModLoader;
namespace TigerVanities.Content.Items.Armor.Vanity.Mio
{
// Token: 0x02000007 RID: 7
[AutoloadEquip(EquipType.Head)]
internal class MioHead : ModItem
{
// Token: 0x06000013 RID: 19 RVA: 0x0000249B File Offset: 0x0000069B
public override void SetStaticDefaults() {
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
}
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
SacrificeTotal = 1;
}
// Token: 0x06000014 RID: 20 RVA: 0x000024D4 File Offset: 0x000006D4
public override void SetDefaults()
{
Item.width = 24;
Item.height = 24;
Item.vanity = true;
Item.rare = 5;
}
// Token: 0x06000015 RID: 21 RVA: 0x00002534 File Offset: 0x00000734
}
}
public override void SetStaticDefaults() {
ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true;
}
{
DisplayName.SetDefault("Mio's Goggles");
Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!");
SacrificeTotal = 1;
}
What is the best place for these C# tutorials? It seems like it might be useful.The issue is you are closing out the method early.
Code:public override void SetStaticDefaults() { ArmorIDs.Head.Sets.DrawFullHair[equipSlotHead] = true; } { DisplayName.SetDefault("Mio's Goggles"); Tooltip.SetDefault("A Pair of Silver goggles you wear on your head!"); SacrificeTotal = 1; }
See here, you open the method with a bracket { then you have 1 line of code, and you close the method immediately with a bracket }
So the rest of this code is outside of SetStaticDefaults() but it should be inside the method.
Can I give a friendly suggestion that you should take a quick 15 min C# tutorial online? Basic syntax is very easy to learn and you'll avoid these types of common errors. Also, if you use VS 2022, it will point these out as you code and even offer suggestions on how to fix them.
Hey thanks alot for your help. My problems have been squashed. The Tutorials helped alot, I also downloaded the VS Community 2022 which also helped pointing out the errors in my code, whereas VS Code did not. Thanks alot for your help!A really simple one is Learn C# - Free Interactive C# Tutorial