• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Begin your search for Journey's End information here and here. Please report bugs and issues for Journey's End here.
  • For issues you find with the Mobile 1.4 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

Standalone [1.3] tModLoader - A Modding API

The javid.ddns.net page isn’t working
I didn't mean the javid.ddns.net page (that's where the mod browser gets its links - of course that doesn't work either).
I meant the actual mod homepages here on the Terraria forums.

A question: Is it currently possible to create a mod which causes cross-mod interactions? For example, a mod which adds boss summons to the Fargo's Mod Mutant NPC shop, or a mod which changes other mod's boomerang-style weapons to contain the right-click damage type change introduced in Zoaklen's.
 

jopojelly

Retinazer
tModLoader
Still trying to build ExampleMod on OSX.

ExampleMod references Microsoft.Xna.Framework, so apparently I need a Windows.dll and a Mono.dll. However, I do not know how to make these files. Are they just reference files to go alongside the ExampleMod.dll, or something different?

I'll keep experimenting in the meantime.

Oh yeah, and one more thing: Windows.dll is supposed to reference a Windows Terraria.exe. Does this mean I cannot use the Terraria.exe that comes with the OSX version?
Your ide will build the windows.dll and the mono.dllfrom your cs files (you'll rename the dll built by the compiler). you'll use one solution configuration fire one, another for the other. Make sure your project is set to build dll.

I'm pretty sure the Mac download has TerrariaWindows.exe in its modcompile folder, which you will reference for the configuration that makes the windows.dll.

The project file might just be easier as two separate projects if you don't want to mess around with conditional references
 
Your ide will build the windows.dll and the mono.dllfrom your cs files (you'll rename the dll built by the compiler). you'll use one solution configuration fire one, another for the other. Make sure your project is set to build dll.

I'm pretty sure the Mac download has TerrariaWindows.exe in its modcompile folder, which you will reference for the configuration that makes the windows.dll.

The project file might just be easier as two separate projects if you don't want to mess around with conditional references
So what I need to do is set up two configurations:
One, called Windows, references XNA and tModLoaderWindows.exe (or vanilla Terraria.exe from windows version)
The other, called Mono, references FNA and tModLoaderMac.exe (or vanilla Terraria.exe from mac version)

Is this what I need to do?
 

jopojelly

Retinazer
tModLoader
So what I need to do is set up two configurations:
One, called Windows, references XNA and tModLoaderWindows.exe (or vanilla Terraria.exe from windows version)
The other, called Mono, references FNA and tModLoaderMac.exe (or vanilla Terraria.exe from mac version)

Is this what I need to do?
Yes.
 
OK, I did that. Now I'm getting this error when trying to compile the mod in-game:
Code:
Error running mcs: Cannot find the specified file
  at Mono.CSharp.CSharpCodeCompiler.CompileFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] in <filename unknown>:0
  at Mono.CSharp.CSharpCodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] in <filename unknown>:0
  at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] in <filename unknown>:0
  at Terraria.ModLoader.ModCompile.CompileMod (Terraria.ModLoader.BuildingMod mod, System.Collections.Generic.List`1 refMods, Boolean forWindows, System.Byte[]& dll, System.Byte[]& pdb) [0x00000] in <filename unknown>:0
  at Terraria.ModLoader.ModCompile.Build (Terraria.ModLoader.BuildingMod mod, IBuildStatus status) [0x00000] in <filename unknown>:0
  at Terraria.ModLoader.ModCompile.Build (System.String modFolder, IBuildStatus status) [0x00000] in <filename unknown>:0
  at Terraria.ModLoader.ModLoader+<>c.<BuildMod>b__41_0 (System.Object _) [0x00000] in <filename unknown>:0
Do you know what this means? (not a rhetorical question :p)
 

jopojelly

Retinazer
tModLoader
OK, I did that. Now I'm getting this error when trying to compile the mod in-game:
Code:
Error running mcs: Cannot find the specified file
  at Mono.CSharp.CSharpCodeCompiler.CompileFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] in <filename unknown>:0
  at Mono.CSharp.CSharpCodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] in <filename unknown>:0
  at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] in <filename unknown>:0
  at Terraria.ModLoader.ModCompile.CompileMod (Terraria.ModLoader.BuildingMod mod, System.Collections.Generic.List`1 refMods, Boolean forWindows, System.Byte[]& dll, System.Byte[]& pdb) [0x00000] in <filename unknown>:0
  at Terraria.ModLoader.ModCompile.Build (Terraria.ModLoader.BuildingMod mod, IBuildStatus status) [0x00000] in <filename unknown>:0
  at Terraria.ModLoader.ModCompile.Build (System.String modFolder, IBuildStatus status) [0x00000] in <filename unknown>:0
  at Terraria.ModLoader.ModLoader+<>c.<BuildMod>b__41_0 (System.Object _) [0x00000] in <filename unknown>:0
Do you know what this means? (not a rhetorical question :p)
Did you set the build.txt to have that nocompile flag?
 
Did you set the build.txt to have that nocompile flag?
Oh, darn! I could've sworn I had! Retrying :p

EDIT: Now it's complaining that I don't even have the files. Is there somewhere special they should be? Currently, they're located in bin/Release, though I've tried just bin/ and there's another copy of the files in bin/Debug as well.
EDIT2: Figured out the files need to be in the ExampleMod root directory. Unfortunately, it seems that the files are assembly name sensitive, so I have to rebuild them (I had changed the name in an attempt to sidestep renaming the .dll files).
 
Last edited:

jopojelly

Retinazer
tModLoader
Oh, darn! I could've sworn I had! Retrying :p

EDIT: Now it's complaining that I don't even have the files. Is there somewhere special they should be? Currently, they're located in bin/Release, though I've tried just bin/ and there's another copy of the files in bin/Debug as well.
Root of the mods folder it looks like (I mean the folder in mod Sources)
 
Success! ExampleMod built successfully! I'm still going to test it in-game, but this is great!

I'll post a guide for other OSX/Linux users out there soon :) (the guide will be posted in this thread)

Nope. Another block. On reloading mods:
Code:
Could not load type 'ExampleMod.ExampleMod' from assembly 'ExampleMod_0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0 
  at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0 
  at Terraria.ModLoader.AssemblyManager.InstantiateMods (System.Collections.Generic.List`1 modsToLoad) [0x00000] in <filename unknown>:0
Help please?
 
Success! ExampleMod built successfully! I'm still going to test it in-game, but this is great!

I'll post a guide for other OSX/Linux users out there soon :) (the guide will be posted in this thread)

Nope. Another block. On reloading mods:
Code:
Could not load type 'ExampleMod.ExampleMod' from assembly 'ExampleMod_0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
  at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
  at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
  at Terraria.ModLoader.AssemblyManager.InstantiateMods (System.Collections.Generic.List`1 modsToLoad) [0x00000] in <filename unknown>:0
Help please?
I fixed the problem! Turns out I was supposed to use the files generated in the obj/ directory as opposed to the bin/ directory. The mod works perfectly in-game!

I'll be able to provide that OSX development guide soon!
 

jopojelly

Retinazer
tModLoader
Success! ExampleMod built successfully! I'm still going to test it in-game, but this is great!

I'll post a guide for other OSX/Linux users out there soon :) (the guide will be posted in this thread)

Nope. Another block. On reloading mods:
Code:
Could not load type 'ExampleMod.ExampleMod' from assembly 'ExampleMod_0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
  at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
  at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
  at Terraria.ModLoader.AssemblyManager.InstantiateMods (System.Collections.Generic.List`1 modsToLoad) [0x00000] in <filename unknown>:0
Help please?
Are you saying it loads once, but on reload it breaks?

This might be a code path we didn't anticipate, looking at that error.


Edit: oh, ok
 

Endershot355

Steampunker
Send help pls...


Specified argument was out of the range of valid values.
Parameter name: Cannot assign music box to vanilla music ID 0
at Terraria.ModLoader.Mod.AddMusicBox(Int32 musicSlot, Int32 itemType, Int32 tileType, Int32 tileFrameY)
at SpiritMod.SpiritMod.Load()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)


Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace SpiritMod
{
    class SpiritMod : Mod
    {
        public SpiritMod()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
                AutoloadGores = true,
                AutoloadSounds = true
            };
        }
        public override void Load()
        {
            AddMusicBox(GetSoundSlot(SoundType.Music, "MusicBox/Megalovania"), ItemType("MysteryMusicBoxItem"), TileType("MysteryMusicBox"));
    }
            public override void UpdateMusic(ref int music)
            {
                    music = this.GetSoundSlot(SoundType.Music, "MusicBox/Megalovania");
                }
           
        }

}
 

Solo-Ion

Dungeon Spirit
That is a bit fast. So I'm guessing that I'll have to use pre/postAI for this. The problem for me there is that I have never tried to use those and don't know anything that you can do with those or even where to start. I understand it would be tricky, but not impossible, right?
preAI and postAI behave just like the AI hook, except they are called before & after the AI hook. You could experiment with both preAI and postAI and see what happens if you try something like projectile.velocity *= 1.5f; to speed it up. You could try using the onHitNPC hook with something like the following, though I don't know how well it would work.
Code:
if (projectile.ai[1] > 0)
     projectile.ai[0] = 0;
if (this.ai[0] == 0f)
{
     this.velocity *= -1;
}
this.netUpdate = true;
If that fails, I guess I could show you some of my boomerang code, but I've made some changes to it so it would need a bit more work to get it back how you'd want it.

Not sure whether this has been reported before but controller support seems to be causing a crash while reloading mods. Specifically, it happens when a world is loaded, exited and then mods are reloaded. To note I was using my keyboard most of the time despite having a controller plugged in and the crash happened essentially every single time conditions mentioned were met. As soon as I unplugged my controller, everything worked fine.

Code:
Indice oltre i limiti della matrice. (Index exceeds matrix dimension)
  in Terraria.GameInput.PlayerInput.GamePadInput()
  in Terraria.GameInput.PlayerInput.UpdateInput()
  in Terraria.Main.do_Update(GameTime gameTime)
  in Terraria.Main.Update(GameTime gameTime)
I have the exact same problem. tModLoader will appear to freeze and require a forced close, but I later realised I could get control back by unplugging my controller, then click the continue button like normal. I'm using a dual PS2 to USB adapter, what kind are you using?
 

UberCAKE

Spazmatism
A while ago I asked...

How would I make a ore spawn like the hardmode ores (Cobalt, Mythril, Adamantite etc) do?

Is it possible to change the image of the moon after the Wall of Flesh and later the Moon Lord are defeated? (Like how wearing sunglasses causes the sun image to change).
Also how would I make a item spawn in one of the dungeon gold chests?

Also how would I make modded biome chests?

For recipes how would I make the tile required be the hardmode anvils (Mythril or Orichalcum) or forges (Adamantite or Titanium) without the pre-hardmode ones being usable?

Also how would I make something require the Demon/Crimson altar to be made?
Sorry if I seem impatient, but I doubt anyone is reading that page anymore :redspin:
 

Endershot355

Steampunker
Send help pls...


Specified argument was out of the range of valid values.
Parameter name: Cannot assign music box to vanilla music ID 0
at Terraria.ModLoader.Mod.AddMusicBox(Int32 musicSlot, Int32 itemType, Int32 tileType, Int32 tileFrameY)
at SpiritMod.SpiritMod.Load()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)


Code:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;

namespace SpiritMod
{
    class SpiritMod : Mod
    {
        public SpiritMod()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
                AutoloadGores = true,
                AutoloadSounds = true
            };
        }
        public override void Load()
        {
            AddMusicBox(GetSoundSlot(SoundType.Music, "MusicBox/Megalovania"), ItemType("MysteryMusicBoxItem"), TileType("MysteryMusicBox"));
    }
            public override void UpdateMusic(ref int music)
            {
                    music = this.GetSoundSlot(SoundType.Music, "MusicBox/Megalovania");
                }
          
        }

}
I just rally want to get this fixed
 

W1K

Witch
I have the exact same problem. tModLoader will appear to freeze and require a forced close, but I later realised I could get control back by unplugging my controller, then click the continue button like normal. I'm using a dual PS2 to USB adapter, what kind are you using?
An Xbox gamepad, it should be as compatible as it can be. We can guess it's a problem with controller support in general.
 
Top Bottom