square root of 1
Terrarian
Hi,
I'm extremely new to Terraria modding and C#, so bear with me please :C
So I'm working on a mod that changes the names of every vanilla item to something different, for inside joke reasons that I do not wish to share.
Obviously I didn't know how to do this, so I went to the googel to find out how to do such a thing, where I found a couple lines of code that use Item.SetNameOverride to essentially just change the name of an item, which I found here.
And here's what I used from that:
I just copied and pasted this and now my code looks like so (sorry I don't know how to explain C# classes and vars and whatnot, again bear with me please):
This worked.
So with that figured out, I decided to try copy and pasting that around 130 times to try to rename every single item in Terraria, shown here:
(please ignore the fact it's all copper shortsword, I just wanted to give an example because the actual code is accurately represented here and also it's kinda sus so shush)
I tested this, and it worked perfectly as far as I could tell. All the items I renamed were renamed properly, and it seemed to leave the rest alone.
Until I tested it with friends.
Apparently what it decided to do was randomly rename items whenever you picked them up and it wasn't even really consistent.
I tried searching this function but there is literally no other documentation on it besides that one forum linked above.
SO (tl;dr), I'm not sure what to do here. Is there something wrong with what I'm doing, and/or is there a better way to do this?
If I need to clarify anything please let me know. Again, I'm sorry I'm not well-versed in C# or Terraria modding
I'm extremely new to Terraria modding and C#, so bear with me please :C
So I'm working on a mod that changes the names of every vanilla item to something different, for inside joke reasons that I do not wish to share.
Obviously I didn't know how to do this, so I went to the googel to find out how to do such a thing, where I found a couple lines of code that use Item.SetNameOverride to essentially just change the name of an item, which I found here.
And here's what I used from that:
C#:
if (item.type == ItemID.Shuriken) {
item.SetNameOverride("Iron Shuriken");
}
C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CoolItemsTest0.Global
{
public class GlobalItemList : GlobalItem
{
public override void SetDefaults(Item item)
{
// Reserved for Copper Shortsword
if (item.type == ItemID.CopperShortsword)
{
item.SetNameOverride("Bronze Edition Crap Sword");
}
}
}
}
This worked.
So with that figured out, I decided to try copy and pasting that around 130 times to try to rename every single item in Terraria, shown here:
C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CoolItemsTest0.Global
{
public class GlobalItemList : GlobalItem
{
public override void SetDefaults(Item item)
{
// Reserved for Copper Shortsword
if (item.type == ItemID.CopperShortsword)
{
item.SetNameOverride("Bronze Edition Crap Sword");
}
//Start of Item List
if (item.type == ItemID.CopperShortsword)
{
item.SetNameOverride("Bronze Edition Crap Sword");
}
if (item.type == ItemID.CopperShortsword)
{
item.SetNameOverride("Bronze Edition Crap Sword");
}
if (item.type == ItemID.CopperShortsword)
{
item.SetNameOverride("Bronze Edition Crap Sword");
}
if (item.type == ItemID.CopperShortsword)
{
item.SetNameOverride("Bronze Edition Crap Sword");
}
if (item.type == ItemID.CopperShortsword)
{
item.SetNameOverride("Bronze Edition Crap Sword");
}
if (item.type == ItemID.CopperShortsword)
{
item.SetNameOverride("Bronze Edition Crap Sword");
}
if (item.type == ItemID.CopperShortsword)
{
item.SetNameOverride("Bronze Edition Crap Sword");
}
}
}
}
I tested this, and it worked perfectly as far as I could tell. All the items I renamed were renamed properly, and it seemed to leave the rest alone.
Until I tested it with friends.
Apparently what it decided to do was randomly rename items whenever you picked them up and it wasn't even really consistent.
I tried searching this function but there is literally no other documentation on it besides that one forum linked above.
SO (tl;dr), I'm not sure what to do here. Is there something wrong with what I'm doing, and/or is there a better way to do this?
If I need to clarify anything please let me know. Again, I'm sorry I'm not well-versed in C# or Terraria modding