tModLoader Official tModLoader Help Thread

thanks guys, btw anyone got the code for a npc with the shop option? example mod only has the one for the help option
[doublepost=1499786015,1499785515][/doublepost]anyway
 
All of a sudden Visual Studio is saying that Terraria.Modloader is not being used in any of my projectiles, despite the using statement very clearly being there. It is grayed out and a lot of errors are being spit out. Also, Terraria is saying the same errors. I don't know why this is happening since 2 days ago these were working and I haven't touched that code. All I have done is added ModPlayer and GlobalProjectile files. If anyone could help me with this bit of information I have given, I would be very grateful.
 
I'm getting the following error:
Code:
...\Terraria\ModLoader\Mod Sources\imkSushisDeathCountersMod\imkSushisDeathCounterWorld.cs(34,94) : error CS0120: An object reference is required for the non-static field, method, or property 'Terraria.ModLoader.ModWorld.mod.get'
for this code:
Code:
    public static void announce()
    {
        foreach(Player players in AllPlayers)
        {
Main.NewText(players.name + " has died " + players.GetModPlayer<imkSushisDeathCounterPlayer>(mod).DeathPlayer.ToString() + " times", 0,0,0); //line 34
        }
        Main.NewText("So far, there have been " + DeathTotal.ToString() + " deaths in this world");
    }
why?
That method is static. mod is a member variable of ModWorld.
 
I get this error when trying to load any 2 mods together... No matter the mod. It doesn't do this the first time i tried to add a mod to my 12mod modlist then I added one, gave me this error, removed it, still got the error.




An unexpected error has occurred. at Terraria.ModLoader.ModLoader.do_Load(Object threadContext) at Terraria.ModLoader.Mod.Autoload() at Microsoft.Xna.Framework.Graphics.Texture2D..ctor(GraphicsDevice graphicsDevice, Stream stream, Int32 width, Int32 height, XnaImageOperation operation)
 
Getting this error when trying to build the mod because I've decided to update it after 6 months:

tJAZurK.png

With this code:
xVmBuXz.png


(I don't know how to do the Code Boxes, it's not in the Rich Text Editor tools at the top of this, I know that.)
 
Getting this error when trying to build the mod because I've decided to update it after 6 months:

tJAZurK.png

With this code:
xVmBuXz.png


(I don't know how to do the Code Boxes, it's not in the Rich Text Editor tools at the top of this, I know that.)
The code blocks are under the "Insert..." option which is at the top, the 4th button from the right.
 
Getting this error when trying to build the mod because I've decided to update it after 6 months:

tJAZurK.png

With this code:
xVmBuXz.png


(I don't know how to do the Code Boxes, it's not in the Rich Text Editor tools at the top of this, I know that.)
replace that Main.itemName.Length with Terraria.ModLoader.ItemLoader.ItemCount
 
Umm... I just can't get my mods to get along... And finally, once they did, I get this:


Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at Terraria.Player.Update(Int32 i)
at Terraria.WorldGen.do_playWorldCallBack(Object threadContext)
at Terraria.WorldGen.playWorldCallBack(Object threadContext)

Any tips/ideas? I am using a lot of mods at once though, mainly, once reloading calamity/tremor/echoes of the ancients seem to be crashing.
 
I am trying to make a gun that shoots, but has an alternative short-sword attack, everything is working fine, but when I try to use the alt attack, the sprite is rotated, is there a code I can use to make it rotate back?
 
i need help i play modded with my friend and he cant join he has all the same mods but then when he joins it says something like the mod is not working but he can play single player PLZ help
 
This is an error I keep getting with my ModPlayer and ModProjectile files. I'm trying to make an accessory that will make all bullets light npcs on fire.
error CS1061: 'Terraria.ModLoader.ModPlayer' does not contain a definition for 'fireInfusion' and no extension method 'fireInfusion' accepting a first argument of type 'Terraria.ModLoader.ModPlayer' could be found (are you missing a using directive or an assembly reference?)
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ExtraGunGear
{
    public class MPlayer : ModPlayer
    {
        public static bool fireInfusion; //Name of buff

        public override void Initialize()
        {
            fireInfusion = false;
        }

        public override void PostUpdate()
        {
            /*Check for accessory, probably don't need this if you have it in your acessory*/

            //Initialize bool for checking if accessory exists
            bool hasFireInfusionStone = false;

            //Loops through accessories to check for accessory
            for (int i = 0; i < 8 + player.extraAccessorySlots; i++)
            {
                //If it exists then set hasFireInfusion stone to true and then break
                if (player.armor[i].type == mod.ItemType("MeteorMuzzle"))
                {
                    hasFireInfusionStone = true;
                    break;
                }
            }

            //If player has it, set fireInfusion to true otherwise, set it to false
            if (hasFireInfusionStone)
            {
                fireInfusion = true;
            }
            else
            {
                fireInfusion = false;
            }
        }
    }
}
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

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

namespace ExtraGunGear
{
    public class ModProjectile : GlobalProjectile
    {
        //Hook post damaging NPC
        public override void OnHitNPC(Projectile projectile, NPC target, int damage, float knockback, bool crit)
        {
            //Get the player by using the ID given by projectile.owner
            Player player = Main.player[projectile.owner];

            //If player has the ModPlayer property of fireInfusion then add buff to NPC
            if (player.GetModPlayer<ModPlayer>(mod).fireInfusion)
            {
                //Add "On Fire!" debuff for 5 ticks on NPC
                target.AddBuff(BuffID.OnFire, (60 * 3), false);
            }
        }
    }
}
Edit: The comments are there because this is mostly from someone else who was trying to help me out.
 
This is an error I keep getting with my ModPlayer and ModProjectile files. I'm trying to make an accessory that will make all bullets light npcs on fire.
error CS1061: 'Terraria.ModLoader.ModPlayer' does not contain a definition for 'fireInfusion' and no extension method 'fireInfusion' accepting a first argument of type 'Terraria.ModLoader.ModPlayer' could be found (are you missing a using directive or an assembly reference?)
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ExtraGunGear
{
    public class MPlayer : ModPlayer
    {
        public static bool fireInfusion; //Name of buff

        public override void Initialize()
        {
            fireInfusion = false;
        }

        public override void PostUpdate()
        {
            /*Check for accessory, probably don't need this if you have it in your acessory*/

            //Initialize bool for checking if accessory exists
            bool hasFireInfusionStone = false;

            //Loops through accessories to check for accessory
            for (int i = 0; i < 8 + player.extraAccessorySlots; i++)
            {
                //If it exists then set hasFireInfusion stone to true and then break
                if (player.armor[i].type == mod.ItemType("MeteorMuzzle"))
                {
                    hasFireInfusionStone = true;
                    break;
                }
            }

            //If player has it, set fireInfusion to true otherwise, set it to false
            if (hasFireInfusionStone)
            {
                fireInfusion = true;
            }
            else
            {
                fireInfusion = false;
            }
        }
    }
}
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

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

namespace ExtraGunGear
{
    public class ModProjectile : GlobalProjectile
    {
        //Hook post damaging NPC
        public override void OnHitNPC(Projectile projectile, NPC target, int damage, float knockback, bool crit)
        {
            //Get the player by using the ID given by projectile.owner
            Player player = Main.player[projectile.owner];

            //If player has the ModPlayer property of fireInfusion then add buff to NPC
            if (player.GetModPlayer<ModPlayer>(mod).fireInfusion)
            {
                //Add "On Fire!" debuff for 5 ticks on NPC
                target.AddBuff(BuffID.OnFire, (60 * 3), false);
            }
        }
    }
}
Edit: The comments are there because this is mostly from someone else who was trying to help me out.
You are referencing a class called ModPlayer:
player.GetModPlayer<ModPlayer>(mod)
but your class is actually called MPlayer
 
You are referencing a class called ModPlayer:
player.GetModPlayer<ModPlayer>(mod)
but your class is actually called MPlayer
I was messing around for a while and this is the new code and it compiles, but it crashes Terraria after a minute or two, but if I shoot any projectile, it instantly crashes :\
Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ExtraGunGear;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ExtraGunGear
{
    public class ModProjectile : GlobalProjectile
    {
        //Hook post damaging NPC
        public override void OnHitNPC(Projectile projectile, NPC target, int damage, float knockback, bool crit)
        {
            //Get the player by using the ID given by projectile.owner
            Player player = Main.player[projectile.owner];

            //If player has the ModPlayer property of fireMuzzle then add buff to NPC
            if (player.GetModPlayer<MPlayer>(mod).fireMuzzle == true)
            {
                //Add "On Fire!" debuff for 5 ticks on NPC
                target.AddBuff(BuffID.OnFire, (60 * 3), false);
            }
        }
    }
}
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ExtraGunGear
{
    public class MPlayer : ModPlayer
    {
        public bool fireMuzzle; //Name of buff
       
        public override void ResetEffects()
        {
            fireMuzzle = false;
        }
    }
}
 
I have a question... I am currently trying to use a fair amount of mods at the same time, the only problem I am having is this:

Object reference not set to an instance of an object.
at EnemyMods.NPCs.gNPC.SetDefaults(NPC npc) in C:\Users\Kenneth\Documents\My Games\Terraria/ModLoader\Mod Sources\EnemyMods\NPCs\gNPC.cs:line 70
at Terraria.ModLoader.NPCLoader.SetDefaults(NPC npc, Boolean createModNPC)
at Terraria.ModLoader.Mod.SetupContent()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)

This is the message that shows up when I try to enable thorium. I have tried resetting terraria and that wont fix it.
If I'm posting this in the wrong place or there is a different place for me to ask please let me know.
 
I have a question... I am currently trying to use a fair amount of mods at the same time, the only problem I am having is this:

Object reference not set to an instance of an object.
at EnemyMods.NPCs.gNPC.SetDefaults(NPC npc) in C:\Users\Kenneth\Documents\My Games\Terraria/ModLoader\Mod Sources\EnemyMods\NPCs\gNPC.cs:line 70
at Terraria.ModLoader.NPCLoader.SetDefaults(NPC npc, Boolean createModNPC)
at Terraria.ModLoader.Mod.SetupContent()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)

This is the message that shows up when I try to enable thorium. I have tried resetting terraria and that wont fix it.
If I'm posting this in the wrong place or there is a different place for me to ask please let me know.
This is PfE (Prefixes for Enemies), the internal name is EnemysMods, gNPC is part of it.
I'm sure PfE got updated just recently, have you updated to the latest version?
 
I beleive I have successfully built mono.csproj, and windows.csproj, (only 8 warnings???) and using the https://forums.terraria.org/index.p...der-a-modding-api.23726/page-526#post-1001200 guide, I have ended up not able to find some Dll files, as you can see in the pictures below. Thanks!!! ( sorry if this post is strangely big, I'm still trying to figure out the forums!!!)
index.php
index.php
index.php
I beleive I have successfully built mono.csproj, and windows.csproj, (only 8 warnings???) and using the https://forums.terraria.org/index.p...der-a-modding-api.23726/page-526#post-1001200 guide, I have ended up not able to find some Dll files, as you can see in the pictures below. Thanks!!! ( sorry if this post is strangely big, I'm still trying to figure out the forums!!!)
index.php
index.php
index.php
 
Two questions:

1) Is it possible to include a modded crafting station as part of the adjTiles array?

2) Vanilla alchemy recipes appear to behave strangely with a modded crafting table with a built in alchemy table. In short, they do not honour the fact that the crafting station is, in fact, an alchemy table. If I *also* include a placed bottle as a part of the crafting station, it works, but I do not appear to get the benefits of the alchemy table itself. Modded recipes DO appear to honour the alchemy table. Potential issue due to vanilla recipes actually requiring a placed bottle?

Interestingly enough, this also seems to be happening with vanilla recipes requiring a base crafting station (eg. Furnace for Bottles) and not honouring upgraded versions of said station (eg. Hellforge).
 
Back
Top Bottom