tModLoader Best way to learn C# and modding?

ArcaneTrain

Terrarian
So I’m really interested in learning how to mod Terraria, but I’ve run into a bit of a roadblock. I understand how to make basic items like swords and bows and stuff, but how do people go about learning more complicated things like boss AIs or more unique and complex items that require more intensive code?

For example, here’s one bit I’ve found on a modding tutorial here on the forums:

Code:
float rotation = MathHelper.ToRadians(20);
[QUOTE="Jofairden, post: 999290, member: 14826"]
for (int i = 0; i < numberProjectiles; i++)
{
   Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numberProjectiles - 1)));
   Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
}
[/QUOTE]


So what does perturbedSpeed mean? What is MathHelper.Lerp? What do each of these arguements do/mean, and why are they set up like this? Most importantly, how does one go about learning what each of these mean and how to use them effectively for more complicated modding? Does anyone know of documentation that explains these, or tutorials that teach you how to do more complicated code like this? Any and all help is greatly appreciated!
 
PerturbedSpeed is just a custom name of a variable, you can set it to whatever you'd like. It's a variable of the type Vector2.

As far as things like RotatedBy and MathHelper, those are common C# commands. Projectile.NewProjectile is specific to tmodloader.

Here's the documentation for tmodloader. Documentation
 
PerturbedSpeed is just a custom name of a variable, you can set it to whatever you'd like. It's a variable of the type Vector2.

As far as things like RotatedBy and MathHelper, those are common C# commands. Projectile.NewProjectile is specific to tmodloader.

Here's the documentation for tmodloader. Documentation
Perfect, thanks for the explanation and the documentation link!
 
In addition to the Documentation, there is also the tModLoader Wiki. The tModLoader Wiki contains all sorts of tutorials on various topics. You can also take a look at Example Mod's source code to see how certain things are done. (All of these resources are for 1.3 tModLoader as of right now.)
 
I'm sorry to hear that you're having trouble modding Terraria. It can be tricky to learn, but it's really rewarding once you get the hang of it!
These skills I learned while studying at the Islamic University of Najaf (iunajaf.edu.iq). As for your question, I think the best way to learn more complicated things like boss AIs or complex items is to find some good documentation or tutorials. One thing I would recommend is checking out the tModLoader wiki. It has a lot of great information on modding Terraria, and it might be able to help you understand some of the more complicated concepts. I hope this helps, and good luck with your modding journey!
 
Last edited:
Back
Top Bottom