tModLoader Official tModLoader Help Thread

I'm making a magic weapon and these errors keep popping up

c:\Users\Skultar\Documents\My Games\Terraria\ModLoader\Mod Sources\MyMod\Items\Weapons\MagicWeapon.cs.cs(21,4) : error CS0118: 'Terraria.ModLoader.ModItem.item' is a 'property' but is used like a 'type'

c:\Users\Skultar\Documents\My Games\Terraria\ModLoader\Mod Sources\MyMod\Items\Weapons\MagicWeapon.cs.cs(32,21) : error CS1061: 'Terraria.ModLoader.Mod' does not contain a definition for 'projectileType' and no extension method 'projectileType' accepting a first argument of type 'Terraria.ModLoader.Mod' could be found (are you missing a using directive or an assembly reference?)
snip
(are you missing a using directive or an assembly reference?) covers itself pretty well: you're missing a "using" directive at the top. Try going through various example code items that do something like you want to do, and look to see what else they have up there. Hint: it involves your other message.

Cheesy newbie method I was using til I started getting a feel for "using" directives: use Visual Studio instead of Notepad++ or whatever. Dump a mess of "using" directives into the top of your page if you think they MIGHT be relevant, then build your code. Any "using" directive you don't need, VS will grey out and, if you mouse over it, VS will tell you it's not being used. You can delete those.
 
2 new errors

c:\Users\Connor\Documents\My Games\Terraria\ModLoader\Mod Sources\MyMod\Items\Weapons\MagicWeapon.cs.cs(32,17) : error CS0428: Cannot convert method group 'ProjectileType' to non-delegate type 'int'. Did you intend to invoke the method?

c:\Users\Connor\Documents\My Games\Terraria\ModLoader\Mod Sources\MyMod\Items\Weapons\MagicWeapon.cs.cs(32,37) : error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
 
2 new errors

c:\Users\Connor\Documents\My Games\Terraria\ModLoader\Mod Sources\MyMod\Items\Weapons\MagicWeapon.cs.cs(32,17) : error CS0428: Cannot convert method group 'ProjectileType' to non-delegate type 'int'. Did you intend to invoke the method?

c:\Users\Connor\Documents\My Games\Terraria\ModLoader\Mod Sources\MyMod\Items\Weapons\MagicWeapon.cs.cs(32,37) : error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
A lot of this is syntax. Go back and look through Example Mod a bit, because, as far as I can see, the syntax of line 32 (the item.shoot line) is way off. Code syntax is very exacting... you have to be careful where you put spaces, how you spell and capitalize things, and which punctuation you put where. I'm gonna be a bit of a pest and point back to here. You know... one page back.
 
Last edited:
If I let it run using generic critter code, the frames actually animate alright, BUT since Bunny looks for seven frames, my critter flickers out every seventh animation because it only has six frames.

It seems more like I'm just having trouble getting the frames for my custom animation to advance... with various iterations of the above, it stays stuck on frame 0. I fiddled with "Main.npcFrameCount[npc.type] = 6;" in SetStaticDefaults and had rolling frame animation problems when I reduced it (back when I was experimenting with generic anim for Bunny), so that seems to inform the system what to look for (using 174 Ypixel PNG, six frame count, so each frame is 29 pixel frame height). Under the generic code, it seems to see the frame height alright, and frame 0 is appearing complete and in-place as-is, so I think it's seeing frame height with this mechanic.

However, the above is pulled from Vanilla Bunny animation code (under VanillaFindFrame) and boiled down slightly because Vanilla code is a bit overwrought when taken piecemeal (this code used eight lines to establish "npc.spriteDirection = npc.direction;"), so, at this point, I'm just walking through the code trying to work out the logic (thus the comments), and wondering why it won't advance from 0 when in motion. Additional note: when it does move, it bobs up and down a little (I think in time with Bunny hops, so not unusual), but, even though Y position is changing regularly, the code at the bottom for Y velocity frames is also not kicking in.

I'm going to worry about AI issues once I have this animation stuff worked out and understand it a bit better; there's a lot of AI work I'd like to do, if I can just get the basics to basically behave. That addendum gives me a place to start looking, though.

Edit: Actually, there's a lot of mechanical stuff there that either shows me something or confirms something I thought I'd worked out, so thanks!
Glad I was of some help.

Btw, I think the reason that your animation is bobbing up and down a little is because of the following line:
npc.frame.Y = npc.frame.Y + 1;
That's only moving the texture by one pixel, not one frame. See if + 29 behaves the way you want.
 
Glad I was of some help.

Btw, I think the reason that your animation is bobbing up and down a little is because of the following line:
npc.frame.Y = npc.frame.Y + 1;
That's only moving the texture by one pixel, not one frame. See if + 29 behaves the way you want.
I stand corrected! I tried the solution you suggested and it smoothed out the critter's animation. Then I second-guessed my reasoning, went back and changed the max frame check to "if (npc.frame.Y >= 145)" (the top of the final frame), and it ALMOST works perfectly! Only one bug I'm facing at this point... it sort of "levitates" slightly up upslopes, and hangs in the air slightly down downslopes. I was hoping making adjustments to the Y velocity frame determinations would change that, but they haven't. Basically, if there's a 1-brick-wide divot in the ground with slope on each side, it'll walk right over it and only drop to meet the ground at the very last moment before the slope comes back up to level. However, it stands and walks just fine on level ground! Exciting!

Thanks again! Sorry for being so dismissive; just goes to show that I should try a suggestion rather than take it for granted.

Edit: If anyone wants to take a look, for their own edification or to help me troubleshoot the rest of it, here (I'm doing preliminary experimentation with a modified Bunny sprite stripe with frame 2 removed, so six frames, but my final plans are for something very different):
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace FarLandsMod.NPCs
{
    public class SnowHare : ModNPC
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Snow Hare");
            Main.npcFrameCount[npc.type] = 6;
        }

        public override void SetDefaults()
        {
            npc.width = 43;
            npc.height = 29;
            npc.friendly = true;
            npc.lifeMax = 5;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath1;
            npc.aiStyle = 7;
            aiType = NPCID.Bunny;
        }

        public override float SpawnChance(NPCSpawnInfo spawnInfo)
        {
            return SpawnCondition.OverworldDaySnowCritter.Chance * 0.1f;
        }
        public override void FindFrame(int frameHeight)
        {
            if (npc.velocity.Y == 0f)
            {
                npc.spriteDirection = npc.direction;
                if (npc.velocity.X == 0f)
                {
                    npc.frame.Y = 0;
                    npc.frameCounter = 0;
                }
                npc.frameCounter++;
                if (npc.frameCounter > 5)
                {
                    npc.frame.Y = npc.frame.Y + 29;
                    npc.frameCounter = 0;
                }
                if (npc.frame.Y >= 145)
                {
                    npc.frame.Y = 0;
                }
            }
            else
            {
                if (npc.velocity.Y < -0.5f)
                {
                    npc.frameCounter = 0;
                    npc.frame.Y = 116;
                }
                if (npc.velocity.Y > 0.5f)
                {
                    npc.frameCounter = 0;
                    npc.frame.Y = 87;
                }
            }
        }
    }
}

Edit 2, Electric Boogaloo: I can't afford much at all, but I would gladly donate for a decent animation tutorial, if that were an option. Obviously, there are plenty of people who have successfully animated things for stuff... it'd be nice to be able to learn from them.
 
Last edited:
So I'm sure most people have already solved this problem but I stuck with the older version of tmodloader so I never got around to fixing this problem so if anyone knows how to fix it I would appreciate it.

When I load up my game I get this message:
System.EntryPointNotFoundException: Unable to find an entry point named 'Init' in DLL 'CSteamworks'.
at Steamworks.NativeMethods.SteamAPI_Init()
at Terraria.Social.Steam.CoreSocialModule.Initialize()
at Terraria.Social.SocialAPI.Initialize(Nullable`1 mode)
at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs)

I saw some people had the solution to this when it was an issue but I have since forgot.
 
So I'm sure most people have already solved this problem but I stuck with the older version of tmodloader so I never got around to fixing this problem so if anyone knows how to fix it I would appreciate it.

When I load up my game I get this message:
System.EntryPointNotFoundException: Unable to find an entry point named 'Init' in DLL 'CSteamworks'.
at Steamworks.NativeMethods.SteamAPI_Init()
at Terraria.Social.Steam.CoreSocialModule.Initialize()
at Terraria.Social.SocialAPI.Initialize(Nullable`1 mode)
at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs)

I saw some people had the solution to this when it was an issue but I have since forgot.
https://github.com/blushiemagic/tMo...-an-entry-point-named-init-in-dll-csteamworks
 
i have a simple question, when setting up a multiplayer server, does my friend have to install the same mods? if so, what happens if there are different mods installed? For instance "recipe browser".
 
I have a question myself, when i go onto my terraria main menu, and i go into the browser, it says "the game has crashed accessing web resources", and i havent even downloaded any mods yet. Help?
 
How would you go about using a config file to change the sprite of an item?
Ex:
TileA has SpriteA. SpriteA isn't animated.
I want TileA to use SpriteB and SpriteSheetB if the config says to.
How would I do this, given it's possible?
 
Hello, I would Like to ask if there is a way to make an item to change colors like the ancient manipulator (it's a normal tile with a gray orb in the center which changes colors through code) and a projectile like the one from last prism (again white and gray sprite which changes colors through code)?
 
Hello, I would Like to ask if there is a way to make an item to change colors like the ancient manipulator (it's a normal tile with a gray orb in the center which changes colors through code) and a projectile like the one from last prism (again white and gray sprite which changes colors through code)?
Yes, those are all possible, it might be useful to come to the discord chat and ask there.
 
Hello, I would Like to ask if there is a way to make an item to change colors like the ancient manipulator (it's a normal tile with a gray orb in the center which changes colors through code) and a projectile like the one from last prism (again white and gray sprite which changes colors through code)?
Yes, those are all possible, it might be useful to come to the discord chat and ask there.
Ok thanks, but in which room? General or Help?
 
Biome looks like this: ZZ.PNG
Grass sprite (tile): ShadaineGrass.png
My biome's grass is spreading very weirdly; it straight up becomes invisible. How can I fix this?
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace Erilipah.Tiles
{
    public class ShadaineGrass : ModTile
    {
        public override void SetDefaults()
        {
            Main.tileSolid[Type] = true;
            Main.tileMergeDirt[Type] = true;
            Main.tileBlockLight[Type] = true;
            Main.tileLighted[Type] = true;
            AddMapEntry(new Color(10, 10, 15));
            mineResist = 1f;
            dustType = 54;
            minPick = 50;
        }

        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            r = 0f;
            g = 0f;
            b = 0.15f;
        }

        /*
                public override int SaplingGrowthType(ref int style)
        {
            style = 0;
            return mod.TileType("ExampleSapling");
        }*/

        public override void RandomUpdate(int i, int j)
        {
            //i = x coord, j = y coord
            Tile tile = Main.tile[(int)i + Main.rand.Next(-7, 7), (int)j + Main.rand.Next(-1, 1)];
            if (tile != null && tile.type == 1) tile.type = (ushort)mod.TileType("ShadaineStone");

            Tile tile3 = Main.tile[(int)i + Main.rand.Next(-1, 1), (int)j + Main.rand.Next(-7, 7)];
            if (tile3 != null && tile3.type == 2) tile3.type = (ushort)mod.TileType("ShadaineGrass");
            Tile tile5 = Main.tile[(int)i + Main.rand.Next(-10, 10), (int)j + Main.rand.Next(-10, 10)];
            if (tile5 != null && tile5.type == 2) tile5.type = (ushort)mod.TileType("ShadaineGrass");

            Tile tile2 = Main.tile[(int)i + Main.rand.Next(-1, 1), (int)j + Main.rand.Next(-7, 7)];
            if (tile2 != null && tile2.type == 60) tile2.type = (ushort)mod.TileType("ShadaineGrass");

            Tile tile1 = Main.tile[(int)i + Main.rand.Next(-1, 1), (int)j + Main.rand.Next(-7, 7)];
            if (tile1 != null && tile1.type == 23) tile1.type = (ushort)mod.TileType("ShadaineGrass");

            Tile tile4 = Main.tile[(int)i + Main.rand.Next(-1, 1), (int)j + Main.rand.Next(-7, 7)];
            if (tile4 != null && tile4.type == 199) tile4.type = (ushort)mod.TileType("ShadaineGrass");
        }

        public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem)
        {
            Tile tile = Main.tile[(int)i, (int)j];
        }
    }
}
 
Biome looks like this: View attachment 187468
Grass sprite (tile): View attachment 187469
My biome's grass is spreading very weirdly; it straight up becomes invisible. How can I fix this?
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace Erilipah.Tiles
{
    public class ShadaineGrass : ModTile
    {
        public override void SetDefaults()
        {
            Main.tileSolid[Type] = true;
            Main.tileMergeDirt[Type] = true;
            Main.tileBlockLight[Type] = true;
            Main.tileLighted[Type] = true;
            AddMapEntry(new Color(10, 10, 15));
            mineResist = 1f;
            dustType = 54;
            minPick = 50;
        }

        public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
        {
            r = 0f;
            g = 0f;
            b = 0.15f;
        }

        /*
                public override int SaplingGrowthType(ref int style)
        {
            style = 0;
            return mod.TileType("ExampleSapling");
        }*/

        public override void RandomUpdate(int i, int j)
        {
            //i = x coord, j = y coord
            Tile tile = Main.tile[(int)i + Main.rand.Next(-7, 7), (int)j + Main.rand.Next(-1, 1)];
            if (tile != null && tile.type == 1) tile.type = (ushort)mod.TileType("ShadaineStone");

            Tile tile3 = Main.tile[(int)i + Main.rand.Next(-1, 1), (int)j + Main.rand.Next(-7, 7)];
            if (tile3 != null && tile3.type == 2) tile3.type = (ushort)mod.TileType("ShadaineGrass");
            Tile tile5 = Main.tile[(int)i + Main.rand.Next(-10, 10), (int)j + Main.rand.Next(-10, 10)];
            if (tile5 != null && tile5.type == 2) tile5.type = (ushort)mod.TileType("ShadaineGrass");

            Tile tile2 = Main.tile[(int)i + Main.rand.Next(-1, 1), (int)j + Main.rand.Next(-7, 7)];
            if (tile2 != null && tile2.type == 60) tile2.type = (ushort)mod.TileType("ShadaineGrass");

            Tile tile1 = Main.tile[(int)i + Main.rand.Next(-1, 1), (int)j + Main.rand.Next(-7, 7)];
            if (tile1 != null && tile1.type == 23) tile1.type = (ushort)mod.TileType("ShadaineGrass");

            Tile tile4 = Main.tile[(int)i + Main.rand.Next(-1, 1), (int)j + Main.rand.Next(-7, 7)];
            if (tile4 != null && tile4.type == 199) tile4.type = (ushort)mod.TileType("ShadaineGrass");
        }

        public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem)
        {
            Tile tile = Main.tile[(int)i, (int)j];
        }
    }
}
You've Used the wrong Spritesheet I think (if that's how it's called). Had the same problem, but then I used this one instead and it works like a charm!
 

Attachments

  • Tile_Template.png
    Tile_Template.png
    12.5 KB · Views: 1,012
Hello, ive been trying to use Tmod Loader but this keeps popping up

Field not found: 'Terraria.Entity.name'.
at imkSushisNamePack.imkSushisNamePackGlobalItem.SetDefaults(Item item)
at Terraria.ModLoader.ItemLoader.SetDefaults(Item item, Boolean createModItem)
at Terraria.ModLoader.Mod.SetupContent()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)

as soon as i open this shows, how can i fix this?


Im not sure exactly but im prety sure
-Imkushi (and the name packt etc)
-Calamity
-Thorium
- (not sure if it is) enemy prefixes
and alot more, i cant check because as soon as i open it it starts to check them mods and it does, well that, ive tried "open logs" and "continue" but it just shows it again
 
Back
Top Bottom