Standalone [1.3] tModLoader - A Modding API

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

  1. Zwip-Zwap Zapony

    Zwip-Zwap Zapony Terrarian

    Whenever ModConfig becomes a thing for tModLoader, will it work by returning the configuration value or by overwriting a variable? In other words, can multiplying a ModConfig value by 2 work something like variable = ModConfig("configValName")*2;, or will it instead have to be something like ModConfig("configValName",variable); variable*=2;? Vanilla Terraria's "Preferences" thing seems to work in the latter way, while I definitely prefer the former and see no negatives about it (while I easily see a few negatives about the latter).
  2. SirGouki

    SirGouki Terrarian

    There actually is an obvious problem to your first method. C# is a strongly typed language, and if you do something like ModConfig("configValName") * 2; there's no garuntee that ModConfig() is returning a correct type. Doing something like
    float c_hp_mod = 0;  //default in case loading fails
        c_hp_mod = ModConfig("config HP modifier");
    catch (exception e)
        debug_message = e.message;
        c_hp_mod = 0;
    c_hp_mod *= 2;
    would be better and allows for exception handling on incorrect typing without causing errors to the player and/or failing and crashing the game.

    edit: forgot the *2 and to actually set the hp modifier incase the config wasn't loaded :sigh:
  3. Quethed

    Quethed Terrarian

    Thanks again.
    (I really should not post this) I have noticed you help constantly (Three times now) and you are the only one who helps. I am offering you to join me making mods because I am that desperate for more modders.
    Last edited: Oct 12, 2018
  4. Eldrazi

    Eldrazi Eater of Worlds

    Sorry mate but I'll have to decline. Good luck with your mod, though :)
  5. Jofairden

    Jofairden Golem

    Your example is unnecessarily complex.
    Yes, you will be able to get any property you add to your config. (What's the point of it if you couldn't?)
    Example config:
  6. Quethed

    Quethed Terrarian

    I personally hate when your code is unnecessarily complex. just saying.
  7. Jofairden

    Jofairden Golem

    What are you trying to say?
  8. Quethed

    Quethed Terrarian

    Nothing important, just an opinion (NOT towards the person)
  9. Quethed

    Quethed Terrarian

    How do you make a block get placed facing the player, without using "TileObjectData" because the game wants to divide by 0
  10. Horcrux

    Horcrux Terrarian

    the most unstable thing I have ever seen, but still; its amazing. Its the reason I have like 200 hours THIS MONTH on terraria
  11. Zwip-Zwap Zapony

    Zwip-Zwap Zapony Terrarian

    Is there a tutorial/guide for custom multiplayer synchronization?

    When I try to compile a mod that I'm working on, tModLoader says "...\RegenFromBosses_NetSynch.cs(21,21) : error CS0120: An object reference is required for the non-static field, method, or property 'Mod.GetPacket(int)' ", however when I compile ExampleMod (which also has custom synchronization), no such error occurs, which means that the error is on my part somehow.

    This is the current RegenFromBosses_NetSynch.cs file, minus two methods to keep the post shorter:
    using System.IO;
    using System.Linq; //For C#6 compiling
    using Terraria;
    using Terraria.ID;
    using Terraria.ModLoader;
    using Terraria.ModLoader.IO;
    //This file is all about synchronizing the regenLife variable in multiplayer
    //It has a function that sends regenLife from the server to all clients (NetSendRegen()),
    //and a function that lets clients ask the server to do the above (NetGetRegen())
    //Note that despite what this file is for, this mod's multiplayer synchronization compatibility is still completely unknown at the time
    namespace RegenFromBosses
        public partial class RegenFromBosses : Mod
            public static void NetSendRegen() //Send the current life regeneration value from the server to all clients
                if (Main.netMode==NetmodeID.Server) //If hosting the server...
    /*ERROR*/       ModPacket packet=GetPacket(); //...create a new network packet...
                    packet.Write((byte)PacketType.ServerSendRegenToClient); //...write what the packet is for...
                    packet.Write(regenLife); //...write the current life regeneration value...
                    packet.Send(); //...and send the packet
            //public static void NetGetRegen() { ... } //Ask the server to transmit the current life regeneration value
            //public override void HandlePacket(BinaryReader reader,int whoAmI) { ... } //Do stuff with network packets
        enum PacketType : byte //Multiplayer synchronization network packet types
            ServerSendRegenToClient,     //Used when the server sends the current life regeneration value to a client
            ClientRequestRegenFromServer //Used when a client requests the current life regeneration value from the server

    Again, ExampleMod doesn't have this issue. Even if I actually copy some similar synchronization code that works in ExampleMod (or other open-source tModLoader mods) and paste it in this place, along with all of the "using" directives, it still errors when compiling.

    What annoys me and made me make this post isn't that I get an error, but that I get an error when doing the exact same thing as something else that does not get an error.
  12. jopojelly

    jopojelly Retinazer

    That method is static, it can't call GetPacket because GetPacket is not a static method
  13. Deathend

    Deathend Terrarian

    if you are using calamity + overhaul they lately dont go well in world creation, if you want to create a world with calamity remove overhaul for the world creation and add it later, also i think spirit mod is having some incompatibilities too
    worldgen previewer also crashes with calamity world gen, and since calamity makes worlds a little bigger i recomend using large world enabler to remove some issues like hell side of map being distorted
  14. Noodle Cult

    Noodle Cult Terrarian

    I've downloaded the Windows version but the application in my files is called 'tModLoaderMac' and wont run on my PC. When I troubleshoot it says its an incompatible version. So how do I get the Windows version?
  15. jopojelly

    jopojelly Retinazer

    tModLoaderMac is a file in the ModCompile folder within the downloaded zip file. You don't run that file, you run Terraria.exe from the zip. Read the readme.txt.
    Gokaiji likes this.
  16. Gokaiji

    Gokaiji Terrarian

    in the new version i have 2 problems with 2 mods ,the thorium and calamity with this mods when i select a character the terraria just crash ,and i cant play alone ,anyone can help me pls?
  17. lukebytes

    lukebytes Terrarian

    how do i update to Tmodloader 1.5? i've tried everything i could think of.
  18. Zwip-Zwap Zapony

    Zwip-Zwap Zapony Terrarian

    Is it possible to override Terraria.Main.checkHalloween() and Terraria.Main.checkXMas()? (If not, I'd like to request that to be possible.) I can't find them in the "patch" things of tModLoader's GitHub page, and I'm trying to make a mod which's sole purpose is to do stuff in those methods (while that mod currently says that those methods can't be overriden).

    Edit: Or perhaps instead of an overrideable checkHalloween() and checkXMas(), maybe some kind of new tModLoader-specific checkDate() that runs when checkHalloween() and checkXMas() usually would, or something specifically for when night passes to day naturally (and vice-versa)? Either thing would be helpful for this mod in any case.
    Last edited: Oct 20, 2018
  19. Uncle_Slime

    Uncle_Slime Terrarian

    Just out of curiosity, the ultimate apocalypse guys claim to have a 64bit Tmodloader. Does any one here know if it's possible? Since terraria it self is 32 bit and all.
  20. ImagineDarkness

    ImagineDarkness Terrarian

    Hola, tengo un problema con el Terraria, el Terraria funciona correctamente pero cuando extraigo los archivos de Modloader v0.10.1.5 me sale este error Ayuda

    Attached Files: