Standalone [1.3] tModLoader - A Modding API

ModProjectile
Allright, so you've got two drawOriginOffsets right? X and Y.
What you want to do with these values is set them in the SetDefaults function of your ModProjectile. Ex:
Code:
public override void SetDefaults()
{
    // Name, width, height, etcetc.
    
    // Now say the texture of your projectile is... 16x16 and you want the projectile to rotate around its center, you'll want to set the origin values to 8, since that will get the middle of the projectile to rotate or draw around.    
    drawOriginOffsetY = drawOriginOffsetY = 8;
}
This is untested, but technically it should work.
 
What I have seen people do is use
Code:
Main.NewText("Using MyMod version 1.0");
upon entering a world. Kind of the same effect (I guess?).
How whould i add these MEssage? to what File i need to to add it and what Method etc
 
How whould i add these MEssage? to what File i need to to add it and what Method etc
I'm not sure if there's a general 'OnWorldJoin' kind of function, but one (not so optimal, but working) way of doing this is by using the following code in a class that derives from ModPlayer:
Code:
private bool loaded = false;
public override void PreUpdate()
{
    if(!loaded)
    {
        Main.NewText("Display your message here.");
        loaded = true;
    }
}
 
Allright, so you've got two drawOriginOffsets right? X and Y.
What you want to do with these values is set them in the SetDefaults function of your ModProjectile. Ex:
Code:
public override void SetDefaults()
{
    // Name, width, height, etcetc.
   
    // Now say the texture of your projectile is... 16x16 and you want the projectile to rotate around its center, you'll want to set the origin values to 8, since that will get the middle of the projectile to rotate or draw around.   
    drawOriginOffsetY = drawOriginOffsetY = 8;
}
This is untested, but technically it should work.
Nope, I can't assign a value because drawOriginOffset is a group of methods.
[doublepost=1465732040,1465731925][/doublepost]
Nope, I can't assign a value because drawOriginOffset is a group of methods.
Huh, now it is working...
 
Nope, I can't assign a value because drawOriginOffset is a group of methods.
[doublepost=1465732040,1465731925][/doublepost]
Huh, now it is working...
What did you change?
drawOriginOffset in itself is nothing, you'll have to either reference the X or Y variable.
 
I'm not sure if there's a general 'OnWorldJoin' kind of function, but one (not so optimal, but working) way of doing this is by using the following code in a class that derives from ModPlayer:
Code:
private bool loaded = false;
public override void PreUpdate()
{
    if(!loaded)
    {
        Main.NewText("Display your message here.");
        loaded = true;
    }
}
How do i change the Color of the Text?
 
How do i change the Color of the Text?
Use the R,G,B parameters of the Main.NewText function. Ex:
Code:
Main.NewText("I'm Red", 255, 0, 0);
Main.NewText("I'm Green", 0, 255, 0);
Main.NewText("I'm Blue", 0, 0, 255);
Main.NewText("I'm... Yellow?", 255, 125, 40);
 
How can I check player's facing?
 
How can I check player's facing?
player.direction. If that variable is -1 the player is facing left. If it's 1, the player is facing right. Ex:
Code:
if(player.direction == -1)
    // Left
else
    // Right
 
player.direction. If that variable is -1 the player is facing left. If it's 1, the player is facing right. Ex:
Code:
if(player.direction == -1)
    // Left
else
    // Right
But I need to check this in SetDefaults to change drawOriginOffset and there is no "player"
 
But I need to check this in SetDefaults to change drawOriginOffset and there is no "player"
Allright, in this case 'player' was just an example of a Player class instance.
If you want to check the direction of the owner of the projectile in the SetDefaults function, something like this may work:
Code:
public override SetDefaults()
{
    Player p = Main.player[projectile.owner];
    if(p.direction == -1)
        // Do your left stuff.
    else
        // Do your right stuff.
}
 
Just so I don't have to test everything again, this should make it so ore can't spawn in trees right?
Because ore runner allows ore to spawn in only specified tiles.

Code:
if (downedDesertScourge)
 {
 for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 15E-05); k++)
 {
 int i2 = WorldGen.genRand.Next(0, Main.maxTilesX);
 int j2 = WorldGen.genRand.Next((int)(Main.maxTilesY * .2f), (int)(Main.maxTilesY * .8f));
 WorldGen.OreRunner(i2, j2, (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(3, 6), (ushort)mod.TileType("AerialiteOre"));
 }
 }
 
Allright, in this case 'player' was just an example of a Player class instance.
If you want to check the direction of the owner of the projectile in the SetDefaults function, something like this may work:
Code:
public override SetDefaults()
{
    Player p = Main.player[projectile.owner];
    if(p.direction == -1)
        // Do your left stuff.
    else
        // Do your right stuff.
}
Yes, it works, thank you
 
What is the bsdiff in the gog version of tmodloader for?
 
Just so I don't have to test everything again, this should make it so ore can't spawn in trees right?
Because ore runner allows ore to spawn in only specified tiles.

Code:
if (downedDesertScourge)
{
for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 15E-05); k++)
{
int i2 = WorldGen.genRand.Next(0, Main.maxTilesX);
int j2 = WorldGen.genRand.Next((int)(Main.maxTilesY * .2f), (int)(Main.maxTilesY * .8f));
WorldGen.OreRunner(i2, j2, (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(3, 6), (ushort)mod.TileType("AerialiteOre"));
}
}
I've been using OreRunner and never had the problem of ore spawning in trees so yeah, this should work (if there are no errors of course).
 
How can I make the projectile spin during flight?
 
Just a quick question to confirm my assumption:
A method when placing a tile is absent, right? I want to use the coordinates of the newly placed tile, so if my assumption is correct, I'm guessing I'll have to do the tile placement manually and go from there?
How can I make the projectile spin during flight?
You could try something like the following:
Code:
public override bool PreUpdate()
{
    projectile.rotation += 0.1F * projectile.direction;
    return false;
}

<<< EDIT >>>
Nevermind my question, I think the placement of Chests has answered it.
 
Last edited:
Can anyone help me on installation please?
 
Back
Top Bottom