fryguythe777th
Terrarian
Hello. I am currently creating an NPC for the first time using code from the ExampleMod. I am receiving multiple errors in my code, which is as follows:
using PogMod.Items.Banners;
using PogMod.Projectiles;
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace PogMod.NPCs
{
//ported from my tAPI mod because I'm lazy
public class YouthTwinklefish : ModNPC
{
public YouthTwinklefish() {
speed = 1f;
speedY = 1f;
acceleration = 0.05f;
accelerationY = 0.05f;
idleSpeed = 0.5f;
bounces = false;
}
public override void SetStaticDefaults() {
DisplayName.SetDefault("Youth Twinklefish");
}
public override void SetDefaults() {
npc.lifeMax = 200;
npc.damage = 90;
npc.defense = 0;
npc.knockBackResist = -0.1f;
npc.width = 26;
npc.height = 26;
npc.aiStyle = 14;
npc.noGravity = true;
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath1;
npc.value = Item.buyPrice(0, 0, 15, 0);
npc.hide = true;
banner = npc.type;
bannerItem = ModContent.ItemType<YouthTwinklefishBanner>();
}
public override void FindFrame(int frameHeight) {
npc.frame.Y = 0;
npc.rotation = 0f;
}
public override float SpawnChance(NPCSpawnInfo spawnInfo) {
return !spawnInfo.playerSafe ? SpawnCondition.HardmodeOceanMonster.Chance * 0.5f : 0f;
}
}
}
The area in my code with the issues is colored yellow. The issues are all the same; the names of all the variables do not exist in the current context. Here are the error messages:
[11:33:36] [Thread Pool Worker/ERROR] [tML]: /Users/patrickpowers/Library/Application Support/Terraria/ModLoader/Mod Sources/PogMod/NPCs/YouthTwinklefish.cs(15,3) : error CS0103: The name 'speed' does not exist in the current context
[11:33:36] [Thread Pool Worker/ERROR] [tML]: /Users/patrickpowers/Library/Application Support/Terraria/ModLoader/Mod Sources/PogMod/NPCs/YouthTwinklefish.cs(16,12) : error CS0103: The name 'speedY' does not exist in the current context
[11:33:36] [Thread Pool Worker/ERROR] [tML]: /Users/patrickpowers/Library/Application Support/Terraria/ModLoader/Mod Sources/PogMod/NPCs/YouthTwinklefish.cs(17,3) : error CS0103: The name 'acceleration' does not exist in the current context
[11:33:36] [Thread Pool Worker/ERROR] [tML]: /Users/patrickpowers/Library/Application Support/Terraria/ModLoader/Mod Sources/PogMod/NPCs/YouthTwinklefish.cs(18,12) : error CS0103: The name 'accelerationY' does not exist in the current context
[11:33:36] [Thread Pool Worker/ERROR] [tML]: /Users/patrickpowers/Library/Application Support/Terraria/ModLoader/Mod Sources/PogMod/NPCs/YouthTwinklefish.cs(19,3) : error CS0103: The name 'idleSpeed' does not exist in the current context
[11:33:36] [Thread Pool Worker/ERROR] [tML]: /Users/patrickpowers/Library/Application Support/Terraria/ModLoader/Mod Sources/PogMod/NPCs/YouthTwinklefish.cs(20,3) : error CS0103: The name 'bounces' does not exist in the current context
Thank you for reading my issue. I hope you will be able to assist me in fixing my code.
using PogMod.Items.Banners;
using PogMod.Projectiles;
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace PogMod.NPCs
{
//ported from my tAPI mod because I'm lazy
public class YouthTwinklefish : ModNPC
{
public YouthTwinklefish() {
speed = 1f;
speedY = 1f;
acceleration = 0.05f;
accelerationY = 0.05f;
idleSpeed = 0.5f;
bounces = false;
}
public override void SetStaticDefaults() {
DisplayName.SetDefault("Youth Twinklefish");
}
public override void SetDefaults() {
npc.lifeMax = 200;
npc.damage = 90;
npc.defense = 0;
npc.knockBackResist = -0.1f;
npc.width = 26;
npc.height = 26;
npc.aiStyle = 14;
npc.noGravity = true;
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath1;
npc.value = Item.buyPrice(0, 0, 15, 0);
npc.hide = true;
banner = npc.type;
bannerItem = ModContent.ItemType<YouthTwinklefishBanner>();
}
public override void FindFrame(int frameHeight) {
npc.frame.Y = 0;
npc.rotation = 0f;
}
public override float SpawnChance(NPCSpawnInfo spawnInfo) {
return !spawnInfo.playerSafe ? SpawnCondition.HardmodeOceanMonster.Chance * 0.5f : 0f;
}
}
}
The area in my code with the issues is colored yellow. The issues are all the same; the names of all the variables do not exist in the current context. Here are the error messages:
[11:33:36] [Thread Pool Worker/ERROR] [tML]: /Users/patrickpowers/Library/Application Support/Terraria/ModLoader/Mod Sources/PogMod/NPCs/YouthTwinklefish.cs(15,3) : error CS0103: The name 'speed' does not exist in the current context
[11:33:36] [Thread Pool Worker/ERROR] [tML]: /Users/patrickpowers/Library/Application Support/Terraria/ModLoader/Mod Sources/PogMod/NPCs/YouthTwinklefish.cs(16,12) : error CS0103: The name 'speedY' does not exist in the current context
[11:33:36] [Thread Pool Worker/ERROR] [tML]: /Users/patrickpowers/Library/Application Support/Terraria/ModLoader/Mod Sources/PogMod/NPCs/YouthTwinklefish.cs(17,3) : error CS0103: The name 'acceleration' does not exist in the current context
[11:33:36] [Thread Pool Worker/ERROR] [tML]: /Users/patrickpowers/Library/Application Support/Terraria/ModLoader/Mod Sources/PogMod/NPCs/YouthTwinklefish.cs(18,12) : error CS0103: The name 'accelerationY' does not exist in the current context
[11:33:36] [Thread Pool Worker/ERROR] [tML]: /Users/patrickpowers/Library/Application Support/Terraria/ModLoader/Mod Sources/PogMod/NPCs/YouthTwinklefish.cs(19,3) : error CS0103: The name 'idleSpeed' does not exist in the current context
[11:33:36] [Thread Pool Worker/ERROR] [tML]: /Users/patrickpowers/Library/Application Support/Terraria/ModLoader/Mod Sources/PogMod/NPCs/YouthTwinklefish.cs(20,3) : error CS0103: The name 'bounces' does not exist in the current context
Thank you for reading my issue. I hope you will be able to assist me in fixing my code.