Standalone [1.3] tModLoader - A Modding API

If say I wanted the EoC to drop a dirt block, but nothing else at all.
You'll want to modify that code:
Code:
public override bool PreNPCLoot(NPC npc)
{
    if(npc.type == NPCID.EyeofCthulhu)
    {
        Item.NewItem(npc.position.X, npc.position.Y, npc.width, npc.height, ItemID.DirtBlock);
        return false;
    }
    return true;
}
 
You'll want to modify that code:
Code:
public override bool PreNPCLoot(NPC npc)
{
    if(npc.type == NPCID.EyeofCthulhu)
    {
        Item.NewItem(npc.position.X, npc.position.Y, npc.width, npc.height, ItemID.DirtBlock);
        return false;
    }
    return true;
}
Thanks. It seems to work.
 
All the documentation for this tool says that there is a ModSources folder in My Games/Terraria/ModLoader. However when I tried to access it, there was no such folder. Please Help.
 
All the documentation for this tool says that there is a ModSources folder in My Games/Terraria/ModLoader. However when I tried to access it, there was no such folder. Please Help.
The "Mod Sources" folder should be created there when you click the mod Sources menu. Have you tried the open mod Sources folder button?
 
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Hypaxi.Items
{
public class ExampleGun : ModItem
{
public override void SetDefaults()
{
item.name = "Specter Rifle";
item.damage = 20;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is a modded gun.";
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 5;
item.noMelee = true;
item.knockBack = 4;
item.value = 10000;
item.rare = 2;
item.useSound = 11;
item.autoReuse = true;
item.shoot = 10;
item.shootSpeed = 16f;
item.useAmmo = ProjectileID.Bullet;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.SetResult(this, 1);
recipe.AddRecipe();
}
}
}

Alright not trying to be annoying but I tried to fix the code with the advice given but it still is having some problems.
 
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Hypaxi.Items
{
public class ExampleGun : ModItem
{
public override void SetDefaults()
{
item.name = "Specter Rifle";
item.damage = 20;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is a modded gun.";
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 5;
item.noMelee = true;
item.knockBack = 4;
item.value = 10000;
item.rare = 2;
item.useSound = 11;
item.autoReuse = true;
item.shoot = 10;
item.shootSpeed = 16f;
item.useAmmo = ProjectileID.Bullet;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.SetResult(this, 1);
recipe.AddRecipe();
}
}
}

Alright not trying to be annoying but I tried to fix the code with the advice given but it still is having some problems.
What is exactly the problem? Can we have the error message?
 
It says

The best overloaded method match for 'Terraria.ModLoader.ModRecipe.ModRecipe(Terraria.ModLoader.Mod)' has some invalid arguments
Argument 1: cannot convert from 'Hypaxi.Items.ExampleGun' to 'Terraria.ModLoader.Mod'
 
It says

The best overloaded method match for 'Terraria.ModLoader.ModRecipe.ModRecipe(Terraria.ModLoader.Mod)' has some invalid arguments
Argument 1: cannot convert from 'Hypaxi.Items.ExampleGun' to 'Terraria.ModLoader.Mod'
In the AddRecipes function, instead of
Code:
ModRecipe recipe = new ModRecipe(this);
You'll want to put
Code:
ModRecipe recipe = new ModRecipe(mod);
 
Alright it compiles but the item does not appear in the craft menu.
 
Alright it compiles but the item does not appear in the craft menu.
Do you have a class deriving from Mod that sets Autoload to true?
 
Just asking does anyone else have a problem with lag or out of memory error when loading 13+ mods? the mods i have enabled are Imksushis mod, Ersion, Longbows FTW, Tremor, More Accessories+, Summoners Association, Quality of life Standard, Helpful Hotkeys, Imksushi mod: Drops Addon, MaxStackPlus, Thorium, Infinity, and battle hardened NPCs... but when I try to load anymore than those ones I get MAJOR lag and have to use task manager to force close terraria or I get out of memory error and this really bugs me Because there are a few other mods I would love to add like the ZoaklenMod or Boss Expertise but I enable one of those and my game freaks out when I try to load a world.
 
namespace Hypaxi.Items
{
public class SpecterRifle : ModItem
{
public override void SetDefaults()
{
item.name = "Specter Rifle";
item.damage = 20;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is a modded gun.";
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 5;
item.noMelee = true;
item.knockBack = 4;
item.value = 10000;
item.rare = 2;
item.useSound = 11;
item.autoReuse = true;
item.shoot = 10;
item.shootSpeed = 16f;
item.useAmmo = ProjectileID.Bullet;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.SetResult(this, 1);
recipe.AddRecipe();
}
}
}

Alright so this is what i've tried now.
here are the errors

error CS1514: { expected
error CS1519: Invalid token ':' in class, struct, or interface member declaration
error CS1519: Invalid token '{' in class, struct, or interface member declaration
 
namespace Hypaxi.Items
{
public class SpecterRifle : ModItem
{
public override void SetDefaults()
{
item.name = "Specter Rifle";
item.damage = 20;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is a modded gun.";
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 5;
item.noMelee = true;
item.knockBack = 4;
item.value = 10000;
item.rare = 2;
item.useSound = 11;
item.autoReuse = true;
item.shoot = 10;
item.shootSpeed = 16f;
item.useAmmo = ProjectileID.Bullet;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.SetResult(this, 1);
recipe.AddRecipe();
}
}
}

Alright so this is what i've tried now.
here are the errors

error CS1514: { expected
error CS1519: Invalid token ':' in class, struct, or interface member declaration
error CS1519: Invalid token '{' in class, struct, or interface member declaration
Is this all the code that is in your class? No using statements?
 
I'm kinda new at this so I do believe that there is no statements.
 
I'm kinda new at this so I do believe that there is no statements.
Allright, if that's all the code, you're missing a few things. You'll want to put the following lines at the top of your code:
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
 
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Hypaxi.Items
{
public class SpecterRifle : ModItem
{
public override void SetDefaults()
{
item.name = "Specter Rifle";
item.damage = 20;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is a modded gun.";
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 5;
item.noMelee = true;
item.knockBack = 4;
item.value = 10000;
item.rare = 2;
item.useSound = 11;
item.autoReuse = true;
item.shoot = 10;
item.shootSpeed = 16f;
item.useAmmo = ProjectileID.Bullet;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.SetResult(this, 1);
recipe.AddRecipe();
}
}
}


Yeah Sorry it didnt copy correctly.
 
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Hypaxi.Items
{
public class SpecterRifle : ModItem
{
public override void SetDefaults()
{
item.name = "Specter Rifle";
item.damage = 20;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is a modded gun.";
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 5;
item.noMelee = true;
item.knockBack = 4;
item.value = 10000;
item.rare = 2;
item.useSound = 11;
item.autoReuse = true;
item.shoot = 10;
item.shootSpeed = 16f;
item.useAmmo = ProjectileID.Bullet;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.SetResult(this, 1);
recipe.AddRecipe();
}
}
}


Yeah Sorry it didnt copy correctly.
Could you copy+paste the exact errors, please?
 
Hi guys,
I'm getting these errors:
c:\Users\Warsmith\Documents\My Games\Terraria\ModLoader\Mod Sources\Terravalice\Items\KnightSwords\Save the Queen.cs(9,20) : error CS1514: { expected

c:\Users\Warsmith\Documents\My Games\Terraria\ModLoader\Mod Sources\Terravalice\Items\KnightSwords\Save the Queen.cs(9,30) : error CS1002: ; expected

c:\Users\Warsmith\Documents\My Games\Terraria\ModLoader\Mod Sources\Terravalice\Items\KnightSwords\Save the Queen.cs(10,2) : error CS1519: Invalid token '{' in class, struct, or interface member declaration

With this code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Terravalice.Items.KnightSwords
{
public class Save the Queen : ModItem
{
public override void SetDefaults()
{
item.name = "Save the Queen";
item.melee = true;
item.damage = 36;
item.knockBack = 5;
item.width = 30;
item.height = 30;
item.useStyle = 1;
item.useAnimation = 20;
item.useTime = 20;
item.useSound = 1;
item.value = 30000;
item.rare = 2;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(Terraria.ID.ItemID.Wood, 1);
recipe.SetResult(this);
recipe.AddRecipe();
}
// Ironskin effect (protect)
public void DamageNPC (Player myPlayer, NPC npc, ref int damage, ref float knockback)
{
// Add the buff
myPlayer.AddBuff (5, 600);
}
}
}

I feel like I'm missing something obvious, but it looks ok to me...
 
Can anyone explain to me how
public virtual bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox)
in modProjectile works?
I'm trying to make a projectile have a damaging trail

[DOUBLEPOST=1457660346,1457660300][/DOUBLEPOST]
Hi guys,
I'm getting these errors:
c:\Users\Warsmith\Documents\My Games\Terraria\ModLoader\Mod Sources\Terravalice\Items\KnightSwords\Save the Queen.cs(9,20) : error CS1514: { expected

c:\Users\Warsmith\Documents\My Games\Terraria\ModLoader\Mod Sources\Terravalice\Items\KnightSwords\Save the Queen.cs(9,30) : error CS1002: ; expected

c:\Users\Warsmith\Documents\My Games\Terraria\ModLoader\Mod Sources\Terravalice\Items\KnightSwords\Save the Queen.cs(10,2) : error CS1519: Invalid token '{' in class, struct, or interface member declaration

With this code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Terravalice.Items.KnightSwords
{
public class Save the Queen : ModItem
{
public override void SetDefaults()
{
item.name = "Save the Queen";
item.melee = true;
item.damage = 36;
item.knockBack = 5;
item.width = 30;
item.height = 30;
item.useStyle = 1;
item.useAnimation = 20;
item.useTime = 20;
item.useSound = 1;
item.value = 30000;
item.rare = 2;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(Terraria.ID.ItemID.Wood, 1);
recipe.SetResult(this);
recipe.AddRecipe();
}
// Ironskin effect (protect)
public void DamageNPC (Player myPlayer, NPC npc, ref int damage, ref float knockback)
{
// Add the buff
myPlayer.AddBuff (5, 600);
}
}
}

I feel like I'm missing something obvious, but it looks ok to me...
The name of your class can't have a space in it
 
Huh, yep, sure enough.
 
Back
Top Bottom