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.
 
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?
 
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
 
Back
Top Bottom