1. 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.
    Dismiss Notice

Tool tDev - a proper developer mode for tAPI

Discussion in 'Released' started by bawr, Feb 14, 2015.

  1. bawr

    bawr Terrarian

    tDev what?

    tDev is a tool for mod makers. It's basically an addition to tAPI (tested with 14.a) with a few little tweaks geared towards developing and debugging your mod:

    • Uses a completely separate game folder. Where tAPI uses "My Games\Terraria\tAPI", tDev uses "My Games\Terraria\tDev".
      Never break your main game again when you accidentally use an unstable mod on your favourite world!

    • Lets you start the game with a debugger attached.
      It seems that tAPI has a bug where you can attach after the game is started, but only then. That's fixed now.

    • Lets you "Edit and Continue".
      That's right, grab an edition of Visual Studio, and off you go. Break, fix, run again - with no restarts required.

    • Lets you build your mod from the command line.
      Finally, developing a mod gets to be really seamless - just set up a post-build task, and you're done.

    tDev how?


    How do I use it, you mean?

    If you're asking how it works, well, use the source, Luke. (tl;dr - patches tAPI with Mono.Cecil)

    • Download tDev and put it in your Terraria game folder. Same folder where tAPI.exe is.

    • You have two files - tDev.exe is the game, and tDev.Build.exe is a command-line mod builder.

    • Run tDev now. It will create its own config folder.

    • Set up your Visual Studio project as follows:
      • Assumptions:
        • Your username is "Mark IV McAwesome"
        • Your mod is called Mark.SuchAwesomeMod (internal name)
        • Your mod's source is in "C:\Code\Mark's Mod"
        • You installed the game in "C:\Games\Terraria"
      • Setup:
        • Add references to tAPI.exe and all Microsoft.Xna.*.dll files
        • Use [ "C:\Games\Terraria\tDev.exe" ] as your startup executable.
        • Use [ "C:\Games\Terraria\tDev.Build.exe" Mark.SuchAwesomeMod "C:\Code\Mark's Mod" ] as a post-build task.
        • Use [ "C:\Users\Mark IV McAwesome\Documents\My Games\Terraria\tDev\Mods\PDB" ] as your output path.

    Yeah, we're using the PDB folder for our assembly, due to the way I hacked around the mod loader. Don't ask, don't tell.

    (This last step is only needed if you intend to use "Edit and Continue", without it the mod will still load.)

    When you're done with development, you can copy your mod package from "C:\Users\John\Documents\My Games\Terraria\tDev\Mods\Local", and put it in your main tAPI folder. Or just double-click it and let tAPI do that.



    tDev where?


    tDev on Dropbox. Download here (v1.0).

    Or you can get the sources.

    Don't expect much, the builder for the tDev binary is just an elaborate patcher of tAPI.




    tDev I have other questions!


    Ask away, I'll do my best to respond. I wrote this for myself, but maybe someone else could use it.
     
    Last edited: Feb 15, 2015
  2. Seamerlin

    Seamerlin Skeletron

    I might try it, it only works for PC,doesn't it?
     
  3. bawr

    bawr Terrarian

    Yeah, target audience is basically people who already use an IDE and a debugger when creating and testing their mods. Geared towards Visual Studio, because that's what I use.

    But if anyone wants to start, the community edition is free and awesome.
     
    Yoraiz0r likes this.
  4. I assume that it works with Visual Studio Express (Windows Desktop 2013) as well?
    Anyhow, this seems really neat. Will help a lot with the debugging process (Especially since I'm new to C#!)

    EDIT: Chrome has apparently blocked it as malware...
     
  5. bawr

    bawr Terrarian

    I see no reason why it shouldn't. Try it out and give me some feedback. ;)
     
  6. I tried to download it, and Chrome blocked it as Malware, and won't allow a bypass. Might want to check that out ;)
     
  7. bawr

    bawr Terrarian

    That's... odd. I'll look into it right away.
     
    Yoraiz0r likes this.
  8. bawr

    bawr Terrarian

    The download link is fixed, apparently Chrome really doesn't like .zip files with .exe files in them.

    But just to be sure, here's an online scan report: tDev.rar, tDev.exe, tDev.Build.exe.

    Enjoy!
     
    Yoraiz0r likes this.
  9. Also, noobish question. How do you actually do the final three steps (Startup-executable, post-build script, etc)? I'm fairly new to Visual Studio and such as you can see. I've been using Eclipse for the longest time :p
     
  10. bawr

    bawr Terrarian

    Heh, we've all been new to VS once. Give me a few minutes and I'll whip up an illustrated guide. ;)
     
    Yoraiz0r likes this.
  11. bawr

    bawr Terrarian

    Well, VS refuses to cooperate with me today, so here's a quick guide which I will turn into an actual illustrated guide later on.

    You want a C# class library project type.

    Once your solution opens, right-click on your project in the solution explorer, and select "Properties". It should be the second entry in the box, the first being the whole solution.

    Now, we're going to do all of our setup on this screen.
    • In the "Application" tab:
      • Set the "Assembly name" and "Default namespace" to your mod name, if it's not set already.
        By default it's whatever you typed in when creating the project.
      • Make sure "Target framework" is set to ".NET Framework 4".
      • Make sure "Output type" is set to "Class library".
    • In the "Build" tab:
      • In the "Configuration" drop-down, select "All configurations".
      • In the "Platform" drop-down, select "Active (x86)".
      • Make sure "Platform target" is set to "x86".
      • Make sure "Output path" is set to tDev's PDB directory (based on the first post).
    • In the "Build events" tab:
      • You want to set the "Post-build event command line", you have two options here.
      • Option 1 - set it to [ C:\Somewhere\Terraria\tDev.Build.exe "$(TargetName)" "$(ProjectDir)\" ], this assumes you set the "Assembly name" to your mod's internal name (which you should).
      • Option 2 - replace "$(TargetName)" with your mod's internal name by hand, and replace "$(ProjectDir)\" with the full path to your mod (where ModBase.cs and ModInfo.json are).
      • Important! If you're writing the full path, it must have a very specific form, it must end with two slashes. So it's "C:\Stuff\MyMod\\" <-- note the double slash. This is because otherwise Visual Studio will think that the final quote is a part of the name.
    • In the "Debug" tab:
      • In the "Configuration" drop-down, select "All configurations", again.
      • In the "Platform" drop-down, select "Active (x86)", again.
      • Under "Start Action" sekect "Start external program", and set it to the tDev.exe file, located in your main game folder.
    Phew!

    That should be all. Hope this helps! ;)
    --- Double Post Merged, Feb 15, 2015 ---
    BTW, I'm making a simple tool to automate all this and generate a simple project for you. ;)
     
    Yoraiz0r likes this.
  12. Sylent :^)

    Sylent :^) Plantera

    Looks awesome. This is probably false, but is it compatible with tAPI? And can you run other people's mods with it?
     
  13. bawr

    bawr Terrarian

    It is! Basically tDev is generated from tAPI binaries, so when in doubt, just remember:
    tDev = tAPI + a few patches for debugging + tDev.Build

    As for running other people's mods - yeah, sure, why not? Just drop them in the tDev mod folder, and remember that tDev has its own mod folder. ;)
    --- Double Post Merged, Feb 16, 2015 ---
    PS: A few hours more and I'll have a Visual Studio project generator (codename: Tempo) ready for y'all. That should make the entry bar even lower. :D I would've had it already, but WPF is a :red:.
     
    Last edited: Feb 16, 2015
  14. Sylent :^)

    Sylent :^) Plantera

    I might try and use this.
     
    bawr likes this.
  15. skamper125

    skamper125 Terrarian

    Mind hitting me up when you have the simplified version? The simpler the better as I have a very limited grasp when it comes to these things. XD
    I'm barely even starting, and the last game I learned to mod was Diablo 2. All written in a unique variant of C++...
     
  16. _Mish

    _Mish Skeletron Prime

    This looks fantastic! I am very interested in using it but.... Do I have to use visual basic to edit while in game?
     
  17. ehhhhh your telling me I can pause my game, edit, and continue? Without loading a billion times? If so, download.
     
    fffffffffffffffff and _Mish like this.
  18. fffffffffffffffff

    fffffffffffffffff Terrarian

    Awesome! Having to rebuild every time I tweaked a tiny thing was a hassle, what are the limitations of it? Will it allow major code changes, such as new classes, or will stuff like that require a restart? Either way this will make everyone's life much easier, awesome job!
     
  19. Chicken Bones

    Chicken Bones Terrarian

    Excellent tool. Any chance of a tDev for server?

    Edit: I used the source and made one that works for my debugging purposes.
     
    Last edited: Jun 12, 2015
  20. Blardow

    Blardow Skeletron Prime

    When I press start on Visual Studio, tDEV says "No Mod selected to build. Required elements : <Mod Name>, <Mod Path>." I made sure to follow all the directions and everything should be correct, however it still doesn't seem to work.