Skip to content

[Mod] Tile Placement on Left Click

Scorch- edited this page Jul 11, 2011 · 1 revision

This works on protected servers as well.

Add a Main function to your ModClass and it should look like this. public static void main() { addtiles(); }

Add a varible at the top of the ModClass. private static string debugLeftClick = "";

The addtiles function should look like this. private static void addtiles() { int num = 0; int num2 = 0; num = (int)((Main.mouseState.X + Main.screenPosition.X) / 16f); num2 = (int)((Main.mouseState.Y + Main.screenPosition.Y) / 16f); if (Main.mouseState.LeftButton == ButtonState.Pressed) { if ((debugLeftClick.CompareTo("addspikes") == 0)) { WorldGen.KillTile(num, num2, false, false, false);//Prevents a bunch of crap from spawning on missed clicks WorldGen.PlaceTile(num, num2, 0x30, false, false, -1); if (Main.netMode == 1) { NetMessage.SendTileSquare(-1, num, num2, 1); } } } }

In the PlaceTile command change the third parameter for the tile you want (0x30 is spikes).

To access these commands simply add this to the OnChat function. case "spike": if (!(parameter == "on")) { debugLeftClick = ""; } debugLeftClick = "addspikes";

Clone this wiki locally