• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Begin your search for Journey's End information here and here. Please report bugs and issues for Journey's End here.
  • For issues you find with the Mobile 1.3 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

Standalone [1.3] tModLoader - A Modding API

blushiemagic

Retinazer
tModLoader
So animationFrameHeight is this (highlighted by a dotted line)?:


Also I believe that each frame of texture of a tile is 16x16 (If I'm not mistaken).
Yes, that would be the animationFrameHeight

then use this
TileObjectData.newTile.CoordinateHeights = new int[]{16};
If I remember correctly, it should already be at 16 by default.

I cant download the tmodloader v0.3.0.1 :(
You can't download it or can't install it?
 

zadum4ivii

Official Terrarian
Yes, that would be the animationFrameHeight


If I remember correctly, it should already be at 16 by default.
So now I'm getting this (The frames are moving):



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

namespace Tremor.Tiles {
public class BlastFurnace : 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.Style3x3);
        TileObjectData.newTile.CoordinateHeights = new int[]{16};
        //TileObjectData.addTile(Type);
        animationFrameHeight = 52;
        AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable);
        mapColor = new Color(117, 117, 117);
        mapName = "Blast Furnace";
        adjTiles = new int[]{TileID.WorkBenches};
    }

public override void AnimateTile(ref int frame, ref int frameCounter)
{
    frameCounter++;
    if(frameCounter > 8)
    {
        frameCounter = 0;
        frame++;
        frame %= 8;
    }
}

    public override void KillMultiTile(int i, int j, int frameX, int frameY)
    {
        Item.NewItem(i * 16, j * 16, 32, 16, mod.ItemType("BlastFurnace"));
    }
 

Smiffy

Skeletron Prime
So I have been working on another WIP project, trying to make an in-game world editor.



Tiles look a mess, but whatever. Is it possible to enable the chatbox so I can create "commands" for this sort of thing?
 

blushiemagic

Retinazer
tModLoader
So I have been working on another WIP project, trying to make an in-game world editor.



Tiles look a mess, but whatever. Is it possible to enable the chatbox so I can create "commands" for this sort of thing?
I haven't really looked much into the chatbox yet, so at the moment I would assume it isn't possible. I'll probably look more into this a bit before I start working on server support.
 

Smiffy

Skeletron Prime
I haven't really looked much into the chatbox yet, so at the moment I would assume it isn't possible. I'll probably look more into this a bit before I start working on server support.
Oh well, it looks like I have to make a tile selection tool for now. The amount of tools I am using is rapidly increasing!
 

Smiffy

Skeletron Prime
any chance that might work with modded tiles too?
I don't see why not. I store a copy of the tile from Terraria.Main.tile[,] at a certain coordinate and the rest of the mod uses that copy as a reference when filling in areas or using brushes.
 

MarioKart7z

Plantera
So I have been working on another WIP project, trying to make an in-game world editor.



Tiles look a mess, but whatever. Is it possible to enable the chatbox so I can create "commands" for this sort of thing?
hope you figure out how to update the tile frames soon... it really does look like a mess
 

EEEPCAN

Steampunker
Yea that seems like a great idea. If you need help just ask and i'll try my best to help you(im still on the newer half of my modding myself :p)
Thanks! I don't exactly know how to mod projectile magic weapons, as most my knowledge comes from reverse engineering other scripts, so a example of a direct-type magic weapon would be most helpful.

Also to anyone who can help, I keep getting the error of:\Users\Me\Documents\My Games\Terraria\ModLoader\Mod Sources\TestMod\TestMod.cs(20,36) : error CS1002: ; expected

Can anyone help or are the lines if the script required for any further information?
 

Smiffy

Skeletron Prime
Thanks! I don't exactly know how to mod projectile magic weapons, as most my knowledge comes from reverse engineering other scripts, so a example of a direct-type magic weapon would be most helpful.

Also to anyone who can help, I keep getting the error of:\Users\Me\Documents\My Games\Terraria\ModLoader\Mod Sources\TestMod\TestMod.cs(20,36) : error CS1002: ; expected

Can anyone help or are the lines if the script required for any further information?
You are missing a ";" on the end of line 20.
 

EEEPCAN

Steampunker
You are missing a ";" on the end of line 20.
...Your magical. You hacked life.
[DOUBLEPOST=1438813044,1438812819][/DOUBLEPOST]Now im getting this: c:\Users\Ethan\Documents\My Games\Terraria\ModLoader\Mod Sources\TestMod\TestMod.cs(19,21) : error CS0246: The type or namespace name 'TestModItem' could not be found (are you missing a using directive or an assembly reference?)
Im confused.
 

WyvernHunter

Terrarian
...Your magical. You hacked life.
[DOUBLEPOST=1438813044,1438812819][/DOUBLEPOST]Now im getting this: c:\Users\Ethan\Documents\My Games\Terraria\ModLoader\Mod Sources\TestMod\TestMod.cs(19,21) : error CS0246: The type or namespace name 'TestModItem' could not be found (are you missing a using directive or an assembly reference?)
Im confused.
Can you post your testmod.cs code and your testmoditem.? Also for a magic weapon(like the gem weapons currently in game, heres an example of what it should look like)
Code:
using System; // you need this
using Terraria; //and this
using Terraria.ID; // and this to call vanilla items
using Terraria.ModLoader; //and this cause its a mod

namespace mainfoldername.Items { //the main folder is also what you name your main .cs 
public class magicWeaponName : ModItem //the magicWeaponName should be the same for your image
{
    public override void SetDefaults()
    {
        item.name = "Name that shows up in game";
        item.mana = 5; //how much mana it costs
        item.useSound = 43; //sounds!
        item.useStyle = 5;
        item.damage = 23; //damage it does
        item.useAnimation = 26; //how long it takes the animation to play
        item.useTime = 26; // time it takes to use
        item.width = 40; //image size
        item.height = 40; //image size
        item.shoot = 126; //the projectile it shoots(cant add customs ones yet)
        item.shootSpeed = 9.5f; //how fast it shoots, the f means float
        item.knockBack = 5.5f; //the knockback
        item.magic = true; //it recieves the bonuses from magic armor/buffs/things
        item.autoReuse = true; //you can hold it and it keeps shooting
        item.value = 30000; //how much it costs
        item.rare = 2; //rarity
        item.noMelee = true; //when you swing the actual item wont hurt things
    }
    public override void AddRecipes()
    {
        ModRecipe recipe = new ModRecipe(mod); //this line adds a new recipe
        recipe.AddIngredient("DirtBlock",1); //adding dirtblock as a ingredient
        recipe.SetResult(this); //setting the result as this item
        recipe.AddRecipe(); //adding the item
    }
}
}
 

Aehnon

Terrarian
So one other issue I've been running into. Can't really find what might be causing it to randomize. I've shortened the code as much as I can think to do without causing errors so. What ends up happening inside the game is whenever I try to place my custom wall, it randomizes a different wall type on every time I enter the game. So it never does the PNG in the folder, but selects one from Terraria at random. Here's what I've got in my Tiles folder:


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

namespace ExampleMod.Tiles {
public class ExampleWall : ModTile
{
    public override void SetDefaults()
    {
        Main.tileSolid[Type] = true;
        Main.tileMergeDirt[Type] = true;
        Main.tileBlockLight[Type] = true;
        Main.tileLighted[Type] = true;
        drop = mod.ItemType("ExampleWall");
        mapColor = new Color(200, 200, 200);
    }

    public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
    {
        r = 0.5f;
        g = 0.5f;
        b = 0.5f;
    }
}}

and here's what's in my regular mod folder:


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

namespace ExampleMod.Items {
public class ExampleWall : ModItem
{
    public override void SetDefaults()
    {
        item.name = "Example Wall";
        item.width = 12;
        item.height = 12;
        item.maxStack = 999;
        AddTooltip("This is a modded wall.");
        item.useTurn = true;
        item.autoReuse = true;
        item.useAnimation = 15;
        item.useTime = 10;
        item.useStyle = 1;
        item.consumable = true;
        item.createWall = mod.TileType("ExampleWall");
    }

    public override void AddRecipes()
    {
        ModRecipe recipe = new ModRecipe(mod);
        recipe.AddIngredient(null, "ExampleItem");
        recipe.SetResult(this, 10);
        recipe.AddRecipe();
    }
}}
 

EEEPCAN

Steampunker
Can you post your testmod.cs code and your testmoditem.? Also for a magic weapon(like the gem weapons currently in game, heres an example of what it should look like)
Thanks! Here is the codes: This is the test weapon I made:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace TestMod.Items {
public class TestWeapon : ModItem
{
public override void SetDefaults()
{
item.name = "Elemental Blade";
item.damage = 300;
item.melee = true;
item.width = 50;
item.height = 50;
item.toolTip = "It is an item! Maybe!"
item.useTime = 1;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 10;
item value = 1000
item.rare = 10;
item.useSound = 1;
item.autoReuse = true;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null, "Wood", 10);
recipe.AddTile(null, "Workbench");
recipe.SetResult(this);
recipe.Addrecipe();
}
public override void MeleeEffects(Player player, Rectangle hitbox)
{
if(Main.rand.Next(3) == 0)
{
int dust = ModDust.NewDust(new Vector2(hitbox.X, hotbox.Y), hitbox.Width, hitbox.Height, mod, "Sparkle");
}
}
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(10,24,20,72)
}
}}

This is the test mod.cs:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using TestMod.Items;

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

public override void Load()
{
SetGlobalItem(new TestModItem());
SetGlobalNPC(new ExampleModNPC());
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(this);
recipe.AddIngredient(null, ItemID.Wood);
recipe.SetResult("TestWeapon")
}
}}
 

blushiemagic

Retinazer
tModLoader
So one other issue I've been running into. Can't really find what might be causing it to randomize. I've shortened the code as much as I can think to do without causing errors so. What ends up happening inside the game is whenever I try to place my custom wall, it randomizes a different wall type on every time I enter the game. So it never does the PNG in the folder, but selects one from Terraria at random. Here's what I've got in my Tiles folder:


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

namespace ExampleMod.Tiles {
public class ExampleWall : ModTile
{
    public override void SetDefaults()
    {
        Main.tileSolid[Type] = true;
        Main.tileMergeDirt[Type] = true;
        Main.tileBlockLight[Type] = true;
        Main.tileLighted[Type] = true;
        drop = mod.ItemType("ExampleWall");
        mapColor = new Color(200, 200, 200);
    }

    public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
    {
        r = 0.5f;
        g = 0.5f;
        b = 0.5f;
    }
}}

and here's what's in my regular mod folder:


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

namespace ExampleMod.Items {
public class ExampleWall : ModItem
{
    public override void SetDefaults()
    {
        item.name = "Example Wall";
        item.width = 12;
        item.height = 12;
        item.maxStack = 999;
        AddTooltip("This is a modded wall.");
        item.useTurn = true;
        item.autoReuse = true;
        item.useAnimation = 15;
        item.useTime = 10;
        item.useStyle = 1;
        item.consumable = true;
        item.createWall = mod.TileType("ExampleWall");
    }

    public override void AddRecipes()
    {
        ModRecipe recipe = new ModRecipe(mod);
        recipe.AddIngredient(null, "ExampleItem");
        recipe.SetResult(this, 10);
        recipe.AddRecipe();
    }
}}
Most likely the problem is that I haven't actually added support for walls yet. Walls will be included in the next update (I'm working on them right now in fact). Not really sure why it's randomizing though.

Thanks! Here is the codes: This is the test weapon I made:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;

namespace TestMod.Items {
public class TestWeapon : ModItem
{
public override void SetDefaults()
{
item.name = "Elemental Blade";
item.damage = 300;
item.melee = true;
item.width = 50;
item.height = 50;
item.toolTip = "It is an item! Maybe!"
item.useTime = 1;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 10;
item value = 1000
item.rare = 10;
item.useSound = 1;
item.autoReuse = true;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null, "Wood", 10);
recipe.AddTile(null, "Workbench");
recipe.SetResult(this);
recipe.Addrecipe();
}
public override void MeleeEffects(Player player, Rectangle hitbox)
{
if(Main.rand.Next(3) == 0)
{
int dust = ModDust.NewDust(new Vector2(hitbox.X, hotbox.Y), hitbox.Width, hitbox.Height, mod, "Sparkle");
}
}
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(10,24,20,72)
}
}}

This is the test mod.cs:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using TestMod.Items;

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

public override void Load()
{
SetGlobalItem(new TestModItem());
SetGlobalNPC(new ExampleModNPC());
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(this);
recipe.AddIngredient(null, ItemID.Wood);
recipe.SetResult("TestWeapon")
}
}}
The problem seems to be with this line:
SetGlobalItem(new TestModItem());
Do you actually have a GlobalItem named TestModItem?
 

Xynom

Terrarian
What can currently be added with this? I am looking to recreate and finish the rpg system from terramod, over on the old forums, and really want to make it with this so I can use other mods
 

blushiemagic

Retinazer
tModLoader
What can currently be added with this? I am looking to recreate and finish the rpg system from terramod, over on the old forums, and really want to make it with this so I can use other mods
At the moment, only items, recipes, dust, and tiles can be added. I am currently working on support for walls, which is partially completed on the Github.

If you want to recreate an rpg system, you'll probably have to wait until I add support for extra player functionality.
 
Top Bottom