Standalone [1.3] tModLoader - A Modding API

1. Yesterday i have some mistakes in my pngs and terria crashed at build. After a fix and restart it shows me the errormessage. Today after a try with the example pngs and again with my pngs (the same files from yesterday) it works. So i don't know why. I don't change anything from the code.
2. I know this, but i don't want to use all mods everytime and if i want only some mods i have to disable all other by hand. A Example: when i have a group of 11 mods to make the game easy and a secound group with 12 mods to make the game harder then i don't want both at the same time.
3. Oh is a example anywhere or somehing else?

Edit:
1. I fix the mistakes yesterday and after it i got again error messenges with crash.
1. Can you show me the error message? All of those kinds of bugs should have been fixed by now.
2. Oh, I see. So basically you want to be able to enable/disable groups of mods at once. We will consider that for the future.
3. There isn't an example. Basically, Terraria doesn't actually have strict biomes; it just has blocks that makes some NPCs valid for spawning, etc., and enough of those blocks changes the music and background, makes items drop, etc. All of those are possible except the music and background right now.
Delete the .tmod file. It shouldn't crash though, what mistake was it (that you made)?
It shouldn't be necessary to delete the file (there's a modName.enabled file whose text you can set to false, and if it doesn't exist you can create it).
 
Über das Ende des Datenstroms hinaus kann nicht gelesen werden.
bei System.IO.BinaryReader.ReadByte()
bei System.IO.BinaryReader.Read7BitEncodedInt()
bei System.IO.BinaryReader.ReadString()
bei Terraria.ModLoader.ModLoader.LoadMod(String modFile, BuildProperties properties)
bei Terraria.ModLoader.ModLoader.LoadMods()
1. Ok normaly it works (with code errors), but if the png isn't correct Terraria chrashed (texture errors). When im start Terraria again it's show me the errormessage.
2. Yes
3. So i need only a start Trigger, a method for changing a block, and a repeate Trigger?
 
One more thing. My only error with all my current items (around 35 or so) is this:

c:\Users\MountainDrew\Documents\my games\Terraria\ModLoader\Mod Sources\CalamityMod\Items\Weapons\Galeforce.cs(37,37) : error CS0117: 'Terraria.ID.ProjectileID' does not contain a definition for 'Arrows'

No definition for Arrows? What? I've tried "Arrows, Arrow, arrows, and arrow", none of them worked. I'm sorry if this is a stupid question, but I have no idea what the projectile ID for arrows is.
 
One more thing. My only error with all my current items (around 35 or so) is this:

c:\Users\MountainDrew\Documents\my games\Terraria\ModLoader\Mod Sources\CalamityMod\Items\Weapons\Galeforce.cs(37,37) : error CS0117: 'Terraria.ID.ProjectileID' does not contain a definition for 'Arrows'

No definition for Arrows? What? I've tried "Arrows, Arrow, arrows, and arrow", none of them worked. I'm sorry if this is a stupid question, but I have no idea what the projectile ID for arrows is.
There is no such thing as a normal arrow in the ProjectileID class. The most basic would be 'ProjectileID.WoodenArrowFriendly'...
 
They call me 'The Ninja' for a reason... WHATAAAA!

But seriously, @MountainDrew why would you try to access an ProjectileID arrow in 35 item scripts?

I dunno, I was probably drunk when I wrote that :confused:

And it was just one item/weapon that was having that issue, and I'm still trying to learn how to code this stuff (I started my first C# coding course this semester). But I've fixed it now, thanks :p
 
Über das Ende des Datenstroms hinaus kann nicht gelesen werden.
bei System.IO.BinaryReader.ReadByte()
bei System.IO.BinaryReader.Read7BitEncodedInt()
bei System.IO.BinaryReader.ReadString()
bei Terraria.ModLoader.ModLoader.LoadMod(String modFile, BuildProperties properties)
bei Terraria.ModLoader.ModLoader.LoadMods()
1. Ok normaly it works (with code errors), but if the png isn't correct Terraria chrashed (texture errors). When im start Terraria again it's show me the errormessage.
2. Yes
3. So i need only a start Trigger, a method for changing a block, and a repeate Trigger?
1. Hm, that's pretty weird. It's hard to tell why that would be happening. What do you mean by the png not being correct?
3. What do you mean? All you need at the moment is to check for the block's type during NPC spawning, check how many blocks of that type are near the player when an item drops (optional), and the ModTile.RandomUpdate hook for spreading (optional).
 
I'm just looking at one place and copying I have no idea how to C# code lol
Not quite a good thing to do. Copy and pasting doesn't help somebody when they want a unique item! I would recommend taking a look at Microsoft Virtual Academy (The site appears to be a bit buggy at times, but it should work). From what I saw of the site, it is free to use, and even comes with a skills assessment or task for each unit. I'd highly recommend that you (Or anyone else who needs to learn C#) take a peek at it!

Also, my reasoning for saying the above: Coding from an API may be easier in the short-game (Even without knowing about programming), but if you want to expand functionality beyond the basics, and create much more complex objects, such as a well done, innovative AI, or unique functionality, you should learn the language. By copy-pasting things, you lose all originality, and that is just plain boring when done ad infinitum.

Also, from my experiences, C# is not that difficult to learn - It's modern, it's syntax is very refreshing and simple, and is fairly easy to access (Unless you run OS X, like me); and think about it, nothing hurts anyone from learning something new (As a matter in fact, I'm an avid supporter of making Computer Science a required credit for both High School and College :p). A skill such as programming is also extremely vital in the Information Age - and that is unlikely to change.
___________________________
NOT REGARDING ANYBODY IN PARTICULAR, JUST A BIT OF INSPIRATION FOR ANYBODY!
And a note (And a bit of inspiration for any other young programmers) regarding any chances of "Age discrepancies": AGE DOES NOT MATTER (Except for legal obligations). For example, I started learning Java when I was 10, and over the course of five years (Up to this very day, of 15 years of age), I've managed to learn HTML/CSS, PhP, JavaScript, jQuery, C#, C++, Python, Lua, and, my personal favorite, Swift, and can program in these rather fluently. So as you can see, age means nothing. It is just a number. Don't let something with no real limitations halt you from something so empowering! Do not let anybody else stand in your way either; and the converse, let others help and support you (And expand your friend base perhaps)! For example, I have had a real fortunate set of friends over the years - especially in High school. They have been supportive of me, and have truly pushed myself to where I am today. I must say, I really do owe it all to them. As a result, I can say that, getting to know others is one of the most important parts of programming. So I say this as if fact, the true catalysts for becoming an efficient programmer: strong relationships and bonds, and having an imagination. At times you may fail, but get back up, and, try and try again!
 
I have 2 questions:

1. How to change the spawn postion of the NPC in this code?
Code:
    public override bool UseItem(Player player)
    {
        NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("mob"));
        Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0);
        return true;
    }
With this code it spawns in random location.

2. I have 2 bosses that spawn at the same time. How to make the items drop from the boss that was killed last (Like Twins)?
 
Not quite a good thing to do. Copy and pasting doesn't help somebody when they want a unique item! I would recommend taking a look at Microsoft Virtual Academy (The site appears to be a bit buggy at times, but it should work). From what I saw of the site, it is free to use, and even comes with a skills assessment or task for each unit. I'd highly recommend that you (Or anyone else who needs to learn C#) take a peek at it!

Also, my reasoning for saying the above: Coding from an API may be easier in the short-game (Even without knowing about programming), but if you want to expand functionality beyond the basics, and create much more complex objects, such as a well done, innovative AI, or unique functionality, you should learn the language. By copy-pasting things, you lose all originality, and that is just plain boring when done ad infinitum.

Also, from my experiences, C# is not that difficult to learn - It's modern, it's syntax is very refreshing and simple, and is fairly easy to access (Unless you run OS X, like me); and think about it, nothing hurts anyone from learning something new (As a matter in fact, I'm an avid supporter of making Computer Science a required credit for both High School and College :p). A skill such as programming is also extremely vital in the Information Age - and that is unlikely to change.
___________________________
NOT REGARDING ANYBODY IN PARTICULAR, JUST A BIT OF INSPIRATION FOR ANYBODY!
And a note (And a bit of inspiration for any other young programmers) regarding any chances of "Age discrepancies": AGE DOES NOT MATTER (Except for legal obligations). For example, I started learning Java when I was 10, and over the course of five years (Up to this very day, of 15 years of age), I've managed to learn HTML/CSS, PhP, JavaScript, jQuery, C#, C++, Python, Lua, and, my personal favorite, Swift, and can program in these rather fluently. So as you can see, age means nothing. It is just a number. Don't let something with no real limitations halt you from something so empowering! Do not let anybody else stand in your way either; and the converse, let others help and support you (And expand your friend base perhaps)! For example, I have had a real fortunate set of friends over the years - especially in High school. They have been supportive of me, and have truly pushed myself to where I am today. I must say, I really do owe it all to them. As a result, I can say that, getting to know others is one of the most important parts of programming. So I say this as if fact, the true catalysts for becoming an efficient programmer: strong relationships and bonds, and having an imagination. At times you may fail, but get back up, and, try and try again!
Dude (I don't often use that term), if I didn't already know how to program, I'd look some tuts up right now! Really Nice motivational speach and ever so true. I starten when I was 11-12 but was so enthousiastic about the whole programming that I soon searched for some tuts as to how to go about it.
Anyway, to get to the point: very good post!
 
I have 2 questions:

1. How to change the spawn postion of the NPC in this code?

2. I have 2 bosses that spawn at the same time. How to make the items drop from the boss that was killed last (Like Twins)?

1. That code spawns them in random positions intended for boss fights. If you want to be more specific about where you spawn them, use a different method that uses the x and y positions, and put these positions relative to the player.

2. Use a conditional to check whether the other boss is dead before spawning any loot, and do the same for the other boss.
 
I have a few questions.

  1. Is there a way to load a custom (mp3) sound for the firing of a weapon? if not, is there a place I can look at a list of all the sounds and their ids?
  2. What usestyle should I use to get a gun to be held under the arm, and if possible from about halfway?
  3. How would I get a custom projectile to rotate, depending on the angle it's fired from the gun?
  4. How do I control how long the burst of shooting is?
Thanks a bunch.
 
Last edited:
1. That code spawns them in random positions intended for boss fights. If you want to be more specific about where you spawn them, use a different method that uses the x and y positions, and put these positions relative to the player.

2. Use a conditional to check whether the other boss is dead before spawning any loot, and do the same for the other boss.
Can you give me an example for a second answer please?
 
Back
Top Bottom