tAPI tAPI Community Resources - Development assistance for developers, by developers.

You shouldn't really do it with coordinates, as it is much more difficult to manage moving where the projectile spawns... This code making it invisible at first then visible allows it so that it will "appear" to be correct when spawned rather than it being just spawned on the player.

I know it :/ but i want to make with it because the spread of this weap it's not much coordinated with the barrel (or it's high or it's lower from the sprite like in the image) and for some bugs that can have with low proj speed like this, now make the proj invisible is good, but only after...

Proj speed is set to 5
Shoots 5
Spread 20
Mult 0,03
If can be useful.
 
For some reason, when I try to load my mod after trying to make a new type of crafting bench/furniture item, it crashes.
{
"displayName": "Alchemiter",
"texture": "Textures/Tiles/Alchemiter",
"size": [2,2],
"frameWidth": 16,
"frameHeight": 16,
"frameImportant": true,
"directional": false,
"blocksLight": false,
"blocksSun": false,
"mergeDirt": false,
"placementConditions": "flatGround",
"placementOrigin": [2,1],
"drop": "terrastuckescg:AlchemiterItem",
"breaksByPick": true,
"dust": 0,
"sound": 1,
"soundGroup": 21,
"mapColor": [179, 125, 31]
}

{
"displayName": "Alchemiter (Item))",
"texture": "Textures/Items/Tiles/AlchemiterItem",
"size": [16,16],
"maxStack": 999,
"value": [0,0,10,0],
"rare": 7,
"useStyle": 1,
"useAnimation": 15,
"useTime": 10,
"autoReuse": true,
"useTurn": true,
"tooltip": "Used to craft things",
"createTile": "terrastuckescg:Alchemiter",
"consumable": true,

"recipes":
[{
"items": { "Dirt Block": 1 },
"tiles": [ "Work Bench" ],
"creates": 1
}]
}

Help! I'm trying to make a Homestuck mod, which is why it's called the alchemiter :3
 
Because I've been making some very glitcthy things I want to ask before I crash my computer: how would you make a sand like tile? is there a specific .json property for it? I know it would involve creating a projectile when there is no tile underneath the block, and then having the projectile turn into a block, but is there any code for determining whether or not there is a block directly underneath the modded one?
 
Because I've been making some very glitcthy things I want to ask before I crash my computer: how would you make a sand like tile? is there a specific .json property for it? I know it would involve creating a projectile when there is no tile underneath the block, and then having the projectile turn into a block, but is there any code for determining whether or not there is a block directly underneath the modded one?
Try using -
"tileSand": true
in the JSON file
 
Yeah Tilesand doesn't work.
Looking at the tAPI's code, it appears the tileSand property is only used during world generation to make sure no hanging tiles are left in the air. Did not know that. Looks like your original assumption was correct. On update check if the tile below is active, if not spawn a projectile that on tile collide creates your tile.
Code:
if (Main.tile[x, y + 1] != null && !Main.tile[x, y + 1].active()) {
    Main.tile[x, y].active(false);
    int damage = 10; // Or whatever
    int type = yourCustomProjectileType;
    Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 + 8), 0f, 0.41f, type, damage, 0f, Main.myPlayer, 0f, 0f);
    WorldGen.SquareTileFrame(x, y);
}
 
For some reason, when I try to load my mod after trying to make a new type of crafting bench/furniture item, it crashes.
{
"displayName": "Alchemiter",
"texture": "Textures/Tiles/Alchemiter",
"size": [2,2],
"frameWidth": 16,
"frameHeight": 16,
"frameImportant": true,
"directional": false,
"blocksLight": false,
"blocksSun": false,
"mergeDirt": false,
"placementConditions": "flatGround",
"placementOrigin": [2,1],
"drop": "terrastuckescg:AlchemiterItem",
"breaksByPick": true,
"dust": 0,
"sound": 1,
"soundGroup": 21,
"mapColor": [179, 125, 31]
}

{
"displayName": "Alchemiter (Item))",
"texture": "Textures/Items/Tiles/AlchemiterItem",
"size": [16,16],
"maxStack": 999,
"value": [0,0,10,0],
"rare": 7,
"useStyle": 1,
"useAnimation": 15,
"useTime": 10,
"autoReuse": true,
"useTurn": true,
"tooltip": "Used to craft things",
"createTile": "terrastuckescg:Alchemiter",
"consumable": true,

"recipes":
[{
"items": { "Dirt Block": 1 },
"tiles": [ "Work Bench" ],
"creates": 1
}]
}

Help! I'm trying to make a Homestuck mod, which is why it's called the alchemiter :3
The tiles placementOrigin is outside the bounds of the tile.
The tile size is 2x2, so the tile has these placement positions available.
(0, 0) (1, 0)
(0, 1) (1, 1)
Placement origin is usually
Ceiling((TileWidth / 2) - 1) => For the X coordinate
TileHeight - 1 => For the Y coordinate ( Unless it hangs like a chandelier or banner, then the y coordinate is 0 )
Try changing to => "placementOrigin": [0, 1]
 
Looking at the tAPI's code, it appears the tileSand property is only used during world generation to make sure no hanging tiles are left in the air. Did not know that. Looks like your original assumption was correct. On update check if the tile below is active, if not spawn a projectile that on tile collide creates your tile.
Code:
if (Main.tile[x, y + 1] != null && !Main.tile[x, y + 1].active()) {
    Main.tile[x, y].active(false);
    int damage = 10; // Or whatever
    int type = yourCustomProjectileType;
    Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 + 8), 0f, 0.41f, type, damage, 0f, Main.myPlayer, 0f, 0f);
    WorldGen.SquareTileFrame(x, y);
}
The x,y code doesn't seem to work, is there a certain reference I need?
 
The tiles placementOrigin is outside the bounds of the tile.
The tile size is 2x2, so the tile has these placement positions available.
(0, 0) (1, 0)
(0, 1) (1, 1)
Placement origin is usually
Ceiling((TileWidth / 2) - 1) => For the X coordinate
TileHeight - 1 => For the Y coordinate ( Unless it hangs like a chandelier or banner, then the y coordinate is 0 )
Try changing to => "placementOrigin": [0, 1]
It's refusing to work- it still crashes on loadup, thanks for the help though :3
 
The x,y code doesn't seem to work, is there a certain reference I need?
In your tiles cs file try -
Code:
public override bool TileFrame(int x, int y) {
    
    if (Main.tile[x, y + 1] != null && !Main.tile[x, y + 1].active()) {
        
        Main.tile[x, y].active(false);
        int damage = 10; // Or whatever
        int type = yourCustomProjectileType;
        Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 + 8), 0f, 0.41f, type, damage, 0f, Main.myPlayer, 0f, 0f);
        WorldGen.SquareTileFrame(x, y);
        
    }
    
    return false; // Might try true as well to see which works better
    
}
 
In your tiles cs file try -
Code:
public override bool TileFrame(int x, int y) {
   
    if (Main.tile[x, y + 1] != null && !Main.tile[x, y + 1].active()) {
       
        Main.tile[x, y].active(false);
        int damage = 10; // Or whatever
        int type = yourCustomProjectileType;
        Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 + 8), 0f, 0.41f, type, damage, 0f, Main.myPlayer, 0f, 0f);
        WorldGen.SquareTileFrame(x, y);
       
    }
   
    return false; // Might try true as well to see which works better
   
}
question, how would one accomplish the whole, OnTileCollide place this block? Is it something like, tile.newTile? If so, it would be greatly appreciated if you could post the string to accomplish this
 
In your tiles cs file try -
Code:
public override bool TileFrame(int x, int y) {
   
    if (Main.tile[x, y + 1] != null && !Main.tile[x, y + 1].active()) {
       
        Main.tile[x, y].active(false);
        int damage = 10; // Or whatever
        int type = yourCustomProjectileType;
        Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 + 8), 0f, 0.41f, type, damage, 0f, Main.myPlayer, 0f, 0f);
        WorldGen.SquareTileFrame(x, y);
       
    }
   
    return false; // Might try true as well to see which works better
   
}
Thanks! just one more question, in the line "int type = myprojectile;" would I have to type something like "projdef.byName["my projectile"] to make it work with my custom projectile?
 
Thanks! just one more question, in the line "int type = myprojectile;" would I have to type something like "projdef.byName["my projectile"] to make it work with my custom projectile?
most likely, that's what it seems like you would need to do... there may be a different method, however
[DOUBLEPOST=1431388396,1431388263][/DOUBLEPOST]
Thanks! just one more question, in the line "int type = myprojectile;" would I have to type something like "projdef.byName["my projectile"] to make it work with my custom projectile?
or even better, as I'm not sure that ProjDef.byname could be converted to an integer, you may just want to go into the line
Code:
 Projectile.NewProjectile((float)(x * 16 + 8), (float)(y * 16 + 8), 0f, 0.41f, type, damage, 0f, Main.myPlayer, 0f, 0f);
and replace the type, with ProjDef.byname["myprojectile'sname"].type
 
question, how would one accomplish the whole, OnTileCollide place this block? Is it something like, tile.newTile? If so, it would be greatly appreciated if you could post the string to accomplish this
I found some code for that awhile ago on either the Tapi page or another modding help page, however it was for turning liquids into a tile when the projectile hit it, I edited it a bit, so it should work but I haven't tested it with this method of giving gravity to blocks, but here it is anyway
Code:
        public override void PostKill()
        {
     int x = (int)(projectile.Center.X / 16f);
int y = (int)(projectile.Center.Y/ 16f);
Main.tile[x, y].type = TileDef.byName["Ardium:ScarredSand"];
Main.tile[x, y].active(true);
if (Main.netMode == 2)
{
    NetMessage.SendTileSquare(-1, x, y, 1);
}
else
{
    WorldGen.SquareTileFrame(x, y, true);
I give full credit to bluemagic for this code.
 
I found some code for that awhile ago on either the Tapi page or another modding help page, however it was for turning liquids into a tile when the projectile hit it, I edited it a bit, so it should work but I haven't tested it with this method of giving gravity to blocks, but here it is anyway
Code:
        public override void PostKill()
        {
     int x = (int)(projectile.Center.X / 16f);
int y = (int)(projectile.Center.Y/ 16f);
Main.tile[x, y].type = TileDef.byName["Ardium:ScarredSand"];
Main.tile[x, y].active(true);
if (Main.netMode == 2)
{
    NetMessage.SendTileSquare(-1, x, y, 1);
}
else
{
    WorldGen.SquareTileFrame(x, y, true);
I give full credit to bluemagic for this code.


Well, allow me to explain what I'm trying to do, I may be overlooking something obvious, but I'm trying to make it so that and item I have, when you press a keybind (already set that stuffs up) allows you to place a tile, that lasts for about 30 seconds, it seemed to me that projectiles were the easiest way to do this, but they may not be. All I really need is to know if there's a line that I can put in that places a tile.
 
Well, allow me to explain what I'm trying to do, I may be overlooking something obvious, but I'm trying to make it so that and item I have, when you press a keybind (already set that stuffs up) allows you to place a tile, that lasts for about 30 seconds, it seemed to me that projectiles were the easiest way to do this, but they may not be. All I really need is to know if there's a line that I can put in that places a tile.
In that case I'm not too sure, I know that code will place a tile upon the projectiles death, but I'm not sure if there is any singular line of code for spawning a tile.
 
In that case I'm not too sure, I know that code will place a tile upon the projectiles death, but I'm not sure if there is any singular line of code for spawning a tile.
Well, I may be stupid, or lazy, but is there just a way to make the projectile die when it meets your cursor? Or, if you don't know that, is there a way to make it so you can place a tile in midair?
 
Back
Top Bottom