tModLoader Error in the code of my pet

Zeta_Undead

Terrarian
These are the mistakes:

The sequence does not contain any matching elements
In System.Linq.Enumerable.Single [TSource] (IEnumerable`1 source, Func`2 predicate)
In Terraria.ModLoader.AssemblyManager.InstantiateMods (List`1 modsToLoad)

C: \ Users \ edu \ Documents \ My Games \ Terraria \ ModLoader \ Mod Sources \ YourModName \ Projectiles \ PetName.cs (28,13): Error CS0246: Can not find the type or namespace name 'MyPlayer '(Are you missing a using directive or an assembly reference?)


-----------------------------------------------------------------------------------
This is MyPlayer code:

using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;

namespace YourModName
{
public class MyPlayer : ModPlayer
{
public bool Pet = false;

----------------------------------------------------------------------------------
This is my pet code:

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

namespace YourModName.Projectiles
{
public class PetName : ModProjectile
{
public override void SetDefaults()
{
projectile.CloneDefaults(ProjectileID.ZephyrFish);
projectile.name = "Cool Pet";
aiType = ProjectileID.ZephyrFish;
Main.projFrames[projectile.type] = 4;
Main.projPet[projectile.type] = true;
}

public override bool PreAI()
{
Player player = Main.player[projectile.owner];
player.zephyrfish = false;
return true;
}

public override void AI()
{
Player player = Main.player[projectile.owner];
MyPlayer modPlayer = player.GetModPlayer<MyPlayer>(mod);
if (player.dead)
{
modPlayer.Pet = false;
}
if (modPlayer.Pet)
{
projectile.timeLeft = 2;
}
}
}
}

----------------------------------------------------------------------
This is the invoker's code:

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

namespace YourModName.Items
{
public class PetCall : ModItem
{
public override void SetDefaults()
{
item.CloneDefaults(ItemID.ZephyrFish);
item.name = "Cool Pet";
item.toolTip = "Summons a Cool Pet to follow you";
item.shoot = mod.ProjectileType("PetName");
item.buffType = mod.BuffType("PetBuff");
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.AddTile(null, "WBName");
recipe.SetResult(this);
recipe.AddRecipe();
}

public override void UseStyle(Player player)
{
if (player.whoAmI == Main.myPlayer && player.itemTime == 0)
{
player.AddBuff(item.buffType, 3600, true);
}
}
}
}

---------------------------------------------------------------------------------------------------

I also have the buff code, but I do not think that has to do, because I just fixed an error with that code and then I had an error with the PetName:


C: \ Users \ edu \ Documents \ My Games \ Terraria \ ModLoader \ Mod Sources \ YourModName \ Projectiles \ PetName.cs (28,13): Error CS0246: Can not find the type or namespace name 'MyPlayer '(Are you missing a using directive or an assembly reference?)

-------------------------------------------------------------------------------------------------------------------------

I'm practically new to mods, so this may be a super easy thing to do. By the way, sorry if something is misspelled, but I am spanish speaking and all this is written with the Google Translator.
I await your answers.:happy:
 
Moving to General Mod Discussion.

@NuovaPrime, you can Report the first post in a thread if you think it's in a wrong section, and then the forum staff will decide if it needs to be moved. Reporting to move a thread won't get the thread creator in trouble, it just helps us keep the forums organized. Thanks.
 
Back
Top Bottom