tModLoader Official tModLoader Help Thread

Hey elderzi when have my sword code all in the cs file and my sprite in my weapons folder i go ingame and it isent there to be crafted? Can you help me?
 
Hey elderzi when have my sword code all in the cs file and my sprite in my weapons folder i go ingame and it isent there to be crafted? Can you help me?
Could you show me your recipe code?
Also, a mistake that is very commonly made, if you have the ExampleMod, you see there's a file called ExampleMod.cs in the root folder of the ExampleMod mod, right?
You'll want to create a class alike to that one, using only the function called SetModInfo.
 
Hey, can someone help me with my mod? I'm trying to add some accessories that combine other accessories, so how can I use vanilla accessory effects in a modded accessory? I unpacked the mod Miscellania by @goldenapple and it contained this in an accessory:

public override void UpdateAccessory(Player player, bool hideVisual)
{
player.blackBelt = true;
player.dash = 1;
}

I then tried doing my accessory the same way, here's the complete item code:

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MokkelMod.Items.Accessories
{
public class phoenixboots : ModItem
{
public override void SetDefaults()
{
item.name = "Phoenix Boots";
item.width = 32;
item.height = 28;
AddTooltip("Melee attacks set enemies on fire");
AddTooltip("Walk on and take no damage from lava");
item.value = Item.sellPrice(0, 5);
item.rare = 3;
item.accessory = true;
}

public override void UpdateAccessory(Player player, bool hideVisual)
{
player.magmaStone = true;
player.lavaWaders = true;
}

public override void AddRecipes()
{
var recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.LavaWaders);
recipe.AddIngredient(ItemID.MagmaStone);
recipe.AddTile(TileID.TinkerersWorkbench);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

But when I try to build my mod, it tells me that there is no definition for "lavaWaders" and "magmaStone" and that there was no extension that contained it. If someone can help I'll be very happy.
 
Hey, can someone help me with my mod? I'm trying to add some accessories that combine other accessories, so how can I use vanilla accessory effects in a modded accessory? I unpacked the mod Miscellania by @goldenapple and it contained this in an accessory:

public override void UpdateAccessory(Player player, bool hideVisual)
{
player.blackBelt = true;
player.dash = 1;
}

I then tried doing my accessory the same way, here's the complete item code:

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MokkelMod.Items.Accessories
{
public class phoenixboots : ModItem
{
public override void SetDefaults()
{
item.name = "Phoenix Boots";
item.width = 32;
item.height = 28;
AddTooltip("Melee attacks set enemies on fire");
AddTooltip("Walk on and take no damage from lava");
item.value = Item.sellPrice(0, 5);
item.rare = 3;
item.accessory = true;
}

public override void UpdateAccessory(Player player, bool hideVisual)
{
player.magmaStone = true;
player.lavaWaders = true;
}

public override void AddRecipes()
{
var recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.LavaWaders);
recipe.AddIngredient(ItemID.MagmaStone);
recipe.AddTile(TileID.TinkerersWorkbench);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

But when I try to build my mod, it tells me that there is no definition for "lavaWaders" and "magmaStone" and that there was no extension that contained it. If someone can help I'll be very happy.
Well, I know for one that 'lavaWaders' is not a variable that is available from the Player class.
Instead, if you want to reproduce the LavaWaders effect, you'll want to use the following code:
Code:
player.waterWalk = true;
player.fireWalk = true;
player.lavaMax += 420;
As for the magmaStone... That's weird and should (probably) just work as intended.
 
Sry that i am asking this question again but how do i make an NPC that rotate around the player?
Like orbit? Try positioning the npc using Sine and Cosine for x and y respectively. An example of orbiting you can use is in my tutorial in my sig, though it is for projectiles, you can edit it for npcs pretty easily since they are pretty similar to each other.
 
Like orbit? Try positioning the npc using Sine and Cosine for x and y respectively. An example of orbiting you can use is in my tutorial in my sig, though it is for projectiles, you can edit it for npcs pretty easily since they are pretty similar to each other.

Ok thank you, oh im just wondering what is sig :p ?
 
Ok thank you, oh im just wondering what is sig :p ?
The signature. Usually it is the stuff below comments for example I have two spoilers after each of my post that says either "tModLoader stuff" or "tAPI stuff". You want to look at my tModLoader stuff for what you are looking for.
 
I was coding a custom enemy NPC, a small lava slime type thing, and I had two questions relating to it. Firstly I would like to know how to get it to spawn where I want. Their is a layer of the cavern where the walls change to a cracked stone with lava flowing through it, above the underworld, and I was wondering how to get it to spawn there. I know about the Main.rockLayer, but is their an end that can get it to spawn direct in that area, or will I have to get it by adding and subtracting to set a spawn zone. Secondly I just want to know how to make it glow. I've got some experience, but I'm still really not good at actual game coding, since the largest extent I've really gone to was tutorials and guides online.
 
yes a projectile
Oww, there is a big difference though :p
Anyways, on your projectile you can override the OnHitNPC hook and apply the buff in there:
Code:
public override void OnHitNPC(NPC target, int damage, float knockBack, bool crit)
{
    npc.AddBuff(mod.BuffType("MyModBuff"), 120);
}
Note that when applying the buff, the second parameter of the AddBuff function determines the time the buff lasts. This time is calculated in ticks and there are 60 ticks (or updates, whichever naming you prefer) each second, meaning that the example above lasts 2 seconds. Just something to keep in mind.
 
Back
Top Bottom