• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Begin your search for Journey's End information here and here. Please report bugs and issues for Journey's End here.
  • For issues you find with the Mobile 1.3 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

Standalone [1.3] tModLoader - A Modding API

Eared

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

namespace core.Items {
public class ultsword : ModItem
{
public override void SetDefaults()
{
item.name = "ultsword";
item.damage = 500;
item.melee = true;
item.width = 40;
item.height = 40;
item.toolTip = "die.";
item.useTime = 1;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 14;
item.value = 10000;
item.rare = 2;
item.useSound = 1;
item.autoReuse = true;
}
public override void AddRecipes() {
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null,ItemID.DirtBlock);
recipe.SetResult(this);
//recipe.AddTile(134);
recipe.AddRecipe();
}
}
Also, you have 4 "{" and 3 "}"
 

Jofairden

Duke Fishron
tModLoader
So I made like this:
Code:
AnimateTile(ref int frame, ref int frameCounter)
{
    frameCounter++;
    if(frameCounter > 8)
    {
        frameCounter = 0;
        frame++;
        frame %= 8;
    }
}
But it now says that
Code:
c:\My Documents\My Games\Terraria\ModLoader\Mod Sources\Tremor\Tiles\BlastFurnaceTile.cs(28,1) : error CS1520: Methods should include the return type
28 line is "AnimateTile(ref int frame, ref int frameCounter)".
Well just saying you should really do some more basic c# stuff imo. The method doesn't have any modifiers nor return type, which it should always have.
And this is pretty basic.. like.. really.. A good thing to remember is that when using tModLoader methods you'll pretty much always override them.
 

Jofairden

Duke Fishron
tModLoader
sorry im new and whenever i try to correct errors it gives me a new one
I understand. If you're new you should follow basic C# tutorials first. Modding is not a good place to start for 'basics' imo, a few console tutorials will do that way better. There's loads to find, just type in "C# tutorials" on Google. Most of them are pretty short, and don't even require brains either imo. They'll get you covered, so you won't have to ask anymore about those errors I'm readin atm.. because really; you'll solve them yourself in an instant.
 

NightX

Terrarian
i already have a } in my 34 line
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace core.Items {
public class ultsword : ModItem
{
public override void SetDefaults()
{
item.name = "ultsword";
item.damage = 500;
item.melee = true;
item.width = 40;
item.height = 40;
item.toolTip = "die.";
item.useTime = 1;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 14;
item.value = 10000;
item.rare = 2;
item.useSound = 1;
item.autoReuse = true;
}
public override void AddRecipes() {
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null,ItemID.DirtBlock);
recipe.SetResult(this);
//recipe.AddTile(134);
recipe.AddRecipe();
}
}
You have a '}' missing in the line 34

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace core.Items {
public class ultsword : ModItem
{
public override void SetDefaults()
{
item.name = "ultsword";
item.damage = 500;
item.melee = true;
item.width = 40;
item.height = 40;
item.toolTip = "die.";
item.useTime = 1;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 14;
item.value = 10000;
item.rare = 2;
item.useSound = 1;
item.autoReuse = true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null,ItemID.DirtBlock);
recipe.SetResult(this);
//recipe.AddTile(134);
recipe.AddRecipe();
}
}
}

Pro Tip 2: Use Notepad++ when you are coding. It can help you a little. Use Microsoft Visual Studio for the best results
 

turttheturtle

Terrarian
You have a '}' missing in the line 34

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace core.Items {
public class ultsword : ModItem
{
public override void SetDefaults()
{
item.name = "ultsword";
item.damage = 500;
item.melee = true;
item.width = 40;
item.height = 40;
item.toolTip = "die.";
item.useTime = 1;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 14;
item.value = 10000;
item.rare = 2;
item.useSound = 1;
item.autoReuse = true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null,ItemID.DirtBlock);
recipe.SetResult(this);
//recipe.AddTile(134);
recipe.AddRecipe();
}
}
}

Pro Tip 2: Use Notepad++ when you are coding. It can help you a little. Use Microsoft Visual Studio for the best results
now it says
c:\Users\joshuaho\Documents\My Games\Terraria\ModLoader\Mod Sources\ultsword\ultsword.cs(38,1) : error CS0116: A namespace cannot directly contain members such as fields or methods

c:\Users\joshuaho\Documents\My Games\Terraria\ModLoader\Mod Sources\ultsword\ultsword.cs(78,2) : error CS1513: } expected
 

Eared

Pixel Pirate
c:\Users\joshuaho\Documents\My Games\Terraria\ModLoader\Mod Sources\ultsword\ultsword.cs(38,1) : error CS0116: A namespace cannot directly contain members such as fields or methods

c:\Users\joshuaho\Documents\My Games\Terraria\ModLoader\Mod Sources\ultsword\ultsword.cs(78,2) : error CS1513: } expected
Just to check. Your mod called ultsvord but you has core.Items namespace?
[DOUBLEPOST=1438722101,1438721969][/DOUBLEPOST]
You need to show the main code, not the item code
 

turttheturtle

Terrarian
Just to check. Your mod called ultsvord but you has core.Items namespace?
[DOUBLEPOST=1438722101,1438721969][/DOUBLEPOST]
You need to show the main code, not the item code
what am i supposed to name it
heres my main code
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using core;

namespace core{
public class Core : Mod
{
public override void SetModInfo(out string name, ref ModProperties properties)
{
name = "core";
properties.Autoload = true;
}

public override void Load()
{
AddItem("ultsword", new ultsword());



}

/* public override void AddRecipes();
{
RecipeHelper.AddVanillaRecipes(this);
} */
}
}
 
what am i supposed to name it
heres my main code
You want to change "namespace core" to "namespace ultsvord.Items" or at least I'm 99% sure that's what should fix it.

I would strongly recommend taking a peek at Microsofts tutorials for C# and the .NET framework. Modding will be so much easier for you if you fully, or even partially understand the base roots of the language - let alone an API. A link to the tutorials is HERE (More like a demo, but it gave enough info for me to learn the language [Maybe it's just my programming background in 9 other languages :p]). The tutorials are for making your own application, but once you understand how applications are made, you will learn how to expand upon it.
 

Jofairden

Duke Fishron
tModLoader
Enough ways to QuickRecipe yet?? pffffff (part of Snippet)
Please tell me if you see anything missing
Code:
public static void QuickRecipe(Mod mod, int createItemType, int createItemStack = 1)

public static void QuickRecipe(Mod mod, int createItemType, int createItemStack, int requiredItem, int requiredItemStack = 1)

public static void QuickRecipe(Mod mod, int createItemType, int createItemStack, int requiredItem, int requiredItemStack, int requiredTile)

public static void QuickRecipe(Mod mod, int createItemType, int createItemStack, int[] requiredItems, int requiredItemStack = 1)

public static void QuickRecipe(Mod mod, int createItemType, int createItemStack, int[] requiredItems, int[] requiredItemsStack)

public static void QuickRecipe(Mod mod, int createItemType, int createItemStack, int requiredItem, int requiredItemStack, int[] requiredTilesArray)

public static void QuickRecipe(Mod mod, int createItemType, int createItemStack, int[] requiredItems, int[] requiredItemsStack, int[] requiredTilesArray)

public static void QuickRecipe(Mod mod, int createItemType, int createItemStack, int[] requiredItems, int requiredItemsStack, int[] requiredTilesArray)

public static void QuickRecipe(Mod mod, int createItemType, int createItemStack, int[,] requiredItemsArray)

public static void QuickRecipe(Mod mod, int createItemType, int createItemStack, int[,] requiredItemsArray, int requiredTile)

public static void QuickRecipe(Mod mod, int createItemType, int createItemStack, int[,] requiredItemsArray, int[] requiredTilesArray)
 

turttheturtle

Terrarian
You want to change "namespace core" to "namespace ultsvord.Items" or at least I'm 99% sure that's what should fix it.

I would strongly recommend taking a peek at Microsofts tutorials for C# and the .NET framework. Modding will be so much easier for you if you fully, or even partially understand the base roots of the language - let alone an API. A link to the tutorials is HERE (More like a demo, but it gave enough info for me to learn the language [Maybe it's just my programming background in 9 other languages :p]). The tutorials are for making your own application, but once you understand how applications are made, you will learn how to expand upon it.
it doesnt work its giving me the errors
c:\Users\joshuaho\Documents\My Games\Terraria\ModLoader\Mod Sources\ultsword\core.cs(19,24) : error CS0118: 'ultsword' is a 'namespace' but is used like a 'type'

c:\Users\joshuaho\Documents\My Games\Terraria\ModLoader\Mod Sources\ultsword\ultsword.cs(30,1) : error CS0121: The call is ambiguous between the following methods or properties: 'Terraria.ModLoader.ModRecipe.AddIngredient(string, int)' and 'Terraria.ModLoader.ModRecipe.AddIngredient(Terraria.ModLoader.ModItem, int)'
 

Smiffy

Skeletron Prime
Okay, so I have found out how to place tiles and walls in the world using an item I added to the game. The problem I am having is that they don't update their texture to look correct. I am currently using this code to achieve this:

Code:
        Main.tile[tileCoords.X, tileCoords.Y] = new Tile();
        Main.tile[tileCoords.X, tileCoords.Y].wall = WallID.Marble;
        Main.tile[tileCoords.X, tileCoords.Y].ResetToType(TileID.StoneSlab);
Blocked from success.png


I think I am supposed to call the PlaceTile function in the WorldGen class, but I can't access it.
 

blushiemagic

Retinazer
tModLoader
Okay, so I have found out how to place tiles and walls in the world using an item I added to the game. The problem I am having is that they don't update their texture to look correct. I am currently using this code to achieve this:

Code:
        Main.tile[tileCoords.X, tileCoords.Y] = new Tile();
        Main.tile[tileCoords.X, tileCoords.Y].wall = WallID.Marble;
        Main.tile[tileCoords.X, tileCoords.Y].ResetToType(TileID.StoneSlab);
View attachment 68621

I think I am supposed to call the PlaceTile function in the WorldGen class, but I can't access it.
If you want an item to create a tile, you just need to set item.createTile in the SetDefaults method, and item.createWall for walls.
 

Smiffy

Skeletron Prime
If you want an item to create a tile, you just need to set item.createTile in the SetDefaults method, and item.createWall for walls.
Ah, but this is no ordinary item. I am attempting to see how much of an in-game WorldEditing tool I can make. I intend to change the tool to select two coordinates and then fill the area in between with whatever block and wall the user desires. Currently the tool is just a test to see if I could insert tiles into the world, and that is the result.
 

blushiemagic

Retinazer
tModLoader
Ah, but this is no ordinary item. I am attempting to see how much of an in-game WorldEditing tool I can make. I intend to change the tool to select two coordinates and then fill the area in between with whatever block and wall the user desires. Currently the tool is just a test to see if I could insert tiles into the world, and that is the result.
Ah, I see. It looks like the problem is that the frame isn't updating. So there are two options here: WorldGen.PlaceTile to actually place the tile then update the frame, or WorldGen.TileFrame / WorldGen.SquareTileFrame (preferrably SquareTileFrame) to update the tile's frame. You said you weren't able to access WorldGen.PlaceTile, but I'm not really sure why since it's public and static in the source code.

public static bool PlaceTile(int i, int j, int type, bool mute = false, bool forced = false, int plr = -1, int style = 0)

public static void TileFrame(int i, int j, bool resetFrame = false, bool noBreak = false)

public static void SquareTileFrame(int i, int j, bool resetFrame = true)
 

Smiffy

Skeletron Prime
Ah, I see. It looks like the problem is that the frame isn't updating. So there are two options here: WorldGen.PlaceTile to actually place the tile then update the frame, or WorldGen.TileFrame / WorldGen.SquareTileFrame (preferrably SquareTileFrame) to update the tile's frame. You said you weren't able to access WorldGen.PlaceTile, but I'm not really sure why since it's public and static in the source code.

public static bool PlaceTile(int i, int j, int type, bool mute = false, bool forced = false, int plr = -1, int style = 0)

public static void TileFrame(int i, int j, bool resetFrame = false, bool noBreak = false)

public static void SquareTileFrame(int i, int j, bool resetFrame = true)
Looking at the sourcecode for 1.3.0.7, the WorldGen class is internal. Perhaps this has something to do with it.
 
Top Bottom