Standalone [1.3] tModLoader - A Modding API

Discussion in 'Works-in-Progress' started by blushiemagic, Jul 7, 2015.

  1. XerX

    XerX Terrarian

    I've given this a try. Seems easy enough. I tried following your example however, but even your example doesn't work. I've done the steps correctly, but the recipes don't show up in-game. And no, I'm not getting compiling errors either.
     
    Dan Yami and Modiceai like this.
  2. zadum4ivii

    zadum4ivii Official Terrarian

    So, in this API you can connect .json and .cs? Looks conveniently.
     
    Dan Yami and Modiceai like this.
  3. Jofairden

    Jofairden Golem

    It's only C#
     
    Dan Yami and Modiceai like this.
  4. tell me what i did wrong
    I ran the file in the download and got terraria and terraria backup (this was after i put in there vanilla terraria), then i put terraria in my folder where i got terraria. don't currently have any mods installed
     
    Dan Yami and Modiceai like this.
  5. Jofairden

    Jofairden Golem

    What is the problem?
     
    Dan Yami and Modiceai like this.
  6. Chakratos

    Chakratos Terrarian

    And what is wrong with that?

    ----------------------------------

    Where can i see which methods i can override?
     
    Dan Yami and Modiceai like this.
  7. Forgot to mention, when i did that it didn't work, steam didn't let me start it and i couldn't start it from the application
     
    Dan Yami and Modiceai like this.
  8. Jofairden

    Jofairden Golem

    What does it say?
     
    Dan Yami and Modiceai like this.
  9. Jofairden

    Jofairden Golem

    I managed to get the .dll files and it does actually build my mod now. But now there's some new errors, not my code:
    error CS0103: The name 'recipe' does not exist in the current context
    error CS0103: The name 'recipe' does not exist in the current context
    error CS0103: The name 'recipe' does not exist in the current context
    error CS0103: The name 'recipe' does not exist in the current context

    Giving it a capital (Recipe) gives these errors:

    error CS0117: 'Terraria.Recipe' does not contain a definition for 'AddTile'
    error CS0117: 'Terraria.Recipe' does not contain a definition for 'AddIngredient'
    error CS0117: 'Terraria.Recipe' does not contain a definition for 'SetResult'
    error CS0117: 'Terraria.Recipe' does not contain a definition for 'AddRecipe'

    For the .dll files:

    Goto: "C:\Windows\Microsoft.NET\assembly\GAC_32"
    In there search for the following folders:
    "Microsoft.Xna.Framework"
    "Microsoft.Xna.Framework.Game"
    "Microsoft.Xna.Framework.Graphics"
    "Microsoft.Xna.Framework.Xact"

    COPY (do not cut/delete it) the .dll file inside each folder to your Terraria folder (C:\Program Files (x86)\Steam\SteamApps\common\Terraria)
     
    Dan Yami and Modiceai like this.
  10. Chakratos

    Chakratos Terrarian

    Post some source if you need help, but it seems like you didn´t use the Recipe method right.

    ModRecipe recipe = new ModRecipe(this);
    recipe.AddIngredient(ItemID.DirtBlock);
    recipe.SetResult(ItemID.LifeCrystal, 15);
    recipe.AddRecipe();
     
    Dan Yami, Modiceai and blushiemagic like this.
  11. Jofairden

    Jofairden Golem

    Oooh, I forgot ModRecipe recipe = new ModRecipe(this);
    Guess what happened when I added that... RUNTIME ERROR.
    Check the picture.
    The given key was not present in the dictionary.
    at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
    at Terraria.ModLoader.ModLoader.GetTexture(String name)
    at Terraria.ModLoader.Mod.SetupContent()
    at Terraria.ModLoader.ModLoader.Load()
    at Terraria.ModLoader.ModLoader.Reload()
    at Terraria.ModLoader.Interface.AddMenuButtons(Main main, Int32 selectedMenu, String[] buttonNames, Single[] buttonScales, Int32& offY, Int32& spacing, Int32& buttonIndex, Int32& numButtons)
    at Terraria.Main.DrawMenu(GameTime gameTime)
    at Terraria.Main.do_Draw(GameTime gameTime)
    at Terraria.Main.Draw(GameTime gameTime)
    Screenshot_1.png
     
    Dan Yami and Modiceai like this.
  12. Chakratos

    Chakratos Terrarian

    Do you have added an Textur.png for your item?
    It must be named EXACTLY like the .cs
     
    Dan Yami and Modiceai like this.
  13. Jofairden

    Jofairden Golem

    Sorry this is the first time I've attempted modding Terraria. I just copied his 'tutorial'.. And it gives me these errors.
    I have an image for the sword, but not exactly sure where to put it.
     
    Dan Yami and Modiceai like this.
  14. Jofairden

    Jofairden Golem

    I can get recipe to work with existing items but not custom items.. they won't show up when crafting.. but custom recipe for existing items do.

    Nevermind I got it to work now, I guess I messed up somehow.
     
    Dan Yami and Modiceai like this.
  15. blushiemagic

    blushiemagic Retinazer

    Woah everyone replied while I was sleeping

    Sure, there isn't anything stopping you from making one.

    For now, you can look at the documentation and see which methods are virtual or abstract. Abstract methods must be overridden, and virtual methods can be overridden if you want to.

    For the dll problem, I have it fixed so that it automatically finds the right directories for you in the next version.
    For the texture problem, it looks like you've already got it fixed but I'll say it here for everyone else: when you call GetTexture you're essentially passing in the path of the texture as a parameter, starting with the mod's directory and not including the extension. For example, the ExampleMod folder contained all the files in the temporary tutorial, and it also had a folder called Items, which contained ExampleSword.png. So I used "ExampleMod/Items/ExampleSword".
     
    Dan Yami and Modiceai like this.
  16. Jofairden

    Jofairden Golem

    So I'm trying to create my own 'soul' as an item.. but it gives me this error.
    Screenshot_2.png

    My code for GetTexture is valid.. I'm trying .gif it gave me an error.. I tried .png and it gives me an error still..
    Now it is simply giving me this:
    c:\Users\Daniel\Documents\My Games\Terraria\ModLoader\Mod Sources\ItemOverhaulOverpower\Items\SoulOfPower.cs(17,8) : error CS1061: 'Terraria.Item' does not contain a definition for 'GetTexture' and no extension method 'GetTexture' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

    My cs file is there.. I checked code and thats all ok.
    'item.GetTexture = "ItemOverhaulOverpower/Items/SoulOfPower";'

    (SoulOfPower.gif)
     
    Dan Yami and Modiceai like this.
  17. Jofairden

    Jofairden Golem

    Somehow I got it in the game now but it doesn't behave as it should.
     
    Dan Yami and Modiceai like this.
  18. blushiemagic

    blushiemagic Retinazer

    Whoops, I forgot, the GetTexture method isn't actually needed for assigning textures to items. You can give items a texture by passing in the texture name as the third parameter of AddItem, since I call GetTexture for you with that. The GetTexture method is mostly for if people want to do their own custom drawing (for example, skeletron's arms). Also, gif files currently aren't supported by this mod.
    I haven't looked into how souls animate yet; I will do that before the next update though.
     
    Dan Yami and Modiceai like this.
  19. Jofairden

    Jofairden Golem

    Please work on gifs. Hehe. I'm working on a mod that allows the player to 'empower' items with souls. So basically if you already have a HM character you can give pre HM gear a boost. This is just an idea I think it is quite fun. Basically a sort of 'enchanthing'
     
    Dan Yami and Modiceai like this.
  20. Chakratos

    Chakratos Terrarian

    Oh ok, now i get it.
    In the Documentation is everything that exist, i thought you could make custom enemys atm ^^
     
    Dan Yami and Modiceai like this.