Standalone [1.3] tModLoader - A Modding API

Hi I'm new here and i just tried to download the tmod loader only my virusscan began to shout that there was a virus in the zip file i clicked it away but i really want this mod so did i do something wrong or is the virusscanner oversensitive? i hope you can help me?
Okay thank you but where can i find the link i downloaded it on this forum (version 0.8, windows version) or is it because i've got the worse possible virusscanner mcafee?
 
Okay thank you but where can i find the link i downloaded it on this forum (version 0.8, windows version) or is it because i've got the worse possible virusscanner mcafee,
My apologies i see what i did wrong, thanx for the help!
I gobnna enjoy this i know for sure
 
How can I make visual armor/accessories effects? (like full chlorophyte armor has green glow, spectre is semi-transparent etc.)
 
Hi I'm new here and i just tried to download the tmod loader only my virusscan began to shout that there was a virus in the zip file i clicked it away but i really want this mod so did i do something wrong or is the virusscanner oversensitive? i hope you can help me?
you have a few errors
your virusscan is a bad one, i got mine virus free, as there is no virus, its just the .jar that the computer doesnt like, get something different, ok?
there is no virus in there, ok? just turn off or get a different anti-virus, then download again, make sure its an actuall popular one that isnt in the corners of the web.
[doublepost=1460205660,1460205299][/doublepost]
It looks like you are going off this: http://forums.terraria.org/index.php?threads/official-tmodloader-help-thread.28901/#post-656325

But you only copied in the helper function, not the actual hook:

put this at the top: "using Microsoft.Xna.Framework;"

Code:
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Vector2[] speeds = ExampleGun.evenSpread(16f, 16f, 45, 5);
            for (int i = 0; i < 5; ++i)
            {
                Terraria.Projectile.NewProjectile(position.X, position.Y, speeds[i].X, speeds[i].Y, 45, 45, 15f);
            }
            return false;
        }
so, welp, bugs galore. CS0246 the type or namespace name 'Player' could not be found, Are you missing directive or assembly reference? i pretty well expect the code here to be needed
Code:
using Terraria.ID;
using Microsoft.Xna.Framework;
using Terraria.ModLoader;

namespace ExampleMod.Items.Weapons
{
    public class ExampleGun : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Hotti Shotti";
            item.damage = 20;
            item.ranged = true;
            item.width = 40;
            item.height = 20;
            item.toolTip = "FEEL THE BURN";
            item.toolTip2 = "litteraly";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 5;
            item.noMelee = true; //so the item's animation doesn't do damage
            item.knockBack = 4;
            item.value = 10000;
            item.rare = 2;
            item.useSound = 11;
            item.autoReuse = false;
            item.shoot = 10; //idk why but all the guns in the vanilla source have this
            item.shootSpeed = 16f;
            item.useAmmo = ProjectileID.Bullet;
        }

        public static Microsoft.Xna.Framework.Vector2[] evenSpread (float speedX,  float speedY, int angle, int num)
        {
            var posArray = new Microsoft.Xna.Framework.Vector2[num];
            float spread = (float)(angle * 0.0174532925);
            float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
            double startAngle = System.Math.Atan2(speedX, speedY) - spread / 5 ; //i have no idea what to seat the spread / X at, so thats why it is at 5
            double deltaAngle = spread / (float)num;
            double offsetAngle;
            for (int i = 0; i < num; ++i)
            {
                offsetAngle = startAngle + deltaAngle * i;
                posArray[i] = new Microsoft.Xna.Framework.Vector2(baseSpeed * (float)System.Math.Sin(offsetAngle), baseSpeed * (float)System.Math.Cos(offsetAngle));
            }
            return (Microsoft.Xna.Framework.Vector2[])posArray;
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Vector2[] speeds = ExampleGun.evenSpread(16f, 16f, 45, 5);
            for (int i = 0; i < 5; ++i)
            {
                Terraria.Projectile.NewProjectile(position.X, position.Y, speeds[i].X, speeds[i].Y, 45, 45, 15f);
            }
            return false;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "ExampleItem", 10);
            recipe.AddTile(null, "ExampleWorkbench");
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
I dont know what set of code to use so i used both.
 
Is there a place I can get an image template or guide for the various Items?

I'm trying to make some custom armor and I want to make custom sprites to go with it but I'm looking through the Example Mod and I'm having a difficult time figuring out the patterns for the images. For example the ExampleHelmet has different numbers of pixels between all the various helmets in the image. Most are 36 pixels apart but some are 34 and I don't know if there are any other differences in there since I didn't check each and every one. Also I can't tell from the example file which sprite is used when.

Thanks in Advance

- Aerlock
 
you have a few errors
your virusscan is a bad one, i got mine virus free, as there is no virus, its just the .jar that the computer doesnt like, get something different, ok?
there is no virus in there, ok? just turn off or get a different anti-virus, then download again, make sure its an actuall popular one that isnt in the corners of the web.
[doublepost=1460205660,1460205299][/doublepost]
so, welp, bugs galore. CS0246 the type or namespace name 'Player' could not be found, Are you missing directive or assembly reference? i pretty well expect the code here to be needed
Code:
using Terraria.ID;
using Microsoft.Xna.Framework;
using Terraria.ModLoader;

namespace ExampleMod.Items.Weapons
{
    public class ExampleGun : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Hotti Shotti";
            item.damage = 20;
            item.ranged = true;
            item.width = 40;
            item.height = 20;
            item.toolTip = "FEEL THE BURN";
            item.toolTip2 = "litteraly";
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 5;
            item.noMelee = true; //so the item's animation doesn't do damage
            item.knockBack = 4;
            item.value = 10000;
            item.rare = 2;
            item.useSound = 11;
            item.autoReuse = false;
            item.shoot = 10; //idk why but all the guns in the vanilla source have this
            item.shootSpeed = 16f;
            item.useAmmo = ProjectileID.Bullet;
        }

        public static Microsoft.Xna.Framework.Vector2[] evenSpread (float speedX,  float speedY, int angle, int num)
        {
            var posArray = new Microsoft.Xna.Framework.Vector2[num];
            float spread = (float)(angle * 0.0174532925);
            float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
            double startAngle = System.Math.Atan2(speedX, speedY) - spread / 5 ; //i have no idea what to seat the spread / X at, so thats why it is at 5
            double deltaAngle = spread / (float)num;
            double offsetAngle;
            for (int i = 0; i < num; ++i)
            {
                offsetAngle = startAngle + deltaAngle * i;
                posArray[i] = new Microsoft.Xna.Framework.Vector2(baseSpeed * (float)System.Math.Sin(offsetAngle), baseSpeed * (float)System.Math.Cos(offsetAngle));
            }
            return (Microsoft.Xna.Framework.Vector2[])posArray;
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Vector2[] speeds = ExampleGun.evenSpread(16f, 16f, 45, 5);
            for (int i = 0; i < 5; ++i)
            {
                Terraria.Projectile.NewProjectile(position.X, position.Y, speeds[i].X, speeds[i].Y, 45, 45, 15f);
            }
            return false;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "ExampleItem", 10);
            recipe.AddTile(null, "ExampleWorkbench");
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
I dont know what set of code to use so i used both.

Looks like you forgot to put using Terraria; at the top of your code.
 
Hello, I'm kinda new to modding, and when I downloaded this onto my Mac it's not showing me the characters/players I used to have (Same with worlds) I checked Finder and the Players and World files are still there but the game shows no players or worlds. Please help, thanks so much in advance!:)

Is this normal if I can't see my old characters/worlds? I just took out the tmodloader files and now Terraria won't open :( Please help!
 
Last edited:
Hello,my friend has been getting crashes to desktop. He is using the latest versions of tmodloader and his mods (Thorium mod and The Lugage mod).
Here is the message he is getting:
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at Terraria.Main.DrawMenu(GameTime gameTime)
at Terraria.Main.do_Draw(GameTime gameTime)
at Terraria.Main.Draw(GameTime gameTime)
at Microsoft.Xna.Framework.Game.DrawFrame()
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
at Terraria.Program.LaunchGame(String[] args)


Any idea what is the problem? Thanks!
 
Last edited:
Hello, I'm kinda new to modding, and when I downloaded this onto my Mac it's not showing me the characters/players I used to have (Same with worlds) I checked Finder and the Players and World files are still there but the game shows no players or worlds. Please help, thanks so much in advance!:)

Is this normal if I can't see my old characters/worlds? I just took out the tmodloader files and now Terraria won't open :( Please help!
tModLoader creates a separate folder to store players and worlds created with mods.

Taking the files out without replacing the originals will just cause Terraria to not work because you don't have a Terraria executable anymore. Repair/verify Terraria through Steam and your original Terraria will work again with all the old worlds and players.

When I started modding I just copied my Terraria folder and renamed it so I could have vanilla Terraria and modded Terraria side by side. You might want to try that if you're still interested in playing your vanilla players/worlds.

- Aerlock
 
tModLoader creates a separate folder to store players and worlds created with mods.

Taking the files out without replacing the originals will just cause Terraria to not work because you don't have a Terraria executable anymore. Repair/verify Terraria through Steam and your original Terraria will work again with all the old worlds and players.

When I started modding I just copied my Terraria folder and renamed it so I could have vanilla Terraria and modded Terraria side by side. You might want to try that if you're still interested in playing your vanilla players/worlds.

- Aerlock
That is very smart! Thank you so much that is a cool idea to mod and vanilla at the same time! (Ok, vanilla is a verb now... yay...)
 
Hello,my friend has been getting crashes to desktop. He is using the latest versions of tmodloader and his mods (Thorium mod and The Lugage mod).
Here is the message he is getting:
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at Terraria.Main.DrawMenu(GameTime gameTime)
at Terraria.Main.do_Draw(GameTime gameTime)
at Terraria.Main.Draw(GameTime gameTime)
at Microsoft.Xna.Framework.Game.DrawFrame()
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
at Terraria.Program.LaunchGame(String[] args)


Any idea what is the problem? Thanks!
Does this happen with all worlds/players or just one?
Can he create a new player and world without getting the error?
Does or still happen if he removes one or both of the mods?
Can other games play fine on the same system?
What are the system specs (RAM, CPU, Hard drive) for the machine he's playing on?
What else is he running at the same time as Terraria?

Something is eating up all the available memory and that's what is causing Terraria to crash.

- Aerlock
 
I'm having trouble with my mod still, whats the problem?

Sequence contains no matching element
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at Terraria.ModLoader.AssemblyManager.InstantiateMods(List`1 modsToLoad)
 
I'm trying to code an item that places Planteras Bulb, but it isn't working:
Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;

namespace imkSushisMod.Items
{
    public class MysteriousSeed : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Mysterious Seed";
            item.width = 18;
            item.height = 30;
            item.toolTip = "The beginning of the Plant Era";
            item.consumable = true;
            item.useAnimation = 15;
            item.useTime = 10;
            item.useStyle = 1;
            item.useTurn = true;
            item.rare = 1;
            item.autoReuse = true;
            item.maxStack = 30;
            item.createTile = TileID.PlanteraBulb;
        }
    }
}
 
Looks like you forgot to put using Terraria; at the top of your code.
thanks.
edit: now it shoots a few demon circle things in the bottom right... they do no damage... so what i mean is it shoots a few demon circle things to hte bottom right that do no damage, how to fix this?
 
I'm having trouble with my mod still, whats the problem?

Sequence contains no matching element
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at Terraria.ModLoader.AssemblyManager.InstantiateMods(List`1 modsToLoad)
I forget what this problem is, just zip up your mod sources and I'll look.

whats the code for a item to drop from a NPC/Mob
ExampleMod has plenty of examples, here is for vanilla npc: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/NPCs/ExampleGlobalNPC.cs#L32

That is very smart! Thank you so much that is a cool idea to mod and vanilla at the same time! (Ok, vanilla is a verb now... yay...)
You don't need to copy the whole folder, just either rename Vanilla Terraria.exe to TerrariaVanilla.exe or rename tmodloader Terraria.exe to tModLoader.exe.
 
i just need a code for dropping items cant really get anything from that link page
The link I showed you should be helpful. Oh well. Here's another example from ExampleMod.

Code:
        public override void NPCLoot()
        {
            if (Main.rand.Next(50) == 0)
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Nazar);
            }
        }
 
Back
Top Bottom