Standalone [1.3] tModLoader - A Modding API

So with public virtual void DrawEffects(NPC npc, ref Color drawColor), Does drawColor allow me to change the color of the enemy like poison and ichor do? If its not too much trouble, could I get a real basic example of it?
 
So with public virtual void DrawEffects(NPC npc, ref Color drawColor), Does drawColor allow me to change the color of the enemy like poison and ichor do? If its not too much trouble, could I get a real basic example of it?
Yeah, that's what it does. Here's an example that should theoretically draw the NPC darker and in a more red shade:
Code:
drawColor.R = (byte)(drawColor.R * 0.75f);
drawColor.G = (byte)(drawColor.G * 0.25f);
drawColor.B = (byte)(drawColor.B * 0.25f);
 
Yeah, that's what it does. Here's an example that should theoretically draw the NPC darker and in a more red shade:
Code:
drawColor.R = (byte)(drawColor.R * 0.75f);
drawColor.G = (byte)(drawColor.G * 0.25f);
drawColor.B = (byte)(drawColor.B * 0.25f);
Works like a charm, thank you very much!
 
Suggestion:
If you have the source code of a mod, and the build you have is different from the one on the Mod Browser, the Mod Browser should not say 'Update', and instead should say 'Reset'.
 
Oh :red:
c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(22,24) : error CS1519: Invalid token 'using' in class, struct, or interface member declaration

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(22,36) : error CS1519: Invalid token ';' in class, struct, or interface member declaration

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(23,30) : error CS1519: Invalid token ';' in class, struct, or interface member declaration

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(24,15) : error CS1519: Invalid token ';' in class, struct, or interface member declaration

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(25,18) : error CS1519: Invalid token ';' in class, struct, or interface member declaration

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(26,25) : error CS1519: Invalid token ';' in class, struct, or interface member declaration

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(27,33) : error CS1519: Invalid token ';' in class, struct, or interface member declaration

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(28,32) : error CS1519: Invalid token ';' in class, struct, or interface member declaration

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(30,1) : error CS1519: Invalid token '{' in class, struct, or interface member declaration

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(69,2) : error CS0116: A namespace cannot directly contain members such as fields or methods

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(74,19) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(80,27) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(84,48) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(84,81) : error CS1031: Type expected

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(84,110) : error CS1002: ; expected

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(85,13) : error CS0116: A namespace cannot directly contain members such as fields or methods

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(92,14) : error CS0116: A namespace cannot directly contain members such as fields or methods

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(93,9) : error CS1022: Type or namespace definition, or end-of-file expected

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(31,15) : error CS0542: 'ExampleBlock': member names cannot be the same as their enclosing type

Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria.World.Generation;
namespace ExampleMod.Tiles
{
public class ExampleBlock : ModTile
{
public override void SetDefaults()
{
Main.tileSolid[Type] = true;
Main.tileMergeDirt[Type] = true;
Main.tileBlockLight[Type] = true;
Main.tileLighted[Type] = true;
dustType = mod.DustType("Sparkle");
AddMapEntry(new Color(200, 200, 200));
}

public override void using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria.World.Generation;
namespace ExampleMod.Tiles
{
public class ExampleBlock : ModTile
{
public override void SetDefaults()
{
Main.tileSolid[Type] = true;
Main.tileMergeDirt[Type] = true;
Main.tileBlockLight[Type] = true;
Main.tileLighted[Type] = true;
dustType = mod.DustType("Sparkle");
AddMapEntry(new Color(200, 200, 200));
}

public override void NumDust(int i, int j, bool fail, ref int num)
{
num = fail ? 1 : 3;
}

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;
}
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
{
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));

tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress)
{
progress.Message = "Growing Enderuim Crystals...";

for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
{
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("ExampleBlock"), false, 0f, 0f, false, true);
}
}));
}
}
}NumDust(int i, int j, bool fail, ref int num)
{
num = fail ? 1 : 3;
}

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;
}
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
{
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));

tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress)
{
progress.Message = "Growing Enderuim Crystals...";

for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
{
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("ExampleBlock"), false, 0f, 0f, false, true);
}
}));
}
}
}
[DOUBLEPOST=1457382449,1457381979][/DOUBLEPOST]
Oh :red:


Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria.World.Generation;
namespace ExampleMod.Tiles
{
public class ExampleBlock : ModTile
{
public override void SetDefaults()
{
Main.tileSolid[Type] = true;
Main.tileMergeDirt[Type] = true;
Main.tileBlockLight[Type] = true;
Main.tileLighted[Type] = true;
dustType = mod.DustType("Sparkle");
AddMapEntry(new Color(200, 200, 200));
}

public override void using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria.World.Generation;
namespace ExampleMod.Tiles
{
public class ExampleBlock : ModTile
{
public override void SetDefaults()
{
Main.tileSolid[Type] = true;
Main.tileMergeDirt[Type] = true;
Main.tileBlockLight[Type] = true;
Main.tileLighted[Type] = true;
dustType = mod.DustType("Sparkle");
AddMapEntry(new Color(200, 200, 200));
}

public override void NumDust(int i, int j, bool fail, ref int num)
{
num = fail ? 1 : 3;
}

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;
}
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
{
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));

tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress)
{
progress.Message = "Growing Enderuim Crystals...";

for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
{
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("ExampleBlock"), false, 0f, 0f, false, true);
}
}));
}
}
}NumDust(int i, int j, bool fail, ref int num)
{
num = fail ? 1 : 3;
}

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;
}
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
{
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));

tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress)
{
progress.Message = "Growing Enderuim Crystals...";

for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
{
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("ExampleBlock"), false, 0f, 0f, false, true);
}
}));
}
}
}
NVM, I did some stupid copy paste
[DOUBLEPOST=1457382517][/DOUBLEPOST]using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria.World.Generation;

namespace Enderuim.Tiles
{
public class Enderuim : ModWorld
{
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
{
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));

tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress){;
{
progress.Message = "Growing Enderuim Crystals...";

for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
{
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("ExampleBlock"), false, 0f, 0f, false, true);
}
};
}));
}
}}

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlockGen.cs(17,48) : error CS0246: The type or namespace name 'PassLegacy' could not be found (are you missing a using directive or an assembly reference?)
 
c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlockGen.cs(17,48) : error CS0246: The type or namespace name 'PassLegacy' could not be found (are you missing a using directive or an assembly reference?)
using Terraria.GameContent.Generation;
 
When I use 'if (item.type == ItemID.an item)' it gives me an error message when I try to compile it saying that:
The name 'item' does not exist in the current context. Why?
 
When I use 'if (item.type == ItemID.an item)' it gives me an error message when I try to compile it saying that:
The name 'item' does not exist in the current context. Why?

Like it says, there is no variable named item in your class or method. Either you forgot to declare it or it's not in the same scope as your method.
 
Back
Top Bottom