Fandom

Surfpup's tConfig Mod Wiki

Custom Plant Creation

124pages on
this wiki
Add New Page
Comments0 Share

Hello everyone, here I have written a brief tutorial on how to make a plant in tConfig that grows, and can be harvested just like Blinkroots, Dayblooms, or Waterleafs. I must give credit, however, to Will Huxtable for his awesome videos on various tConfig projects, I simply took his video and made a written version for  this wiki. I am not taking credit for any of this code.

Setting Up The ItemEdit

This part shouldn't take you very long. Simply make a basic tile-creating item, using a code like this

[Stats]
width=16
height=16
type=-1
useStyle=1
useAnimation=15
useTime=10
createTileName=Plant
placeStyle=1
consumable=True
autoReuse=True
maxStack=250
useTurn=True
scale=1
value=0
className=Item
[Recipe]
Amount=250
needWater=False
Items=0 Wood

and tweak it to your preferences. Also, obviously, add an image for the item and place them both in the Item folder of your mod.

Making the TilesEdit

Okay, so to make the plant grow, what is happening is once the seed is placed, it creates a tile which is the first stage of the plant. It waits a certain amount of time, then the tile changes into the second phase of the plant; finally it replaces the tile with the third stage of the plant, and at that point if it is destroyed, it will drop the item specified in the cs file in the Tile folder.

int ticks;
int ticksNeeded = 600; //10 seconds, each tick represents a frame in the game, and terraria runs at 60 frames a second!
 
public void Initialize(int x, int y){
    	tileX = x;
	tileY = y;
}
 
public void Update(){
	int x = tileX;
	int y = tileY;
	
	if(Main.tile[x, y].type == (byte)Config.tileDefs.ID["Plant"]){//Change "{Plant" to the name of your first tile!
		if(ticks == ticksNeeded){
			Main.tile[x, y].type = (byte)Config.tileDefs.ID["Plant2"];//Change "Plant2" to the name of your second tile!
			ticks = 0;
		}
		else{
			ticks++;
		}
	}
	else if(Main.tile[x, y].type == (byte)Config.tileDefs.ID["Plant2"]){//Change "Plant2" to the name of your second tile!
		if(ticks == ticksNeeded){
			Main.tile[x, y].type = (byte)Config.tileDefs.ID["Plant3"];//Change "Plant3" to the name of your third tile!
			ticks = 0;
		}
		else{
			ticks++;
		}
	}
}
 
public static void KillTile(int x, int y, Player player){
	if(Main.tile[x, y].type == (byte)Config.tileDefs.ID["Plant3"]){//Change "Plant3" to the name of your third tile!
		Item.NewItem(x * 16, y * 16 - 10, 16, 16, (int)Config.itemDefs.byName["Plant Seed"].type);//Replace 'Plant Seed' with whatever you want to be harvested from your plant once it is fully grown.
	}
}
 
//Just some saving stuff
public void Load(BinaryReader R){
	ticks = R.ReadInt32();
	ticksNeeded = R.ReadInt32();
}
public void Save(BinaryWriter W){
	W.Write(ticks);
	W.Write(ticksNeeded);
}

Now, we will be using this same file for all three of the plant tiles. To do this, use a code like this for the ini files of all three plant stages, Plant1, Plant2, and Plant3.

[Stats]
id=-1 
Width=1
Height=1
pick=1
axe=0
hammer=0
Lighted=False
MergeDirt=False
Cut=False
Alch=False
Shine=0
Shine2=True
Stone=False
WaterDeath=False
LavaDeath=False
Table=False
BlockLight=False
NoSunLight=False
Dungeon=False
SolidTop=False
Solid=False
NoAttach=False
NoFail=True
FrameImportant=True
special=true
code=Plant

Now, this is probably the way you want your plant; not a solid block, not a table, it doesn't emit light, etc... But if you do want to tweak the code, make sure not to delete the last line, code=Plant. That line tells the Plant2 and Plant3 tiles to all use the Plant.cs file. But if you change the name if the plant tiles, you must change the code=Plant to whatever the .cs file that contains the cs file up above is called. So, now you should have an item that places tile Plant, or the seed, pictures of the three stages of the plants, 16x16 pixels, and their ini files, which should probably be the same just with different names, and lastly, the cs file, placed in the tile folder. Make sure if you changed the names of the plant tiles, that you changed their names in the cs file, and the seed item ini. If you want a better understanding of how all this code works, I would highly reccomend going to Will Huxtable's website and watch some of his tConfig tutorials, they go over some really cool stuff. Anyways, thanks for reading, and if you need help please comment.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.