Standalone [1.3] tModLoader - A Modding API

I can wait:p. But when are UI hooks coming, if some one know I would like to know
(In the OP):
v0.7.5: Hooks for interface

You may not need to wait that long though, I've heard subtle whispers for the next update about some UI implementation...
 
Li'll question:
Does anyone know how to prevent the drawing of wings on a player when (lets say) a certain buff is active?

As per this post, I don't think there is a simple fix for this. Then again, I'd like to proven wrong on this account.

I suppose you could use WingUpdate to draw wings as an empty frame when said buff is active, but I don't think the trouble of overriding every single vanilla wing and adding an empty frame to their sprite sheets is worth it.
 
As per this post, I don't think there is a simple fix for this. Then again, I'd like to proven wrong on this account.

I suppose you could use WingUpdate to draw wings as an empty frame when said buff is active, but I don't think the trouble of overriding every single vanilla wing and adding an empty frame to their sprite sheets is worth it.
I would be lazy and just set wings variable to 0. But then again that sounds a whole lot better than going through the player layer searching for the data value from vanilla code and use that data value to remove from the list. Setting wings to 0 may just end up making wings unusable.
 
As per this post, I don't think there is a simple fix for this. Then again, I'd like to proven wrong on this account.

I suppose you could use WingUpdate to draw wings as an empty frame when said buff is active, but I don't think the trouble of overriding every single vanilla wing and adding an empty frame to their sprite sheets is worth it.
I'm glad I can prove you wrong then (no offense :) ). I've found a way to do it (just by trial and error):
Code:
public override void ModifyDrawLayers(System.Collections.Generic.List<PlayerLayer> layers)
{
    for (int i = 0; i < layers.Count; ++i)
    {
        if (layers[i].Name == "Wings" && this.myBuffActive)
        {
            layers[i].visible = false;
        }
    }
}
This is in my ModPlayer class. Now I'm not sure if this is the most 'optimal' version, but i'm already glad it works.
 
Li'll question:
Does anyone know how to prevent the drawing of wings on a player when (lets say) a certain buff is active?
As per this post, I don't think there is a simple fix for this. Then again, I'd like to proven wrong on this account.

I suppose you could use WingUpdate to draw wings as an empty frame when said buff is active, but I don't think the trouble of overriding every single vanilla wing and adding an empty frame to their sprite sheets is worth it.
Theoretically you should be able to set player.wings to 0 in this hook: https://github.com/bluemagic123/tModLoader/wiki/ModPlayer#public-virtual-void-frameeffects

I haven't actually tried it for myself though.

Out of interest, how do you (tModLoader Devs) learn how to code in C#?
C# is pretty similar to Java and I already knew Java, so it was pretty easy to learn what exactly was different from Java.

I learned Java by making a small game, battling through all the bugs, etc., with help from the fact that I learned the concepts of object-oriented programming from school.

(In the OP):
v0.7.5: Hooks for interface

You may not need to wait that long though, I've heard subtle whispers for the next update about some UI implementation...
We haven't worked on any UI stuff yet; although it is possible to hack something together using one of the drawing hooks and the XNA input states.
 
Hey there. I see that the chest sync bug in MP is listed as fixed in an unreleased version. Can I get a status on that please?
 
Hi! I'm new here. I apologize if either of my questions are already answered in the ~400 pages of this thread, I haven't managed to read all the posts.

I have a couple questions about modding Terraria that I hope you guys can answer for me.
1.) If I apply a mod to Terraria is every world automatically affected by it or is it only worlds created after the mod is applied? I want to create a mod for my kids to play while still having access to my regular vanilla characters and worlds.
2.) Is it possible to remove/hide items from vanilla Terraria? I'm trying to get my kids (3 and 5) into the game and they seem really into the building and mining aspects of the game so I would like to remove the monsters so they can dig and build uninterrupted in their play.

Thanks in advance!
- Aerlock
 
Hi! I'm new here. I apologize if either of my questions are already answered in the ~400 pages of this thread, I haven't managed to read all the posts.

I have a couple questions about modding Terraria that I hope you guys can answer for me.
1.) If I apply a mod to Terraria is every world automatically affected by it or is it only worlds created after the mod is applied? I want to create a mod for my kids to play while still having access to my regular vanilla characters and worlds.
2.) Is it possible to remove/hide items from vanilla Terraria? I'm trying to get my kids (3 and 5) into the game and they seem really into the building and mining aspects of the game so I would like to remove the monsters so they can dig and build uninterrupted in their play.

Thanks in advance!
- Aerlock
Tmodloader saves are separate from your original saves. And you could do a global npc script that override the spawning of the monsters . If you dont know how to make that PM me and I can do the mod it for you:p
 
Hi! I'm new here. I apologize if either of my questions are already answered in the ~400 pages of this thread, I haven't managed to read all the posts.

I have a couple questions about modding Terraria that I hope you guys can answer for me.
1.) If I apply a mod to Terraria is every world automatically affected by it or is it only worlds created after the mod is applied? I want to create a mod for my kids to play while still having access to my regular vanilla characters and worlds.
2.) Is it possible to remove/hide items from vanilla Terraria? I'm trying to get my kids (3 and 5) into the game and they seem really into the building and mining aspects of the game so I would like to remove the monsters so they can dig and build uninterrupted in their play.

Thanks in advance!
- Aerlock
hello! I have a suggestion! after you download and install TModLoader there should be a mod in the "mod browser (beta)" called "creative mode" just download that..go to the "mods" section..enable it..reload mods..and then when the game starts press the enter key and type in "/godmode" without quotes of course..you will be immortal and deal EXTREME damage to all monsters..making them a non-issue
 
I've got quite the request here... But Is it possible to get some info on how to better translate this from the ancient tConfig style, into tModLoader? If its too long or not very manageable, its cool. Basically the code is supposed to create vilethorn like entities, that branch at the ends.
Code:
public void AI()
{
    Projectile P = projectile;
    Vector2 PC = P.position+new Vector2(P.width/2,P.height/2);
    P.rotation = (float)Math.Atan2((double)P.velocity.Y, (double)P.velocity.X) + (float)(Math.PI/2);
    if (P.ai[0] == 0f)
    {
        P.alpha -= 50;
        if (P.alpha <= 0)
        {
            P.alpha = 0;
            P.ai[0] = 1f;
            if (P.ai[1] == 0f)
            {
                P.ai[1] += 1f;
                P.position += P.velocity * 1f;
            }
            if (P.type == 7 && Main.myPlayer == P.owner)
            {
                int Projectile_Type = P.type;
                if (P.ai[1] >= 8) // change for max parts
                {
                    Projectile_Type = Config.projDefs.byName["RevoltingThorn2"].type;
                }
                else
                    Projectile_Type = Config.projDefs.byName["RevoltingThorn1"].type;
                if((int)(P.ai[1])%3==0)
                {
                    Vector2 MemoryUnit = new Vector2(P.velocity.X,P.velocity.Y);

                    float RotatoryAngle = (float)((Math.PI*1)/8f)*(float)Main.rand.NextDouble();
                  
                    #region Projectile 1
                  
                    P.velocity=RotateAboutOrigin(MemoryUnit,RotatoryAngle);

                    int Projectile_Index = Projectile.NewProjectile(
                    PC.X + P.velocity.X ,
                    PC.Y + P.velocity.Y,
                    P.velocity.X,
                    P.velocity.Y,
                    Projectile_Type,
                    P.damage,
                    P.knockBack,
                    P.owner
                    );
                    Projectile Inheritor = Main.projectile[Projectile_Index];
                    Inheritor.damage = P.damage;
                    Inheritor.ai[1] = P.ai[1] + 1f;
                    NetMessage.SendData(27, -1, -1, "", Projectile_Index, 0f, 0f, 0f, 0);

                    #endregion

                    #region Projectile 2

                    RotatoryAngle = (float)((Math.PI*1)/8f)*(float)Main.rand.NextDouble();

                    P.velocity=RotateAboutOrigin(MemoryUnit,-RotatoryAngle);

                    Projectile_Index = Projectile.NewProjectile(
                    PC.X + P.velocity.X ,
                    PC.Y + P.velocity.Y,
                    P.velocity.X,
                    P.velocity.Y,
                    Projectile_Type,
                    P.damage,
                    P.knockBack,
                    P.owner
                    );
                    Inheritor = Main.projectile[Projectile_Index];
                    Inheritor.damage = P.damage;
                    Inheritor.ai[1] = P.ai[1] + 1f;
                    NetMessage.SendData(27, -1, -1, "", Projectile_Index, 0f, 0f, 0f, 0);

                    #endregion
                }
                else
                {
                    int Projectile_Index = Projectile.NewProjectile(
                    PC.X + P.velocity.X ,
                    PC.Y + P.velocity.Y,
                    P.velocity.X,
                    P.velocity.Y,
                    Projectile_Type,
                    P.damage,
                    P.knockBack,
                    P.owner
                    );
                    Projectile Inheritor = Main.projectile[Projectile_Index];
                    Inheritor.damage = P.damage;
                    Inheritor.ai[1] = P.ai[1] + 1f;
                    NetMessage.SendData(27, -1, -1, "", Projectile_Index, 0f, 0f, 0f, 0);
                }
                return;
            }
        }
    }
    else
    {
        if (P.alpha < 170 && P.alpha + 5 >= 170)
        {
            for (int j = 0; j < 3; j++)
            {
                Dust.NewDust(P.position, P.width, P.height, 18, P.velocity.X * 0.025f, P.velocity.Y * 0.025f, 170, default(Color), 1.2f);
            }
            Dust.NewDust(P.position, P.width, P.height, 14, 0f, 0f, 170, default(Color), 1.1f);
        }
        P.alpha += 5;
        if (P.alpha >= 255)
        {
            P.Kill();
            return;
        }
    }          
}


#region Rotate by Angles


public Vector2 RotateByRightAngle(Vector2 vector)
{
    return new Vector2(vector.Y, -vector.X);
}


public Vector2 RotateByLeftAngle(Vector2 vector)
{
    return new Vector2(-vector.Y, vector.X);
}


#endregion


#region Rotate About Origin


        public Vector2 RotateAboutOrigin(Vector2 point, float rotation)
        {
            if(rotation < 0)
                rotation+=(float)(Math.PI*4);
            Vector2 u = point; //point relative to origin

            if (u == Vector2.Zero)
                return point;

            float a = (float)Math.Atan2(u.Y, u.X); //angle relative to origin
            a += rotation; //rotate

            //u is now the new point relative to origin
            u = u.Length() * new Vector2((float)Math.Cos(a), (float)Math.Sin(a));
            return u;
        }


#endregion
 
I've got quite the request here... But Is it possible to get some info on how to better translate this from the ancient tConfig style, into tModLoader? If its too long or not very manageable, its cool. Basically the code is supposed to create vilethorn like entities, that branch at the ends.
Code:
public void AI()
{
    Projectile P = projectile;
    Vector2 PC = P.position+new Vector2(P.width/2,P.height/2);
    P.rotation = (float)Math.Atan2((double)P.velocity.Y, (double)P.velocity.X) + (float)(Math.PI/2);
    if (P.ai[0] == 0f)
    {
        P.alpha -= 50;
        if (P.alpha <= 0)
        {
            P.alpha = 0;
            P.ai[0] = 1f;
            if (P.ai[1] == 0f)
            {
                P.ai[1] += 1f;
                P.position += P.velocity * 1f;
            }
            if (P.type == 7 && Main.myPlayer == P.owner)
            {
                int Projectile_Type = P.type;
                if (P.ai[1] >= 8) // change for max parts
                {
                    Projectile_Type = Config.projDefs.byName["RevoltingThorn2"].type;
                }
                else
                    Projectile_Type = Config.projDefs.byName["RevoltingThorn1"].type;
                if((int)(P.ai[1])%3==0)
                {
                    Vector2 MemoryUnit = new Vector2(P.velocity.X,P.velocity.Y);

                    float RotatoryAngle = (float)((Math.PI*1)/8f)*(float)Main.rand.NextDouble();
                 
                    #region Projectile 1
                 
                    P.velocity=RotateAboutOrigin(MemoryUnit,RotatoryAngle);

                    int Projectile_Index = Projectile.NewProjectile(
                    PC.X + P.velocity.X ,
                    PC.Y + P.velocity.Y,
                    P.velocity.X,
                    P.velocity.Y,
                    Projectile_Type,
                    P.damage,
                    P.knockBack,
                    P.owner
                    );
                    Projectile Inheritor = Main.projectile[Projectile_Index];
                    Inheritor.damage = P.damage;
                    Inheritor.ai[1] = P.ai[1] + 1f;
                    NetMessage.SendData(27, -1, -1, "", Projectile_Index, 0f, 0f, 0f, 0);

                    #endregion

                    #region Projectile 2

                    RotatoryAngle = (float)((Math.PI*1)/8f)*(float)Main.rand.NextDouble();

                    P.velocity=RotateAboutOrigin(MemoryUnit,-RotatoryAngle);

                    Projectile_Index = Projectile.NewProjectile(
                    PC.X + P.velocity.X ,
                    PC.Y + P.velocity.Y,
                    P.velocity.X,
                    P.velocity.Y,
                    Projectile_Type,
                    P.damage,
                    P.knockBack,
                    P.owner
                    );
                    Inheritor = Main.projectile[Projectile_Index];
                    Inheritor.damage = P.damage;
                    Inheritor.ai[1] = P.ai[1] + 1f;
                    NetMessage.SendData(27, -1, -1, "", Projectile_Index, 0f, 0f, 0f, 0);

                    #endregion
                }
                else
                {
                    int Projectile_Index = Projectile.NewProjectile(
                    PC.X + P.velocity.X ,
                    PC.Y + P.velocity.Y,
                    P.velocity.X,
                    P.velocity.Y,
                    Projectile_Type,
                    P.damage,
                    P.knockBack,
                    P.owner
                    );
                    Projectile Inheritor = Main.projectile[Projectile_Index];
                    Inheritor.damage = P.damage;
                    Inheritor.ai[1] = P.ai[1] + 1f;
                    NetMessage.SendData(27, -1, -1, "", Projectile_Index, 0f, 0f, 0f, 0);
                }
                return;
            }
        }
    }
    else
    {
        if (P.alpha < 170 && P.alpha + 5 >= 170)
        {
            for (int j = 0; j < 3; j++)
            {
                Dust.NewDust(P.position, P.width, P.height, 18, P.velocity.X * 0.025f, P.velocity.Y * 0.025f, 170, default(Color), 1.2f);
            }
            Dust.NewDust(P.position, P.width, P.height, 14, 0f, 0f, 170, default(Color), 1.1f);
        }
        P.alpha += 5;
        if (P.alpha >= 255)
        {
            P.Kill();
            return;
        }
    }         
}


#region Rotate by Angles


public Vector2 RotateByRightAngle(Vector2 vector)
{
    return new Vector2(vector.Y, -vector.X);
}


public Vector2 RotateByLeftAngle(Vector2 vector)
{
    return new Vector2(-vector.Y, vector.X);
}


#endregion


#region Rotate About Origin


        public Vector2 RotateAboutOrigin(Vector2 point, float rotation)
        {
            if(rotation < 0)
                rotation+=(float)(Math.PI*4);
            Vector2 u = point; //point relative to origin

            if (u == Vector2.Zero)
                return point;

            float a = (float)Math.Atan2(u.Y, u.X); //angle relative to origin
            a += rotation; //rotate

            //u is now the new point relative to origin
            u = u.Length() * new Vector2((float)Math.Cos(a), (float)Math.Sin(a));
            return u;
        }


#endregion
I have zero experience with tConfig, but what you have right there is code that works with Terraria, so you should be able to plop that into tModLoader without much effort.
 
I have zero experience with tConfig, but what you have right there is code that works with Terraria, so you should be able to plop that into tModLoader without much effort.
I suppose the biggest problem I encountered was finding similar methods to
public Vector2 RotateAboutOrigin(Vector2 point, float rotation), public Vector2 RotateByRightAngle(Vector2 vector) and Public Vector2 RotateByLeftAngle(Vector2 vector). But maybe the problem is my lack of a necessary reference...

 
I suppose the biggest problem I encountered was finding similar methods to
public Vector2 RotateAboutOrigin(Vector2 point, float rotation), public Vector2 RotateByRightAngle(Vector2 vector) and Public Vector2 RotateByLeftAngle(Vector2 vector). But maybe the problem is my lack of a necessary reference...
Those methods look like they should have been defined from wherever you got that code.

Terraria does have something in its own code that could help you though:
public static Vector2 RotatedBy(this Vector2 spinningpoint, double radians, Vector2 center = default(Vector2))
That basically adds RotatedBy to Vector2, and it has more freedom than RotateAboutOrigin, etc.
 
Can anyone help me on why I cant play multiplayer!? Every time my friend tries to join my server it says "found server" then about a minute later it crashes. Please someone help I really want to play these mods on multiplayer!!
 
Can you plwase help me on how the multiplayer works. I cant play multiplayer on any of the mods i play because my friend can never join me, it always says found server and crashes like a minute after. PLEASE HELP
 
Tmodloader saves are separate from your original saves. And you could do a global npc script that override the spawning of the monsters . If you dont know how to make that PM me and I can do the mod it for you:p
Thanks for the help!
Is it possible to change the location of the TModLoader saves like with vanilla Terraria? adding -savedirectory "<directory>" to the end of the shortcut that launches Terraria
I took a look at the documentation for TmodLoader and I think I can figure out how to make that global NPC script work. I do have one question: Are the Town NPCs affected by the Global NPC script or are they different?

hello! I have a suggestion! after you download and install TModLoader there should be a mod in the "mod browser (beta)" called "creative mode" just download that..go to the "mods" section..enable it..reload mods..and then when the game starts press the enter key and type in "/godmode" without quotes of course..you will be immortal and deal EXTREME damage to all monsters..making them a non-issue
Thanks for the suggestion, I'll try that if nothing else works. I'm trying to remove the fighting from the game so my wife won't object to the kids playing. Our 3 year old likes to "pretend" to fight zombies and has been hitting. He like the digging and building too so I'm trying to separate the two to keep him from trying to emulate the game.

Thanks
- Aerlock
 
nO6ttet.jpg


Anyone know what caused this crash?
 
Back
Top Bottom