Standalone [1.3] tModLoader - A Modding API

Kazzymodus

Moderator
Staff member
Moderator
I REALLY need help, I am developing my first mod and I have had about 30 errors which have been solved, but this one just does not make any sense what so ever. CSerror0117:
'Terraria.Item' does not contain a definition for 'name'
It says there is a problem with line 15 but I cant solve it.
My Coding is this:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace YourModName.Items.Weapons //where is located
{
public class DirtSword : ModItem
{
public override void SetDefaults()
{
Item.Name = "Dirt Sword"; //sword name
Item.damage = 5; //sword damage
Item.melee = true;
Item.width = 50;
item.height = 50;
item.toopTip = "Finaly a starter weapon that isnt complete poop, maybe I can use dirt to make more things...";
item.useTime = 25;
Item.useAnimation = 25;
Item.useStyle = 1;
Item.Knockback = 5;
Item.value = .33;
Item.rare = 10;
Item.usesound = 1;
Item.autoReuse = true;
Item.useTurn = true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(Mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();



}
}
}
Please Help me as soon as possible, I have some great ideas I would love to enter into the terraira modding community, Thanks in advance!
If you type Item with a capital, the code thinks you're referring to the Item class of Terraria. Item should be lowercase in all the lines from SetDefaults, as well as Name and Knockback.
 

SpikeLicious

Terrarian
If you type Item with a capital, the code thinks you're referring to the Item class of Terraria. Item should be lowercase in all the lines from SetDefaults, as well as Name and Knockback.
Now I get the same error but this time with knockback, and I uncapitalized everything like you said and I got past the name thing. Now Its doing the same for knockback any ideas?
My Updated code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace YourModName.Items.Weapons //where is located
{
public class DirtSword : ModItem
{
public override void SetDefaults()
{
item.name = "Dirt Sword"; //sword name
item.damage = 5; //sword damage
item.melee = true;
item.width = 50;
item.height = 50;
item.toolTip = "Finaly a starter weapon that isnt complete poop, maybe I can use dirt to make more things...";
item.useTime = 25;
item.useAnimation = 25;
item.useStyle = 1;
item.knockback = 5;
item.value = .33;
item.rare = 10;
item.usesound = 1;
item.autoReuse = true;
item.useTurn = true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(Mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();



}
}
}
 

Snrasha

Terrarian
If you have no mods installed (or active) can you play with players who don't have tModLoader but have Terraria for Steam? Can they join your world if no mods are installed (or active)?
No, Modloader is a mod for include mods. So same if you have not active mods, meh, this is not the same thing ^^.

Now I get the same error but this time with knockback, and I uncapitalized everything like you said and I got past the name thing. Now Its doing the same for knockback any ideas?
My Updated code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace YourModName.Items.Weapons //where is located
{
public class DirtSword : ModItem
{
public override void SetDefaults()
{
item.name = "Dirt Sword"; //sword name
item.damage = 5; //sword damage
item.melee = true;
item.width = 50;
item.height = 50;
item.toolTip = "Finaly a starter weapon that isnt complete poop, maybe I can use dirt to make more things...";
item.useTime = 25;
item.useAnimation = 25;
item.useStyle = 1;
item.knockback = 5;
item.value = .33;
item.rare = 10;
item.usesound = 1;
item.autoReuse = true;
item.useTurn = true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(Mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();



}
}
}

I think 100% than knockback is knockBack and usesound is useSound ^^. Use Examplemod for have correct word or VisualStudio(or, if you cannot, use a other IDE) who see error instantly and propose you a correction.
 

Kazzymodus

Moderator
Staff member
Moderator
Now I get the same error but this time with knockback, and I uncapitalized everything like you said and I got past the name thing. Now Its doing the same for knockback any ideas?
My Updated code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace YourModName.Items.Weapons //where is located
{
public class DirtSword : ModItem
{
public override void SetDefaults()
{
item.name = "Dirt Sword"; //sword name
item.damage = 5; //sword damage
item.melee = true;
item.width = 50;
item.height = 50;
item.toolTip = "Finaly a starter weapon that isnt complete poop, maybe I can use dirt to make more things...";
item.useTime = 25;
item.useAnimation = 25;
item.useStyle = 1;
item.knockback = 5;
item.value = .33;
item.rare = 10;
item.usesound = 1;
item.autoReuse = true;
item.useTurn = true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(Mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();



}
}
}
The b in knockback needs to be capitalised (knockBack). That's what's causing the issue.

I recommend installing Visual Studio, it has the IntelliSense feature which auto-completes your code, and all in all prevents you from making these mistakes. It'll make everything a lot simpler and faster.
 

SpikeLicious

Terrarian
The b in knockback needs to be capitalised (knockBack). That's what's causing the issue.

I recommend installing Visual Studio, it has the IntelliSense feature which auto-completes your code, and all in all prevents you from making these mistakes. It'll make everything a lot simpler and faster.
Thats what im using, it autocorrected to that but I thought it was wrong, my mistake. thank you so much!
 

gagadoliano

Spazmatism
When I click on "Download" in any mod of the mod browser,it don't works and shows this in the log:

The system can not find the file specified
em System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
em System.Diagnostics.Process.Start()
em System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
em Terraria.ModLoader.UI.UIErrorMessage.OpenFile(UIMouseEvent evt, UIElement listeningElement)
em Terraria.UI.UIElement.Click(UIMouseEvent evt)
em Terraria.UI.UserInterface.Update(GameTime time)
em Terraria.Main.do_Update(GameTime gameTime)
em Terraria.Main.Update(GameTime gameTime)
 

SpikeLicious

Terrarian
Hello, I am trying to make a mod for my friend and I to play, its for his birthday so I'm trying to make it as weird and amusing as possible thus the weird item I will ask about. Anyway I am getting this error when I try to add a accessory: (26,25) : CS1518: Expected class, delegate, enum, interface, or struct
I have had so many problems so far which I have worked around. But please help me with this.
My code for the accessory:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SpikyBelly.Items
{
public class BellyEmblem : ModItem
{


public override void SetDefaults()
{
item.name = "Belly Emblem";
item.width = 10;
item.height = 14;
item.toolTip = "Use this if your willing to take the path of a belly.";
item.toolTip2 = "This can be fused with the souls of the bosses";
item.value = 10;
item.rare = 3;
item.accessory = true;
}
}

public override void UpdateAccessory(Player, player bool hideVisual)

{

player.noFallDmg = false;
player.canRocket = false;
player.rocketTime = 0;
player.rocketBoots = 0;
player.rocketTimeMax = 0;
player.aggro += 0;
player.meleeCrit += 0;
player.meleeDamage += 0f;
player.meleeSpeed += 0f;
player.moveSpeed += 0f;
player.rangedCrit += 0;
player.rangedDamage += 0f;
player.maxMinions++;
player.minionDamage += 0f;
player.statManaMax2 += 40;
player.manaCost -= 0.15f;
player.magicCrit += 7;
player.magicDamage += 3f;
}
}
 

DoYouEvenCookie

Terrarian
I have a couple of questions about npc ai, projectile ai, and other stuff for my custom boss. I be soo lost

- how do I make the npc texture change to something else kinda like the EoC changes to have a mouth.

- how do I make the npc shoot a projectile from the edge of the texture and not the center to where it's facing, not necessarily at the player EDIT: sorta like the way either one of the twins shoots, my shots usually come out in weird angles from the texture center to where the player is when it is shot.

- how do I make the npc stay stationary and spin
- also how might I make the npc invincible and regen while it is spinning

- how do I make the npc hover above the player like the nimbus, only stay in that position relative to the player no matter how fast they move

- how do I draw a giant rectangle, sort of like the circle around the abomination in that it is shaded, with the player's position, when it is first drawn, as the center when the boss is first summoned, and stay put until the boss is defeated or leaves, which it will do if the player dies
- also how might I move the npc to the center of the rectangle
- also how might I make the npc charge super fast at the payer and deal 1,000,000,000,000 damage or what ever the max damage in terraria is and be invincible if the player leaves the inside of the rectangle (I know it's OP, buuut... the summon item will warn you not to leave...)

- how might I make a bouncing projectile, that bounces like the meteorite bullet, but with no limit
- also how could I make this projectile bounce of the side of the rectangle, but only if it hits them from the inside (or is this even possible)
- also how could I make this projectile shoot motionless projectile every single tick to stay along the path it took and damage the player

- how might I make the npc damage and defence increase the more damaged it is

- how might I make the npc shoot a beam like the moon lord's death ray thing

-how do I make the npc face the player and then charge like the expert EoC

EDIT: 'a couple questions' is a huge understatement. I just noticed that

pls help me

can anyone answer any of these, or point me towards tutorials that explain these things to me.
 

jopojelly

Retinazer
tModLoader
Hello, I am trying to make a mod for my friend and I to play, its for his birthday so I'm trying to make it as weird and amusing as possible thus the weird item I will ask about. Anyway I am getting this error when I try to add a accessory: (26,25) : CS1518: Expected class, delegate, enum, interface, or struct
I have had so many problems so far which I have worked around. But please help me with this.
My code for the accessory:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SpikyBelly.Items
{
public class BellyEmblem : ModItem
{


public override void SetDefaults()
{
item.name = "Belly Emblem";
item.width = 10;
item.height = 14;
item.toolTip = "Use this if your willing to take the path of a belly.";
item.toolTip2 = "This can be fused with the souls of the bosses";
item.value = 10;
item.rare = 3;
item.accessory = true;
}
}

public override void UpdateAccessory(Player, player bool hideVisual)

{

player.noFallDmg = false;
player.canRocket = false;
player.rocketTime = 0;
player.rocketBoots = 0;
player.rocketTimeMax = 0;
player.aggro += 0;
player.meleeCrit += 0;
player.meleeDamage += 0f;
player.meleeSpeed += 0f;
player.moveSpeed += 0f;
player.rangedCrit += 0;
player.rangedDamage += 0f;
player.maxMinions++;
player.minionDamage += 0f;
player.statManaMax2 += 40;
player.manaCost -= 0.15f;
player.magicCrit += 7;
player.magicDamage += 3f;
}
}
It's probably that extra } that is terminating the class. Move the UpdateAccessory method into the class.
 

Snrasha

Terrarian
How do I make a weapon chargeable? Like the charged blaster cannon.
You copy just the code of the charged blaster cannon, and after 1 hour, you can that: http://imgur.com/dvGlUou
For say simple: The item shoot the weapon who is a projectile, then, you need just know coded and you can go easy all things. I do not send because, you can very easy found the code then delete useless thing.

How to I add throwing damage to a accessory?
public override void UpdateAccessory(Player player, bool hideVisual)
{
player.thrownDamage*=1.1f;
//player.thrownCrit
//player.thrownVelocity
}
 

Joost8910

Dungeon Spirit
You copy just the code of the charged blaster cannon, and after 1 hour, you can that: http://imgur.com/dvGlUou
For say simple: The item shoot the weapon who is a projectile, then, you need just know coded and you can go easy all things. I do not send because, you can very easy found the code then delete useless thing.
Huh? How do I find the code? I've never been able to find Terraria's code... And what do you mean by delete useless thing? Your reply is unhelpful.
 

64BTX

Official Terrarian
What do I do with the ExampleMod when I download it? Do I put the Mod Sources folder and dllReferences folder in the Mod Compile Folder?
 

Joost8910

Dungeon Spirit
How do I use a custom sound in main.playsound?
EDIT: I can't get it to work with items Either, what am I doing wrong?
Code:
using Microsoft.Xna.Framework.Audio;
using Terraria;
using Terraria.ModLoader;

namespace JoostMod.Sounds.Item
{
public class IceBeam : ModSound
{
public override void PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type)
{
soundInstance = sound.CreateInstance();
soundInstance.Volume = volume * .5f;
soundInstance.Pan = pan;
soundInstance.Pitch = -1.0f;
Main.PlaySoundInstance(soundInstance);
}
}
}
Code:
item.useSound = mod.GetSoundSlot(SoundType.Item, "Sounds/Item/IceBeam");
EDIT: I found that I need to use AutoLoadSounds in the mod.cs
EDIT: But I still don't know how with modsound, like for when a projectile dies
 
Last edited:

Xaminaf

Terrarian
So I updated my tModLoader, installed some mods, and whenever I try to make a world it just gets stuck in the middle of "Generating Structures...Minecart Tracks".
 
Top Bottom