Standalone [1.3] tModLoader - A Modding API

Just a note: tModLoader v0.9.0.0 has been available for modders over on the discord channel since a day or so ago. It's not officially released yet because I wanted modders to have a chance to do some porting and testing.

If you aren't a modder, don't even think about installing it, you will be severely disappointed since there are 0 mods.


If you are on mac or linux please come and help test the new release. I haven't found a single Mac or Linux user to test the new executable to see if it works.

That's a pretty big update on the status. Thanks Jopo, you never disappoint.
 
Just a note: tModLoader v0.9.0.0 has been available for modders over on the discord channel since a day or so ago. It's not officially released yet because I wanted modders to have a chance to do some porting and testing.

If you aren't a modder, don't even think about installing it, you will be severely disappointed since there are 0 mods.


If you are on mac or linux please come and help test the new release. I haven't found a single Mac or Linux user to test the new executable to see if it works.
Great to hear! Eager to finally try out all that 1.3.4 content. :p
 
Is it possible to make the summon minion cap per weapon?

I was thinking maybe an accessory item you could wear that subtracts from your max, but lets you summon each minion you want up to the cap.

Like say you have 8 minion cap -- the new accessory drops it to 6, but you can have 6 ufos, 6 tiki, 6 cell, etc...

With this API is that a big change, little change, or impossible?
 
Is your item sprite and cs file in the Weapons subfolder of your Items directory?
[doublepost=1480915002,1480914885][/doublepost]
You can have more than one class instance in one file, that's how to compact your code; You just can't have different namespaces in the same file afaik. For example, you could have all your non weapon, material items in one big class named "Materials.cs". The sprites of each item would just be the name of each class inside.
nope we have the same mods
 
Just a note: tModLoader v0.9.0.0 has been available for modders over on the discord channel since a day or so ago. It's not officially released yet because I wanted modders to have a chance to do some porting and testing.

If you aren't a modder, don't even think about installing it, you will be severely disappointed since there are 0 mods.


If you are on mac or linux please come and help test the new release. I haven't found a single Mac or Linux user to test the new executable to see if it works.

Have you asked on reddit for Mac and Linux users. I believe I've seen several users there who might be willing to help.
 
So, I've looked around for a while but couldn't find anything to do this; I need something that basically does:
Code:
If(Somewaytotellifplayerdoesdamagetosomething == true)
player.GetModPlayer<SpecialsPlayer>(mod).SagCD = true;
---
Code:
namespace Specials.Items
{
    class SagiCharm : ModItem
    {

        public override void SetDefaults()
        {
            item.name = "Charm of Sagittarius";
            item.width = 40;
            item.height = 40;
            item.toolTip = "Grants 45% bonus damage every 5 seconds when using a ranged weapon.";
            item.toolTip2 = "Bonus damage is used after 1 attack";
            item.value = 10000;
            item.rare = 3;
            item.accessory = true;
            item.waistSlot = 5;
        }

        int timer1 = 300;
        public override void UpdateAccessory(Player player, bool hideVisual = false)
        {
            base.UpdateAccessory(player, hideVisual);

            if (timer1 <= 0)
            {
                player.rangedDamage = 1.45f;
                player.GetModPlayer<SpecialsPlayer>(mod).SagDamage = true;
            }
            if (player.GetModPlayer<SpecialsPlayer>(mod).SagCD == true && player.GetModPlayer<SpecialsPlayer>(mod).SagDamage == true)
                {
                    timer1 = 300;
                    player.rangedDamage = 1 / 1.45f;
                }

            timer1--;
        }
    }
}
 
Last edited:
So, I've looked around for a while but couldn't find anything to do this; I need something that basically does:
Code:
If(Somewaytotellifplayerdoesdamagetosomething == true)
player.GetModPlayer<SpecialsPlayer>(mod).SagCD = true;
---
Code:
namespace Specials.Items
{
    class SagiCharm : ModItem
    {

        public override void SetDefaults()
        {
            item.name = "Charm of Sagittarius";
            item.width = 40;
            item.height = 40;
            item.toolTip = "Grants 45% bonus damage every 5 seconds when using a ranged weapon.";
            item.toolTip2 = "Bonus damage is used after 1 attack";
            item.value = 10000;
            item.rare = 3;
            item.accessory = true;
            item.waistSlot = 5;
        }

        int timer1 = 300;
        public override void UpdateAccessory(Player player, bool hideVisual = false)
        {
            base.UpdateAccessory(player, hideVisual);

            if (timer1 <= 0)
            {
                player.rangedDamage = 1.45f;
                player.GetModPlayer<SpecialsPlayer>(mod).SagDamage = true;
            }
            if (player.GetModPlayer<SpecialsPlayer>(mod).SagCD == true && player.GetModPlayer<SpecialsPlayer>(mod).SagDamage == true)
                {
                    timer1 = 300;
                    player.rangedDamage = 1 / 1.45f;
                }

            timer1--;
        }
    }
}
For that specific thing, you would not use an if statement, but instead, use would want to use this code in an entirely different hook. You would use this hook in the Global Player file instead of the item, since you are dealing with only ranged.

Code:
public override void OnHitNPCWithProj(Projectile proj, NPC target, int damage, float knockback, bool crit)

With that in mind, you can also do the timer within Pre or Post Update in the Player file. I prefer to use a private integer to cover for as a timer. For readability's sake, I would recommend using two variables, one holding the constant value and one to act as the actual timer, but of course you can keep it as optimal as possible by using the least amount of code possible.

To make your code much better, it'd be better just to move the timer to player update. Here's how I would make your accessory.

In your SagiCharm.cs
Code:
namespace Specials.Items
{
    class SagiCharm : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Charm of Sagittarius";
            item.width = 40;
            item.height = 40;
            item.toolTip = "Grants 45% bonus damage every 5 seconds when using a ranged weapon.";
            item.toolTip2 = "Bonus damage is used after 1 attack";
            item.value = 10000;
            item.rare = 3;
            item.accessory = true;
            item.waistSlot = 5;
        }
        public override void UpdateAccessory(Player player, bool hideVisual = false)
        {
            base.UpdateAccessory(player, hideVisual);

            if (!player.GetModPlayer<SpecialsPlayer>(mod).SagCD)
            {
                player.rangedDamage += 0.45f;
                player.GetModPlayer<SpecialsPlayer>(mod).SagDamage = true;
            }
        }
    }

In your SpecialPlayers.cs
Code:
        private int cdTimer = 300;
        public override void OnHitNPCWithProj(Projectile proj, NPC target, int damage, float knockback, bool crit)
        {
            if(!SagCD)
            {
                SagCD = true;
                SagDamage = false;
            }
        }
        public override void PreUpdate()
        {
            //These are local calls to the player file so you won't necessarily need the direct mod player calls.
            if(SagCD)
            {
                cdTimer--;
                if(cdTimer < 1)
                {
                    SagCD = false;
                }
            }
        }
 
Ummm guys, I have a question, it may be embarrassing but, is legit programming like, like scratch???
 
Ummm guys, I have a question, it may be embarrassing but, is legit programming like, like scratch???
What do you mean by "scratch", like the phrase "by scratch" or like chicken scratch?
 
Ummm guys, I have a question, it may be embarrassing but, is legit programming like, like scratch???
I have done scratch and it is a good way to get some basic experience for coding but u can't make a mod with it.
 
I have done scratch and it is a good way to get some basic experience for coding but u can't make a mod with it.

Well I didn't even know what Scratch was till today.

Ummm guys, I have a question, it may be embarrassing but, is legit programming like, like scratch???

Programming is, unfortunately, not like Scratch. This is mostly because instead of using coding blocks (the GUI interface for actions in Scratch), we have to actually type things and hope it works (ok, we don't actually type things at random, but sometimes it feels like it). There is of course the method I like to call, the "Copy, Paste, Edit" programming, where you copy and paste code and then edit it to your suiting. The advantage of this is that you don't need to type too much and makes programming much faster, but the disadvantage is the fact that sometimes you don't know why it works and or readability from your code sucks... a lot. So I mostly recommend reading code and go over what each part does, if you know what each part does, you can then proceed to do the "Copy, Paste, Edit" strategy, because learning is great!
 
Ummm guys, I have a question, it may be embarrassing but, is legit programming like, like scratch???
@Zekrom 2, it's best to keep these type of general questions elsewhere - either on your own profile or doing a google search. This is a thread about tModLoader, let's keep the posts on-topic and about tModLoader.
 
@Zekrom 2, it's best to keep these type of general questions elsewhere - either on your own profile or doing a google search. This is a thread about tModLoader, let's keep the posts on-topic and about tModLoader.
Yes daddy Moderator, not being disrespectful, just being dumb :P
[doublepost=1481036268,1481036158][/doublepost]
Well I didn't even know what Scratch was till today.



Programming is, unfortunately, not like Scratch. This is mostly because instead of using coding blocks (the GUI interface for actions in Scratch), we have to actually type things and hope it works (ok, we don't actually type things at random, but sometimes it feels like it). There is of course the method I like to call, the "Copy, Paste, Edit" programming, where you copy and paste code and then edit it to your suiting. The advantage of this is that you don't need to type too much and makes programming much faster, but the disadvantage is the fact that sometimes you don't know why it works and or readability from your code sucks... a lot. So I mostly recommend reading code and go over what each part does, if you know what each part does, you can then proceed to do the "Copy, Paste, Edit" strategy, because learning is great!
Welll, yeh, I can see that. But on an above post I saw
So, I've looked around for a while but couldn't find anything to do this; I need something that basically does:
Code:
If(Somewaytotellifplayerdoesdamagetosomething == true)
player.GetModPlayer<SpecialsPlayer>(mod).SagCD = true;
---
Code:
namespace Specials.Items
{
    class SagiCharm : ModItem
    {

        public override void SetDefaults()
        {
            item.name = "Charm of Sagittarius";
            item.width = 40;
            item.height = 40;
            item.toolTip = "Grants 45% bonus damage every 5 seconds when using a ranged weapon.";
            item.toolTip2 = "Bonus damage is used after 1 attack";
            item.value = 10000;
            item.rare = 3;
            item.accessory = true;
            item.waistSlot = 5;
        }

        int timer1 = 300;
        public override void UpdateAccessory(Player player, bool hideVisual = false)
        {
            base.UpdateAccessory(player, hideVisual);

            if (timer1 <= 0)
            {
                player.rangedDamage = 1.45f;
                player.GetModPlayer<SpecialsPlayer>(mod).SagDamage = true;
            }
            if (player.GetModPlayer<SpecialsPlayer>(mod).SagCD == true && player.GetModPlayer<SpecialsPlayer>(mod).SagDamage == true)
                {
                    timer1 = 300;
                    player.rangedDamage = 1 / 1.45f;
                }

            timer1--;
        }
    }
}
i saw that 'if' thing, like in scratch. But whatever, lets just drop it
 
I'm getting this error when trying to update Crystillium, Moar, and Thorium:
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.MulticastDelegate.CombineImpl(Delegate follow)
at System.Delegate.Combine(Delegate a, Delegate b)
at CheatSheet.UI.UIView.add_onMouseDown(ClickEventHandler value) in d:\Documents\My Games\Terraria\ModLoader\Mod Sources\CheatSheet
 
I'm getting this error when trying to update Crystillium, Moar, and Thorium:
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.MulticastDelegate.CombineImpl(Delegate follow)
at System.Delegate.Combine(Delegate a, Delegate b)
at CheatSheet.UI.UIView.add_onMouseDown(ClickEventHandler value) in d:\Documents\My Games\Terraria\ModLoader\Mod Sources\CheatSheet
Well, it seems that the Cheat Sheet is crashing it. The most likely cause is probably that there are too many assets for it to read. But this is just a guess, but it most definitely is Cheat Sheets acting up.
 
Hey guys,

I'm trying to download some new mods, but the browser seems to be down or something, is there a known issues/outages status page or anything? or does anyone know whats happening.

The error I keep getting is "Unknown Mod Error. Cancelling download"
 
Well, it seems that the Cheat Sheet is crashing it. The most likely cause is probably that there are too many assets for it to read. But this is just a guess, but it most definitely is Cheat Sheets acting up.
well, that was in the logs. the specific error was unknown mod error. try again later.
[doublepost=1481057093,1481057076][/doublepost]
well, that was in the logs. the specific error was unknown mod error. try again later.
and, it's just when I attempt to update.
 
Hi i have been gone for "a while" so i don't know what happened to Tmodreader? Or am i just stupid and can't find it?
Btw if it has been a really long time since it dissapeared, it was the tool that extracted codes/files from other mods so you could use it as a learning tool.
 
Hi i have been gone for "a while" so i don't know what happened to Tmodreader? Or am i just stupid and can't find it?
Btw if it has been a really long time since it dissapeared, it was the tool that extracted codes/files from other mods so you could use it as a learning tool.
It's on the front page dude. :p
 
Back
Top Bottom