tModLoader Official tModLoader Help Thread

Should ExampleMod prevent the player from making torches but the example torch?
If active I can't make normal torches anymore.
 
I am having a problem.I just want my NPC to be nameless but when I try to erase the highlighted code,it had resulted in saying that the town NPC's name is "No-name",which I do not want.Please help me.

using System.Linq;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.Utilities;

namespace DarkFantasy.NPCs
{
[AutoloadHead]
public class Firekeeper : ModNPC
{
public override string Texture
{
get
{
return "DarkFantasy/NPCs/Firekeeper";
}
}


public override bool Autoload(ref string name)
{
name = "Firekeeper";
return mod.Properties.Autoload;
}

public override void SetStaticDefaults()
{
DisplayName.SetDefault("Firekeeper");
Main.npcFrameCount[npc.type] = 23;
NPCID.Sets.ExtraFramesCount[npc.type] = 5;
NPCID.Sets.AttackFrameCount[npc.type] = 4;
NPCID.Sets.DangerDetectRange[npc.type] = 600;
NPCID.Sets.AttackType[npc.type] = 0;
NPCID.Sets.AttackTime[npc.type] = 25;
NPCID.Sets.AttackAverageChance[npc.type] = 2;
NPCID.Sets.HatOffsetY[npc.type] = 6;
}

public override void SetDefaults()
{
npc.townNPC = true;
npc.friendly = true;
npc.width = 40;
npc.height = 58;
npc.aiStyle = 7;
npc.damage = 20;
npc.defense = 15;
npc.lifeMax = 250;
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath1;
npc.knockBackResist = 0.7f;
animationType = NPCID.Steampunker;
}

public override string TownNPCName()
{
switch (WorldGen.genRand.Next(4))
{
case 0:
return "-";
}
}


public override void FindFrame(int frameHeight)
{
/*npc.frame.Width = 40;
if (((int)Main.time / 10) % 2 == 0)
{
npc.frame.X = 40;
}
else
{
npc.frame.X = 0;
}*/
}

public override string GetChat()
{
switch (Main.rand.Next(5))
{
default:
return "Ashen one, to be Unkindled is to be a vessel for souls. Sovereignless souls will become thy strength. I will show thee how. Ashen one, bring me souls, plucked from their vessels...";
}
}

/*
// Consider using this alternate approach to choosing a random thing. Very useful for a variety of use cases.
// The WeightedRandom class needs "using Terraria.Utilities;" to use
public override string GetChat()
{
WeightedRandom<string> chat = new WeightedRandom<string>();
int partyGirl = NPC.FindFirstNPC(NPCID.PartyGirl);
if (partyGirl >= 0 && Main.rand.Next(4) == 0)
{
chat.Add("Can you please tell " + Main.npc[partyGirl].GivenName + " to stop decorating my house with colors?");
}
chat.Add("Sometimes I feel like I'm different from everyone else here.");
chat.Add("What's your favorite color? My favorite colors are white and black.");
chat.Add("What? I don't have any arms or legs? Oh, don't be ridiculous!");
chat.Add("This message has a weight of 5, meaning it appears 5 times more often.", 5.0);
chat.Add("This message has a weight of 0.1, meaning it appears 10 times as rare.", 0.1);
return chat; // chat is implicitly cast to a string. You can also do "return chat.Get();" if that makes you feel better
}
*/

public override void SetChatButtons(ref string button, ref string button2)
{
button = Language.GetTextValue("LegacyInterface.28");
}

public override void OnChatButtonClicked(bool firstButton, ref bool shop)
{
if (firstButton)
{
shop = true;
}
}

public override void SetupShop(Chest shop, ref int nextSlot)
{
shop.item[nextSlot].SetDefaults(ItemID.ThornsPotion);
nextSlot++;
shop.item[nextSlot].SetDefaults(ItemID.LesserManaPotion);
nextSlot++;
shop.item[nextSlot].SetDefaults(ItemID.LesserHealingPotion);
nextSlot++;
shop.item[nextSlot].SetDefaults(ItemID.WoodenArrow);
nextSlot++;
if (Main.moonPhase < 2)
{
shop.item[nextSlot].SetDefaults(ItemID.ManaPotion);
nextSlot++;
}
if (Main.moonPhase < 2)
{
shop.item[nextSlot].SetDefaults(ItemID.WrathPotion);
nextSlot++;
}
else if (Main.moonPhase < 4)
{
shop.item[nextSlot].SetDefaults(ItemID.JestersArrow);
nextSlot++;
shop.item[nextSlot].SetDefaults(ItemID.HolyArrow);
nextSlot++;
}
else if (Main.moonPhase < 6)
{
shop.item[nextSlot].SetDefaults(ItemID.SilverBow);
nextSlot++;
}
else
{
}
}

public override void TownNPCAttackStrength(ref int damage, ref float knockback)// Allows you to determine the damage and knockback of this town NPC attack
{
damage = 9; //npc damage
knockback = 0f; //npc knockback
}

public override void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown) //Allows you to determine the cooldown between each of this town NPC's attack. The cooldown will be a number greater than or equal to the first parameter, and less then the sum of the two parameters.
{
cooldown = 5;
randExtraCooldown = 10;
}
public override void TownNPCAttackProj(ref int projType, ref int attackDelay)//Allows you to determine the projectile type of this town NPC's attack, and how long it takes for the projectile to actually appear
{
projType = ProjectileID.BallofFire;
attackDelay = 1;
}

public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)//Allows you to determine the speed at which this town NPC throws a projectile when it attacks. Multiplier is the speed of the projectile, gravityCorrection is how much extra the projectile gets thrown upwards, and randomOffset allows you to randomize the projectile's velocity in a square centered around the original velocity
{
multiplier = 7f;
// randomOffset = 4f;

}

//----------------------------------This is an example of how to make the npc use a gun and a projectile ----------------------------------
/*public override void DrawTownAttackGun(ref float scale, ref int item, ref int closeness) //Allows you to customize how this town NPC's weapon is drawn when this NPC is shooting (this NPC must have an attack type of 1). Scale is a multiplier for the item's drawing size, item is the ID of the item to be drawn, and closeness is how close the item should be drawn to the NPC.
{
scale = 1f;
item = mod.ItemType("GunName");
closeness = 20;
}
public override void TownNPCAttackProj(ref int projType, ref int attackDelay)//Allows you to determine the projectile type of this town NPC's attack, and how long it takes for the projectile to actually appear
{
projType = ProjectileID.CrystalBullet;
attackDelay = 1;
}

public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)//Allows you to determine the speed at which this town NPC throws a projectile when it attacks. Multiplier is the speed of the projectile, gravityCorrection is how much extra the projectile gets thrown upwards, and randomOffset allows you to randomize the projectile's velocity in a square centered around the original velocity
{
multiplier = 7f;
// randomOffset = 4f;

} */

}
}
 
Last edited:
Hi, I need help with my custom bow:
using Sys;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace NaoMod.Items.Weapons;{
{
public class Devastation : ModItem
{
public override void SetStaticDefaults();
{
DisplayName.SetDefault("Devastation");
}
public override void SetDefaults();
{
item.width = 32;
item.height = 32;
item.useTime = 7;
item.useAnimation = 20;
item.useStyle = 5; // Bow Use Style
item.noMelee = true; // Doesn't deal damage if an enemy touches at melee range.
item.value = Item.buyPrice(0, 2, 10, 0); // Another way to handle value of item.
item.rare = 5;
item.UseSound = SoundID.Item5; // Sound for Bows
item.useAmmo = AmmoID.Arrow; // The ammo used with this weapon
item.shoot = 1;
item.shootSpeed = 1f;
item.ranged = true; // For Ranged Weapon
}
}
}

this is code ^ ^ ^

and here is errors:
c:\Users\Win10\Documents\My Games\Terraria\ModLoader\Mod Sources\NaoMod\Items\Devastation.cs(10,31) : error CS1514: expected {.
c:\Users\Win10\Documents\My Games\Terraria\ModLoader\Mod Sources\NaoMod\Items\Devastation.cs(12,39) : error CS1514: expected {.
c:\Users\Win10\Documents\My Games\Terraria\ModLoader\Mod Sources\NaoMod\Items\Devastation.cs(12,39) : error CS1519:
c:\Users\Win10\Documents\My Games\Terraria\ModLoader\Mod Sources\NaoMod\Items\Devastation.cs(15,9) : error CS1519:
c:\Users\Win10\Documents\My Games\Terraria\ModLoader\Mod Sources\NaoMod\Items\Devastation.cs(16,35) : error CS1519:
c:\Users\Win10\Documents\My Games\Terraria\ModLoader\Mod Sources\NaoMod\Items\Devastation.cs(19,25) : error CS1518:
c:\Users\Win10\Documents\My Games\Terraria\ModLoader\Mod Sources\NaoMod\Items\Devastation.cs(36,1) : error CS1022:
 
can any one fix this mod?
i want the recipe to be one stone for each part of the armor
and i want it so i can craft it at a workbench
please help
 

Attachments

  • Help please.zip
    240.3 KB · Views: 152
I extracted a mod using the mod reader and I noticed that the png files were rawimg file. And I have no idea how to convert it to png. Pls help
 
I only checked the first couple of files, but you have 'recipe.AddTile(TileID.18 30);'
To tell the game to make it the workbench tile, you would just use either the internal name (/whatever its called) or the number
So " recipe.AddTile(18); " or " recipe.AddTile(TileID.WorkBenches); "
I don't know why you have that '30' there but its not needed.
'1' is also a pickaxe, check https://github.com/blushiemagic/tModLoader/wiki/Vanilla-Item-IDs (as well as the wiki in general so that you can understand what you're doing).


I extracted a mod using the mod reader and I noticed that the png files were rawimg file. And I have no idea how to convert it to png. Pls help
I know that is an "issue" with the older standalone tModreader program, but the current way to extract mods is using the in-game extract option (iirc you click a 'more info' button from the mods menu, but its been a while). AFAIK that second method should still work - is that what you were doing?
 
Hey, sorry if anyone's already asked this, but is there a way to edit the positioning of custom wings on a character? I am trying to make something like Lazure's Barrier Platform in terms of placement, but the placement obviously defaults to the back, where wings normally go. Thanks!
 
Hello. A few days ago I tried to mod terraria for the first time. I installed calamity and thorium. However, it started crashing after playing like 30 minutes. It just goes to the desktop with no message or error description. I also installed the 4gb patch, but it didn't seem to help. I have not found any topics about this kind of crash, which is without errors. Also, I did the rotation of disabling-reloading-resetting etc., however, it did not help as well. Moreover, I found a couple of posts that I could install both mods and I have also seen others playing with 20-30 mods with no problems. Furthermore, when it was not borderless fullscreen and I alt-tabbed, the probability of crashing sooner grew and it usually did so, too. I have installed the latest versions of the mods and tModloader. I do not know which mod is causing the problem, but I think it is the Thorium mod, because there were more complaints about that in the various forum posts.

Edit: Somehow it stopped crashing. What I did was create a new world and played in it like 30-40minutes, but nothing happened. Then I decided to check if the same thing was happening on the crashing save, but I have been playing for an hour and a half and I have also been alt-tabbing, but it hasn't crashed yet. I don't know how it got fixed. Maybe I had to restart my computer?

Edit: It started crashing again after a couple of hours. Tried launching in admin mode, deleting Thorium cache file (metal_clank), reinstalling Terraria and the mods.
 
Well I installed tmodloader and mods and was about to start playing. Created a character, then tried to create a world but everytime I try to create a world it crashes and shows me that error.
Please, I need your help!
 

Attachments

  • Error.png
    Error.png
    25.3 KB · Views: 158
Well I installed tmodloader and mods and was about to start playing. Created a character, then tried to create a world but everytime I try to create a world it crashes and shows me that error.
Please, I need your help!

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.
 
Back
Top Bottom