Standalone [1.3] tModLoader - A Modding API

Can you show us the code when you have the error so we can check out the problem? It makes it easier for us to debug. But judging from the error message, you forgot to add a return code to it. For OnTileCollide, it should either "return true" for the projectile to be killed or "return false" for the projectile not to be killed when it contacts a tile.
I put return true, but it doesn't work how I wanted. It sometimes doesn't work, it doesn't make a sound, and it doesn't occasionally drop like a normal shuriken would. I just want it to have the exact same thing as the normal shuriken but drop the modded shuriken instead.
 
Can anyone help me with changing the color of a projectile?


Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework.Graphics;

namespace ProjectDelta.Projectiles
{
    public class CorrosiveGel : ModProjectile

    {


        public override void SetDefaults()
        {
            projectile.name = "Corrosive Gel";
            projectile.damage = 17;
            projectile.aiStyle = 12;
            projectile.penetrate = 2;
            projectile.height = 20;
            projectile.width = 15;
            projectile.hostile = false;
            projectile.friendly = true;
            projectile.tileCollide = true;
            projectile.alpha = 100;
        }
      
                 public Color GetColor()
        {
            return new Color(45, 255, 189);
        }
    }


    }
 
Can anyone help me with changing the color of a projectile?


Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework.Graphics;

namespace ProjectDelta.Projectiles
{
    public class CorrosiveGel : ModProjectile

    {


        public override void SetDefaults()
        {
            projectile.name = "Corrosive Gel";
            projectile.damage = 17;
            projectile.aiStyle = 12;
            projectile.penetrate = 2;
            projectile.height = 20;
            projectile.width = 15;
            projectile.hostile = false;
            projectile.friendly = true;
            projectile.tileCollide = true;
            projectile.alpha = 100;
        }
     
                 public Color GetColor()
        {
            return new Color(45, 255, 189);
        }
    }


    }
You'll want to use the GetAlpha method instead:
Code:
public override Color? GetAlpha(Color lightColor)
{
    // Return your color.
}
 
You'll want to use the GetAlpha method instead:
Code:
public override Color? GetAlpha(Color lightColor)
{
    // Return your color.
}

Is there anything else I'm supposed to do because when I applied the new code it didn't seem to do anything.
 
Could you show your current code?

Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework.Graphics;

namespace ProjectDelta.Projectiles
{
    public class CorrosiveGel : ModProjectile

    {


        public override void SetDefaults()
        {
            projectile.name = "Corrosive Gel";
            projectile.damage = 17;
            projectile.aiStyle = 12;
            projectile.penetrate = 2;
            projectile.height = 20;
            projectile.width = 15;
            projectile.hostile = false;
            projectile.friendly = true;
            projectile.tileCollide = true;
            projectile.alpha = 100;
        }

        public override Color? GetAlpha(Color lightColor)
        {
            return new Color(86, 255, 192);         
        }
      
    }


}
 
How do I fix that?
h_1454843093_5192463_445ab3f5a3.jpg

Full code:
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;

namespace PHIP.Tiles.Statues
{
    public class AStatue : ModTile
    {
        public override void SetDefaults()
        {
            Main.tileFrameImportant[Type] = true;
            TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2);
            TileObjectData.newTile.Height = 2;
            TileObjectData.newTile.Origin = new Point16(1, 1);
            TileObjectData.newTile.CoordinateHeights = new int[] { 17, 19 };
            TileObjectData.newTile.CoordinateWidth = new int[] { 17, 17 };
            TileObjectData.addTile(Type);
            Main.tileLavaDeath[Type] = true;
            Main.tileTable[Type] = true;
            Main.tileSolidTop[Type] = false;
            AddMapEntry(new Color(200, 200, 200));
            disableSmartCursor = false;
        }
        public override void KillMultiTile(int i, int j, int frameX, int frameY)
        {
            Item.NewItem(i * 16, j * 16, 32, 16, mod.ItemType("AStatue"));
        }
    }
}
 
Does anybody know what a Vector 2 is?

Ex:
int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, mod.DustType("Sparkle"));
[DOUBLEPOST=1454857813,1454857240][/DOUBLEPOST]And is it possible to check if there is a block at a certain (x, y) coordinate?
 
Does anybody know what a Vector 2 is?

Ex:
int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, mod.DustType("Sparkle"));
[DOUBLEPOST=1454857813,1454857240][/DOUBLEPOST]And is it possible to check if there is a block at a certain (x, y) coordinate?
A Vector2 is basically a variable that holds two floats (X and Y) and is therefore mainly used as a position indicator (you also have Vector3, which will allow positions in 3 dimensions).

And it is possible to check a tile at a certain x,y coordinate. You'll want to watch out for world coordinates, though (player.position, npc.position, projectile.position, etc), since you'll want to recalculate those to 'tile coordinates'. You can do this by dividing the X and Y values of the coordinate by 16 (which is the tile size in pixels in Terraria). After that, you can call 'Main.tile[x, y]' to get the tile at the given coordinates (example using an NPC):
Code:
int x = (int)(npc.position.X / 16); // Getting the X axis as a 'tile coordinate'.
int y = (int)(npc.position.Y / 16); // Getting the Y axis as a 'tile coordinate'.
// Now you've got your tile (using Main.tile[x, y]), do with it what you want.
 
A Vector2 is basically a variable that holds two floats (X and Y) and is therefore mainly used as a position indicator (you also have Vector3, which will allow positions in 3 dimensions).

And it is possible to check a tile at a certain x,y coordinate. You'll want to watch out for world coordinates, though (player.position, npc.position, projectile.position, etc), since you'll want to recalculate those to 'tile coordinates'. You can do this by dividing the X and Y values of the coordinate by 16 (which is the tile size in pixels in Terraria). After that, you can call 'Main.tile[x, y]' to get the tile at the given coordinates (example using an NPC):
Code:
int x = (int)(npc.position.X / 16); // Getting the X axis as a 'tile coordinate'.
int y = (int)(npc.position.Y / 16); // Getting the Y axis as a 'tile coordinate'.
// Now you've got your tile (using Main.tile[x, y]), do with it what you want.
Ok thx. Do you know how to check if a keyboard key is pressed?(I'm trying to make new controls)
 
Ok thx. Do you know how to check if a keyboard key is pressed?(I'm trying to make new controls)
You can use Main.keyState. You'll want to google XNA/MonoGame KeyboardState to get a better understanding of how that's working.
 
Where in the player is the coordinate counted?
(like, since the player is roughly 2x3 blocks, which block does the (x, y) coordinate describe?)
 
Where in the player is the coordinate counted?
(like, since the player is roughly 2x3 blocks, which block does the (x, y) coordinate describe?)
Depends on which coordinate you're getting. player.position refers to the upper left corner of the player.
 
Depends on which coordinate you're getting. player.position refers to the upper left corner of the player.
K thx so much!
[DOUBLEPOST=1454862437,1454862288][/DOUBLEPOST]
Depends on which coordinate you're getting. player.position refers to the upper left corner of the player.
Oh yeah, and how would you use Main.tile to check if there's empty space? (I'm trying to make something similar to the rod of discord, where it checks if you can teleport)
 
K thx so much!
[DOUBLEPOST=1454862437,1454862288][/DOUBLEPOST]
Oh yeah, and how would you use Main.tile to check if there's empty space? (I'm trying to make something similar to the rod of discord, where it checks if you can teleport)
Yeah, that's a weird one... You'll have to check if it's null at first (because some tiles seem to be null) and then you can check if the tile is not solid:
Code:
if(Main.tile[x, y] != null && !Main.tileSolid[(int)Main.tile[x, y].type])
{
    
}
 
For some reason, most of the items in the mods im playing have a white square around them, and its really annoying. Please Help!
 
Back
Top Bottom