Standalone [1.3] tModLoader - A Modding API

Ok so me and a friend are trying to play together but we are having issues it wont let us if any one has any clue how we could thanks
 
Ok so me and a friend are trying to play together but we are having issues it wont let us if any one has any clue how we could thanks
Could you post the error if there is one? Can you tell us if your using Mac? What exactly is happening thats preventing you guys from playing?
 
I came before, no one resolved my problem
Is your item sprite and cs file in the Weapons subfolder of your Items directory?
[doublepost=1480915002,1480914885][/doublepost]
Wait, you're not putting this all in one file are you?

You need to split out class instances through different files.
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.
 
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.
 
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
 
Back
Top Bottom