tModLoader Official tModLoader Help Thread

hi anyone know what this means? my terraria has been weird lately too. sometimes when i talk to NPCs, there's no dialogue boxes or cant use any items.
May222020 - 170.png
 
1590086362037.png
Every time I try to open up terraria 1.4 with Tmodloader this shows up. Idk what I did wrong, and I am new to the forums. Any help would be appreciated, thanks!
 
Everytime I try to load tModloader, steam or not, I always get this error and i dont know why. Does anyone know any fixes? Terraria works just fine!
Terraria not working.PNG
 
Does anyone know why I'm getting the following error when I try to build my project?
"Silently Caught Exception:
Terraria.ModLoader.Exceptions.MissingResourceException: Expected resource not found:
Projectiles/MyProjectile
Closest guess: (Is there a spelling or folder placement error?)
Items/FirstSword"

I DO have Projectiles/MyProjectile, autocompleted and verified by VS. Here's the source:

Any help would be appreciated, thanks!
 
View attachment 272674Every time I try to open up terraria 1.4 with Tmodloader this shows up. Idk what I did wrong, and I am new to the forums. Any help would be appreciated, thanks!
You need to download tModLoader 0.11.7 + version, that's the only one that will work with 1.4 terraria installation.

Does anyone know why I'm getting the following error when I try to build my project?
"Silently Caught Exception:
Terraria.ModLoader.Exceptions.MissingResourceException: Expected resource not found:
Projectiles/MyProjectile
Closest guess: (Is there a spelling or folder placement error?)
Items/FirstSword"

I DO have Projectiles/MyProjectile, autocompleted and verified by VS. Here's the source:

Any help would be appreciated, thanks!
There is no MyProjectile.png texture file alongside the .cs file
 
I wanted to make a staff that shoots hearts to heal people for a modded class wars game. i did:

item.shoot = 58;

Which should work because that is the itemid for heart. but it shoots chainsaws? I also tried:


item.shoot = ItemID.Heart;

But even then it shot chainsaws. I wanted to see how messed up this really was so i did:


item.shoot = ItemID.Wood;

AND IT SHOT STAR WRATH STARS. Please help me make my weapon shoot hearts, and explain what the heck is happening here. (I'm using the steam tmodloader if that makes any difference)
 
Try ProjectileID since ItemID and projectileID both return integers they are kind of compartible.

Edit 1:I looked it up and I didn't find a heart projectile. Maybe I'll find a workaround.

Edit 2:I got an idea how it could work, but I couldn't test it because I need a 1.17.1 compiler but can only download the 1.17 one :mad:.
This basicly creates a projectile wich when it gets destroyed spawns a heart.
That's the code.

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Mod.Projectiles       //Change it to the corect folder
{

    
public class heartproj: ModProjectile
    {
        public override void SetDefaults()
        {
            //projectile.name = "Heartprojectile"; //Name of the projectile, only shows this if you get killed by it
            projectile.width = 12;  //Set the hitbox width
            projectile.height = 12; //Set the hitbox height
            projectile.hostile = true;  //Tells the game whether it is friendly to players/friendly npcs or not
            projectile.ignoreWater = true;  //Tells the game whether or not projectile will be affected by water
            projectile.ranged = true;  //Tells the game whether it is a ranged projectile or not
            projectile.penetrate = 1; //Tells the game how many enemies it can hit before being destroyed, -1 infinity
            projectile.timeLeft = 600;  //The amount of time the projectile is alive for
        }
        public override void Kill(int timeLeft) {
            Item.NewItem(projectile.position,ItemID.Heart,1);
        }
        public override bool OnTileCollide(Vector2 oldVelocity)
        {
            projectile.Kill();
            return false;
        }
    
    }
}

Just remember to spawn it using:
Code:
item.shoot = mod.ProjectileType("heartproj");

Edit 3:
Now the code is right!
 
Last edited:
Does anyone know why I'm getting the following error when I try to build my project?
"Silently Caught Exception:
Terraria.ModLoader.Exceptions.MissingResourceException: Expected resource not found:
Projectiles/MyProjectile
Closest guess: (Is there a spelling or folder placement error?)
Items/FirstSword"

I DO have Projectiles/MyProjectile, autocompleted and verified by VS. Here's the source:

Any help would be appreciated, thanks!
You need a .png to show tmodloader how the projectile looks like.
 
This might seem silly, but i'm having serious trouble trying to organize my curly brackets. Like I'm using Visual Studio Code and it normally shows the colors for the text, but it won't and when i build + reload my mod, it says error: cs1519: invalid token '{' in class, struct, or interface member declaration
 
This might seem silly, but i'm having serious trouble trying to organize my curly brackets. Like I'm using Visual Studio Code and it normally shows the colors for the text, but it won't and when i build + reload my mod, it says error: cs1519: invalid token '{' in class, struct, or interface member declaration

I usually count the curley braces you add one for a { and subtract one for }.
If your value is 2 you can wirte a methode or a variable that is for the whole class.
With a value of 3 you are inside a void.
With 1 you can write a class.
If you want to write a class you have to get the value to 1.
If you want to make a methode you need to get it to 2. etc.
 
Last edited:
Hello everyone! I have a question about partially drawing a UIImage.

The image itself is a circle that represents how much of a certain resource (let's say "soul") the player has, and it "fills up" from bottom to top when player gets more of that resource, like water in an aquarium.
So if the player has zero of that resource, the image isn't drawn at all;
If the player has reached 50% capacity, the bottom half of the image is drawn (from half its height down to the bottom);
And if player has reached maximum of what they can hold, the image is drawn as normal.

Is there a way to achieve this effect?

I'm including code of my attempt to implement a similar sort of thing (did this just to experiment; hoping this would add some context?)
I tried dynamically setting the image's Height value, which would do the opposite of what I want (im assuming that it would draw from top to bottom instead of bottom to top since Y increases from top to bottom), but that would still be something... that didn't work at all and doing it this way currently draws the whole sprite.
C#:
internal class UISoulOrb : UIState
    private UIImage soulOrbFillerImage;

    public override void OnInitialize()
    {
        area = new UIElement(); //base UIElement for this whole thing
        area.Left.Set(-area.Width.Pixels - 600, 1f);
        area.Top.Set(30, 0f);
        area.Width.Set(190, 0f);
        area.Height.Set(140, 0f);
        ...
        soulOrbFillerImage = new UIImage(GetTexture("TestMod/UI/SoulOrbFiller"));
        soulOrbFillerImage.Left.Set(10f, 0f);
        soulOrbFillerImage.Top.Set(26f, 0f);
        soulOrbFillerImage.Width.Set(100, 0f);
        //height is (supposed to be) set dynamically later
        soulOrbFillerImage.Height.Set(0f, 0f);
        ...
        area.Append(soulOrbFillerImage);
        Append(area);
    }
    public override void Update(GameTime gameTime)
    {
        var modPlayer = Main.LocalPlayer.GetModPlayer<SoulPlayer>();
        //this is supposed to dynamically change height parameter in-game:
        var soulPercentage = modPlayer.soulCurrent / modPlayer.soulMax2;
        soulOrbFillerImage.Height.Set((float)soulPercentage, 0f);
        base.Update(gameTime);
    }
Thanks in advance!
 
Back
Top Bottom