tModLoader Official tModLoader Help Thread

Because your issue is related to TModLoader, it's not valid as a regular report for the vanilla game. Your Post has been moved to be a post in this Thread where people familiar with TModLoader may be able to help you.
Thanks :). Well I could create a SMALL worlds. Medium and large crash with that error.
So, when I created small it showed me
 

Attachments

  • wtf.png
    wtf.png
    1.3 MB · Views: 235
I need some code that changes the values at which vanilla healing potions and hearts heal. I want to set custom HP values for the five items and also change tooltips to show the correct amount of HP healed accordingly.
 
I need some code that changes the values at which vanilla healing potions and hearts heal. I want to set custom HP values for the five items and also change tooltips to show the correct amount of HP healed accordingly.
I figured it out. So what you have to do is create a file in your "Items" folder. Name it whatever you want, but I'm going to go with "GlobalItem.cs". Next, just put this code inside the file:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace YourMod.Items
{
    internal sealed class ExampleGlobalItem : GlobalItem
    {
        public override void SetDefaults(Item item)
        {
            if(item.type==5){
                item.healLife=100;
            }
        }
    }
}
What this does is create an copy of the class "GlobalItem", which is able to override attributes Terraria put in place to items, like damage. Then we check if the item has a type, or id, of 5, which is a mushroom, and then sets its healing value to 100 instead of 15. If you don't know how to get item ids, just go to https://terraria.wiki.gg/Item_IDs. BE CAREFUL not to use the tile ids. You can also set it to give mana and stuff, like mana potions do.

To do tooltips, you have to use "GlobalItem" again. Just paste in the code from below:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TestMod.Items  
{
    internal sealed class TestGlobalItem : GlobalItem
    {
        public override void ModifyTooltips(Item item, List<TooltipLine> tooltips)
        {
                for(int i=0;i<tooltips.Count;i++)
                {
                    if(tooltips[i].Name.Equals("Tooltip0")&&tooltips[i].Name.Equals("Tooltip1"))
                    {
                        tooltips[i].text="Your text here";
                    }
                }
        }

      
    }
}
Here, most of the code is the same except for the new function. The for loop loops over every tooltip, which counts the name, the damage, and all that stuff. The if statement checks if the name (ref: http://blushiemagic.github.io/tModLoader/html/class_terraria_1_1_mod_loader_1_1_tooltip_line.html) of the tooltip are the tooltips you normally customize. Finally, "tooltips.text="Your text here";" just changes the text of the tooltip. Remember to put this inside the "GlobalItem.cs" file you hopefully made earlier.
 
Last edited:
  • Like
Reactions: 000
Hello everyone!!! I have a problem. A long time ago i'd make small mod at tAPI. But now Terraria is 1.3.5, and tAPI is no more supported. I use on my armor set this effects and it works fine.(at tAPI)
public override void UpdateArmorSet(Player player)
{
player.drawGlow = true;
player.drawAura = true;
player.drawAfterimage = true;
}
But them not working on tModLoader. Are there people who know, how to register these effects of armor sets at tModLoader? Any help is extremely welcome!
And if someone know other effects what developers adds to the game at last couple updates, tell me please and also write code for them.(solar, vortex or some armor maybe has also unique FX)
Also, sorry for my english, if something not correct.
Use ArmorSetShadows and set any of these

KBwtFYu.png
 
Hi, is there a way to get the assigned key of a default Terraria hotkey? I'm aware you can do so with a custom hotkey using the GetAssignedKeys method. The source of Terraria appears to use the strings cLeft, cJump etc., but when I use those they always return the default keybindings.

Edit: I found a way to do it; for anyone who may be interested:
Include a using statement for Terraria.GameInput (i.e. "using Terraria.GameInput") and use, for example, "PlayerInput.CurrentProfile.InputModes[InputMode.Keyboard].KeyStatus["Up"][0]". It will read as a string of the hotkey for, in this case, the "Up" keybinding. So by default, "W".

You can change the "Up" to any default keybinding or change "InputMode.Keyboard" to "InputMode.XBoxGamepad" for gamepad controls.
 
Last edited:
AYY does anyone know how to increase ranged velocity with accesory?
I tried:
player.rangedVelocity += 0.1f;
player.velocity += 0.1f;
 
Hi. Let me know if this is the wrong place for this. I've been trying to get started with making my own mod but I can't quite get it to work. I generated a skeleton using the site listed on the official tmodloader page. Made sure everything was correct and just to test I tried building the mod without really doing anything to it besides creating a .sln (solution) of the project for MVS. Immediately after trying to build the mod, tmodloader crashed and spat out this first error. After trying to reload tmodloader, it crashed while loading the mods after spitting out the loading error and again spat out the disposed object error. The loading error doesn't make any sense to me because the actual thing it is looking for happens to actually be in the folder that it is searching. All namespace, image title and everything else match up so this shouldn't be happening. If anyone can help me figure this out it would be much appreciated.
folder.png
error 2.png
Error 1.png
 
Hi. Let me know if this is the wrong place for this. I've been trying to get started with making my own mod but I can't quite get it to work. I generated a skeleton using the site listed on the official tmodloader page. Made sure everything was correct and just to test I tried building the mod without really doing anything to it besides creating a .sln (solution) of the project for MVS. Immediately after trying to build the mod, tmodloader crashed and spat out this first error. After trying to reload tmodloader, it crashed while loading the mods after spitting out the loading error and again spat out the disposed object error. The loading error doesn't make any sense to me because the actual thing it is looking for happens to actually be in the folder that it is searching. All namespace, image title and everything else match up so this shouldn't be happening. If anyone can help me figure this out it would be much appreciated.View attachment 203052 View attachment 203050 View attachment 203051
You have an extra layer of folder there: BasicSwordMod/BasicSwordMod/...
 
Not sure if im at the right place for this, but I found a bug with the drops of frost moon and pumpkin moon bosses. Bosses like the Santa-nk1 and Frost queen drop nothing but money and hearts when killed. However, when using a mod like recipe browser to view the drops of these enemies, they are not shown to drop anything. This has applied to all of the pumpkin and frost moon bosses, making their weapons unobtainable. I have tried everything. Reinstalling Tmodloader does nothing to fix this, as well as playing without any mods enabled. Ive heard nothing of this bug before encountering it, so im pretty lost for a fix.
 
i seem to keep on getting this error on my minion file

c:\Users\dylan\Documents\My Games\Terraria\ModLoader\Mod Sources\MagnarMadness\Projectiles\Minions\IlluminatiMinion.cs(18,24) : 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?)

c:\Users\dylan\Documents\My Games\Terraria\ModLoader\Mod Sources\MagnarMadness\Projectiles\Minions\IlluminatiMinionP.cs(17,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?)

i have the code here
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MagnarMadness.Projectiles.Minions
{  
    public class IlluminatiMinion : IlluminatiMinionINFO
    {
        public override void SetDefaults()
        {
            projectile.netImportant = true;
            projectile.name = "Illuminati Minion";
            projectile.width = 32;
            projectile.height = 32;
            Main.projFrames[projectile.type] = 3;
            projectile.friendly = true;
            Main.projPet[projectile.type] = true;
            projectile.minion = true;
            projectile.netImportant = true;
            projectile.minionSlots = 1;
            projectile.penetrate = 1;
            projectile.timeLeft = 18000;
            projectile.tileCollide = false;
            projectile.ignoreWater = true;
            ProjectileID.Sets.MinionSacrificable[projectile.type] = true;
            ProjectileID.Sets.Homing[projectile.type] = true;
            inertia = 30f;
            shoot = mod.ProjectileType("IlluminatiMinionP");
            shootSpeed = 10f;
            ProjectileID.Sets.LightPet[projectile.type] = true;
            Main.projPet[projectile.type] = true;
        }

        public override void CheckActive()
        {
            Player player = Main.player[projectile.owner];
            MyPlayer modPlayer = (MyPlayer)player.GetModPlayer(mod, "MyPlayer");
            if (player.dead)
            {
                modPlayer.minionName = false;
            }
            if (modPlayer.minionName)
            {
                projectile.timeLeft = 2;
            }
        }

        public override void CreateDust()
        {
            Lighting.AddLight((int)(projectile.Center.X / 16f), (int)(projectile.Center.Y / 16f), 0.6f, 0.9f, 0.3f);
        }

        public override void SelectFrame()
        {
            projectile.frameCounter++;
            if (projectile.frameCounter >= 8)
            {
                projectile.frameCounter = 0;
                projectile.frame = (projectile.frame + 1) % 3;
            }
        }
    }
}
 
Hello there. can anyone tell me how can i equip 2 of the same accessories at the mean time? i mean, how should i write the code?
thanks in advance.
 
Hello there. can anyone tell me how can i equip 2 of the same accessories at the mean time? i mean, how should i write the code?
thanks in advance.
I think the code prevents that. Why would you want to equip the same accessory twice?
 
I think the code prevents that. Why would you want to equip the same accessory twice?
"the code prevent that." so if i got it right, that means if i create a new item, and did not write anything except the setdefault() and addrecipe(), i should be able to equip 2 of this item at the same time? don't think so.
"Why would you want to equip the same accessory twice?"
because i want to try death mode for my new character, but i got almost 100 damage for a single hit by the bees in the jungle. i think maybe some defense should help. so, if i equip 5 of the same item with 2 defense each, should benefit a little bit. might sounds crazy go to the jungle in the very beginning of the game, but you know, just trying.
but thanks for replying anyway.
 
"the code prevent that." so if i got it right, that means if i create a new item, and did not write anything except the setdefault() and addrecipe(), i should be able to equip 2 of this item at the same time? don't think so.
"Why would you want to equip the same accessory twice?"
because i want to try death mode for my new character, but i got almost 100 damage for a single hit by the bees in the jungle. i think maybe some defense should help. so, if i equip 5 of the same item with 2 defense each, should benefit a little bit. might sounds crazy go to the jungle in the very beginning of the game, but you know, just trying.
but thanks for replying anyway.
I mean that Terraria code prevents that, not your code.
 
I mean that Terraria code prevents that, not your code.
oh my. but i still think there is some way to do this. in my limited experience, i already found 2 accessories in Calamity and the vanilla shackle can equip multiple at the same time.
anyway, waiting for someone answer my question.
 
oh my. but i still think there is some way to do this. in my limited experience, i already found 2 accessories in Calamity and the vanilla shackle can equip multiple at the same time.
anyway, waiting for someone answer my question.
You can't equip multiple Shackle.
 
Back
Top Bottom