tModLoader Terraria Eevee NPC

RinGodOfAnger

Official Terrarian
Hey I'm trying to make the code for a Terraria Eevee NPC, but it keeps saying ''A namespace cannot directly contain members such as fields or methods'', can someone help me? this is the code so far:


public static bool TownSpawn() {
if(Main.hardMode)
return true;
else
return false;
}
public static string SetName () {
int result = Main.rand.Next(4);
string name = "";

if (result == 0)
{
name = "Loneliness";
}
else if (result == 1)
{
name = "Lonliness";
}
return name;

}
public static string Chat() {
int result = Main.rand.Next(3);
string text = "";
if (result == 0)
{
text = "Go away...";
}
else if (result == 1)
{
text = "Hello...";
}
else if (result == 2)
{
text = "Why have I got red eyes? BECAUSE I'M DEAD YOU IDIOT";
}
else if (result == 3)
{
text = "What do you mean my unholy arrows are expencive... ):";
}

return text;
}
public static void SetupShop(Chest chest) {
int index=0;
chest.item[index].SetDefaults("CorruptionKey");
chest.item[index].value = 55000;
index++;
chest.item[index].SetDefaults("CrimsonKey");
chest.item[index].value = 55000;
index++;
chest.item[index].SetDefaults("ShadowScale");
chest.item[index].value = 5000;
index++;
chest.item[index].SetDefaults("UnholyArrow");
chest.item[index].value = 1040;
index++;
chest.item[index].SetDefaults("UnholyWater");
chest.item[index].value = 40;
index++;
chest.item[index].SetDefaults("UnholyTrident");
chest.item[index].value = 700000;
index++;
}
 
Hey I'm trying to make the code for a Terraria Eevee NPC, but it keeps saying ''A namespace cannot directly contain members such as fields or methods'', can someone help me? this is the code so far:


public static bool TownSpawn() {
if(Main.hardMode)
return true;
else
return false;
}
public static string SetName () {
int result = Main.rand.Next(4);
string name = "";

if (result == 0)
{
name = "Loneliness";
}
else if (result == 1)
{
name = "Lonliness";
}
return name;

}
public static string Chat() {
int result = Main.rand.Next(3);
string text = "";
if (result == 0)
{
text = "Go away...";
}
else if (result == 1)
{
text = "Hello...";
}
else if (result == 2)
{
text = "Why have I got red eyes? BECAUSE I'M DEAD YOU IDIOT";
}
else if (result == 3)
{
text = "What do you mean my unholy arrows are expencive... ):";
}

return text;
}
public static void SetupShop(Chest chest) {
int index=0;
chest.item[index].SetDefaults("CorruptionKey");
chest.item[index].value = 55000;
index++;
chest.item[index].SetDefaults("CrimsonKey");
chest.item[index].value = 55000;
index++;
chest.item[index].SetDefaults("ShadowScale");
chest.item[index].value = 5000;
index++;
chest.item[index].SetDefaults("UnholyArrow");
chest.item[index].value = 1040;
index++;
chest.item[index].SetDefaults("UnholyWater");
chest.item[index].value = 40;
index++;
chest.item[index].SetDefaults("UnholyTrident");
chest.item[index].value = 700000;
index++;
}
You need to have a class inside the namespace, please look up Basic and Advanced C# tutorials
 

Hey I'm trying to make the code for a Terraria Eevee NPC, but it keeps saying ''A namespace cannot directly contain members such as fields or methods'', can someone help me? this is the code so far:


public static bool TownSpawn() {
if(Main.hardMode)
return true;
else
return false;
}
public static string SetName () {
int result = Main.rand.Next(4);
string name = "";

if (result == 0)
{
name = "Loneliness";
}
else if (result == 1)
{
name = "Lonliness";
}
return name;

}
public static string Chat() {
int result = Main.rand.Next(3);
string text = "";
if (result == 0)
{
text = "Go away...";
}
else if (result == 1)
{
text = "Hello...";
}
else if (result == 2)
{
text = "Why have I got red eyes? BECAUSE I'M DEAD YOU IDIOT";
}
else if (result == 3)
{
text = "What do you mean my unholy arrows are expencive... ):";
}

return text;
}
public static void SetupShop(Chest chest) {
int index=0;
chest.item[index].SetDefaults("CorruptionKey");
chest.item[index].value = 55000;
index++;
chest.item[index].SetDefaults("CrimsonKey");
chest.item[index].value = 55000;
index++;
chest.item[index].SetDefaults("ShadowScale");
chest.item[index].value = 5000;
index++;
chest.item[index].SetDefaults("UnholyArrow");
chest.item[index].value = 1040;
index++;
chest.item[index].SetDefaults("UnholyWater");
chest.item[index].value = 40;
index++;
chest.item[index].SetDefaults("UnholyTrident");
chest.item[index].value = 700000;
index++;
}
You need to have a class inside the namespace, please look up Basic and Advanced C# tutorials
how do i do that? can you show me what I need to type please?
 
It would be like "
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModName.NPCs.Eevee
{
public class Eevee : ModNPC
{"

then put all your code

then put 3 more brackets at the end
 
It would be like "
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModName.NPCs.Eevee
{
public class Eevee : ModNPC
{"

then put all your code

then put 3 more brackets at the end
I tried what you said and now I've got error CS1503: Argument 1: cannot convert 'string' to 'int'
 
Back
Top Bottom