Trekko727
Terrarian
umm how?? I get what you mean but I cant seem to work it outTrue, sometimes even nanoseconds, but XNA (the library used for Terraria) allows for a 'standard' framerate (a bit like vsync). This will cap your FPS at 60 and will try to make updates work towards that number (when you're experiencing frame drops). So you can safely state that there are 60 ticks every second using XNA/Terraria.
No more, no less.
Eldrazi
Eater of Worlds
What are you struggling with exactly? What can't you work out?umm how?? I get what you mean but I cant seem to work it out
Trekko727
Terrarian
the delay of 0.1 second?What are you struggling with exactly? What can't you work out?
like in lua its just
wait(0.1)
Eldrazi
Eater of Worlds
Yeah, unfortunately this ain't that simple. If you want to use a build in 'wait' command, you'll either have to work with 'workers' or 'threading' (those are the two fastest/easiest), but I wouldn't recommend any of them, since it's just for this one function (it's really over-the-top to use something like what I mentioned to implement what you want). You could also use a while loop, but... meh. Like I said, best thing you can do is make a timer yourself.the delay of 0.1 second?
like in lua its just
wait(0.1)
Create a variable, increment that variable every update (so 60x every second). You can then check that value against 60 or 120 or 180, etc depending on the time you want to wait. Waiting for 0.1 second would mean you need to check the variable against 6.
Trekko727
Terrarian
I might have solved it using System.Diagnostic.Stopwatch sw = new Stopwatch();Yeah, unfortunately this ain't that simple. If you want to use a build in 'wait' command, you'll either have to work with 'workers' or 'threading' (those are the two fastest/easiest), but I wouldn't recommend any of them, since it's just for this one function (it's really over-the-top to use something like what I mentioned to implement what you want). You could also use a while loop, but... meh. Like I said, best thing you can do is make a timer yourself.
Create a variable, increment that variable every update (so 60x every second). You can then check that value against 60 or 120 or 180, etc depending on the time you want to wait. Waiting for 0.1 second would mean you need to check the variable against 6.
code:
Code:
public override void UseStyle(Player player)
{
int counter = 1; //charge-up counter
int Power = 6; //projectile speed
int counterLimit = 11; //say every "charge" is per 0.1 sec which makes the limit to 1 second (full charge)
//int PenBase = 3; //defense reduction
if (counter > 1 && item.channel == true)
{
stylenumber = 4;
} else if (counter >1 && item.channel == true){
stylenumber = 5;
item.shootSpeed = Power;
item.shoot = mod.ProjectileType("SASKnife");
} else if (item.channel == true){
if (counter < counterLimit)
{
System.Diagnostics.Stopwatch sw = new Stopwatch();
sw.Start();
if (sw.ElapsedMilliseconds == 100)
{
sw.Stop();
Power++;
counter++;
}
sw.Reset();
}
} else {
stylenumber = 1;
}
}
Eldrazi
Eater of Worlds
Well, if you think that's the way to go about it (and it works) then go right aheadI might have solved it using System.Diagnostic.Stopwatch sw = new Stopwatch();
code:
haven't added the projectile for SASKnife (one is for melee the other is to throw)Code:public override void UseStyle(Player player) { int counter = 1; //charge-up counter int Power = 6; //projectile speed int counterLimit = 11; //say every "charge" is per 0.1 sec which makes the limit to 1 second (full charge) //int PenBase = 3; //defense reduction if (counter > 1 && item.channel == true) { stylenumber = 4; } else if (counter >1 && item.channel == true){ stylenumber = 5; item.shootSpeed = Power; item.shoot = mod.ProjectileType("SASKnife"); } else if (item.channel == true){ if (counter < counterLimit) { System.Diagnostics.Stopwatch sw = new Stopwatch(); sw.Start(); if (sw.ElapsedMilliseconds == 100) { sw.Stop(); Power++; counter++; } sw.Reset(); } } else { stylenumber = 1; } }
lol internet!
Terrarian
HOW TO MAKE MOD PLEASE TUTORIAL !
Eldrazi
Eater of Worlds
Please do not post with Capital letters only...HOW TO MAKE MOD PLEASE TUTORIAL !
Other than that, there aren't that many tutorials out there yet, but there is a link in the OP that should help you get started.
You can also download the Example mod to look at how things are done exactly.
It's also recommendable to search for some C# tutorials (if you don't know how to code with it already that is).
silent_ptr
Plantera
I might post a tutorial on my YouTube.HOW TO MAKE MOD PLEASE TUTORIAL !
Well, it's a good thing I've been adding tapi classes and methods ever since I started working on this, right?I think some tapi classes and method can be added in this tool
Instead of using a stopwatch, you can just create a projectile that behaves the same way as drills, etc. (the example mod has a drill), and use a value in the projectile's ai array to keep count of stuff. (The Sarcophagus has an example of keeping track of time with the ai array.)I might have solved it using System.Diagnostic.Stopwatch sw = new Stopwatch();
code:
haven't added the projectile for SASKnife (one is for melee the other is to throw)Code:public override void UseStyle(Player player) { int counter = 1; //charge-up counter int Power = 6; //projectile speed int counterLimit = 11; //say every "charge" is per 0.1 sec which makes the limit to 1 second (full charge) //int PenBase = 3; //defense reduction if (counter > 1 && item.channel == true) { stylenumber = 4; } else if (counter >1 && item.channel == true){ stylenumber = 5; item.shootSpeed = Power; item.shoot = mod.ProjectileType("SASKnife"); } else if (item.channel == true){ if (counter < counterLimit) { System.Diagnostics.Stopwatch sw = new Stopwatch(); sw.Start(); if (sw.ElapsedMilliseconds == 100) { sw.Stop(); Power++; counter++; } sw.Reset(); } } else { stylenumber = 1; } }
silent_ptr
Plantera
How do you animate tiles? Say, a 3x2 tile. How would I animate it?
Eldrazi
Eater of Worlds
You need to set 'animationFrameHeight' in the SetDefaults method of your ModTile to the height of one frame (note that you need to INCLUDE the padding).How do you animate tiles? Say, a 3x2 tile. How would I animate it?
Then you can do something like the following:
Code:
public override void AnimateTile(ref int frame, ref int frameCounter)
{
frameCounter++;
if (frameCounter >= 10) // Here you can change the speed at which your tile animates.
{
frame = (frame + 1) % 8; // The '8' needs to be changed to the max frame amount.
frameCounter = 0;
}
}
eatintoast
Terrarian
I have been trying to make a simple mod that adds crafting recipes for vanilla items using vanilla items but when i try to compile i get this error.
Here is my code:
build.txt
craftingrecipes.cs
recipehelper.cs
Code:
c:\Users\~\Documents\My Games\Terraria\ModLoader\Mod Sources\Craftingrecipes\recipehelper.cs(11,24) : error CS0115: 'Craftingrecipes.RecipeHelper.AddRecipes(Terraria.ModLoader.Mod)': no suitable method found to override
Here is my code:
build.txt
Code:
author = eatintoast
version = v.10
displayName = craftingrecipes
craftingrecipes.cs
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace Craftingrecipes {
public class Craftingrecipes : Mod
{
public override void SetModInfo(out string name, ref ModProperties properties)
{
name = "Craftingrecipes";
properties.Autoload = true;
}
public override void AddRecipes()
{
RecipeHelper.AddRecipes(this);
}
}
}
recipehelper.cs
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace Craftingrecipes
{
public class RecipeHelper
{
public override void AddRecipes(Mod mod)
{
ModRecipe recipe= new ModRecipe(mod);
recipe.AddIngredient(ItemId.StoneBlock, 10);
recipe.AddIngredient(ItemId.Silk, 10);
recipe.AddIngredient(ItemId.Wood, 10);
recipe.SetResult(ItemId.Aglet);
recip.Addrecipe();
}
}
}
silent_ptr
Plantera
Look at the Mod mod parameter.I have been trying to make a simple mod that adds crafting recipes for vanilla items using vanilla items but when i try to compile i get this error.
Code:c:\Users\~\Documents\My Games\Terraria\ModLoader\Mod Sources\Craftingrecipes\recipehelper.cs(11,24) : error CS0115: 'Craftingrecipes.RecipeHelper.AddRecipes(Terraria.ModLoader.Mod)': no suitable method found to override
Here is my code:
build.txt
Code:author = eatintoast version = v.10 displayName = craftingrecipes
craftingrecipes.cs
Code:using System; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace Craftingrecipes { public class Craftingrecipes : Mod { public override void SetModInfo(out string name, ref ModProperties properties) { name = "Craftingrecipes"; properties.Autoload = true; } public override void AddRecipes() { RecipeHelper.AddRecipes(this); } } }
recipehelper.cs
Code:using System; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace Craftingrecipes { public class RecipeHelper { public override void AddRecipes(Mod mod) { ModRecipe recipe= new ModRecipe(mod); recipe.AddIngredient(ItemId.StoneBlock, 10); recipe.AddIngredient(ItemId.Silk, 10); recipe.AddIngredient(ItemId.Wood, 10); recipe.SetResult(ItemId.Aglet); recip.Addrecipe(); } } }
Eldrazi
Eater of Worlds
Yeah, that ain't going to work. You've got your RecipeHelper class, which doesn't inherit from anything, and you're trying to call an override function...I have been trying to make a simple mod that adds crafting recipes for vanilla items using vanilla items but when i try to compile i get this error.
Code:c:\Users\~\Documents\My Games\Terraria\ModLoader\Mod Sources\Craftingrecipes\recipehelper.cs(11,24) : error CS0115: 'Craftingrecipes.RecipeHelper.AddRecipes(Terraria.ModLoader.Mod)': no suitable method found to override
Here is my code:
build.txt
Code:author = eatintoast version = v.10 displayName = craftingrecipes
craftingrecipes.cs
Code:using System; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace Craftingrecipes { public class Craftingrecipes : Mod { public override void SetModInfo(out string name, ref ModProperties properties) { name = "Craftingrecipes"; properties.Autoload = true; } public override void AddRecipes() { RecipeHelper.AddRecipes(this); } } }
recipehelper.cs
Code:using System; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace Craftingrecipes { public class RecipeHelper { public override void AddRecipes(Mod mod) { ModRecipe recipe= new ModRecipe(mod); recipe.AddIngredient(ItemId.StoneBlock, 10); recipe.AddIngredient(ItemId.Silk, 10); recipe.AddIngredient(ItemId.Wood, 10); recipe.SetResult(ItemId.Aglet); recip.Addrecipe(); } } }
Just make that function
Code:
public void AddRecipes(Mod mod)
{
ModRecipe recipe= new ModRecipe(mod);
recipe.AddIngredient(ItemId.StoneBlock, 10);
recipe.AddIngredient(ItemId.Silk, 10);
recipe.AddIngredient(ItemId.Wood, 10);
recipe.SetResult(ItemId.Aglet);
recip.Addrecipe();
}
silent_ptr
Plantera
Is there any way to do that effect on Shadowscale when you put the entire set on? (That drag effect type thing??.)
Eldrazi
Eater of Worlds
Yeah, there is. It's on the tModLoader wiki right here.Is there any way to do that effect on Shadowscale when you put the entire set on? (That drag effect type thing??.)
Trekko727
Terrarian
I'll check it out! thanks for the infoWell, it's a good thing I've been adding tapi classes and methods ever since I started working on this, right?
Instead of using a stopwatch, you can just create a projectile that behaves the same way as drills, etc. (the example mod has a drill), and use a value in the projectile's ai array to keep count of stuff. (The Sarcophagus has an example of keeping track of time with the ai array.)
silent_ptr
Plantera
Tile animation not working! Code:
Sprite:
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;
namespace TerraMod.Tiles
{
public class RudoniateForgeBlock : 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.Style3x2);
TileObjectData.newTile.CoordinateHeights = new int[]{ 34 };
TileObjectData.addTile(Type);
this.animationFrameHeight = 34;
this.minPick = 190;
dustType = 37;
drop = mod.ItemType("RudoniateForge");
AddMapEntry(new Color(24, 97, 134));
}
public override void AnimateTile(ref int frame, ref int frameCounter)
{
frameCounter++;
if (frameCounter >= 50)
{
frame = (frame + 1) % 4;
frameCounter = 0;
}
}
}
}
Similar threads
- Replies
- 40
- Views
- 22K
- Replies
- 5
- Views
- 1K
- Replies
- 893
- Views
- 890K
- Replies
- 0
- Views
- 468
- Sticky
- Replies
- 270
- Views
- 261K
-
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.