Standalone [1.3] tModLoader - A Modding API

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.
Yes
 
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.

I thought so, would keep things in line with other standard languages. I tend to avoid that however as it clutters things up pretty quickly.

As for the problem, the error message you have now is stating that you're missing the image file in the specified directory. Basically, the way the mod loader looks for image files from what I have seen (Somebody can correct me if I'm wrong) is that it looks at the definition of the class instance (Namespace and Class Name), and builds a directory tree from this. Therefore if I define an object for instance as:

Code:
namespace MyMod.Items.RandoStuff {

    public class MyFirstItem : ModItem {

    }

}

The mod loader will then look for a sprite image (.PNG / .JPG / ETC) in /MyMod/Items/RandoStuff/MyFirstItem.EXT where .EXT is one of the aforementioned extensions. Please validate that your image file is located in the correct directory and then try to build it again.
 
Just a few questions:
1. how do I set a timer in my code that does not affect game's performance?
2. My intention is when the player takes out the weapon (gun with magazine), I want the weapon to not reset (like if I used 20 rounds from a 30 round magazine, and put back in and take out afterwards, the weapon should remain with 10 rounds left) whenever I equip it. Should I label the magazines upon game startup in my code?
3. I want my mouse to switch into the reticle image I created, how should I do this?
 
Uhh hi...I am new to the forums. I have played Terraria both vanilla and the Tmodloader for two years by now. I am not socially open in the internet and I am nervous to join the forums. However I would like to hear some advise from people around the globe about modding Terraria

I know Tmodloader that is compatible for Terraria 1.3.4 is not released yet, but some how you guys manage to get the older version working on a older version of terraria. I do have backed up versions of vanilla Terraria since 1.3. I am wondering if anyone of you could kindly tell me how to get Tmodloader working on my older version of terraria so I can start modding again. I need to mention that I am not an expert computer user so please make it understandable by a casual user.

Also some advise on using the forums might be helpful too. I am still kind of shy about this...
 
Just a few questions:
1. how do I set a timer in my code that does not affect game's performance?
2. My intention is when the player takes out the weapon (gun with magazine), I want the weapon to not reset (like if I used 20 rounds from a 30 round magazine, and put back in and take out afterwards, the weapon should remain with 10 rounds left) whenever I equip it. Should I label the magazines upon game startup in my code?
3. I want my mouse to switch into the reticle image I created, how should I do this?
I'm not so certain on the cursor change part, but for your first two things...

How do I set a timer in my code that does not affect game's performance? How can I use it for a weapon.
It really depends what your counter is doing and where it affects. For your magazine example, you would want to use the Global Player file. The global player file should sort of look like this. In here, you would want to create a new global variable (variable not inside the hook, set to public) for each magazine. I guess there would be a usable ammo counter and a max ammo capacity for each magazine, so probably 2 variables.

Now I'm guessing you would want a certain reload time, so we would need to set up a third variable for reload time. We would also need to check whether the player is reloading, so I suppose we need a boolean variable to check the player.

Now the thing about this is that, we won't be using the player update much, since we'll be handling it all in the item instead.

So far it should probably look like this....

Code:
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModName
{
    public class MPlayer : ModPlayer
    {
       
//Global variables that can be used outside this class file
        //All this variables are arbitrary, meaning you can set them later on, maybe on the item
        public static int maxAmmoCount = 30;
        public static int usableAmmoCount = maxAmmoCount;
        public static bool isReloading = false;
        public static bool reloadTime = 0;
        public static bool reloadTimer = reloadTime; 
       
        public override void PreUpdate()
        {
            if(usableAmmoCount < 1)
            {
                isReloading = true;
            }
            if(isReloading)
            {
                reloadTimer--; // Decrement reloadTimer
               
                //If reloadTimer reaches zero
                if(reloadTimer < 1)
                {
                    reloadTimer = reloadTime; //resets the reload time
                    isReloading = false; //resets the player to not reloading
                    usableAmmoCount = maxAmmoCount; //resets ammo count
                }
            }
        }
    }
}

Code:
using System;
using Microsoft.Xna.Framework;

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModName.Items.Usables
{
    public class AModItem : ModItem
    {
        public override void SetDefaults()
        {
            //Fill in the rest here
            MPlayer.maxAmmoCount = 30; //Calls the variable from MPlayer file and changes the thing, there is an actual way but we'll stick with this for now
            MPlayer.reloadTime = 60; //Remember, an update/tick in terraria is 1/60 of a second, so 60 ticks is 1 second
        }
        public override bool CanUseItem(Player player)
        {
            //If player is reloading don't use item
            if(MPlayer.isReloading)
            {
                return false;
            }
            //If the player has no usable ammo, don't use item
            if(MPlayer.usableAmmoCount < 1)
            {
                return false;
            }
            return true;
        }
        public override bool UseItem(Player player)
        {
            MPlayer.usableAmmoCount--;
            return true;
        }
       
    }
}

So now we got it to automatically reload when the player runs out of ammo and should maintain the ammo count for this singular item. The problem with that is that it will only work with one item. So what you will do is edit this to make each of the integer variables to be arrays. So make an integer array for each value and make the array size the amount of weapons there are and put the values you want in the array. You can do it something like this.

Code:
Uninitialized Array
public static int[] maxAmmoCount = new int[10]; //Initiallizes an array of size 10

Initialized Array
public static int[] maxAmmoCount = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; //Initializes an array with these values

You can always pull values from the array depending on the weapon, so use an integer index to store with your item for the array, for example a machine gun uses the first array slot, so we would have to check:

maxAmmoCount[0] //Indexes ALWAYS start with 0, not 1
 
Uhh hi...I am new to the forums. I have played Terraria both vanilla and the Tmodloader for two years by now. I am not socially open in the internet and I am nervous to join the forums. However I would like to hear some advise from people around the globe about modding Terraria

I know Tmodloader that is compatible for Terraria 1.3.4 is not released yet, but some how you guys manage to get the older version working on a older version of terraria. I do have backed up versions of vanilla Terraria since 1.3. I am wondering if anyone of you could kindly tell me how to get Tmodloader working on my older version of terraria so I can start modding again. I need to mention that I am not an expert computer user so please make it understandable by a casual user.

Also some advise on using the forums might be helpful too. I am still kind of shy about this...
You can install the latest tmodloader on your current version of terraria, no backup needed. It's just an exe file, so all the version specific stuff is included in the exe.
 
You can install the latest tmodloader on your current version of terraria, no backup needed. It's just an exe file, so all the version specific stuff is included in the exe.

But my Terraria is version 1.3.4.3. Does it still works?
 
Tmodloader will bring it down to 1.3.3.

I always get the "Start the client trough steam error" when trying to install the latest tmodloader. I tried a fresh install trough steam and launched steam with administrator rights.
 
Tmodloader will bring it down to 1.3.3.

Is it going to keep the current terraria version in the next tmodloader update? If not then when?
 
Whenever I try to boot up tmodloader I get some weird message that says "System.DIINotFoundException..." and a whole bunch of other stuff. Is there any way to fix this? Thanks
 
Could you update it to 1.3.4.3?
 
Disrespectful posts will not be tolerated
Could you update it to 1.3.4.3?
I am tired of people like you. He is working on it, likely very hard. 1.3.4 changed a lot of how sentry summons work, he probably needs to recode the whole thing. He is also probably adding new methods and fields so that we can do more with creating mods. Seriously, piss off. Be patient, and stop whining.
 
Disrespectful posts will not be tolerated
I am tired of people like you. He is working on it, likely very hard. 1.3.4 changed a lot of how sentry summons work, he probably needs to recode the whole thing. He is also probably adding new methods and fields so that we can do more with creating mods. Seriously, piss off. Be patient, and stop whining.
Stop being so toxic, jeez. Yes, of COURSE jopojelly and Bluemagic are working hard on it. The people that keep asking the same question probably go to the last page, and see if it's on it, then ask. And when there are 700+ pages of COMMENTS, can't blame them for not wanting to read. So, telling someone to piss off for asking an honest question, is just wrong. I want to know when it will be finished too. I won't begrudge jopo if it takes another week or two, I just want an ETA. Which he gave, about 6 days ago, saying a week. But 6 days ago we were only on like page 694. So don't expect people to go back and read EVERY SINGLE COMMENT to find an answer to a simple question. A good response would have been: "Jopojelly is currently working hard on it, and it should be finished sometime this week. Just check back every day to see if it's arrived ^_^". Seriously, people like you make me sick with your toxicity.

Just thought I'd mention as an aside, sorry that I am giving the credit solely to Jopo for the tModLoader. I just don't know who, if anybody, else is working with him on this. So keep up the good work tModLoader team @jopojelly @bluemagic123 ! I am extremely excited for the new update ^_^
 
Last edited:
I am tired of people like you.
Seriously, piss off. Be patient, and stop whining.

Stop being so toxic, jeez.
Seriously, people like you make me sick with your toxicity.
@solunareclipse1 and @Derpius The Reaper, none of this language is appropriate for the forums. Either post respectfully or don't post at all.

Also, @diekonradish , don't like an obviously toxic comment, as it helps nobody and just makes you look as bad.
@Derpius The Reaper, it's not up to you to tell other members what posts they can and can't "like".
 
As an attempt to head off any further inquiries into the update, I will note that tModLoader is open source, with development visible on GitHub.
 
Is it going to keep the current terraria version in the next tmodloader update? If not then when?
Yes. All tModLoader changes is the .exe and when the new one will be released, it will simply replace the old outdated one.

EDIT: unless I misunderstood the question?
 
As an attempt to head off any further inquiries into the update, I will note that tModLoader is open source, with development visible on GitHub.
Unfortunately, I think that people will ask regardless.
Still, I might just take a look-see at what's on the GitHub, even though it doesn't make a bit of sense to me.
 
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.
 
Back
Top Bottom