tModLoader Official tModLoader Help Thread

@pat1231 sorry idk how to quote xD

I fixed that issue based on what you said, found out some of the files didnt have the right name. However, now i get a new error when loading

Line 14, character 15

error CS1061: "Terraria.Projectile" does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type "Terraria.Projectile" could be found (are you missing a using directive or an assembly reference?)

---Code---

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;



public class MagicProjectile : ModProjectile
{
public override void SetDefaults()
{
projectile.name = ("Book Of Faults Projectile");
projectile.width = 40;
projectile.height = 40;
projectile.friendly = true;
projectile.penetrate = -1; //this is the projectile penetration
Main.projFrames[projectile.type] = 4; //this is projectile frames
projectile.hostile = false;
projectile.magic = true; //this make the projectile do magic damage
projectile.tileCollide = true; //this make that the projectile does not go thru walls
projectile.ignoreWater = true;
}

public override void AI()
{
//this is projectile dust
int DustID2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width + 2, projectile.height + 2, mod.DustType("DustName"), projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 20, default(Color), 2.9f);
Main.dust[DustID2].noGravity = true;
//this make that the projectile faces the right way
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
projectile.localAI[0] += 1f;
projectile.alpha = (int)projectile.localAI[0] * 2;

if (projectile.localAI[0] > 130f) //projectile time left before disappears
{
projectile.Kill();
}

}
public override bool PreDraw(SpriteBatch sb, Color lightColor) //this is where the animation happens
{
projectile.frameCounter++; //increase the frameCounter by one
if (projectile.frameCounter >= 10) //once the frameCounter has reached 10 - change the 10 to change how fast the projectile animates
{
projectile.frame++; //go to the next frame
projectile.frameCounter = 0; //reset the counter
if (projectile.frame > 3) //if past the last frame
projectile.frame = 0; //go back to the first frame
}
return true;
}
}
 
However, now i get a new error when loading
1. just mark what you wanna quote then there should be a little window where the word quote+ is in it: click that and then go to the reply and click in the lower left corner "insert quotes"
2. let me guess: you used a outdated tutorial
the name/description doesnt belong there
between the class and "setdefaults" you just put in this:

public override void SetStaticDefaults()
{
DisplayName.SetDefault("Name");
Tooltip.SetDefault("Description");
}
and that should solve this problem
3. i just saw you deleted the namespace
this isnt the way to go
it should look like that and it should be before the class:

namespace Aoa.Items.Weapons

in my case its first namespace (thats standard)
then there is "Aoa": its the name you gave the mod folder in the datas
after that you just have to see from there in which mod your .cs file is
and there you have it: just put the
directory of the file in there or there will be no sprite or even an error
 
Last edited:
1. just mark what you wanna quote then there should be a little window where the word quote+ is in it: click that and then go to the reply and click in the lower left corner "insert quotes"

Thanks xD

2. let me guess: you used a outdated tutorial
the name/description doesnt belong there
between the class and "setdefaults" you just put in this:

public override void SetStaticDefaults()
{
Displayname.SetDefault("Name");
Tooltip.SetDefault("Description");
}
and that should solve this problem

Ok ik this might start getting annoying, but i got more or less the same error. Ill past lines 10 to 17 here. the error points to line 17 character 24

public class MagicProjectile : ModProjectile
{
public override void SetStaticDefaults()
{
Displayname.SetDefault("Name");
Tooltip.SetDefault("Description");
}
public override void SetStaticDefaults();

EDIT just kidding the error is actually different: CS0111 Type "Magic.Projectile" already defines a member called "SetStaticDefault" with the same parameter types
[doublepost=1500665201,1500664932][/doublepost]Ok, as im clearly dumb i actually figured it out myself, by removing line 17 completely since it was basically a dupe

However, now i get this:

The name "Displayname" does not exist in the current context. Line 14 character 5
 
1.instead of "SetStaticDefaults", "SetDefaults"
2. i wrote "Displayname" but its "DisplayName"

So i changed the SetStaticDefaults in line 12 to SetDefaults, and changed Displayname to DisplayName. Got another error, so i added the "public override void SetStaticDefaults();" line back in after the codegroup you told me to paste in, this is the line i got rid of. Now its pointing to line 20, character 30, with the error "Type "Magic.Projectile" already defines a member called "SetDefaults" with the same parameter type"

Again i apologize for all this xD im literally brand new to coding, im using terraria to try and get a grasp of it. I swear ill save a template of this magic projectile code for reference when it works properly
[doublepost=1500666291,1500666258][/doublepost]This is like 20 btw:

public override void SetDefaults()
[doublepost=1500666626][/doublepost]Fixed that, it needed a ";"

Now it points to me having an invalid { token on line 21. I got rid of it, and then it pointed to the = on line 22, then the paranthesis, then the contents of the name in quotes i had. Im pretty sure its going to do this for all my spell books parameters, so ill paste those here

Lines 20 to 32

public override void SetDefaults();
{
projectile.name = ("Book Of Faults Projectile");
projectile.width = 40;
projectile.height = 40;
projectile.friendly = true;
projectile.penetrate = -1; //this is the projectile penetration
Main.projFrames[projectile.type] = 4; //this is projectile frames
projectile.hostile = false;
projectile.magic = true; //this make the projectile do magic damage
projectile.tileCollide = true; //this make that the projectile does not go thru walls
projectile.ignoreWater = true;
}
 
So i changed the SetStaticDefaults in line 12 to SetDefaults,
i just edit your codes
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace 1stfolder.2ndfolder //Just an example write your folder names instead

public class MagicProjectile : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefaults("Book Of Faults Projectile");
}
public override void SetDefaults()
{
projectile.width = 40;
projectile.height = 40;
projectile.friendly = true;
projectile.penetrate = -1; //this is the projectile penetration
Main.projFrames[projectile.type] = 4; //this is projectile frames
projectile.hostile = false;
projectile.magic = true; //this make the projectile do magic damage
projectile.tileCollide = true; //this make that the projectile does not go thru walls
projectile.ignoreWater = true;
}

public override void AI()
{
//this is projectile dust
int DustID2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width + 2, projectile.height + 2, mod.DustType("DustName"), projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 20, default(Color), 2.9f);
Main.dust[DustID2].noGravity = true;
//this make that the projectile faces the right way
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
projectile.localAI[0] += 1f;
projectile.alpha = (int)projectile.localAI[0] * 2;

if (projectile.localAI[0] > 130f) //projectile time left before disappears
{
projectile.Kill();
}

}
public override bool PreDraw(SpriteBatch sb, Color lightColor) //this is where the animation happens
{
projectile.frameCounter++; //increase the frameCounter by one
if (projectile.frameCounter >= 10) //once the frameCounter has reached 10 - change the 10 to change how fast the projectile animates
{
projectile.frame++; //go to the next frame
projectile.frameCounter = 0; //reset the counter
if (projectile.frame > 3) //if past the last frame
projectile.frame = 0; //go back to the first frame
}
return true;
}
}

you gotta look if it works i think it would. just paste it into your file

will be a lot easier '^^
 
I swear im trying QQ

So, for line 8 character 27 i got an error saying "{ expected" so i added one. It asked me to add a } on like 57 too, so like 57 is exactly as written: }}

Now im getting that one error again. Terraria.ModLoader.ModTranslation does not contain a definition for setdefaults and no extension method for setdefaults accepting a first argument of Terraria.ModLoader.ModTranslation could be found
 
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SaobiesMod.Items //Just an example write your folder names instead
{
public class MagicProjectile : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefaults("Book Of Faults Projectile");
}
public override void SetDefaults()
{
projectile.width = 40;
projectile.height = 40;
projectile.friendly = true;
projectile.penetrate = -1; //this is the projectile penetration
Main.projFrames[projectile.type] = 4; //this is projectile frames
projectile.hostile = false;
projectile.magic = true; //this make the projectile do magic damage
projectile.tileCollide = true; //this make that the projectile does not go thru walls
projectile.ignoreWater = true;
}

public override void AI()
{
//this is projectile dust
int DustID2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width + 2, projectile.height + 2, mod.DustType("DustName"), projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 20, default(Color), 2.9f);
Main.dust[DustID2].noGravity = true;
//this make that the projectile faces the right way
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
projectile.localAI[0] += 1f;
projectile.alpha = (int)projectile.localAI[0] * 2;

if (projectile.localAI[0] > 130f) //projectile time left before disappears
{
projectile.Kill();
}

}
public override bool PreDraw(SpriteBatch sb, Color lightColor) //this is where the animation happens
{
projectile.frameCounter++; //increase the frameCounter by one
if (projectile.frameCounter >= 10) //once the frameCounter has reached 10 - change the 10 to change how fast the projectile animates
{
projectile.frame++; //go to the next frame
projectile.frameCounter = 0; //reset the counter
if (projectile.frame > 3) //if past the last frame
projectile.frame = 0; //go back to the first frame
}
return true;
}
}}
 
... OH GOD!!
how did i miss THAT??

DisplayName.SetDefault()

...not "SetDefaults" but "SetDefault"!!!

XDD

Thanks for being so patient and helping me so far. We seem to be past that issue now. Its coming up with an error for line 8 character 35, saying "{ expected"

Here is line 8

namespace SaobiesMod.Items.Weapons; //Just an example write your folder names instead
[doublepost=1500669086,1500669043][/doublepost]Just to clarify, i did try adding a { in like 9, and i also tried adding one right at the end of line 8. Neither seemed to fix it
 
Thanks for being so patient and helping me so far.
yeah thats how i am '^^
but the code (the projectile itself)worked for me

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SaobiesMod.Item //Just an example write your folder names instead
{
public class magicprojectile : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefaults("Book Of Faults Projectile");
}
public override void SetDefaults()

this is the code that worked for me
gotta try out if its works if not send again all the code which you have at the moment
 
Got a string of issues i tried to solve myself, and it ended on the issue about a certain thing already defining a class

Just to clarify, this spell tome im making is supposed to be an late pre-hardmode tome that causes ichor. And this is just the projectile script, it hasnt gotten to the weapon script yet, so that might be riddled with issues too

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SaobiesMod.Item //Just an example write your folder names instead
{
public class magicprojectile : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefaults("Book Of Faults Projectile");
}
public override void SetDefaults()

public override void SetDefault()
{
projectile.width = 40;
projectile.height = 40;
projectile.friendly = true;
projectile.penetrate = -1; //this is the projectile penetration
Main.projFrames[projectile.type] = 4; //this is projectile frames
projectile.hostile = false;
projectile.magic = true; //this make the projectile do magic damage
projectile.tileCollide = true; //this make that the projectile does not go thru walls
projectile.ignoreWater = true;
}

public override void AI()
{
//this is projectile dust
int DustID2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width + 2, projectile.height + 2, mod.DustType("DustName"), projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 20, default(Color), 2.9f);
Main.dust[DustID2].noGravity = true;
//this make that the projectile faces the right way
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
projectile.localAI[0] += 1f;
projectile.alpha = (int)projectile.localAI[0] * 2;

if (projectile.localAI[0] > 130f) //projectile time left before disappears
{
projectile.Kill();
}

}
public override bool PreDraw(SpriteBatch sb, Color lightColor) //this is where the animation happens
{
projectile.frameCounter++; //increase the frameCounter by one
if (projectile.frameCounter >= 10) //once the frameCounter has reached 10 - change the 10 to change how fast the projectile animates
{
projectile.frame++; //go to the next frame
projectile.frameCounter = 0; //reset the counter
if (projectile.frame > 3) //if past the last frame
projectile.frame = 0; //go back to the first frame
}
return true;
}
}}
 
public override void SetStaticDefaults()
{
DisplayName.SetDefaults("Book Of Faults Projectile");
}
public override void SetDefaults()

public override void SetDefault()
the problem are the two "SetDefault"s
just delete "SetDefault"
and DisplayName.SetDefault
instead of DisplayName.SetDefaults
 
Lines 8 through 19 now look like this

namespace SaobiesMod.Item //Just an example write your folder names instead
{
public class magicprojectile : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Book Of Faults Projectile");
}
public override void SetDefault()


{

So i got this issue about the games saying SaobiesMod.item.magicprojectile.SetDefault() is not valid. So i added a ; after SaobiesMod.Items

Now its saying a { is expected on that same line, same character. So i deleted the ; and put a { there. The error then returned for line 9 character 1, saying a namespace cannot directly contain members such as fields or methods
 
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SaobiesMod.Item //Just an example write your folder names instead
{
    public class magicprojectile : ModProjectile
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Book Of Faults Projectile");
        }

        public override void SetDefaults()
        {
            projectile.width = 40;
            projectile.height = 40;
            projectile.friendly = true;
            projectile.penetrate = -1; //this is the projectile penetration
            Main.projFrames[projectile.type] = 4; //this is projectile frames
            projectile.hostile = false;
            projectile.magic = true; //this make the projectile do magic damage
            projectile.tileCollide = true; //this make that the projectile does not go thru walls
            projectile.ignoreWater = true;
        }

        public override void AI()
        {
            //this is projectile dust
            int DustID2 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 2f), projectile.width + 2, projectile.height + 2, mod.DustType("DustName"), projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 20, default(Color), 2.9f);
            Main.dust[DustID2].noGravity = true;
            //this make that the projectile faces the right way
            projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
            projectile.localAI[0] += 1f;
            projectile.alpha = (int)projectile.localAI[0] * 2;

            if (projectile.localAI[0] > 130f) //projectile time left before disappears
            {
                projectile.Kill();
            }

        }
        public override bool PreDraw(SpriteBatch sb, Color lightColor) //this is where the animation happens
        {
            projectile.frameCounter++; //increase the frameCounter by one
            if (projectile.frameCounter >= 10) //once the frameCounter has reached 10 - change the 10 to change how fast the projectile animates
            {
                projectile.frame++; //go to the next frame
                projectile.frameCounter = 0; //reset the counter
                if (projectile.frame > 3) //if past the last frame
                    projectile.frame = 0; //go back to the first frame
            }
            return true;
        }
    }
}

sorry for my inpatience but here are the codess they should work fully fine
just copy/paste them and try to understand them if you need anymore questions you can also pm me before we fill up this whole thread '^^
 
Back
Top Bottom