tModLoader Official tModLoader Help Thread

I'm having a problem finishing this code for my custom vanity head. When I type item.Name I get an error saying "Property or indexer 'item.Name' cannot be assigned to -- it is read only." Also, Autoload says "Cannot find a suitable method to override." Can someone tell me what is wrong with my code?
 

Attachments

  • PunkDuddsHead.cs
    203 bytes · Views: 121
Is there some sort of Step by Step thing for this? I find it confusing trying to install this.

Are you talking about installing tmodloader?
**Read all of this before doing it, please
If so...
just go to the tmodloader website and then download the file. After you've done that open the file in file explorer or whatever you have. Before you do the next step, you need to make a backup of your Terraria.exe file. Then you can make a shortcut of the backup and when you extract the files in the next step so that you can play non-modded Terraria if you want. Next, extract all of the files to this folder (assuming you have Windows): C:\ProgramFiles(x86)\Steam\steamapps\common\Terraria. Next open the Terraria.exe file (not the backup you made). It should then launch the tmodloader version of Terraria.
If this is not what you were talking about, then please tell me what you were talking about.(PS, it helps to be a little more specific when you have questions ;) )
If you have any questions feel free to ask, I'll gladly answer them.
 
I have a question: on a mac, how would I quickly switch between modded and vanilla terraria? All descriptions of how to do this are made for windows. All of said descriptions (as far as I can tell) don't work on mac. If someone could help that'd be much appreciated. Thanks :D
 
I'm having a problem finishing this code for my custom vanity head. When I type item.Name I get an error saying "Property or indexer 'item.Name' cannot be assigned to -- it is read only." Also, Autoload says "Cannot find a suitable method to override." Can someone tell me what is wrong with my code?
To specify a name, you have to make it lowercase "item.name".
 
What? No. Item names are defined in SetStaticDefaults().
Code:
public override void SetStaticDefaults()
{
   DisplayName.SetDefault("Item Name");
   Tooltip.SetDefault("Tooltip Description");
}

Okay i fixed the item.name thing. I remember that now, thanks. I'm still having a problem with the autoload thing though.
[doublepost=1531593334,1531592947][/doublepost]
I have a question: on a mac, how would I quickly switch between modded and vanilla terraria? All descriptions of how to do this are made for windows. All of said descriptions (as far as I can tell) don't work on mac. If someone could help that'd be much appreciated. Thanks :D

You have to go into your files in your steam folder and just make a shortcut using both the Terraria.exe backup and the modded file. If you right click on the file there should be an option to make a shortcut.**Not sure if this works or not. I'm not very familiar with Mac but most computers are generally the same.
 
I didn't forget about that, at least not in my current version. Please note this is not in any way an up-to-date version. Here's an example of how you'd add a requiredTile
This is taken from a mod I'm currently working on ^^
Code:
Recipes.QuickRecipe(this, ItemID.SlimeStaff, 1, new int[,] { { ItemID.Gel, 200 }, { ModItems.OddStaff, 1 } }, TileID.TinkerersWorkbench);

If you want the above example, I can give you that snippet really quick,

Code:
        public static void QuickRecipe(Mod mod, int createItemType, int createItemStack, int[,] requiredItemsArray, int requiredTile)
        {
            ModRecipe recipe = new ModRecipe(mod);
            for (int i = 0; i < requiredItemsArray.Length / 2; i++)
            {
                recipe.AddIngredient(requiredItemsArray[i, 0], requiredItemsArray[i, 1]);
            }
            recipe.AddTile(requiredTile);
            recipe.SetResult(createItemType, createItemStack);
            recipe.AddRecipe();
        }
how did you do that little box you got for your replies and junk?
 
how did you do that little box you got for your replies and junk?
At the bottom right of someone's post, you can click the Reply link and it'll put it in your message as a quote block.

Or do you mean the code?
Press the Insert button next to the arrows and press Code
pQemoTE.png
 
I would like some help with a custom projectile, an animated one. All references I could find were outdated, and I've tried a lot. I have it in a gif and in a spritesheet png but neither shows up animated, but the projectile otherwise works fine. Here it is. Any help appreciated. Thanks.
 

Attachments

  • LenicusTome.cs
    1.3 KB · Views: 124
  • Lenicus.png
    Lenicus.png
    3.2 KB · Views: 122
  • Lenicus.gif
    Lenicus.gif
    52.1 KB · Views: 117
  • Lenicus.cs
    2.5 KB · Views: 152
Returned to the forums to ask a quick question.

If I want to have different worlds with separate mod packs, how would I go about it? Could I potentially disable the mods I don't want, enable the ones I do, reload the game, and make sure to only use the characters & worlds I want with the new mod pack, or will there be any bleeding happening?

Essentially, can I have multiple different worlds running on different mods?
 
No, I've used several different modpacks and no profiles have been corrupted. As long as you use the right characters and disable each modpack when you do a new one, you'll be ok.
 
Hello, I want to make a projectile with an animation like the ghastly glaive,what I have to do?
I already made the png with the animation, but when i try to use the weapon it shoot the entire png (all frame)
 
I would like some help with a custom projectile, an animated one. All references I could find were outdated, and I've tried a lot. I have it in a gif and in a spritesheet png but neither shows up animated, but the projectile otherwise works fine. Here it is. Any help appreciated. Thanks.
Try this:
Code:
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Lenicus");
            Main.projFrames[projectile.type] = 7; //This is an animated projectile
        }

        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();
            }
                       // Loop through the 56 animation frames, spending 15 ticks on each.
            if (++projectile.frameCounter >= 15)
            {
                projectile.frameCounter = 0;
                if (++projectile.frame >= 56)
                {
                    projectile.frame = 0;
                }
            }
        }
You should look at ExampleMod, that would help you with this sort of stuff.

Make sure you use the spritesheet
 
Right, so I've created a custom shadowflame hex doll type weapon. Unfortunately, I have a problem. When my weapon fires my projectile, it just goes in a straight line, like when you fire the shadowflame tentacle with a custom weapon. I've looked at the source code and cannot figure it out. What I'm asking is: How do I make my projectile curve randomly, like the shadowflame tentacle?
Please help if you can :)
 
Try this:
Code:
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Lenicus");
            Main.projFrames[projectile.type] = 7; //This is an animated projectile
        }

        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();
            }
                       // Loop through the 56 animation frames, spending 15 ticks on each.
            if (++projectile.frameCounter >= 15)
            {
                projectile.frameCounter = 0;
                if (++projectile.frame >= 56)
                {
                    projectile.frame = 0;
                }
            }
        }
You should look at ExampleMod, that would help you with this sort of stuff.

Make sure you use the spritesheet
Thanks, but where are the animated projectiles in ExampleMod?
 
I would like to add an image to the game at the cursor while the player is holding an item. Like how chairs and tables do when you hold them. But the image will not be the same as the item. Any help would be apreciated.
 
Back
Top Bottom