tModLoader Official tModLoader Help Thread

thank you! turns out the reason it was invisible.... was b/c it was spawning way the :red: far away b/c of the not multiplying by 16 thing. should be a lot easier to do stuff now that I can see the projectile.

EDIT: for the sprite intersection, that "tileSprite" thing is the only one I haven't been able to figure out at all. it doesn't seem to exist anywhere, where did you even get that from :p ? there doesn't seem to be anything related to sprites in ModTile, but I'm pretty tired so I might have better luck tomorrow.
 
Last edited:
thank you! turns out the reason it was invisible.... was b/c it was spawning way the :red: far away b/c of the not multiplying by 16 thing. should be a lot easier to do stuff now that I can see the projectile.

EDIT: for the sprite intersection, that "tileSprite" thing is the only one I haven't been able to figure out at all. it doesn't seem to exist anywhere, where did you even get that from :p ? there doesn't seem to be anything related to sprites in ModTile, but I'm pretty tired so I might have better luck tomorrow.
You can probably just do a straight up number for your tileSprite's width and height, just assume that 1 tile block = 16 x 16 pixels.

How can I modify the critical strike chance of a weapon?
And is it possible to reduce player speed while using a weapon?
1. Try

Code:
item.crit

2. It is possible, depending on the thing, most likely want to use the this hook

Code:
public override bool UseItem(Player player)

And then adjust player.velocity.
 
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace WeirdStuff.Items
{
public class Large Crystal : ModItem
{
public override void SetDefaults()
{
item.name = "Large Crystal";
item.width = 20;
item.height = 20;
item.maxStack = 999;
AddTooltip(Shiny, isn't it.);
item.value = 100;
item.rare = 1;
item.useAnimation = 30;
item.useTime = 30;
item.useStyle = 4;
item.consumable = true;
}
public override bool CanUseItem(Player player)
{
return !NPC.AnyNPCs(mod.NPCType("Crystal Lord")); //you can't spawn this boss multiple times
return !Main.dayTime; //can use only at night
}
public override bool UseItem(Player player)
{
NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Crystal Lord")); //boss spawn
Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0);

return true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}


Can Someone please help me because I got the error CS1010 But I just cant find whats the problem
 
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace WeirdStuff.Items
{
public class Large Crystal : ModItem
{
public override void SetDefaults()
{
item.name = "Large Crystal";
item.width = 20;
item.height = 20;
item.maxStack = 999;
AddTooltip(Shiny, isn't it.);
item.value = 100;
item.rare = 1;
item.useAnimation = 30;
item.useTime = 30;
item.useStyle = 4;
item.consumable = true;
}
public override bool CanUseItem(Player player)
{
return !NPC.AnyNPCs(mod.NPCType("Crystal Lord")); //you can't spawn this boss multiple times
return !Main.dayTime; //can use only at night
}
public override bool UseItem(Player player)
{
NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Crystal Lord")); //boss spawn
Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0);

return true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}


Can Someone please help me because I got the error CS1010 But I just cant find whats the problem
which tmodloader Version use you?
 
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace WeirdStuff.Items
{
public class Large Crystal : ModItem
{
public override void SetDefaults()
{
item.name = "Large Crystal";
item.width = 20;
item.height = 20;
item.maxStack = 999;
AddTooltip(Shiny, isn't it.);
item.value = 100;
item.rare = 1;
item.useAnimation = 30;
item.useTime = 30;
item.useStyle = 4;
item.consumable = true;
}
public override bool CanUseItem(Player player)
{
return !NPC.AnyNPCs(mod.NPCType("Crystal Lord")); //you can't spawn this boss multiple times
return !Main.dayTime; //can use only at night
}
public override bool UseItem(Player player)
{
NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Crystal Lord")); //boss spawn
Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0);

return true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}


Can Someone please help me because I got the error CS1010 But I just cant find whats the problem
Your item name shouldn't have spaces, use underlines instead.
And your tooltip needs quotation marks: AddTooltip("Shiny, isn't it.");
 
2. It is possible, depending on the thing, most likely want to use the this hook

Code:
public override bool UseItem(Player player)

And then adjust player.velocity.

If feel stupid about not knowing item.crit, but I can't seem to get the speed thing to work.
My code compiles, but it doesn't do anything.
Code:
  public override bool UseItem(Player player)

  {
  player.velocity.X *= 0.2f;
  return true;
  }

I tried using a debuff instead cause I thought it wold be easier, but that didn't work either :/
Code:
  public override bool UseItem(Player player)

  {
  player.AddBuff(BuffID.Slow, 90);
  return true;
  }
Nothing happens.
 
View attachment 172357


I've went back to Terraria after a long time of not playing, I uninstalled Terraria and deleted all the mods so I can start fresh. I downloaded Terraria and then I downloaded Tmodloader, and it refuses to work. I have a Mac and only Terraria and TMod, no mods or anything. TMod will not work. I've uninstalled Terraria numerous times and downloaded TMod in many other different ways, but it does not work. Terraria works fine without it.

I've come to the conclusion that it is TMod's fault for there is nothing that can be conflicting with it as the only Terraria files I have are Terraria and TMod. Perhaps it needs an update or it does not work with Macs, but I'm very grown weary and I'm out of ideas and solutions. I'm at a loss and I am quite desperate.

Does anyone what TMod's problem is?

I'm having the same problem. To clarify, this is only the steam install. The GOG install is loading the vanilla game, even after I follow the instructions found in this thread: https://forums.terraria.org/index.php?threads/tml-gog-patcher-beta.50413/

Is there any fix to this, either install?
 
If feel stupid about not knowing item.crit, but I can't seem to get the speed thing to work.
My code compiles, but it doesn't do anything.
Code:
  public override bool UseItem(Player player)

  {
  player.velocity.X *= 0.2f;
  return true;
  }

I tried using a debuff instead cause I thought it wold be easier, but that didn't work either :/
Code:
  public override bool UseItem(Player player)

  {
  player.AddBuff(BuffID.Slow, 90);
  return true;
  }
Nothing happens.
Try setting player velocity to equal 0 and see if it stops the player when the item is used, it might help with what you are doing. I'm completely unsure of how to actually go about this.
 
Try setting player velocity to equal 0 and see if it stops the player when the item is used, it might help with what you are doing. I'm completely unsure of how to actually go about this.
Thanks, but I managed to make it work with this:
Code:
public override void UseStyle(Player player)
  {
  if (player.whoAmI == Main.myPlayer)
  {
  player.velocity.X *= 0.5f;
  }
  }
 
Add this to your file:
Code:
  public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
  {
  Vector2 muzzleOffset = Vector2.Normalize(new Vector2(speedX, speedY)) * 32f;
  if (Collision.CanHit(position, 0, 0, position + muzzleOffset, 0, 0))
  {
  position += muzzleOffset;
  }
  return true;
  }
The higher the value (here 32f) the further it is from the player.
 
Wat i do frong?

=======================================================================

using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;


namespace TooManyItems.Items.Accesory.Wings
{
[AutoloadEquip(EquipType.Wings)]
public class Dreculan : ModItem
{


public override void SetDefaults()
{
item.name = "Dreculan Wings";
item.width = 30;
item.height = 28;
item.toolTip = "Fast?";
item.value = 10;
item.rare = 5;
item.accessory = true;
}

public override void UpdateAccessory(Player player, bool hideVisual)
{
player.wingTimeMax = 100; //wings Height
}

public override void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising,
ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
{
ascentWhenFalling = 0.65f;
ascentWhenRising = 0.15f;
maxCanAscendMultiplier = 1f;
maxAscentMultiplier = 2f;
constantAscend = 0.135f;
}

public override void HorizontalWingSpeeds(ref float speed, ref float acceleration)
{
speed = 15f;
acceleration *= 2.2f;
}

public override void AddRecipes() //How to craft this item
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Feather, 10);
recipe.AddIngredient(ItemID.Cobweb, 5);
recipe.AddIngredient(ItemID.Silk, 4);
recipe.AddTile(TileID.SkyMill);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
 
Wat i do frong?

=======================================================================

using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;


namespace TooManyItems.Items.Accesory.Wings
{
[AutoloadEquip(EquipType.Wings)]
public class Dreculan : ModItem
{


public override void SetDefaults()
{
item.name = "Dreculan Wings";
item.width = 30;
item.height = 28;
item.toolTip = "Fast?";
item.value = 10;
item.rare = 5;
item.accessory = true;
}

public override void UpdateAccessory(Player player, bool hideVisual)
{
player.wingTimeMax = 100; //wings Height
}

public override void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising,
ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
{
ascentWhenFalling = 0.65f;
ascentWhenRising = 0.15f;
maxCanAscendMultiplier = 1f;
maxAscentMultiplier = 2f;
constantAscend = 0.135f;
}

public override void HorizontalWingSpeeds(ref float speed, ref float acceleration)
{
speed = 15f;
acceleration *= 2.2f;
}

public override void AddRecipes() //How to craft this item
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Feather, 10);
recipe.AddIngredient(ItemID.Cobweb, 5);
recipe.AddIngredient(ItemID.Silk, 4);
recipe.AddTile(TileID.SkyMill);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
Rename .txt to .cs
In tModLoader v0.10, changes in the code.
 

Attachments

  • Dreculan.txt
    1.4 KB · Views: 138
Back
Top Bottom