Standalone [1.3] tModLoader - A Modding API

I just want to get a world I made in TModLoader, take it out, then put it in the normal Terraria. When I go look at the world files folder for TModLoader, they are .twld files. If I could convert those to .wld files then I could put them in my regular Terraria worlds folder. Are there any ways I could make a .twld into a .wld? Or would that not work?
Actually, it's really easy. tModLoader's .wld files are basically vanilla files, and the .twld file is a sidecar file that contains the modded data. You can copy the .wld file from tModLoader to the vanilla version. However, you might get corruption if you make changes in vanilla then copy back to tModLoader, (because the .twld file may conflict with changes made by the vanilla version,) so backup your worlds before overwriting.
 
How do I make it so that I can make an accessory that will make you immune to Cursed Inferno?
I can't find anything useful.

Code:

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TerrariaMod.Items
{
public class CursedFlame : ModItem
{
public override void SetDefaults()
{
item.name = "Cursed Flame";
item.width = 32;
item.height = 32;
item.toolTip = "Immunity to Cursed Inferno";
item.value = 1000000;
item.rare = 6;
item.accessory = true;
}

public override void UpdateAccessory(Player player, bool hideVisual)
{
player.immune =
}
}
}
 
Verify that you have the right TML version with the right GOG Terraria version. Version mismatch is the most common cause of such issues. Make sure you are using the latest GOG version of Terraria which is 1.3.3.2 with the latest TML GOG patch which is 0.8.3.4. If you can't resolve the issue, then please send me a PM and I'll do my best to get you up and running. :)
thats okay, i got it now.. just had wrong terraria version :) thanks :)
[doublepost=1475397039,1475396920][/doublepost]
Verify that you have the right TML version with the right GOG Terraria version. Version mismatch is the most common cause of such issues. Make sure you are using the latest GOG version of Terraria which is 1.3.3.2 with the latest TML GOG patch which is 0.8.3.4. If you can't resolve the issue, then please send me a PM and I'll do my best to get you up and running. :)
thats okay, i got it now.. just had wrong terraria version :) thanks :)
 
Actually, it's really easy. tModLoader's .wld files are basically vanilla files, and the .twld file is a sidecar file that contains the modded data. You can copy the .wld file from tModLoader to the vanilla version. However, you might get corruption if you make changes in vanilla then copy back to tModLoader, (because the .twld file may conflict with changes made by the vanilla version,) so backup your worlds before overwriting.
The world I want to use on vanilla Terraria only has 3 files for some reason (.twld, .twld.bak, and wld.bak). The .wld file is missing. All my other worlds made in TModLoader have .wld files.
 
How do I make it so that I can make an accessory that will make you immune to Cursed Inferno?
I can't find anything useful.

Code:

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TerrariaMod.Items
{
public class CursedFlame : ModItem
{
public override void SetDefaults()
{
item.name = "Cursed Flame";
item.width = 32;
item.height = 32;
item.toolTip = "Immunity to Cursed Inferno";
item.value = 1000000;
item.rare = 6;
item.accessory = true;
}

public override void UpdateAccessory(Player player, bool hideVisual)
{
player.immune =
}
}
}
Put player.buffImmune[BuffID.CursedInferno] = true; in your UpdateAccessory method.
 
The world I want to use on vanilla Terraria only has 3 files for some reason (.twld, .twld.bak, and wld.bak). The .wld file is missing. All my other worlds made in TModLoader have .wld files.

Just use tEdit, edit the modded world and save it in your normal worlds folder. This way the map reverts back to vanilla.
 
I have a problem with my Tmod loader, it works as if it was a compleatly separate Terraria and when i installed the latest version, it compleatly bugged out with a error code over, and over, and over, again, dose anyone know how to help???
 
I'm having a problem where sometimes not all the mods I have are showing on my mods list. I need to refresh it and that occasionally makes my game say:
"Terraria is not responding"
 
When I compile I get the error "error CS0117: 'Terraria.ModLoader.ModNPC' does not contain a definition for 'Center'"
 
So, bit of weirdness. Recently updated a few mods on the Mod Browser, and now when I reloaded the mod list, I now have a crash when it reaches the end of the Loading state... Anyone else suffering that error?
 
So, bit of weirdness. Recently updated a few mods on the Mod Browser, and now when I reloaded the mod list, I now have a crash when it reaches the end of the Loading state... Anyone else suffering that error?

Yeah, it seems a lot of people are. The problem (for me) came from Nightmares Unleashed. I moved that mod out of my folder and, sure enough, everything works fine now. I'm sure Psychotic will find a solution soon.
If that isn't what is causing it for you, then I don't know...
 
Yeah, it seems a lot of people are. The problem (for me) came from Nightmares Unleashed. I moved that mod out of my folder and, sure enough, everything works fine now. I'm sure Psychotic will find a solution soon.
If that isn't what is causing it for you, then I don't know...
Ah, got that in my folder, so that's probably the reason!

Relatedly, anyone know of a mod that tries to stuff everything into the ammo slot first, even when there's stacks in the inventory already? Because if so, that's annoying as all hell and I want to figure out the pros and cons of removing that one too >_>
 
When I consume the item you're supposed to get an item all of the time. But for somereason when I open up the item I get nothing.
this is the items code:
Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace EpicnessModRemastered.Items
{
    public class SuperMagicalChest : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Super Magical Chest";
            item.maxStack = 1;
            item.consumable = true;
            item.width = 24;
            item.height = 24;
            item.useTime = 10;
            item.useAnimation = 10;
            item.useStyle = 4;
            item.toolTip = "Left click to open";
            item.rare = 10;
            item.useSound = mod.GetSoundSlot(SoundType.Item, "Sounds/Item/Legendaryget");
        }
        public override bool UseItem(Player player)
        {
            if (Main.rand.Next(2) == 0)
            {
            player.QuickSpawnItem(mod.ItemType("SparkyCard"));
            }
            else if (Main.rand.Next(2) == 1)
            {
            player.QuickSpawnItem(mod.ItemType("LumberJacksAxe"));
            }
            else if (Main.rand.Next(2) == 2)
            {
            player.QuickSpawnItem(mod.ItemType("PrincessesBow"));
            }
            return true;
           
        }
    }
}
 
public override bool UseItem(Player player)
{
if (Main.rand.Next(2) == 0)
{
player.QuickSpawnItem(mod.ItemType("SparkyCard"));
}
else if (Main.rand.Next(2) == 1)
{
player.QuickSpawnItem(mod.ItemType("LumberJacksAxe"));
}
else if (Main.rand.Next(2) == 2)
{
player.QuickSpawnItem(mod.ItemType("PrincessesBow"));
}
return true;

}
[/CODE]

It is because you are rolling the dice each time you are checking it. The first time will not always be 0, so no SparkyCard, the second time will not always return 1, so no LumberJacksAxe, and the third time will NEVER be 2, because Next() returns 0 to n - 1, ie Next(2) will return 0 or 1.

Call Next(3) once and store it in a variable, ie int result = Main.rand.Next(3);, and then check that variable in your if statements.
 
It is because you are rolling the dice each time you are checking it. The first time will not always be 0, so no SparkyCard, the second time will not always return 1, so no LumberJacksAxe, and the third time will NEVER be 2, because Next() returns 0 to n - 1, ie Next(2) will return 0 or 1.

Call Next(3) once and store it in a variable, ie int result = Main.rand.Next(3);, and then check that variable in your if statements.
I'm sorry for asking this but how do I set that up?
Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace EpicnessModRemastered.Items
{
    public class SuperMagicalChest : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Super Magical Chest";
            item.maxStack = 1;
            item.consumable = true;
            item.width = 24;
            item.height = 24;
            item.useTime = 10;
            item.useAnimation = 10;
            item.useStyle = 4;
            item.toolTip = "Left click to open";
            item.rare = 10;
            item.useSound = mod.GetSoundSlot(SoundType.Item, "Sounds/Item/Legendaryget");
        }
        public override bool UseItem(Player player)
        {
            (Main.rand.Next(3) == int result Main.rand.Next(3));,
            if (int result Main.rand.Next(3); == 0)
            {
            player.QuickSpawnItem(mod.ItemType("SparkyCard"));
            }
            else if (int result Main.rand.Next(3); == 1)
            {
            player.QuickSpawnItem(mod.ItemType("LumberJacksAxe"));
            }
            else if (int result Main.rand.Next(3); == 2)
            {
            player.QuickSpawnItem(mod.ItemType("PrincessesBow"));
            }
            return true;
           
        }
    }
}
 
I'm sorry for asking this but how do I set that up?
Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace EpicnessModRemastered.Items
{
    public class SuperMagicalChest : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Super Magical Chest";
            item.maxStack = 1;
            item.consumable = true;
            item.width = 24;
            item.height = 24;
            item.useTime = 10;
            item.useAnimation = 10;
            item.useStyle = 4;
            item.toolTip = "Left click to open";
            item.rare = 10;
            item.useSound = mod.GetSoundSlot(SoundType.Item, "Sounds/Item/Legendaryget");
        }
        public override bool UseItem(Player player)
        {
            (Main.rand.Next(3) == int result Main.rand.Next(3));,
            if (int result Main.rand.Next(3); == 0)
            {
            player.QuickSpawnItem(mod.ItemType("SparkyCard"));
            }
            else if (int result Main.rand.Next(3); == 1)
            {
            player.QuickSpawnItem(mod.ItemType("LumberJacksAxe"));
            }
            else if (int result Main.rand.Next(3); == 2)
            {
            player.QuickSpawnItem(mod.ItemType("PrincessesBow"));
            }
            return true;
          
        }
    }
}

i normally use right click but thats just me
he means something like this

------------------------------------------------------------ this is the right click function
public override bool CanRightClick()
{
return true;
}

public override void RightClick(Player player)
------------------------------------------------------------
{
int f = Main.rand.Next(0, 5);
if(f >= 0 && f <= 0)
{
player.QuickSpawnItem(mod.ItemType("item1"));
}
else if(f >= 1 && f <= 1)
{
player.QuickSpawnItem(mod.ItemType("item2"));
}
else if(f >= 2 && f <= 2)
{
player.QuickSpawnItem(mod.ItemType("item3"));
}
else if(f >= 3 && f <= 3)
{
player.QuickSpawnItem(mod.ItemType("item4"));
}
else if(f >= 4 && f <= 4)
{
player.QuickSpawnItem(mod.ItemType("item5"));
}
}
 
i normally use right click but thats just me
he means something like this

------------------------------------------------------------ this is the right click function
public override bool CanRightClick()
{
return true;
}

public override void RightClick(Player player)
------------------------------------------------------------
{
int f = Main.rand.Next(0, 5);
if(f >= 0 && f <= 0)
{
player.QuickSpawnItem(mod.ItemType("item1"));
}
else if(f >= 1 && f <= 1)
{
player.QuickSpawnItem(mod.ItemType("item2"));
}
else if(f >= 2 && f <= 2)
{
player.QuickSpawnItem(mod.ItemType("item3"));
}
else if(f >= 3 && f <= 3)
{
player.QuickSpawnItem(mod.ItemType("item4"));
}
else if(f >= 4 && f <= 4)
{
player.QuickSpawnItem(mod.ItemType("item5"));
}
}
Why are you not just checking f for equality (f == 0)? Isn't that a lot easier?
I'm sorry for asking this but how do I set that up?
Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace EpicnessModRemastered.Items
{
    public class SuperMagicalChest : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Super Magical Chest";
            item.maxStack = 1;
            item.consumable = true;
            item.width = 24;
            item.height = 24;
            item.useTime = 10;
            item.useAnimation = 10;
            item.useStyle = 4;
            item.toolTip = "Left click to open";
            item.rare = 10;
            item.useSound = mod.GetSoundSlot(SoundType.Item, "Sounds/Item/Legendaryget");
        }
        public override bool UseItem(Player player)
        {
            (Main.rand.Next(3) == int result Main.rand.Next(3));,
            if (int result Main.rand.Next(3); == 0)
            {
            player.QuickSpawnItem(mod.ItemType("SparkyCard"));
            }
            else if (int result Main.rand.Next(3); == 1)
            {
            player.QuickSpawnItem(mod.ItemType("LumberJacksAxe"));
            }
            else if (int result Main.rand.Next(3); == 2)
            {
            player.QuickSpawnItem(mod.ItemType("PrincessesBow"));
            }
            return true;
       
        }
    }
}
Good start, but I'll explain where and why you went wrong.

What you need to do is to create a variable at the start of UseItem, and then you can do whatever you want with that variable until UseItem is finished (then it's discarded). So first, to declare a variable, you need to use the format <type - identifier - assignment (optional)>. This means, from left to right, what kind of variable you want, what it's called, and what value you want it to start it with respectively.

Because you want an integer (whole number) called result, you should type int result;. But because you want to put a random number in it, you have to assign (=) the result of the game's random number generator (Main.rand.Next(5), which means you are generating one of five different numbers (0, 1, 2, 3 and 4)). So that becomes:
Code:
int result = Main.rand.Next(5);
Now you have that value, you can check your if-statements against it, like so:
Code:
if (result == 0)
{
  // Stuff.
}
else if (result == 1)
{
  // Stuff.
}
// And so on.
You don't have to use int anymore, because the script remembers that result is an integer; if you use int again, the code thinks you're trying to make a new variable with the same name, which isn't allowed. You also don't have to use Main.rand.Next() anymore, because you only need to assign that random value once.

Hope that clears things up for you. :)
 
The world I want to use on vanilla Terraria only has 3 files for some reason (.twld, .twld.bak, and wld.bak). The .wld file is missing. All my other worlds made in TModLoader have .wld files.
Something must have happened to the *.wld file, but thankfully you have a backup. Copy the *.wld.bak file to the vanilla worlds folder and remove .bak from the filename. Hopefully that will work.

When I compile I get the error "error CS0117: 'Terraria.ModLoader.ModNPC' does not contain a definition for 'Center'"
I'm guessing a bit here because I can't see the context, but I think you need 'ModNPC.npc.Center' not 'ModNPC.Center'. The ModNPC is kind of a parent class to the npc, so you need to refer to the child npc class.
 
An unexpected error has occurred.
here: Microsoft.Xna.Framework.Graphics.Texture2D..ctor(GraphicsDevice graphicsDevice, Stream stream, Int32 width, Int32 height, XnaImageOperation operation)
here: Terraria.ModLoader.Mod.Autoload()
here: Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
Fix????
 
Back
Top Bottom