Sorry if this post is chaotic, aggressive, and/or a pain to read. I don't know what to do or how and it kinda frustrates me.
Started modding terraria, want a weapon that shoots random projectiles. Started looking for a way to generate a random number. No way that i have found in other forums seem to work. This could be simply my inexperience not letting me know what to do with the code, It could be a problem with TMODLoader, I honestly have no clue whatsoever.
random number, c#, tried common methods, error message "error CS0103: The name 'random' does not exist in the current context warnings at Terraria.ModLoader.Core.ModCompile.CompileMod(BuildingMod mod, String outputPath, List`1& refMods, Boolean xna)"
want a single line basic one-off method random number 1-7 (including both), New to coding, if you're introducing any new lines of code and doing something that requires more than "int x = thingytogetrandomnumber(min, max); then tell me what i'm supposed to do with the code"
I have tried
var result = random.Next(0, 2);
Random rando = new Random();
i = rando.Next(0, 2);
I don't want a essay on how a number cannot be truly randomly generated, or a 20 line function i don't understand a inch of. I would prefer a simple one line way to get a random number. I will only be using this for a limited number of times, so a function or utility etc is entirely unnecessary. This does come of kinda ranty and aggressive, But all i've found is blocks of code that i don't know what to do with. I've put the code in int wproj = HERE, but get the same error message. Have no clue what it means
int wproj = random.Next(0, 2);
if (wproj == 1)
{
Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ProjectileID.CursedBullet, damage, knockBack, player.whoAmI);
}
if (wproj == 2).....
Only result is below. Expected result is random number 1-7(inc both) and series of if statements that use that variable.
error CS0103: The name 'random' does not exist in the current context warnings at Terraria.ModLoader.Core.ModCompile.CompileMod(BuildingMod mod, String outputPath, List`1& refMods, Boolean xna)
Aucun commentaire:
Enregistrer un commentaire