How do I create mods?

There are currently 2 things that allow for 1.3 modding, they are Prism and tModLoader. I can only link you tModLoader because I'm too lazy to find Prism.

http://forums.terraria.org/index.php?threads/1-3-tmodloader-a-modding-api.23726/

tModLoader is sort of like tAPI if you have ever used it, one of the differences is that tModLoader does not use json files, rather just a singular cs file for all coding. Making basic items actually isn't that difficult, all you would do instead of a json file is set up the item's class file and then use SetDefaults() hook to set properties such as

Code:
this.shoot = 2;

You should be able o find all you would need within the tModLoader page. Documentation will help you find the right hooks in the right section. There's also an example mod zip file to help you start out.
 
Can you make a detailed explanation on how to make mods with it? I haven't done anything similar and I have no idea what to do.
 
Can you make a detailed explanation on how to make mods with it? I haven't done anything similar and I have no idea what to do.
I haven't really touched tModLoader at all, but I'll see what I can do to help you. You of course, have to download the program, which you can get from the Download section of the opening post. After that, you should install it in which it creates folders to start making your mods. Now that you've got these, you would need to go to the tModLoader's mod folders, which you can find in this location:

C:\Users\<yourUserName>\Documents\My Games\Terraria\ModLoader

From here, you will see many folders, which are logs, mod sources, mods, and players. Now we go to mod sources and you should see that it is empty initially. So let's create a folder for your mod, let's call it... myFirstMod. Now that you have created this folder I think you have to make a txt file for your mod called build.txt. From here you just put stuff like name and stuff. Here's one from the ExampleMod that the creator of tModLoader uploaded for us for reference.

Code:
author = bluemagic123
version = v0.6
displayName = Example Mod

So the properties you only need to make for your build.txt are the author, version, and displayName. So let's set up the build.txt we're gonna use for myFirstMod.

Code:
author = Faux Nom
version = 1.0
displayName = My First Mod

Now we got our build.txt. Afterwards we'll make a cs file for it. This part I don't think I know what I'm doing so I may be completely wrong. You can make a cs file by just changing the extension name of a txt file extension .txt to a cs file which is file extension .cs, if you have the view file extensions on in windows explorer. If you can't see file extensions then click the view tab found near the place where it says file. From here just checkbox File Name Extensions. We'll call the cs file myFirstMod.cs. Here we would put this code to display the name of the mod.

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

namespace myFirstMod
{
    public class myFirstMod : Mod 
    {
        public override void SetModInfo(out string name, ref ModProperties properties)
        {
            name = "myFirstMod";
        }
    }
}

Now that we have that, we'll now make a folder inside of our myFirstMod folder called Items to get ourselves a really basic item. Here we will make our first item. Inside our Items folder, we will make a new cs file named myFirstItem.cs. In here we will set all the properties of the item. I'm gonna borrow code from the ExampleMod. Here's how it should look like.

Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace myFirstMod.Items
{
    public class myFirstItem : ModItem
    {
        public override void SetDefaults() //This lets you set the properties of the items
        {
            item.name = "My First Item";
            item.width = 20;
            item.height = 20;
            item.maxStack = 999;
            AddTooltip("This is a modded item.");
            item.value = 100;
            item.rare = 1;
        }

        public override void AddRecipes() //This lets you make a recipe for your item
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock);
            recipe.SetResult(this, 999);
            recipe.AddRecipe();
        }
    }
}

Before we call it off, we need a texture for our item, so we need to have a png image to serve as our texture in which you name it as myFirstItem. Both the cs file and the png file have to have the same name so that tModLoader can properly load the item into the game. Now you have your first item, though I highly doubt this would actually work because I have never used tModLoader before.
 
I haven't really touched tModLoader at all, but I'll see what I can do to help you. You of course, have to download the program, which you can get from the Download section of the opening post. After that, you should install it in which it creates folders to start making your mods. Now that you've got these, you would need to go to the tModLoader's mod folders, which you can find in this location:

C:\Users\<yourUserName>\Documents\My Games\Terraria\ModLoader

From here, you will see many folders, which are logs, mod sources, mods, and players. Now we go to mod sources and you should see that it is empty initially. So let's create a folder for your mod, let's call it... myFirstMod. Now that you have created this folder I think you have to make a txt file for your mod called build.txt. From here you just put stuff like name and stuff. Here's one from the ExampleMod that the creator of tModLoader uploaded for us for reference.

Code:
author = bluemagic123
version = v0.6
displayName = Example Mod

So the properties you only need to make for your build.txt are the author, version, and displayName. So let's set up the build.txt we're gonna use for myFirstMod.

Code:
author = Faux Nom
version = 1.0
displayName = My First Mod

Now we got our build.txt. Afterwards we'll make a cs file for it. This part I don't think I know what I'm doing so I may be completely wrong. You can make a cs file by just changing the extension name of a txt file extension .txt to a cs file which is file extension .cs, if you have the view file extensions on in windows explorer. If you can't see file extensions then click the view tab found near the place where it says file. From here just checkbox File Name Extensions. We'll call the cs file myFirstMod.cs. Here we would put this code to display the name of the mod.

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

namespace myFirstMod
{
    public class myFirstMod : Mod
    {
        public override void SetModInfo(out string name, ref ModProperties properties)
        {
            name = "myFirstMod";
        }
    }
}

Now that we have that, we'll now make a folder inside of our myFirstMod folder called Items to get ourselves a really basic item. Here we will make our first item. Inside our Items folder, we will make a new cs file named myFirstItem.cs. In here we will set all the properties of the item. I'm gonna borrow code from the ExampleMod. Here's how it should look like.

Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace myFirstMod.Items
{
    public class myFirstItem : ModItem
    {
        public override void SetDefaults() //This lets you set the properties of the items
        {
            item.name = "My First Item";
            item.width = 20;
            item.height = 20;
            item.maxStack = 999;
            AddTooltip("This is a modded item.");
            item.value = 100;
            item.rare = 1;
        }

        public override void AddRecipes() //This lets you make a recipe for your item
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock);
            recipe.SetResult(this, 999);
            recipe.AddRecipe();
        }
    }
}

Before we call it off, we need a texture for our item, so we need to have a png image to serve as our texture in which you name it as myFirstItem. Both the cs file and the png file have to have the same name so that tModLoader can properly load the item into the game. Now you have your first item, though I highly doubt this would actually work because I have never used tModLoader before.
Don't forget to have 'properties.Autoload = true;' in the SetModInfo function! Otherwise the item won't get loaded.
Seeing as you haven't touched tModLoader, this seems like a nice explanation! Kudos.
 
So when I make a modded item or anything I have to write it's properties in a txt file and change it to cs when I'm done?
Don't forget to have 'properties.Autoload = true;' in the SetModInfo function! Otherwise the item won't get loaded.
Seeing as you haven't touched tModLoader, this seems like a nice explanation! Kudos.
Where do I find this setting?
 
So when I make a modded item or anything I have to write it's properties in a txt file and change it to cs when I'm done?

Where do I find this setting?
You just set it into the mod cs file's SetModInfo, which in the case of the example it would be inside the myFirstMod.cs. There is a hook in there called SetModInfo() in which you add the "properties.Autoload = true" in between the brackets with "name".
 
This is my cs file inside my mod folder in txt form:

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

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

Is there anything wrong here?
 
This is my cs file inside my mod folder in txt form:

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

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

Is there anything wrong here?

You just need to add the code inside SetModInfo, so the cs file should look like this.

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

namespace myFirstMod
{
  public class myFirstMod : Mod
  {
  public override void SetModInfo(out string name, ref ModProperties properties, properties.Autoload = true)
  {
  name = "myFirstMod";
  properties.Autoload = true; //This is where we set the properties.Autoload code so the mod will work as Eldrazi said.
  }
  }
}
 
If you have no C# experience, I suggest learning before "making mods".
If you don't know what one or more of these words mean, please learn C# first.
Framework
XNA
C#
Method
Class
CSharp
Visual Studio
 
Imagine if you could find complete codes for everything, ITEM, MeleeWeapon,RangedWeapon,MagicWeapon,Consumable etc etc...
People would copy that and be able to make huge mods without having to spend ages learning computer languages.
If someone here had just made that possible...
 
Imagine if you could find complete codes for everything, ITEM, MeleeWeapon,RangedWeapon,MagicWeapon,Consumable etc etc...
People would copy that and be able to make huge mods without having to spend ages learning computer languages.
If someone here had just made that possible...
Nope.
New updates come out the whole thing would have to be updated.
Repositories, compiling, updates, time, willingness.
Such a "domain" of code wouldn't be possible just because you're too lazy to write some code.
 
Nope.
New updates come out the whole thing would have to be updated.
Repositories, compiling, updates, time, willingness.
Such a "domain" of code wouldn't be possible just because you're too lazy to write some code.
I wrote this but erased it again... What I wanted to say is that alot of people, by the looks of it, come here. What if they could make a gigantic mod in a matter of minutes with the right tool? Updates, yes, but with enough ideas and a tool to create with they'll complete their mod very fast. People are very creative.
I have a pic somewhere on my phone from the wikia saying "Terraria 1.3 coming out april 2014", let's just imagine that a super creative kid started making a mod and wanted to complete it, and was able to, before that april 2014, people would be able to play his mod for a very long time. I don't think the next update is coming very soon either....
 
I wrote this but erased it again... What I wanted to say is that alot of people, by the looks of it, come here. What if they could make a gigantic mod in a matter of minutes with the right tool? Updates, yes, but with enough ideas and a tool to create with they'll complete their mod very fast. People are very creative.
I have a pic somewhere on my phone from the wikia saying "Terraria 1.3 coming out april 2014", let's just imagine that a super creative kid started making a mod and wanted to complete it, and was able to, before that april 2014, people would be able to play his mod for a very long time. I don't think the next update is coming very soon either....
It exists, it's called the source code.

Anyway, if everyone is just making clones of vanilla terraria items, modding would be extremely boring. Copy pasting is fine for getting an idea of the structure of a mod, but it is a crutch.

For example, imagine you wanted to make a minion and you came across the code for Stardust dragon (and everyone comes across the same code). People would shovel out stardust dragon clones (with various damage values) and all the mods would be extremely boring. It takes an understanding of how to actually code to make something unique worth anyone's time. (At least, for Minions and NPC behaviors. There are still a lot of copy paste opportunities in other aspects of modding.)
 
It exists, it's called the source code.

Anyway, if everyone is just making clones of vanilla terraria items, modding would be extremely boring. Copy pasting is fine for getting an idea of the structure of a mod, but it is a crutch.

For example, imagine you wanted to make a minion and you came across the code for Stardust dragon (and everyone comes across the same code). People would shovel out stardust dragon clones (with various damage values) and all the mods would be extremely boring. It takes an understanding of how to actually code to make something unique worth anyone's time. (At least, for Minions and NPC behaviors. There are still a lot of copy paste opportunities in other aspects of modding.)
Yes, can you redirect me to the sourcecode?
 
I found the thing that I needed... thank you for the help. And sorry for the disturbance...
Doubt I'll ever have to ask for help again to be honest.
 
Last edited:
heres the code i made
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace RandomMod
public class RandomMod : Mod
{
public override void SetModInfo(out string name, ref ModProperties properties, properties.Autoload = true)
{
name = "RandomMod";
properties.Autoload = true;
}
}
}
You're missing an opening curly bracket for your namespace.
 
the error is still there,
heres the error
c:\Users\Person Person\Documents\My Games\Terraria\ModLoader\Mod Sources\RandomMod\RandomMod.cs(9,108) : error CS1001: Identifier expected
heres my code
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace{ RandomMod
public class RandomMod : Mod
{
public override void SetModInfo(out string name, ref ModProperties properties, properties.Autoload = true)
{
name = "RandomMod";
properties.Autoload = true;
}
}
}
can you help me?
The bracket is in the wrong place. Look at your class and where that opening bracket is. public class RandomMod so the bracket is *after* the name of the class. This applies to namespaces too.
 
Back
Top Bottom