Standalone [1.3] tModLoader - A Modding API

So you mean like how a Wooden Arrow spawns itself when it hits a block? In that case you would call (in the projectile coding)
Code:
public override void Kill(int timeLeft)
then do an item spawn. I think you use Item.NewItem (just guessing :)), but I'm pretty inexperienced myself. :/
No, I need to make a orb that randomly spawn items.
 
I need alot of help with clarifying your new mods..
what is
Code:
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "ExampleItem", 10); // what is null ( I know its nothing but why null)
            recipe.AddTile(null, "ExampleWorkbench"); //(why is null here agin)
            recipe.SetResult(this); //god damnit. can you explain everything, we cant read your mind.
            recipe.AddRecipe();
 
An orb that randomly spawns items, eh? Well, there are timers that you can set up, such as npc.ai[1] and they spawn an item every few seconds. You may want to ask @bluemagic123 for this, because I am pretty bad at this. I think if you do something like this it should work, if it's incorrect don't blame me please :)
Code:
public override void AI()
    {
        if(Main.rand.Next(10) == 0)
        Item.NewItem(mod.ItemType(YourItem),(int)projectile.position.X, (int)projectile.position.Y)
    //bluemagic123, can you insert something else here for a timer?
    }
Sorry if the comment in it bothers you, I don't know how to set up a timer.
 
No, I need to make a orb that randomly spawn items.
You can just call Item.NewItem inside an if statement checking Main.rand.Next in your AI hook.

I need alot of help with clarifying your new mods..
what is
Code:
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "ExampleItem", 10); // what is null ( I know its nothing but why null)
            recipe.AddTile(null, "ExampleWorkbench"); //(why is null here agin)
            recipe.SetResult(this); //god damnit. can you explain everything, we cant read your mind.
            recipe.AddRecipe();
For pretty much all of those, explanations are right here: https://github.com/bluemagic123/tModLoader/wiki/ModRecipe
 
I need alot of help with clarifying your new mods..
what is
Code:
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(null, "ExampleItem", 10); // what is null ( I know its nothing but why null)
            recipe.AddTile(null, "ExampleWorkbench"); //(why is null here agin)
            recipe.SetResult(this); //god damnit. can you explain everything, we cant read your mind.
            recipe.AddRecipe();
null clarifies that the tile/item/etc. in question isn't from vanilla terraria (which uses vanilla ids). SetResult(this) means the crafting recipe makes this item (you can put a number after (this) to specify how much of the item will be made by the recipe (this, #)

Edit: Ninja'd
 
null clarifies that the tile/item/etc. in question isn't from vanilla terraria (which uses vanilla ids). SetResult(this) means the crafting recipe makes this item (you can put a number after (this) to specify how much of the item will be made by the recipe (this, #)

Edit: Ninja'd
thanks alot!
EDIT: what if I want my mod to be crafted with more than 1 material?
 
Well then. I've wrote more than 10 variants of codes and they all compiled successfully but with no effect at all
a simple example is:

Code:
  using System;
  using Terraria;
  using Terraria.ModLoader; 

  namespace mymod 
  { 
  public class mymod : Mod
  {
   
  public override void SetModInfo(out string name, ref ModProperties properties)
  {
  name = "mymod"
  }
   
  public void Update(Player player)
  {
  if (player.whoAmI == Main.myPlayer)
  {
  player.maxMinions = 99;
  }
  }
  }
  }

Yes I'm aware of that, compiled successfully don't mean it'll work. but really what is the problem
by the way i saw few examples about .cs file created to use with tML and most if not all the methods contain the "override" modifier. tried add it but it gave me the following error when compiling: "no suitable methods to override" so if possible could someone give me a full tML .cs example not a part of it?
 
Well then. I've wrote more than 10 variants of codes and they all compiled successfully but with no effect at all
a simple example is:

Code:
  using System;
  using Terraria;
  using Terraria.ModLoader;

  namespace mymod
  {
  public class mymod : Mod
  {
  
  public override void SetModInfo(out string name, ref ModProperties properties)
  {
  name = "mymod"
  }
  
  public void Update(Player player)
  {
  if (player.whoAmI == Main.myPlayer)
  {
  player.maxMinions = 99;
  }
  }
  }
  }

Yes I'm aware of that, compiled successfully don't mean it'll work. but really what is the problem
by the way i saw few examples about .cs file created to use with tML and most if not all the methods contain the "override" modifier. tried add it but it gave me the following error when compiling: "no suitable methods to override" so if possible could someone give me a full tML .cs example not a part of it?

Basically, for a beginner, never should any of your methods NOT be override. If they aren't override, Terraria isn't going to call them, it's dead code.

You need to look over Example Mod: https://github.com/bluemagic123/tModLoader/tree/master/ExampleMod
And you need to look over the wiki to see what methods are available to override: https://github.com/bluemagic123/tModLoader/wiki

Your code extends Mod. If you notice in the wiki, https://github.com/bluemagic123/tModLoader/wiki/Mod , there is no "update" method for Mod. It doesn't make sense, Mod is just a class that handles setting things up. I'd suggest starting with making an item. Make a new .cs file along with the one you have and extend the ModItem class: https://github.com/bluemagic123/tModLoader/wiki/ModItem . ModItem has an UpdateAccessory class that would be a good place to put your "player.maxMinions = 99" code. Look at ExampleShield as an example: https://github.com/bluemagic123/tMo...6d366b95ea3/ExampleMod/Items/ExampleShield.cs

Basically, you have to extend the right class to get your methods called. If it says no method to overwrite, you need to check the documentation and examples again.

I got a problem. Is there a function can load like magazine size and reticle UI before the game starts?
Are you just talking about loading a texture?..please explain.
 
Basically, for a beginner, never should any of your methods NOT be override. If they aren't override, Terraria isn't going to call them, it's dead code.

You need to look over Example Mod: https://github.com/bluemagic123/tModLoader/tree/master/ExampleMod
And you need to look over the wiki to see what methods are available to override: https://github.com/bluemagic123/tModLoader/wiki

Your code extends Mod. If you notice in the wiki, https://github.com/bluemagic123/tModLoader/wiki/Mod , there is no "update" method for Mod. It doesn't make sense, Mod is just a class that handles setting things up. I'd suggest starting with making an item. Make a new .cs file along with the one you have and extend the ModItem class: https://github.com/bluemagic123/tModLoader/wiki/ModItem . ModItem has an UpdateAccessory class that would be a good place to put your "player.maxMinions = 99" code. Look at ExampleShield as an example: https://github.com/bluemagic123/tMo...6d366b95ea3/ExampleMod/Items/ExampleShield.cs

Basically, you have to extend the right class to get your methods called. If it says no method to overwrite, you need to check the documentation and examples again.


Are you just talking about loading a texture?..please explain.
Loading texture (reticle with a offset position) and with numbers on it (the gun's magazine size) and then the reload timer (after the magazine is finished to be reloaded).
 
Basically, for a beginner, never should any of your methods NOT be override. If they aren't override, Terraria isn't going to call them, it's dead code.

You need to look over Example Mod: https://github.com/bluemagic123/tModLoader/tree/master/ExampleMod
And you need to look over the wiki to see what methods are available to override: https://github.com/bluemagic123/tModLoader/wiki

Your code extends Mod. If you notice in the wiki, https://github.com/bluemagic123/tModLoader/wiki/Mod , there is no "update" method for Mod. It doesn't make sense, Mod is just a class that handles setting things up. I'd suggest starting with making an item. Make a new .cs file along with the one you have and extend the ModItem class: https://github.com/bluemagic123/tModLoader/wiki/ModItem . ModItem has an UpdateAccessory class that would be a good place to put your "player.maxMinions = 99" code. Look at ExampleShield as an example: https://github.com/bluemagic123/tMo...6d366b95ea3/ExampleMod/Items/ExampleShield.cs

Basically, you have to extend the right class to get your methods called. If it says no method to overwrite, you need to check the documentation and examples again.


Are you just talking about loading a texture?..please explain.

It was alot easier than what I expected... Now I feel like an idiot :p
I made an accessory and put the following, worked perfectly
it's a *little* overpowered tho.. thanks again

Code:
public override void UpdateAccessory(Player player)
     {
         player.meleeDamage += 1.5f;
         player.thrownDamage += 1.5f;
         player.rangedDamage += 1.5f;
         player.magicDamage += 1.5f;
         player.minionDamage += 1.5f;
         player.meleeSpeed += 1.5f;
         player.magicCrit += 50;
         player.meleeCrit += 50;
         player.rangedCrit += 50;
         player.maxMinions = 99;
       player.statLife = player.statLifeMax;
       player.statMana = player.statManaMax;
       player.breath = player.breathMax;
       player.noFallDmg = true;
         player.accFlipper = true;
         player.blockRange = 100;
         player.canRocket = true;
         player.rocketBoots = 1;
         player.fireWalk = true;
         player.jumpBoost = true;
         player.lavaImmune = true;
         player.moveSpeed = 40f;
         player.noKnockback = true;
         player.rocketTimeMax = 300;
         player.waterWalk = true;


     }
 
Hey, can someone tell if this can be used to change the names and sprites of vanilla items?

Also, does this have custom crafting recipes yet?
 
Hey, can someone tell if this can be used to change the names and sprites of vanilla items?

Also, does this have custom crafting recipes yet?
Every example in the example mod has a custom crafting recipe, or are you trying to ask something else?

The Animated loom in the example mod shows swapping out vanilla textures.

Changing names is trivial with globalitem.setdefaults()
 
Every example in the example mod has a custom crafting recipe, or are you trying to ask something else?

The Animated loom in the example mod shows swapping out vanilla textures.

Changing names is trivial with globalitem.setdefaults()
Thank you, that is everything I need to know!

(I haven't installed it yet so I haven't tried the example mod)
 
What is wrong with this?
Code:
public override void AI()
    {
        if(Main.rand.Next(360) == 0)
        {
            Item.NewItem(ItemID.Heart, (int)projectile.position.X, (int)projectile.position.Y);
        }
    }

I have the error CS1501
 
What is wrong with this?
Code:
public override void AI()
    {
        if(Main.rand.Next(360) == 0)
        {
            Item.NewItem(ItemID.Heart, (int)projectile.position.X, (int)projectile.position.Y);
        }
    }

I have the error CS1501

The NewItem method looks like this:

Code:
public static int NewItem(int X, int Y, int Width, int Height, int Type, int Stack = 1, bool noBroadcast = false, int pfix = 0, bool noGrabDelay = false, bool reverseLookup = false);

First two parameters are position, second two are width and height (I don't actually know what the point of these is, but every example I've seen just uses the width and height of wherever the item is spawning from, so in this case it would be the projectile width and height I guess). The fifth one is the item id. So your function call would have to look like this, at the least:

Code:
Item.NewItem((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height, ItemID.Heart);

You might need to cast projectile.width and height to ints.
 
The NewItem method looks like this:

Code:
public static int NewItem(int X, int Y, int Width, int Height, int Type, int Stack = 1, bool noBroadcast = false, int pfix = 0, bool noGrabDelay = false, bool reverseLookup = false);

First two parameters are position, second two are width and height (I don't actually know what the point of these is, but every example I've seen just uses the width and height of wherever the item is spawning from, so in this case it would be the projectile width and height I guess). The fifth one is the item id. So your function call would have to look like this, at the least:

Code:
Item.NewItem((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height, ItemID.Heart);

You might need to cast projectile.width and height to ints.
I love you men, seriously, I love you :p
I tried with that in the past, but for some reason that didnt work :/
 
Back
Top Bottom