tModLoader Tutorial: [1] Getting started with tModLoader

What Do I Do?!
[doublepost=1543090905,1543090508][/doublepost]My code is:

using Terraria.ID;
using Terraria.ModLoader;

namespace DogMod.Items
{
public class DogSword : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("DogSword");
Tooltip.SetDefault("It was the dying wish of Doge to make a weapon such Meme.");
}
public override void SetDefaults()
{
item.damage = 888;
item.melee = true;
item.width = 80;
item.height = 80;
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 1;
item.knockBack = 1;
item.value = 10000;
item.rare = 25;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.TerraBlade, 2);
recipe.AddIngredient(ItemID.SoulofLight, 8);
recipe.AddIngredient(ItemID.DogWhistle, 1);recipe.AddIngredient(ItemID.TerraBlade, 2);
recipe.AddIngredient(ItemID.LunarBar, 88);
recipe.AddIngredient(ItemID.HallowedBar, 88);
recipe.AddIngredient(ItemID.ShroomiteBar, 88);
recipe.AddIngredient(ItemID.BrokenHeroSword, 4);
recipe.AddTile(TileID.LunarCraftingStation);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

and this error message appears
 

Attachments

  • Screenshot (1).png
    Screenshot (1).png
    293.4 KB · Views: 292
  • Screenshot (1).png
    Screenshot (1).png
    293.4 KB · Views: 184
What to dooooo:


c:\Users\darcy\Documents\My Games\Terraria\ModLoader\Mod Sources\Drigonis'sMod\Drigonis'sMod.cs(3,19) : error CS1010: Newline in constant

c:\Users\darcy\Documents\My Games\Terraria\ModLoader\Mod Sources\Drigonis'sMod\Drigonis'sMod.cs(3,19) : error CS1012: Too many characters in character literal

c:\Users\darcy\Documents\My Games\Terraria\ModLoader\Mod Sources\Drigonis'sMod\Drigonis'sMod.cs(6,16) : error CS1010: Newline in constant

c:\Users\darcy\Documents\My Games\Terraria\ModLoader\Mod Sources\Drigonis'sMod\Drigonis'sMod.cs(6,16) : error CS1012: Too many characters in character literal

c:\Users\darcy\Documents\My Games\Terraria\ModLoader\Mod Sources\Drigonis'sMod\Drigonis'sMod.cs(9,18) : error CS1010: Newline in constant

c:\Users\darcy\Documents\My Games\Terraria\ModLoader\Mod Sources\Drigonis'sMod\Drigonis'sMod.cs(9,18) : error CS1012: Too many characters in character literal

c:\Users\darcy\Documents\My Games\Terraria\ModLoader\Mod Sources\Drigonis'sMod\Drigonis'sMod.cs(3,19) : error CS1514: { expected

c:\Users\darcy\Documents\My Games\Terraria\ModLoader\Mod Sources\Drigonis'sMod\Drigonis'sMod.cs(6,16) : error CS1514: { expected

c:\Users\darcy\Documents\My Games\Terraria\ModLoader\Mod Sources\Drigonis'sMod\Drigonis'sMod.cs(6,16) : error CS1519: Invalid token ''\u0073'' in class, struct, or interface member declaration

c:\Users\darcy\Documents\My Games\Terraria\ModLoader\Mod Sources\Drigonis'sMod\Drigonis'sMod.cs(9,18) : error CS1519: Invalid token ''\u0073'' in class, struct, or interface member declaration



Here is the code that it says has an error:

using Terraria.ModLoader;

namespace Drigonis'sMod
{

class Drigonis'sMod : Mod
{

public Drigonis'sMod()

{
}
}
}

is the problem that there is ' in the name????
[doublepost=1543110768,1543110409][/doublepost]Nevermind, I removed the apostrophes in the name and it worked. Well, now there's another problem...


c:\Users\darcy\Documents\My Games\Terraria\ModLoader\Mod Sources\Drigonis'sMod\Items\AncientBlade.cs(19,19) : error CS0266: Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?)

c:\Users\darcy\Documents\My Games\Terraria\ModLoader\Mod Sources\Drigonis'sMod\Items\AncientBlade.cs(20,24) : error CS0266: Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?)
[doublepost=1543111100][/doublepost]Btw, this is the code for the reply above ^^^^^

using Terraria.ID;
using Terraria.ModLoader;

namespace DrigonissMod.Items
{
public class AncientBlade : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("AncientBlade");
Tooltip.SetDefault("Millions of years old");
}
public override void SetDefaults()
{
item.damage = 21;
item.melee = true;
item.width = 60;
item.height = 60;
item.useTime = 0.5;
item.useAnimation = 0.3;
item.useStyle = 1;
item.knockBack = 6;
item.value = 25000;
item.rare = 3;
item.UseSound = SoundID.Item1;
item.autoReuse = false;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.GoldBar, 10);
recipe.AddIngredient(ItemID.VineRope, 20);
recipe.AddIngredient(ItemID.Sapphire, 3);
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
 
[...]
item.height = 60;
item.useTime = 0.5;
item.useAnimation = 0.3;
item.useStyle = 1;
[...]
item.useTime and item.useAnimation are integer values, meaning no decimals. Both are counted in ticks (1/60 of a second). If the 0.5 is supposed to be 1/2 a second, then it should be 30 (30 ticks, 30/60 = 1/2).
 
Um, how do I fix this? Can anyone send me like a tutorial on how to fix problems like this, I've been getting alot of them. This is the problem, does anybody know how to fix it?

Parameter is not valid.
at System.Drawing.Bitmap..ctor(Stream stream)
at Terraria.ModLoader.IO.ImageIO.ToRaw(Stream src, Stream dst)
at Terraria.ModLoader.IO.ImageIO.ToRawBytes(Stream src)
at Terraria.ModLoader.ModCompile.AddResource(TmodFile modFile, String relPath, String filePath)
at Terraria.ModLoader.ModCompile.Build(BuildingMod mod, IBuildStatus status)
at Terraria.ModLoader.ModCompile.Build(String modFolder, IBuildStatus status)
at Terraria.ModLoader.ModLoader.<>c.<BuildMod>b__74_0(Object _)
 
Last edited:
thanks!
[doublepost=1543138413,1543138269][/doublepost]I thought it meant seconds, not ticks. I'm changing it now, hopefully it fixes the problem :p
[doublepost=1543138578][/doublepost]o noes, another dumb problem eeeeeee
how to fix?
here is what it says:

Namespace and Folder name do not match. The top level namespace must match the folder name.

my question is what does it mean by namespace and folder name? :(
[doublepost=1543138791][/doublepost]well im renaming everything to DrigonissMod cus i cant have it like i used to: Drigonis's Mod
[doublepost=1543138961][/doublepost]that fixed it, but god damnit, the problems never end.
problem:

Parameter is not valid.
at System.Drawing.Bitmap..ctor(Stream stream)
at Terraria.ModLoader.IO.ImageIO.ToRaw(Stream src, Stream dst)
at Terraria.ModLoader.IO.ImageIO.ToRawBytes(Stream src)
at Terraria.ModLoader.ModCompile.AddResource(TmodFile modFile, String relPath, String filePath)
at Terraria.ModLoader.ModCompile.Build(BuildingMod mod, IBuildStatus status)
at Terraria.ModLoader.ModCompile.Build(String modFolder, IBuildStatus status)
at Terraria.ModLoader.ModLoader.<>c.<BuildMod>b__74_0(Object _)
Hi there @Farmer Joe, welcome to the forums. :) In the future I’d like to ask that you Edit your post if you want to add more to it. That is much preferred rather than double/triple/quadruple/quintuple posting. Thanks.

If you need help on how to do that (help with editing your post, not with the tmodloader code) send me a private message by clicking ‘Start a Conversation’ under my avatar at the bottom.
 
I really really need help with this problem! I've had it twice now, even though I've decided to make a new mod with LITERALLY NO PROBLEMS IN THE CODE AT ALL!
This is what it says:

Parameter is not valid.
at System.Drawing.Bitmap..ctor(Stream stream)
at Terraria.ModLoader.IO.ImageIO.ToRaw(Stream src, Stream dst)
at Terraria.ModLoader.IO.ImageIO.ToRawBytes(Stream src)
at Terraria.ModLoader.ModCompile.AddResource(TmodFile modFile, String relPath, String filePath)
at Terraria.ModLoader.ModCompile.Build(BuildingMod mod, IBuildStatus status)
at Terraria.ModLoader.ModCompile.Build(String modFolder, IBuildStatus status)
at Terraria.ModLoader.ModLoader.<>c.<BuildMod>b__74_0(Object _)
 
I keep getting a CS0119 terrariaid/tileid does not contain a definition for "furnace"
What are you creating?
Try 'Furnace' with a capital letter at the start, if that doesn't work,
try 'Forges', and if THAT doesn't work,
maybe do MythrilAnvil or Anvils
(Write them exactly how I did, (no spaces, capital letter at the start of each word, 's' on the end of 'Anvil')

(If you still can't fix it, Edit your post and type in the code the Error directs you to)
 
I tryed Furnaces with a s and it worked but know im getting one saying "Expected resource not found: items/CaramelApple
At Terraria.ModLoader.Mod.GetTexture(String name)
At Terraria.ModLoader.ModLoader.GetTexture(String name)
At Terraria.ModLoader.ModItem.AutoStaticDefaults()
At Terraria.ModLoader.Mod.SetupContent()
At Terraria.ModLoader.ModLoader.Do_Load(Object ThreadContext)
 
I tryed Furnaces with a s and it worked but know im getting one saying "Expected resource not found: items/CaramelApple
At Terraria.ModLoader.Mod.GetTexture(String name)
At Terraria.ModLoader.ModLoader.GetTexture(String name)
At Terraria.ModLoader.ModItem.AutoStaticDefaults()
At Terraria.ModLoader.Mod.SetupContent()
At Terraria.ModLoader.ModLoader.Do_Load(Object ThreadContext)
I have no idea, I suck at coding, but I think maybe you don't have a texture/picture for that item 'CaramelApple'.
Go to Piskel.com and make a texture for it, then go to file explorer and move it into Steam.Terraria.ModLoader.ModSources.Mods.(YourModName).Items
 
I tryed Furnaces with a s and it worked but know im getting one saying "Expected resource not found: items/CaramelApple
At Terraria.ModLoader.Mod.GetTexture(String name)
At Terraria.ModLoader.ModLoader.GetTexture(String name)
At Terraria.ModLoader.ModItem.AutoStaticDefaults()
At Terraria.ModLoader.Mod.SetupContent()
At Terraria.ModLoader.ModLoader.Do_Load(Object ThreadContext)
tModLoader is looking for an images called ‘CarmelApple’ in the ‘items’ folder. Make sure there’s a file there, and if there is, make sure the namespace matches up with the filepath. (Ex: Image at <Modname>\items would have a namespace of <Modname>.items)
 
i keep getting this:

c:\Users\Tatum_Venn\Documents\My Games\Terraria\ModLoader\Mod Sources\morsmod\morsmod.cs(9,3) : error CS1519: Invalid token '{' in class, struct, or interface member declaration

c:\Users\Tatum_Venn\Documents\My Games\Terraria\ModLoader\Mod Sources\morsmod\morsmod.cs(10,13) : error CS1519: Invalid token '=' in class, struct, or interface member declaration

c:\Users\Tatum_Venn\Documents\My Games\Terraria\ModLoader\Mod Sources\morsmod\morsmod.cs(11,24) : error CS1519: Invalid token '=' in class, struct, or interface member declaration

c:\Users\Tatum_Venn\Documents\My Games\Terraria\ModLoader\Mod Sources\morsmod\morsmod.cs(12,25) : error CS1519: Invalid token '=' in class, struct, or interface member declaration

c:\Users\Tatum_Venn\Documents\My Games\Terraria\ModLoader\Mod Sources\morsmod\morsmod.cs(15,1) : error CS1022: Type or namespace definition, or end-of-file expected

c:\Users\Tatum_Venn\Documents\My Games\Terraria\ModLoader\Mod Sources\morsmod\Items\the ruiner.cs(9,3) : error CS1519: Invalid token '{' in class, struct, or interface member declaration

c:\Users\Tatum_Venn\Documents\My Games\Terraria\ModLoader\Mod Sources\morsmod\Items\the ruiner.cs(10,26) : error CS1519: Invalid token '(' in class, struct, or interface member declaration

c:\Users\Tatum_Venn\Documents\My Games\Terraria\ModLoader\Mod Sources\morsmod\Items\the ruiner.cs(11,22) : error CS1519: Invalid token '(' in class, struct, or interface member declaration

c:\Users\Tatum_Venn\Documents\My Games\Terraria\ModLoader\Mod Sources\morsmod\Items\the ruiner.cs(13,19) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Tatum_Venn\Documents\My Games\Terraria\ModLoader\Mod Sources\morsmod\Items\the ruiner.cs(29,19) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Tatum_Venn\Documents\My Games\Terraria\ModLoader\Mod Sources\morsmod\Items\the ruiner.cs(31,27) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Tatum_Venn\Documents\My Games\Terraria\ModLoader\Mod Sources\morsmod\Items\the ruiner.cs(38,2) : error CS1022: Type or namespace definition, or end-of-file expected

c:\Users\Tatum_Venn\Documents\My Games\Terraria\ModLoader\Mod Sources\morsmod\Items\the ruiner.cs(39,1) : error CS1022: Type or namespace definition, or end-of-file expected
Show code, these are syntax errors.
 
I'm completely new to Terraria modding but have intermediate knowledge about coding.
After I import project to Visual Studio, I saw I need external libraries about Terraria or I can't get its methods etc because it throws namespace errors and can't compile the project.
Where can I find these mandatory packages/libraries etc.?
 
Last edited:
I'm completely new to Terraria modding but have intermediate knowledge about coding.
After I import project to Visual Studio, I saw I need external libraries about Terraria or I can't get its methods etc because it throws namespace errors and can't compile the project.
Where can I find these mandatory packages/libraries etc.?
You need to at least reference Terraria.exe (the tModLoader version) and XNA .dlls,
read this page also: blushiemagic/tModLoader
[doublepost=1556291905,1556291865][/doublepost]
c:\Users\Vam\Documents\My Games\Terraria\ModLoader\Mod Sources\CsMod\Items\knife.cs(47,26) : error CS0246
You need to post the entire error
 
Back
Top Bottom