v.0.11.3 modding problem.

Castled

Terrarian
My issue has been resolved, so you don't need to say anything in this post
 
Last edited:
You need to add using Terraria; to the top of your file.

Whenever you get this error it's either because you've forgotten a using directive or you spelled the name of the class wrong. ;)

With that said, once you fix that issue, you're likely going to get another one in newItem; that should be NewItem with a capital N.
 
To Kazzymodus: I got 4 new errors after I edited the code with your recommendations. I only needed a recommendation for a different using directive / class: (NPC npc). I already knew that I should've put using Terraria;. Is there a using directive / class which is useable for NPC's in v.0.11.3?

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[7/ERROR] error CS0029: Cannot implicitly convert type 'int' to 'bool'

[7/ERROR] error CS1061: 'NPC' does not contain a definition for 'NewItem' and no accessible extension method 'NewItem' accepting a first argument of type 'NPC' could be found (are you missing a using directive or an assembly reference?)

[7/ERROR] error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

[7/ERROR] error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



Here is the edited code:

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace CastledsContent.NPCs
{
public class NpcLoot : GlobalNPC
{
private void NPCLoot(NPC npc)
{
if (npc.type = NPCID.MartianSaucerCore)
{
npc.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrokenSosCore"), 1);
}
}
}
}
 
To Kazzymodus: I got 4 new errors after I edited the code with your recommendations. I only needed a recommendation for a different using directive / class: (NPC npc). I already knew that I should've put using Terraria;. Is there a using directive / class which is useable for NPC's in v.0.11.3?

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[7/ERROR] error CS0029: Cannot implicitly convert type 'int' to 'bool'

[7/ERROR] error CS1061: 'NPC' does not contain a definition for 'NewItem' and no accessible extension method 'NewItem' accepting a first argument of type 'NPC' could be found (are you missing a using directive or an assembly reference?)

[7/ERROR] error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

[7/ERROR] error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



Here is the edited code:

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace CastledsContent.NPCs
{
public class NpcLoot : GlobalNPC
{
private void NPCLoot(NPC npc)
{
if (npc.type = NPCID.MartianSaucerCore)
{
npc.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrokenSosCore"), 1);
}
}
}
}
Some things:
1. Change ‘private void NPCLoot (NPC npc)’ to ‘public override void NPCLoot(NPC npc)’
2. Add a second equals sign to the if statement (npc.type == NPCID.MartianSaucerCore)
3. Change ‘npc.NewItem’ to ‘Item.NewItem’.
 
Some things:
1. Change ‘private void NPCLoot (NPC npc)’ to ‘public override void NPCLoot(NPC npc)’
2. Add a second equals sign to the if statement (npc.type == NPCID.MartianSaucerCore)
3. Change ‘npc.NewItem’ to ‘Item.NewItem’.

If im going to change npc.NewItem to item.NewItem, doesn't that mean that I should change: NpcLoot(NPC npc)?
 
No, keep that as (NPC npc). Also, make sure it's "Item.NewItem" with a capital I.

Now that I did that, I have fewer errors, but I keep getting this error, and I keep getting it twice:
MartianSaucerCore.cs(12,16 & 29) : error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement.

My best guess is that the error is at this line:
Item.NewItemsemicolon((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrokenSosCore"), 1);

I put semicolon because whenever I try to put in the code, it puts the crying emoticon at the semicolon + right bracket
 
Now that I did that, I have fewer errors, but I keep getting this error, and I keep getting it twice:
MartianSaucerCore.cs(12,16 & 29) : error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement.

My best guess is that the error is at this line:
Item.NewItemsemicolon((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrokenSosCore"), 1);

I put semicolon because whenever I try to put in the code, it puts the crying emoticon at the semicolon + right bracket
That error is in a different file called ‘MartianSaucerCore.cs’. Could you post that file?
 
Back
Top Bottom