Standalone [1.3] tModLoader - A Modding API

Ok, it looks like I fixed it by restarting my computer. Now I get this error:
Code:
Missing texture ExampleMod/Dusts/Sparkle
   at Terraria.ModLoader.ModLoader.GetTexture(String name)
   at Terraria.ModLoader.Mod.AddDust(String name, ModDust dust, String texture)
   at Terraria.ModLoader.Mod.AutoloadDust(Type type)
   at Terraria.ModLoader.Mod.Autoload()
   at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
I checked in the Dusts directory and there is a file named Sparkle.png.
 
Ok, it looks like I fixed it by restarting my computer. Now I get this error:
Code:
Missing texture ExampleMod/Dusts/Sparkle
   at Terraria.ModLoader.ModLoader.GetTexture(String name)
   at Terraria.ModLoader.Mod.AddDust(String name, ModDust dust, String texture)
   at Terraria.ModLoader.Mod.AutoloadDust(Type type)
   at Terraria.ModLoader.Mod.Autoload()
   at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
I checked in the Dusts directory and there is a file named Sparkle.png.
Now, that is weird. I remember one other person had this problem before. Maybe... I might have to build a tool that can split .tmod files into their code and images. Can you send me the .tmod file?
 
I just PM'ed it to you. :)
Alright, I've finished the mod unpacking tool and it looks like the mod built perfectly fine for you. So I'm not really sure why it isn't working for you; weird things are happening.

Hey @bluemagic123 do you know why my recipes aren't appearing? It's pretty strange that it doesn't appear even though I have the recipes set up and everything.
Can I see the code for the recipes that don't show up?
 
Well that would pretty much be the whole mod (at least that I made again since the update) but sure.

Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using StarMod.Items;

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

        public override void AddCraftGroups()
        {
            AddCraftGroup("StarFragment", Lang.misc[37] + " " + GetItem("StarFragment").item.name);
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(this);
            recipe.AddIngredient(null, "StarFragment");
            recipe.AddTile(null, "StarAnvil");
            recipe.SetResult(ItemID.FallenStar);
            recipe.AddRecipe();

            recipe = new ModRecipe(this);
            recipe.AddIngredient(ItemID.FallenStar, 25);
            recipe.SetResult(null, "StarAnvil");
            recipe.AddRecipe();
        }
    }
}
Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace StarMod.Items
{
    public class StarFragment : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Star Fragment";
            item.width = 20;
            item.height = 20;
            item.maxStack = 999;
            AddTooltip("YOU BROKE IT!!! Oh wait...");
            item.value = 1000;
            item.rare = 2;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.FallenStar);
            recipe.SetResult(this, 5);
            recipe.AddRecipe();
        }
    }
}
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;

namespace StarMod.Items
{
    public class StarAnvil : ModTile
    {
        public override void SetDefaults()
        {
            Main.tileSolidTop[Type] = true;
            Main.tileFrameImportant[Type] = true;
            Main.tileNoAttach[Type] = true;
            Main.tileTable[Type] = true;
            Main.tileLavaDeath[Type] = true;
            TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1);
            TileObjectData.newTile.CoordinateHeights = new int[] { 18 };
            TileObjectData.addTile(Type);
            AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable);
            mapColor = new Color(200, 200, 200);
            mapName = "Star Anvil";
            adjTiles = new int[] { TileID.Anvils };
        }

        public override void KillMultiTile(int i, int j, int frameX, int frameY)
        {
            Item.NewItem(i * 16, j * 16, 32, 16, mod.ItemType("StarAnvil"));
        }
    }
}
 
Well that would pretty much be the whole mod (at least that I made again since the update) but sure.

Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using StarMod.Items;

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

        public override void AddCraftGroups()
        {
            AddCraftGroup("StarFragment", Lang.misc[37] + " " + GetItem("StarFragment").item.name);
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(this);
            recipe.AddIngredient(null, "StarFragment");
            recipe.AddTile(null, "StarAnvil");
            recipe.SetResult(ItemID.FallenStar);
            recipe.AddRecipe();

            recipe = new ModRecipe(this);
            recipe.AddIngredient(ItemID.FallenStar, 25);
            recipe.SetResult(null, "StarAnvil");
            recipe.AddRecipe();
        }
    }
}
Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace StarMod.Items
{
    public class StarFragment : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Star Fragment";
            item.width = 20;
            item.height = 20;
            item.maxStack = 999;
            AddTooltip("YOU BROKE IT!!! Oh wait...");
            item.value = 1000;
            item.rare = 2;
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.FallenStar);
            recipe.SetResult(this, 5);
            recipe.AddRecipe();
        }
    }
}
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;

namespace StarMod.Items
{
    public class StarAnvil : ModTile
    {
        public override void SetDefaults()
        {
            Main.tileSolidTop[Type] = true;
            Main.tileFrameImportant[Type] = true;
            Main.tileNoAttach[Type] = true;
            Main.tileTable[Type] = true;
            Main.tileLavaDeath[Type] = true;
            TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1);
            TileObjectData.newTile.CoordinateHeights = new int[] { 18 };
            TileObjectData.addTile(Type);
            AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable);
            mapColor = new Color(200, 200, 200);
            mapName = "Star Anvil";
            adjTiles = new int[] { TileID.Anvils };
        }

        public override void KillMultiTile(int i, int j, int frameX, int frameY)
        {
            Item.NewItem(i * 16, j * 16, 32, 16, mod.ItemType("StarAnvil"));
        }
    }
}
Do you have an item version of the Star Anvil?
 
Do you have an item version of the Star Anvil?
Nope. I guess I didn't pay enough attention to things in the example mod (lol oops). But I don't really know how that would effect the recipe for the Star Fragments when they aren't needing to use it to be crafted but I'll get right on making the item version of the Star Anvil.
 
Nope. I guess I didn't pay enough attention to things in the example mod (lol oops). But I don't really know how that would effect the recipe for the Star Fragments when they aren't needing to use it to be crafted but I'll get right on making the item version of the Star Anvil.
The problem was that you had a recipe with the Star Anvil as a result, except that there was no Star Anvil item, causing an exception in the recipe menu to make stuff not appear.
 
Hey @bluemagic123 I have this problem with my mod that it only works if it's the only mod being used and if other mods get enabled and are being used and I load into the world then all the stuff from the mod disappears and when I disable the other mods then it will make my inventory disappear and it only shows my buffs, mana, health, and minimap.

Edit: Also I can fix it by building and reloading the mod while the other mods are disabled.
 
Damnit ... I tried that but it seems to crash the rendering thread, but Terraria is too damn stubborn to crash or give me an exception to work with. Is there any sort of log that I can get to (I tried catch{exception.tostring}, no cigar)? Here's my code:
Code:
public override void PostDraw(int i, int j, SpriteBatch spriteBatch) {
     try {
     int num9 = 32;
     int num11 = 0;
     Vector2 zero = new Vector2((float)Main.offScreenRange, (float)Main.offScreenRange);
     if (Main.drawToScreen)
     {
       zero = Vector2.Zero;
     }
     var rect = new Vector2((float)(i * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(j * 16 - (int)Main.screenPosition.Y + num11)) + zero;
     var color = new Microsoft.Xna.Framework.Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 255);
     
     spriteBatch.Draw(Main.tileTexture[mod.ItemType("RainbowWorkbench")], rect, color);
     }
     catch (Exception e)
     { //doesn't work
        System.IO.File.WriteAllText(@"C:\tModLoaderLog.txt", e.ToString());
     }
   }
Screenshot (23).png
Keep in mind that this is for a furniture item (hence num9/width being 32 instead of 16), but it also dies for blocks.
 
Where can I find info about what player variables to use? Where can I find info about settings of all vanilla items?
I want to create boots accessories that can run a bit faster than frostspark/lightning.
 
Where can I find info about what player variables to use? Where can I find info about settings of all vanilla items?
I want to create boots accessories that can run a bit faster than frostspark/lightning.
You'll need the decompiled source of Terraria. Use ILSpy or dotPeek.

Look in Terraria.ID/ItemID.cs. In there are a bunch of ID's. Find Lightning boots and remember the ID.

Open Terraria/Player.cs and press ctrl+f. Type in the ID (898) and you'll find this:
Code:
if (this.armor[l].type == 898)
           {
             this.accRunSpeed = 6.75f;
             this.rocketBoots = 2;
             this.moveSpeed += 0.08f;
           }

Throw those middle 3 lines in your UpdateAccessory hook (changing 'this' to 'player') and there you go!
 
I'm having trouble with my tiles. I can't get my 3x3 tile to display properly. I only get the left third showing. I tried 2x2 and a few other smaller variants and they seemed to display normally, but incomplete of course. I'm wondering what mistake I could have made, or if something is up with the 3x3 style.

Here's my setDefaults hook.
Code:
public override void SetDefaults()
    {
        Main.tileFrameImportant[Type] = true;
        Main.tileNoAttach[Type] = true;
        Main.tileTable[Type] = true;
        Main.tileLavaDeath[Type] = true;
        TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3);
        TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 };
        TileObjectData.addTile(Type);
        AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable);
        mapColor = new Color(170, 60, 40);
        mapName = "Artists Desk";
        adjTiles = new int[]{TileID.Tables};
    }

And I've attached my tile.
 

Attachments

  • TArtistsDesk.png
    TArtistsDesk.png
    3.4 KB · Views: 238
You'll need the decompiled source of Terraria. Use ILSpy or dotPeek.
...
Throw those middle 3 lines in your UpdateAccessory hook (changing 'this' to 'player') and there you go!

Got it all to work! Thank you for your help! *hugs*


Another question. How do you make a recipe that returns two different tings?
 
Got it all to work! Thank you for your help! *hugs*


Another question. How do you make a recipe that returns two different tings?
No problem xD

You can't directly ... however, you can craft a 'bag' to produce two items. Take a look at the ExplorerBag in the example mod.
 
Back
Top Bottom