• PC NEWS: 1.4.2.3 update is out! More info here. Report bugs here
  • Journey's End on Xbox and PlayStation!: Get all the info by clicking here. A new patch is in QA - expect some Gamepad love, the return of Red's Pick and more. Click here for Known Issues and FAQ. For any other bugs, report them (with as much detail as possible) here.
  • MOBILE NEWS: Stay up to date with the latest mobile news here. Report mobile bugs here

tModLoader Official tModLoader Help Thread

Talus

The Destroyer
I will see if that works! thank you!
EDIT: if this works would you like to be a co-developer in my mod?
 
Tmod Loader keeps getting stuck at adding recipes with 0 progress every time when starting it up. Does anyone know how to fix this?

edit: fixed it but I'm trying to play with a friend but it's not starting
 
Last edited:

Magi∆

Skeletron Prime
tmodloader keeps giving me this error when building or building and reloading my custom mods how do i fix. i heard that you need to reinstall the net framework but when i try it says i already have it installed and i dont know how to uninstall.
1621967273000.png
 
Last edited:

spicyronin

Terrarian
New to this, I get this every time I hop on my friend's server. Help would be appreciated!
 

Attachments

  • image_2021-05-28_143312.png
    image_2021-05-28_143312.png
    44.7 KB · Views: 37

Bobbn

Terrarian
I was wondering how I could change the set bonus of a vanilla armor set. I would be grateful if someone could tell me how to do this.
(I'm pretty new, I can make basic weapons, armor and accessories but not much else)
 

HunterFTP

Terrarian
Hello! I don't know how active it is here but I am trying to write some scripts for TCCI, or terraria content creator integration.

I want to make a command that randomly paints the tiles around me when a specific input. I have the input thing down I am just struggling with the actual script. I can't find if there is a tile variable to color anywhere, or what the variable values would be if I found it. If anyone out there knows a what to do this I am all ears, er eyes i guess. Thanks a bunch!!
 

ward_en

Terrarian
not sure if the 64bit branch has support here but every time i try and load tmod64bit i am stuck on instantiating mods

tmod32bit works fine
 

IceMonkey134

Terrarian
I'm actually dumb and can't find anywhere but is there a way to make it so that you know if you kill something?
I'm trying to make an accessory that greatly increases your damage after 50 kills that lasts for 5 seconds and adds a second every kill up to a max of 5 seconds (kudos to whoever gets the reference), I know how I'd do it I Just need to know how to read one kill.
 

DucisImperium

Terrarian
looking for some help as my game keeps crashing, mostly when going into new biomes and recently while mining sand.

my active mods are:
Dragon ball terraria
alchemist npc
wing slot
thorium
calamity
calamities vanities
terraria overhaul

crashlog:
6/19/2021 1:54:41 PM
System.NullReferenceException: Object reference not set to an instance of an object.
at Terraria.Main.lookForColorTiles()
at Terraria.Main.DoDraw(GameTime gameTime)
at Terraria.Main.Draw(GameTime gameTime)
at Microsoft.Xna.Framework.Game.DrawFrame()
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
at Terraria.Program.LaunchGame_()


it also says that the game keeps running out of memory
 
Last edited:

Simple

Official Terrarian
Hi,

I'm on this thread to ask a question, how do you detect if an NPC is touching a block/on the ground? I'm currently making an enemy that only jumps if it is not in the air.
C#:
                    npc.velocity.Y = 20f;
                    npc.velocity.X = 0f;
                    if (Math.Abs(npc.position.Y - player.position.Y) < 5) {
                        AI_RestTimer = 0;
                        AI_State = State_Charging;
                    }
This code I'm using currently detects if the Y position of the NPC is near the Y position of the player. While the current method is efficient in stopping the enemy from continuously jumping in the air, it creates a whole new problem where if the player is a few blocks below or on top of the enemy, the NPC will freeze and never go into the "Charging" state. If you are willing to help, thank you.
 

WolfofFuture

Terrarian
Hello, I have a problem. I want to change the location from My Games folder to somewhere else but i don't know how. I've tried using savedirectory command but it told me that it was invalid. Is there any other solution? Just dragging from one folder to the other wouldn't work, right? The system is Win x64 and I'm using tmodloader from steam.


EDIT:
I guess I somehow got a solution. Used symbolic links
EDIT2:
Nope, still doesn't work
EDIT3:
Alright, the problem was that the Tmodloader on Steam is 32bit. Downloading the 64bit version solved the issue.
 
Last edited:

Solo-Ion

Dungeon Spirit
Hi,

I'm on this thread to ask a question, how do you detect if an NPC is touching a block/on the ground? I'm currently making an enemy that only jumps if it is not in the air.
C#:
                    npc.velocity.Y = 20f;
                    npc.velocity.X = 0f;
                    if (Math.Abs(npc.position.Y - player.position.Y) < 5) {
                        AI_RestTimer = 0;
                        AI_State = State_Charging;
                    }
This code I'm using currently detects if the Y position of the NPC is near the Y position of the player. While the current method is efficient in stopping the enemy from continuously jumping in the air, it creates a whole new problem where if the player is a few blocks below or on top of the enemy, the NPC will freeze and never go into the "Charging" state. If you are willing to help, thank you.
I'm no expert, but I did something similar on a projectile with the Collision class. Give Collision.SolidCollision(vector2, int, int) your NPC's position, width and height and it will return a bool based on weather or not it's hitting something.

Hope that works.
 

Simple

Official Terrarian
I'm no expert, but I did something similar on a projectile with the Collision class. Give Collision.SolidCollision(vector2, int, int) your NPC's position, width and height and it will return a bool based on weather or not it's hitting something.

Hope that works.
From what I saw, this is apparently a function/method, or a hook, right? If it is not a difficult task, how could I get a variable from one method and use it in another? And thanks for trying to help, I appreciate that.
 

LuckyLMJ

Terrarian
Does anyone know how to detect if an NPC is in water? I thought it was
C#:
if (npc.wet) {
    //insert code here
}
but that doesn't seem to work.


EDIT: I found the issue! My old code was
C#:
if (npc.wet) {
    npc.velocity.Y -= 0.15; //gravity is -0.1, so this should counteract gravity
}

But it turns out that it works if I do
C#:
if (npc.wet) {
    npc.velocity.Y = 0;
    npc.position.Y -= 5;
}
I'm not quite sure why this happens, but it does.
 
Last edited:

Gionas36 1

Official Terrarian
I'm having this problem where the projectile spawns like this, when in reality I want it to appear a little bit in front of the character for example like the Lazer from the Prism in which the lazer spawns in the prism itself?
position.PNG


I basically want it to look like this:

fxbH2vqmJ8SGcZ8pFSzKWrZXsN6Ig5jffjqjo0vAZ1Y.png


This is the code of the projectile:
C#:
using System;
using Terraria;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ID;
using Terraria.ModLoader;

namespace MySword.Projectiles
{
    public class ExProcyonBlast : ModProjectile
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Ex Procyon Blast");
        }

        public override void SetDefaults()
        {
            projectile.width = 500;
            projectile.height = 500;
            projectile.scale = 1f;
            projectile.timeLeft = 30;
            projectile.penetrate = 10;
            projectile.friendly = true;
            projectile.magic = true;
            projectile.tileCollide = false;
            projectile.alpha = 55;
            projectile.light = 1f;
            projectile.aiStyle = 4;
        }

        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            target.AddBuff(mod.BuffType("OnFire!"), 180, false);
        }
    }
}

I also have another question... can i make it so a melee weapon like a sword shoot a projectile that requires mana only when mana is availible?
Ima rephrase it just in case. Can i make a "sword" shoot projectiles when the mana needed is availible but when mana is not availible still be able to be swong/used.

This is the code of the "sword"
C#:
using Terraria;
using Microsoft.Xna.Framework;
using Terraria.ID;
using Terraria.ModLoader;
namespace MySword.Items
{
    public class TrueLizaverde : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("True Lizaverde");
            Tooltip.SetDefault("3000% Water DMG (Magic). Increases own CRI DMG by 30% for 8s. Water units get an extra 30%");
        }

        public override void SetDefaults()
        {
            item.melee = true;
            item.damage = 250;
            item.useStyle = 1;
            item.useTime = 10;
            item.useAnimation = 10;
            item.knockBack = 5;
            item.value = 30000;
            item.rare = -12;
            item.UseSound = SoundID.Item1;
            item.autoReuse = true;
            item.width = 175;
            item.height = 175;
            item.scale = 0.35f;
            item.mana = 10;
            item.crit = 97;

            item.shoot = mod.ProjectileType("FrostWaveLizaverde");
            item.shootSpeed = 30f;
        }

        public override void HoldItem(Player player)
        {
            player.itemLocation.Y = player.Center.Y;
            player.itemLocation.X = player.Center.X - 18 * player.direction;
        }

        public override void AddRecipes()
        {
            ModRecipe TrueLizaverderecipe = new ModRecipe(mod);
            TrueLizaverderecipe.AddIngredient(173, 10);
            TrueLizaverderecipe.AddIngredient(381, 10);
            TrueLizaverderecipe.AddIngredient(19, 10);
            TrueLizaverderecipe.AddIngredient(177, 1);


            TrueLizaverderecipe.AddTile(17);
            TrueLizaverderecipe.SetResult(this);
            TrueLizaverderecipe.AddRecipe();
        }
    }
}

Sword is like "sword" bcs its a scythe but i wanted to be as clear as posible so anyone who reads can uderstand.
TrueLizaverde.png

that is the sprite in question.
 
Last edited:

LuckyLMJ

Terrarian
I'm having this problem where the projectile spawns like this, when in reality I want it to appear a little bit in front of the character for example like the Lazer from the Prism in which the lazer spawns in the prism itself?
View attachment 329442

I basically want it to look like this:

View attachment 329447

This is the code of the projectile:
C#:
using System;
using Terraria;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ID;
using Terraria.ModLoader;

namespace MySword.Projectiles
{
    public class ExProcyonBlast : ModProjectile
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Ex Procyon Blast");
        }

        public override void SetDefaults()
        {
            projectile.width = 500;
            projectile.height = 500;
            projectile.scale = 1f;
            projectile.timeLeft = 30;
            projectile.penetrate = 10;
            projectile.friendly = true;
            projectile.magic = true;
            projectile.tileCollide = false;
            projectile.alpha = 55;
            projectile.light = 1f;
            projectile.aiStyle = 4;
        }

        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            target.AddBuff(mod.BuffType("OnFire!"), 180, false);
        }
    }
}

I also have another question... can i make it so a melee weapon like a sword shoot a projectile that requires mana only when mana is availible?
Ima rephrase it just in case. Can i make a "sword" shoot projectiles when the mana needed is availible but when mana is not availible still be able to be swong/used.

This is the code of the "sword"
C#:
using Terraria;
using Microsoft.Xna.Framework;
using Terraria.ID;
using Terraria.ModLoader;
namespace MySword.Items
{
    public class TrueLizaverde : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("True Lizaverde");
            Tooltip.SetDefault("3000% Water DMG (Magic). Increases own CRI DMG by 30% for 8s. Water units get an extra 30%");
        }

        public override void SetDefaults()
        {
            item.melee = true;
            item.damage = 250;
            item.useStyle = 1;
            item.useTime = 10;
            item.useAnimation = 10;
            item.knockBack = 5;
            item.value = 30000;
            item.rare = -12;
            item.UseSound = SoundID.Item1;
            item.autoReuse = true;
            item.width = 175;
            item.height = 175;
            item.scale = 0.35f;
            item.mana = 10;
            item.crit = 97;

            item.shoot = mod.ProjectileType("FrostWaveLizaverde");
            item.shootSpeed = 30f;
        }

        public override void HoldItem(Player player)
        {
            player.itemLocation.Y = player.Center.Y;
            player.itemLocation.X = player.Center.X - 18 * player.direction;
        }

        public override void AddRecipes()
        {
            ModRecipe TrueLizaverderecipe = new ModRecipe(mod);
            TrueLizaverderecipe.AddIngredient(173, 10);
            TrueLizaverderecipe.AddIngredient(381, 10);
            TrueLizaverderecipe.AddIngredient(19, 10);
            TrueLizaverderecipe.AddIngredient(177, 1);


            TrueLizaverderecipe.AddTile(17);
            TrueLizaverderecipe.SetResult(this);
            TrueLizaverderecipe.AddRecipe();
        }
    }
}

Sword is like "sword" bcs its a scythe but i wanted to be as clear as posible so anyone who reads can uderstand.
View attachment 329445
that is the sprite in question.
You would add in
C#:
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) {
    Projectile.NewProjectile(position.x + velocity.x * multiplier, position.y + velocity.y * multiplier, speedX, speedY, type, damage, knockBack, player.whoAmI);
    return false;
}
.

What this does, is it overrides the vanilla projectile shooting AI (by calling "return false;" at the end) and makes a new AI, where it moves the projectile forwards by the velocity vector times a multiplier value (Which you can set to be whatever you want, just make sure they are both the same number)
 

Solo-Ion

Dungeon Spirit
From what I saw, this is apparently a function/method, or a hook, right? If it is not a difficult task, how could I get a variable from one method and use it in another? And thanks for trying to help, I appreciate that.
Collision.SolidCollision is a function. I don't know exactly what you mean by get a variable from one method and use it in another, but what I was suggesting you do is something like the following.
C#:
if (Collision.SolidCollision(npc.position, npc.width, npc.height))
{
    //do the thing
}
That should return true if your NPC is colliding with anything.
 
Top Bottom