• PC NEWS: 1.4.2.3 update is out! More info here. Report bugs here
  • CONSOLE 1.4 NEWS: The current plan is to have Terraria: Journey's End out for Xbox and PlayStation in Q3 2021 (Jul-Sep). Switch will follow shortly afterwards. More info here. Stay up to date with console news here
  • MOBILE NEWS: Stay up to date with the latest mobile news here. Report mobile bugs here

Standalone [1.3] tModLoader - A Modding API

jopojelly

Retinazer
tModLoader
It says that "Something has caused this program to stop working properly"
Weird, btw I never type anything in the box, I just have the unzipped exe and a few xnbs in a random folder and click go. You can try that. If you still can't get it to work, I can PM you maybe
 

Piterros990

Duke Fishron
You use a GlobalSomething class, check the itemid in setdefaults, change whatever you want. If you want to add an effect, do the same for one of the update accessories hooks.

You can try having the code for your moditem also in update visuals.


You can go to the steam Terraria directory and you'll find the NPC_22.xnb and all the other textures. Convert them to png with the program linked to in my signature

https://dl.dropboxusercontent.com/u/41490830/TerrariaModding/XNB 4.0 Exporter.zip
So for the vanity I have to write:
public override void UpdateVisual(Player player)
{
player.something = something;
}
Right?
 

PapyroKinesis

Steampunker
Can someone help me make a tile count as station for various other ones too? Like, if there is xxx block here, you can use it as both an Anvil and a workbench, etc. I would like to use a Campfire for mine. Thanks!
 

jopojelly

Retinazer
tModLoader
Can someone help me make a tile count as station for various other ones too? Like, if there is xxx block here, you can use it as both an Anvil and a workbench, etc. I would like to use a Campfire for mine. Thanks!
You can use adjtiles to have your custom tile act as other tiles. https://github.com/bluemagic123/tModLoader/search?utf8=✓&q=adjtiles

It sounds like you want a vanilla campfire to work as anvil and workbenches, I think you can do that with globaltile in a similar manner to all the examples I linked you to.
 

PapyroKinesis

Steampunker

THEGamingninja

Terrarian
I found a bug with The Tremor & Thorium mods(they said come here) that no NPC's or bosses will in multiplayer on the t modloader server file, I have confirmed it's not just the world either by summoning a boss in single player with the exact world file in the exact same location, as soon as I got on the world I started getting NPC's and boss summons worked, please fix this as soon as you can!
 

SonicR

Spazmatism
How would I check whether an NPC was behind the player, and if so, make sure a homing projectile does not target them, even if the player turns and faces the NPC after firing the projectile?
 

imkSushi

Eater of Worlds
Why isn't this hotkey working?
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using imkSushisMod.Items;
using imkSushisMod.NPCs;

namespace imkSushisMod {
public class imkSushisMod : Mod
{
       public override void SetModInfo(out string name, ref ModProperties properties)
    {
        name = "imkSushisMod";
        properties.Autoload = true;
    }
        public override void AddRecipes()
    {
        RecipeHelper.AddInterchangeableRecipes(this);
        RecipeHelper.AddMelterRecipes(this);
        RecipeHelper.AddExtraRecipes(this);
        RecipeHelper.AddItemRecipes(this);
    }

    public override void Load()
    {
        RegisterHotKey("sushi", "O");
    }

public virtual void HotKeyPressed(string name)
{
if (name == "sushi")
{
        Main.player[Main.myPlayer].KillMe(999, 0, true, "Oops");
}
}
}}
 

Kazzymodus

Moderator
Staff member
Moderator
Why isn't this hotkey working?
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using imkSushisMod.Items;
using imkSushisMod.NPCs;

namespace imkSushisMod {
public class imkSushisMod : Mod
{
       public override void SetModInfo(out string name, ref ModProperties properties)
    {
        name = "imkSushisMod";
        properties.Autoload = true;
    }
        public override void AddRecipes()
    {
        RecipeHelper.AddInterchangeableRecipes(this);
        RecipeHelper.AddMelterRecipes(this);
        RecipeHelper.AddExtraRecipes(this);
        RecipeHelper.AddItemRecipes(this);
    }

    public override void Load()
    {
        RegisterHotKey("sushi", "O");
    }

public virtual void HotKeyPressed(string name)
{
if (name == "sushi")
{
        Main.player[Main.myPlayer].KillMe(999, 0, true, "Oops");
}
}
}}

There might be more wrong with this, but I'm pretty sure at least the virtual keyword isn't right. That should be override.
 

Kazzymodus

Moderator
Staff member
Moderator
How would I check whether an NPC was behind the player, and if so, make sure a homing projectile does not target them, even if the player turns and faces the NPC after firing the projectile?

You can use player.direction and npc.position to determine whether or not a NPC was behind the player. If you want the projectile to choose a target immediately when it's cast, you can run all enemies in range through the if statement and you're done. If you want it to be able to choose a new target during its lifetime, it gets more complicated. I suppose you could make an array of (in)valid targets at the beginning of the cast and then only let the projectile target NPCs that are (not) in it, but I don''t know if that's the most efficient way.

This compares the position of the NPC with the direction the player is facing (in pseudo-code):
Code:
if ( ( npc.Center.X < player.Center.X  &&  player.direction == 1) || ( npc.Center.X > player.Center.X && player.direction == -1) )
{
 // true if the NPC is not being faced, false if it is.
}

// Alternatively:

if ( ( npc.Center.X > player.Center.X  &&  player.direction == 1) || ( npc.Center.X < player.Center.X && player.direction == -1) )
{
 // true if the NPC is being faced, false if it's not.
}
 

alienmist325

Terrarian
I'm trying to make a projectile which stays still after hitting the ground, rather than killing itself.
I have tried:

public override bool OnTileCollide(Vector2 oldVelocity)
{
projectile.velocity.X = 0;
projectile.velocity.Y = 0;
return false;
}

and I have tried using the
'public override void TileCollideStyle(ref int width, ref int height, ref bool fallThrough)'
method too with the same code inside but nothing is working (The projectile just goes through the ground). What am I doing wrong?

[doublepost=1459077458,1459077280][/doublepost]Actually dw. I got it working
 
Top Bottom