Standalone [1.3] tModLoader - A Modding API

Ok, but how do I fix this, ' i ' is not available in this context
Code:
if (i == Main.myPlayer)
                {
                    player.paladinGive = true;
                }
                else if (player.miscCounter % 5 == 0)
                {
                    int myPlayer = Main.myPlayer;
                    if (Main.player[myPlayer].team == player.team && player.team != 0)
                    {
                        float num3 = player.position.X - Main.player[myPlayer].position.X;
                        float num4 = player.position.Y - Main.player[myPlayer].position.Y;
                        float num5 = (float)Math.Sqrt((double)(num3 * num3 + num4 * num4));
                        if (num5 < 800f)
                        {
                            Main.player[myPlayer].AddBuff(43, 10, true);
                        }
                    }
                }
[DOUBLEPOST=1438554618,1438554255][/DOUBLEPOST]I could also post the whole item code, if needed
Where are you getting "i" from?
 
Thats the problem, from nowhere, but I dont know how to get it actually, I just copied the paladins shield code to get the same function
Well then, that's the problem, you never actually defined a variable called i. My guess is that you should replace it with player.whoAmI. I'd also recommend trying to get more familiar with programming before trying to do that kind of stuff.
 
Well then, that's the problem, you never actually defined a variable called i. My guess is that you should replace it with player.whoAmI. I'd also recommend trying to get more familiar with programming before trying to do that kind of stuff.
Getting familiar with C# would be very helpful. Im familiar with the basics of java, but I have so much fun creating this things altough Im kinda noobie.
btw: I know that ' i ' has no definition in the item code, but I just wanted to know how to replace it.

Thanks again, ill try it tomorrow
 
I know I'm probably going to regret doing this right now when I wake up tomorrow to a bunch of alerts and possibly find out that there's a game-breaking bug I didn't catch. But here we go anyways:

v0.3
-Added build properties to specify display and dependency stuff
--Mod author and version are now build properties
--Added support for mod and dll dependencies
-Modified WorldFile.ValidateWorld so worlds containing modded stuff can load
-Added support for custom tiles (ModTile and GlobalTile)
--Added support for tile kill sounds, dust, drops, and kill-related hooks
--Added support for custom TileObjectData and multi-tile blocks
--Added ModifyLight, SetSpriteEffects, AnimateTile, PreDraw, and PostDraw hooks for tiles
--Added support for tile map colors and names, and related hooks
--Added RandomUpdate and TileFrame hooks for tiles
--Added mineResistance and minPick fields for ModTile
--Added CanPlace and AdjTiles hooks for tiles
--Added RightClick and HitWire hooks for tiles
-Added ConsumeItem hook for ModRecipe
-Added PreDrawInInventory and PostDrawInInventory hooks for items
-Fixed bug with removing custom armor from mannequins
-Improved error-handling for missing textures
-Safeproofed installation process
-Mod.Load is no longer abstract

Note: Mods built in previous versions will not work for this version. This means that mods must be rebuilt for this version. In addition, some things have changed that might require you to make minor changes in your mod's code. For example, some fields in ModProperties have been moved to build.txt.
Edit: Also note that the installation process has slightly changed.
 
Last edited:
I know I'm probably going to regret doing this right now when I wake up tomorrow to a bunch of alerts and possibly find out that there's a game-breaking bug I didn't catch. But here we go anyways:

v0.3
-Added build properties to specify display and dependency stuff
--Mod author and version are now build properties
--Added support for mod and dll dependencies
-Modified WorldFile.ValidateWorld so worlds containing modded stuff can load
-Added support for custom tiles (ModTile and GlobalTile)
--Added support for tile kill sounds, dust, drops, and kill-related hooks
--Added support for custom TileObjectData and multi-tile blocks
--Added ModifyLight, SetSpriteEffects, AnimateTile, PreDraw, and PostDraw hooks for tiles
--Added support for tile map colors and names, and related hooks
--Added RandomUpdate and TileFrame hooks for tiles
--Added mineResistance and minPick fields for ModTile
--Added CanPlace and AdjTiles hooks for tiles
--Added RightClick and HitWire hooks for tiles
-Added ConsumeItem hook for ModRecipe
-Added PreDrawInInventory and PostDrawInInventory hooks for items
-Fixed bug with removing custom armor from mannequins
-Improved error-handling for missing textures
-Safeproofed installation process

Note: Mods built in previous versions will not work for this version. This means that mods must be rebuilt for this version. In addition, some things have changed that might require you to make minor changes in your mod's code. For example, some fields in ModProperties have been moved to build.txt.
Edit: Also note that the installation process has slightly changed.
YAY! JUST YAY!
[DOUBLEPOST=1438594634,1438594229][/DOUBLEPOST]Also how to make animated tile? How to change sound of breaking tiles? And how to use vanilla dust using this code in tiles?
Code:
    public override bool CreateDust(int i, int j, ref int type)
    {
        ModDust.NewDust(new Vector2(i, j) * 16f, 16, 16, mod, "Sparkle");
        return false;
    }
 
Last edited:
Okay, I don't get how the ConsumeItem() function works?

I've been trying for ages to try and override the function but I'm always getting issues. :S
 
Good stuff, I'm holding out for projectiles and NPCs before I start my little project, so looking forward to the upcoming stuff.
 
@bluemagic123 wow, just wow. What you think about it?
While I'm glad they're considering it, he did unfortunately say that it would make a good final update.

YAY! JUST YAY!
[DOUBLEPOST=1438594634,1438594229][/DOUBLEPOST]Also how to make animated tile? How to change sound of breaking tiles? And how to use vanilla dust using this code in tiles?
Code:
    public override bool CreateDust(int i, int j, ref int type)
    {
        ModDust.NewDust(new Vector2(i, j) * 16f, 16, 16, mod, "Sparkle");
        return false;
    }
For vanilla dust you don't even need a hook; you can just set the dustType field using the SetDefaults method to the type of the dust you want.

Okay, I don't get how the ConsumeItem() function works?

I've been trying for ages to try and override the function but I'm always getting issues. :S
Basically, you use an if statement to check for the type, and return 0 if you don't want the item to be consumed. For other items to be consumed normally, you return numRequired after the if statement.
All this happens in a class that extends ModRecipe. Then instead of creating an instance of ModRecipe, you create an instance of your new class and add that.

You should add tModVersion to somewhere in the main screen so we know if we updated correctly tModLoader.
That's a good idea. I've been meaning to do that but I've always been procrastinating :p
 
Fresh Install doesn't work, and it gives me a blue windows error message saying that this version doesn't function on this pc
Huh, so it just says "this version"? I'm not entirely sure what's happening, but it seems that there might be a safer way of installing sometime soon, so I guess you could wait for that then try that.
 
While I'm glad they're considering it, he did unfortunately say that it would make a good final update.


For vanilla dust you don't even need a hook; you can just set the dustType field using the SetDefaults method to the type of the dust you want.


Basically, you use an if statement to check for the type, and return 0 if you don't want the item to be consumed. For other items to be consumed normally, you return numRequired after the if statement.
All this happens in a class that extends ModRecipe. Then instead of creating an instance of ModRecipe, you create an instance of your new class and add that.


That's a good idea. I've been meaning to do that but I've always been procrastinating :p
Well, what about other questions? How to make tile animations and how to change breaking sound?
 
Well, what about other questions? How to make tile animations and how to change breaking sound?
To change the breaking sound, you can set the soundType and soundStyle fields from the SetDefaults method. For animations, first you need to set the animationFrameHeight from the SetDefaults method, so the game can tell the difference between the different frames of animation. Then you need to use this hook:
public virtual void AnimateTile(ref int frame, ref int frameCounter)
to increment frameCounter, and when frameCounter reaches a certain number determined by you set it back to 0 then increment frame.
More information on tiles here: https://github.com/bluemagic123/tModLoader/wiki/ModTile
 
Back
Top Bottom