Standalone [1.3] tModLoader - A Modding API

I can confirm npc disapering in multiplayer. It makes npcloot() not getting called and also the DeadCheck is only called on the killer side since the npc disapear in the client.
 
Does anyone know how to Animate the chests to open and close, i have the chests in my mod fully working with the animation pictures in the same chest picture. Although i dont know how to write the code to animate the opening or closing please help ?
 
When certain conditions are met, I want to draw a frame from my spritesheet in front of my TownNPC. Instead, the NPC isn't drawn at all / disappears (doesn't even appear in housing list).

Code:
        public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            if(winter) spriteBatch.Draw(mod.GetTexture("NPCs/Enthusiast/Enthusiast_Shirt"), npc.Center - Main.screenPosition, new Rectangle(0, npc.frame.Y, 40, 60), Color.White);
        }

What am I doing wrong?
 

Attachments

  • Enthusiast.png
    Enthusiast.png
    6.6 KB · Views: 190
  • Enthusiast_Shirt.png
    Enthusiast_Shirt.png
    2.2 KB · Views: 190
Does anyone know how to Animate the chests to open and close, i have the chests in my mod fully working with the animation pictures in the same chest picture. Although i dont know how to write the code to animate the opening or closing please help ?
At the moment there isn't official support for that; not even ExampleChest does that.

When certain conditions are met, I want to draw a frame from my spritesheet in front of my TownNPC. Instead, the NPC isn't drawn at all / disappears (doesn't even appear in housing list).

Code:
        public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            if(winter) spriteBatch.Draw(mod.GetTexture("NPCs/Enthusiast/Enthusiast_Shirt"), npc.Center - Main.screenPosition, new Rectangle(0, npc.frame.Y, 40, 60), Color.White);
        }

What am I doing wrong?
Hm, and this problem doesn't happen without the custom drawing?

Does this support Windows 10? Because i am getting an error where the installer does not work
Yes, but the installer requires Java 7 or up to run. If you don't want to install that you can also manually copy the files to your steam directory.
 
BlueMagic,

Wouldnt you use something like this, or is this wrong ? I tried it although it didnt work. I hope support is out soon if it will not work. Is there an example on how to create a custom AI btw ?

Code:
public override void AnimateTile(ref int frame, ref int frameCounter)
{
    bool[] array = new bool[1000];
    for (int i = 0; i < 255; i++)
    {
        if (Main.player.active && Main.player.chest >= 0 && Main.player.chest < 1000)
        {
            array[Main.player.chest] = true;
        }
    }
    for (int j = 0; j < 1000; j++)
    {
        Chest chest = Main.chest[j];
        if (chest != null)
        {
            if (array[j])
            {
                chest.frameCounter++;
            }
            else
            {
                chest.frameCounter--;
            }
            if (chest.frameCounter < 0)
            {
                chest.frameCounter = 0;
            }
            if (chest.frameCounter > 10)
            {
                chest.frameCounter = 10;
            }
            if (chest.frameCounter == 0)
            {
                chest.frame = 0;
            }
            else if (chest.frameCounter == 10)
            {
                chest.frame = 2;
            }
            else
            {
                chest.frame = 1;
            }
        }
    }
}
}
}
 
Last edited:
BlueMagic,

Wouldnt you use something like this, or is this wrong ? I tried it although it didnt work. I hope support is out soon if it will not work. Is there an example on how to create a custom AI btw ?

public override void AnimateTile(ref int frame, ref int frameCounter)
{
bool[] array = new bool[1000];
for (int i = 0; i < 255; i++)
{
if (Main.player.active && Main.player.chest >= 0 && Main.player.chest < 1000)
{
array[Main.player.chest] = true;
}
}
for (int j = 0; j < 1000; j++)
{
Chest chest = Main.chest[j];
if (chest != null)
{
if (array[j])
{
chest.frameCounter++;
}
else
{
chest.frameCounter--;
}
if (chest.frameCounter < 0)
{
chest.frameCounter = 0;
}
if (chest.frameCounter > 10)
{
chest.frameCounter = 10;
}
if (chest.frameCounter == 0)
{
chest.frame = 0;
}
else if (chest.frameCounter == 10)
{
chest.frame = 2;
}
else
{
chest.frame = 1;
}
}
}
}
}
}
Uh, could you try putting that code in a code block?
Also, the ExampleMod has plenty of examples of custom AI, but if you want to create your own custom AI, programming experience is literally the only thing that can help.

Nope, before meeting the conditions it works fine.
Hm, can you put your drawing code in a try/catch then log the exception?
 
There i put it in a block, anyway it didnt work, anyideas on how i could change the chests script to animate the lid ? I think it would work similar to the npcs animation. Oh and can we make Minecarts yet. There is no example. Im guessing its some kind of mount.
 
Last edited:

tModLoader-Logo1.png

Current version: v0.7.1.1
Compatible with Terraria 1.3.0.8
Requires Steam
Platforms: Windows, Mac, Linux
Servers currently only work on Windows

  1. Introduction
  2. Creating Mods
    1. Documentation
    2. Example Mod
    3. Instructions
    4. Help and Resources
    5. tModReader
  3. Legal Stuff
  4. Credits
  5. Download
    1. Direct Download
    2. Open Source
    3. Past Versions
  6. Installation
  7. Version History
  8. The Future
  9. News


YdXk3Ru.png

tModLoader is essentially a mod that provides a way to load your own mods without having to work directly with Terraria's source code itself. This means you can easily make mods that are compatible with other people's mods, save yourself the trouble of having to decompile and recompile Terraria.exe, and escape from having to understand all of the obscure "intricacies" of Terraria's source code. It is made to work for Terraria 1.3.

tModLoader saves worlds and players separately from vanilla worlds and players. Vanilla worlds and players can be ported to tModLoader worlds and players simply by copying over save files. Modded content is saved in files separate from .plr and .wld files, so you can also port modded players and worlds back to vanilla at the cost of losing your modded stuff.

My goal for tModLoader it to make it simple as possible while giving the modder powerful control over the game. A secondary goal is that anyone who works with tModLoader enough will be able to make their own standalone mods. tModLoader is designed in a way as to minimize the effort required for me to update to future Terraria versions. Feel free to either suggest hooks or push hooks to Github (link in a later section).

Also please don't email me, I almost never check my email.



INqo7SN.png

Documentation
Link to Documentation
The documentation contains everything you need to know about what tModLoader has to offer. It contains information on all the features, hooks, etc., in tModLoader, complete with descriptions on what everything is used for. Unlike other modding API's, this documentation is kept up-to-date as features are added. Do note that often it will even be ahead of the current released version.

Example Mod
I use an example mod to test features that I add to tModLoader. You can download a zip file here so you can use it to learn how to make your own things.
Example Mod v0.7.1.1 Download

Instructions

To create a mod, first run tModLoader. Click on the "Mod Sources" button in the main menu, then click on the "Open Sources" button to open the folder which contains your mod sources. In this folder, create another folder for your mod, then put all of your .cs files and .png files in that folder. When you are done, build your mod from the "Mod Sources" menu . If the mod failed to build, the game will show you one compile error, and give you an option to view all compile errors as a text file. If the mod successfully builds you will be returned to the main menu. If the game crashes or a mod fails to load, the game will display the error and also give you the option to view the error as a text file. Mods that crash on loading are automatically disabled. Mods are automatically enabled when they are built.

If you are using Mac/Linux, it is possible that your mod will fail to build, no matter what you do. In this case, you will have to pre-compile your mod (see documentation on build.txt for more info).

To distribute a mod, once you have built it, click on the "Mods" button in the main menu, then click on the "Open Mods Folder" button. You will find a file with the .tmod extension for you to distribute.

To install someone else's mod, simply copy the .tmod file to your own Mods folder.

Help and Resources
http://forums.terraria.org/index.ph...amples-handy-code-snippets.28901/#post-656323

Tile Properties and stuff

I and other people who can help with problems can usually be found in the following chatrooms:
tModLoader Discord chat: https://discord.gg/0ZhxukM0qzlWKEqe
tAPI IRC room: http://www.esper.net/publicirc.php (channel = #tapi)

tModReader

tModReader is an application that allows you to unpack .tmod files (assuming the modder has the .tmod file set to allow being unpacked).
tModReader v0.7-v0.7.1.1 Download



Iujuy01.png

Disclaimer and Agreements
  • By downloading tModLoader, you agree to everything in this disclaimer and agreements.
  • I am not responsible for anything that happens to your computer if you download tModLoader. Common sense stuff.
  • Do not use tModLoader to do anything that breaks the Terraria Forums rules.
  • Mods uploaded through the Mod Browser are tagged with your Steam username, so we will know if you do something bad.
  • You are allowed to mod tModLoader (similar to how tModLoader is a mod of Terraria), given that you provide a link to this thread.



j0Qj6pd.png




rIPriBf.png

Current version: v0.7.1.1
Direct Download Links:
Windows | Mac | Linux


Open Source
In case you want to see how messy my code has become, tModLoader is now open source! Feel free to suggest features either on this thread or over Github.
Github Repository Link




xC00PcG.png

Instructions

Once your download is complete, you should have a zipped folder. Unzip this folder. Open the extracted folder and copy all the contents to your Terraria's Steam folder. You may wish to back-up your vanilla Terraria.exe file first. More detailed instructions are in the README file included with the download.



HiViKx8.png

-Servers no longer crash on settling liquids or liquid updates
-Pause menu now shows for clients on steam servers
-Added ResetNearbyTileEffects hook for ModWorld
-Servers now work (so far only on Windows)
-Fixed mods with music being unable to load on Mac/Linux
-Fixed severe FPS drop when armor is equipped and visible
-Fixed bug where custom data could duplicate and corrupt .tplr
-Fixed bug where ItemInfo is not cloned by Item.Clone
-Fixed bug where "endless" ammo can get prefixes
-Fixed bug where modded chest names start out empty
-Fixed vanilla bug with DrawData.useDestinationRectangle
-Added ModWorld
-Added Initialize hook for ModPlayer and ModWorld
-Added SaveCustomData and LoadCustomData hooks for ModWorld
-Added ModifyWorldGenTasks and PostWorldGen hooks for ModWorld
-Added PostUpdate hook for ModWorld
-Added Dangersense hook for tiles
-Added hideVisual parameter to UpdateAccessory hook for items
-Added DrawBehind hook for projectiles
-Added scroll bar to mod info screen
-Added ability to search in the mod browser
-Added the ability to exclude certain files from .tmod resources
-Compiler warnings are now included in the compiler error log file
-Added ModPlayer
-Added ResetEffects and UpdateDead hooks
-Added SaveCustomData and LoadCustomData hooks
-Added SetupStartInventory hook
-Added UpdateBiomes and UpdateBiomeVisuals hooks
-Added UpdateBadLifeRegen, UpdateLifeRegen, and NaturalLifeRegen hooks
-Added PreUpdate, SetControls, PreUpdateBuffs, and PostUpdateBuffs hooks
-Added PostUpdateEquips, PostUpdateMiscEffects, PostUpdateRunSpeeds, and PostUpdate hooks
-Added FrameEffects hook
-Added PreHurt, Hurt, and PostHurt hooks
-Added PreKill and Kill hooks
-Added PreItemCheck and PostItemCheck hooks
-Added GetWeaponDamage and GetWeaponKnockback hooks
-Added ConsumeAmmo, Shoot, and MeleeEffects hooks
-Added OnHitAnything hook
-Added CanHitNPC, ModifyHitNPC, and OnHitNPC hooks
-Added CanHitNPCWithProj, ModifyHitNPCWithProj, and OnHitNPCWithProj hooks
-Added CanHitPvp, ModifyHitPvp, and OnHitPvp hooks
-Added CanHitPvpWithProj, ModifyHitPvpWithProj, and OnHitPvpWithProj hooks
-Added CanBeHitByNPC, ModifyHitByNPC, and OnHitByNPC hooks
-Added CanBeHitByProjectile, ModifyHitByProjectile, and OnHitByProjectile hooks
-Added CatchFish, GetFishingLevel, AnglerQuestReward, and GetDyeTraderReward hooks
-Added DrawEffects, ModifyDrawLayers, and ModifyDrawHeadLayers hooks
-Finished buff support
-Added GlobalBuff
-Added Update(NPC) hook
-Added ReApply hooks
-Added canBeCleared and longerExpertDebuff fields
-Revamped equipment texture system (Added EquipTexture)
-Added all vanity-related ModItem hooks to EquipTexture
-Added Clone hook for ModItem
-Added ExtractinatorUse hook
-Added AutoLightSelect hook for ModItem
-Added PostUpdate hook
-Added SetMatch hook
-Added UpdateVanity hook
-Added GetWeaponDamage and GetWeaponKnockback hooks
-Added projOnSwing field
-Added CaughtFishStack, IsQuestFish, IsAnglerQuestAvailable, and AnglerQuestChat hooks
-Added HoldoutOffset and HoldoutOrigin hooks
-Added DrawHands, ArmorDrawColor, and ArmorArmGlowMask hooks
-Added DrawBody and DrawLegs hooks
-Added support for alternate use functions (right-clicking)
-ItemLoader hooks are now called for hotkey presses and right-click-equips
-Added CloneDefaults methods for Item
-Added disableSmartCursor field and AutoSelect hook for ModTile
-Added support for torches
-Added SetDrawPositions hook for ModTile
-Added WalkDust and MouseOverFar hooks
-Added hooks for grappling hook projectiles
-Added PreDrawExtras hook for projectiles
-Added drawHeldProjInFrontOfHeldItemAndArms field for ModProjectile
-Added support for contact-damage minion projectiles
-Added CloneDefaults method for Projectile
-Added CheckActive and CheckDead hooks for NPCs
-Added DrawEffects hook for NPCs
-Added ResetEffects and UpdateLifeRegen hooks for NPCs
-Added CloneDefaults methods for NPC
-Added PostSetupContent hook for Mod
-Added MidUpdate hook for ModDust
-Added GetLoadedMods method for ModLoader
-Finished music support
-Added support for screen shaders and custom skies
-Custom saved modded item data now persists through the mod being unloaded
-Added DrawLayer and DrawInfo system for custom drawing
-Added EntityInfo system for storing information per entity
-Added the ability to manage mods published on the Mod Browser
-Added sorting buttons to the Mod Browser
-The Mod Browser now checks for tModLoader updates
-Added homepage link and description to mod files
-Added mod info buttons to Mods menu
-Made Terraria.ModLoader.IO.ItemIO public
-Made all hook calls public
-Exception messages now show inner exceptions
-Warnings are now hidden from compile error messages and logs
-Added tModLoader version information to .tmod file structure
-Probably other stuff I forgot
-Mods now unload in the reverse order they were loaded in
-ModifyHitNPC and ModifyHitByItem for NPCs can now modify damage
-Modded items lying in the world now animate at the correct speed
-The Extractinator no longer accepts every single modded item ever
-Doors no longer cause chaos on servers
-Abstract classes are no longer autoloaded
-Fixed severe vanilla-CraftGroup-related FPS drop
-Word wrap on exception messages and mod info no longer splits up words
-Proofed ModRecipe methods against modder mistakes
-Mac support
-.cs files are no longer saved as .tmod resources (woops!)
-Made mods compatible cross-platform
-Added support for building .dll files as mods
-Added Unload hook for Mod
-Revamped how minimap handles mod tiles and walls to cut down minimap's RAM usage
-Fixed bug that made .twld files larger than they had to be
-Made some private Projectile fields public
-Fixed bug where Jungle Temple door cannot be unlocked
-Fixed bug with sign GUI
-Fixed bug where cloud saves are not separate from vanilla cloud saves
-Added mod browser - an easy way to upload / download mods
-Basic buff support
-Added support for platform-like tiles
-Fixed bug where miscellaneous custom sounds don't work
-Improved saving for mannequins and item frames with modded items
-Gave ModDusts their own types
-Added hooks for vanity effects for armor sets
-Linux support
-Made a fancy installer
-Partial music support
-Added "Open Mods Folder" button to Mods menu
-Added support for animating vanilla tiles
-Added support for using vanilla textures
-Two mods can no longer share the same internal name
-Mods must now share names with the folder that contains their content
-Added a default mod that will always be enabled
-Loading mods now completely refreshes recipe list
-Added support for storing items whose mods are unloaded
-Added support for custom NPC banners
-Added support for singleplayer chat + ChatInput hook
-Added support for custom sounds
-Improved system for gores
-Added partial support for mounts
-Added support for miscellaneous file resources in .tmod files
-Added CanTownNPCSpawn and CheckConditions hooks for NPCs
-Added TownNPCName and GetChat hooks for NPCs
-Added SetChatButtons and OnChatButtonClicked hook for NPCs
-Added SetupShop and SetupTravelShop hooks for NPCs
-Fixed bug where locked Jungle Temple door can be opened
-Added BuffTownNPC hook
-Added TownNPCAttackStrength, TownNPCAttackCooldown, TownNPCAttackProj, TownNPCAttackProjSpeed hooks for NPCs
-Added TownNPCAttackShoot, TownNPCAttackMagic, and TownNPCAttackSwing hooks for NPCs
-Added DrawTownAttackGun and DrawTownAttackSwing hooks for NPCs
-Added ScaleExpertStats hook for NPCs
-Added PreAI, AI, PostAI, SendExtraAI, and ReceiveExtraAI hooks for projectiles and NPCs
-Added FindFrame and HitEffect hooks for NPCs
-Added aiType field for ModProjectile and ModNPC + animationType field for ModNPC
-Added support for gores
-Added TileCollideStyle, OnTileCollide, PreKill, and Kill hooks for projectiles
-Added PreNPCLoot and NPCLoot hooks for NPCs
-Added BossLoot hook and bossBag field for NPCs
-Made it easier to customize vanilla NPC loot
-Added CanHitNPC and CanHitPvp hooks for items
-Added CanHitNPC, ModifyHitNPC, and ModifyHitNPC hooks for projectiles
-Added CanHitPvp, ModifyHitPvp, and OnHitPvp hooks for projectiles
-Added CanHitPlayer, ModifyHitPlayer, and OnHitPlayer hooks for projectiles
-Added CanHitPlayer, ModifyHitPlayer, and OnHitPlayer hooks for NPCs
-Added CanHitNPC, ModifyHitNPC, and OnHitNPC hooks for NPCs
-Added CanBeHitByPlayer, ModifyHitByPlayer, and OnHitByPlayer hooks for NPCs
-Added CanBeHitByProjectile, ModifyHitByProjectile, and OnHitByProjectile hooks for NPCs
-Added Colliding hook for projectiles and StrikeNPC hook for NPCs
-Added support for NPC map icons
-Added BossHeadSlot, BossHeadRotation, and BossHeadSpriteEffects hooks for NPCs
-Added support for NPC music
-Added GetAlpha, drawOffset, PreDraw, and PostDraw hooks for projectiles
-Added GetAlpha, PreDraw, drawOffsetY, and PostDraw hooks for NPCs
-Added EditSpawnRate, EditSpawnRange, CanSpawn, EditSpawnPool, and SpawnNPC hooks for NPCs
-Added OpenBossBag hook for items
-Added NearbyEffects hook for tiles
-Code is now optimized by compiler
-Deleting players and worlds will now also delete the associated .tplr and .twld files
-Fixed bug where stackable mod items (ie ammo) can have prefixes
-Fixed bug where vanilla NPC display names are wrong
-Fixed bug where open modded doors invalidate houses
-Removed a log write I accidentally left in
-Possibly other stuff I've forgotten
-Updated to Terraria 1.3.0.8
-Modded world and player data now saves in separate .tplr and .twld files
-Added tModLoader version to main menu
-Added support for theoretically infinite recipes
-Improved error-handling
-Added support for crafting groups
-Added PreOpenVanillaBag and OpenVanillaBag hooks for GlobalItem
-Gave tModLoader exe an (uncreative) icon
-Fixed bug where multi-tile subtiles and alternates are not checked
-Fixed bug where Main.tileValue doesn't work for modded tiles
-Added CanKillTile hook for tiles
-Added support for doors, chests, and beds
-Fixed assembly resolve for dll and mod references
-Added GrabRange, GrabStyle, and OnPickup hooks for items
-Bugfixed custom projectiles and NPCs
-Finally fixed bug where "Build + Reload" wouldn't unload mods
-Hopefully fixed dll reference system
-Autoloading now occurs before manual loading
-Added README to installation
-Added support for multiple global entities per mod
-Added support for autoloading global entities
-Added support for autoloading multiple EquipTypes per item
-Fixed bug where AddTooltip duplicates tooltips
-Improved dll reference system
-Fixed bug where missing equipment textures crashes the game
-Made WorldGen class public
-Added support for walls
--Added support for wall kill sounds, dust, drops, and kill-related hooks
--Added support for wall map colors and names, and related hooks
--Added ModifyLight and RandomUpdate hooks for walls
--Added AnimateWall, PreDraw, and PostDraw hooks for walls
-Added MouseOver and Slope hooks for tiles
-Added support for very basic projectiles and NPCs (Untested)
-Wiring._wireList is now public
-Fixed bug where GlobalItem.SetDefaults did not change vanilla names and tooltips
-Added build properties to specify display and dependency stuff
--Mod author and version are now build properties
--Added support for mod and dll dependencies
-Modified WorldFile.ValidateWorld so worlds containing modded stuff can load
-Added support for custom tiles (ModTile and GlobalTile)
--Added support for tile kill sounds, dust, drops, and kill-related hooks
--Added support for custom TileObjectData and multi-tile blocks
--Added ModifyLight, SetSpriteEffects, AnimateTile, PreDraw, and PostDraw hooks for tiles
--Added support for tile map colors and names, and related hooks
--Added RandomUpdate and TileFrame hooks for tiles
--Added mineResistance and minPick fields for ModTile
--Added CanPlace and AdjTiles hooks for tiles
--Added RightClick and HitWire hooks for tiles
-Added ConsumeItem hook for ModRecipe
-Added PreDrawInInventory and PostDrawInInventory hooks for items
-Fixed bug with removing custom armor from mannequins
-Improved error-handling for missing textures
-Safeproofed installation process
-Mod.Load is no longer abstract
-Removed some log writes that I accidentally left in
-Fixed bug with custom item data saving
-Mods now build as a single file that includes image resources
-Added support for automatically loading items, etc.
-Updated to Terraria 1.3.0.7
-Added ModItem.AddRecipes hook
-Added support for custom dust through ModDust
-Added CanEquipAccessory hook for items
-Added GlobalNPC with PreNPCLoot and NPCLoot hooks since everyone wants that
-Added ModItem.SaveCustomData and ModItem.LoadCustomData hooks
-Made tooltips easier to add
-Mods that crash the game while loading are now auto-disabled
-Mods are now auto-enabled when they are built
-Added a button to the Mod Sources menu to open the Mod Sources folder
-In-game error messages now appear when the game would have crashed and when a build fails
-Item display names can now be separated from internal names in the SetDefault hook
-Added a ton of hooks for ModItem and GlobalItem
--CanUseItem, UseStyle, UseItemFrame, UseItem, and ConsumeItem
--HoldStyle, HoldItem, and HoldItemFrame
--Shoot, ConsumeAmmo, UseItemHitbox, and MeleeEffects
--ModifyHitNPC, OnHitNPC, ModifyHitPvp, and OnHitPvp
--UpdateInventory, UpdateEquip, UpdateAccessory, IsArmorSet, and UpdateArmorSet
--CanRightClick, RightClick, and Update
--VerticalWingSpeeds and HorizontalWingSpeeds
--GetAnimation (ModItem only), GetAlpha, PreDrawInWorld, and PostDrawInWorld
-Added support for armors and accessories
-Fixed decompile bug that caused minimaps to not save
-Updated to Terraria v1.3.0.6
-Fixed missing .dll bug when building mods
-Split ModLoader class into ModLoader and ItemLoader
-Slightly changed the way modded items are saved
-Updated to Terraria v1.3.0.5
-Added support for prefixes for modded items
-Vastly improved the GUI for building and loading mods
--Menu shows status of loading and building mods
--Added menus that show lists of mods and mod sources
--Added the ability to enable and disable mods
--Added the ability to build mods individually
-Added GlobalItem
-Support for mods, recipes, and basic items



PjZa7pT.png

My goals for the next update:

Status: Very busy with homework
v0.7.2:
-Fix server-sync bug with OnPickup hook - Complete
-Add SaveCustomData and LoadCustomData hooks for GlobalItem
-Add hook for item tooltip display
-Fix bug where bottom half of long hair doesn't show - Complete
-Add OnCraft hook for items
-Make it easier to change or remove recipes
-Make includeSource independent from hideResources
-Add more hooks for ModWorld?
-More support for storing unloaded mod content
-Add hooks for biomes
-Add general game hooks

Tentative Future Plans
v0.7.3: Hooks for mounts and tile entities
v0.7.4: Server support + hooks for network
v0.7.5: Hooks for interface
Further in the future: JSON support + other stuff I'm forgetting + full release

? = needs more confirmation
-Mac/Linux cannot host servers
-Modded NPCs disappear upon being hit?
-Steam invites don't work?
-Chests don't sync properly?



dwFwaFN.png

(Updated February 23, 2016) v0.7.1.1 has been released!
http://forums.terraria.org/index.php?threads/1-3-tmodloader-a-modding-api.23726/page-356#post-909879
(Updated February 22, 2016) v0.7.1 has been released!
http://forums.terraria.org/index.php?threads/1-3-tmodloader-a-modding-api.23726/page-353#post-908981

Umm im having an issue where when i go to my charecters to play and theres nothing there and when i press play it wont load i've tried doing everything that i know
 
Make backups before hand. If you want to move saves over to the modded client then you have to move the worlds and player files from the save files which is in my games -> Terraria. My games is found in documents. Then you will need to be in My Games -> Terraria -> Modloader -> (Once here in modloader you merge you files Worlds and Players into the empty files in this file, called worlds and players.
 
Last edited:
Umm im having an issue where when i go to my charecters to play and theres nothing there and when i press play it wont load i've tried doing everything that i know
You mean there are characters with no pictures and they can't be played, or that are no characters at all, or something else?
 
Seems kinda complicated... But, this is the basis for what you would want to start with. This would go into the armor.cs. You would want to set the debuff.cs to be defined a debuff and one with no timer, that way the debuff is only present when water walking is activated. As for the npc speaking, you would need to set up a player.cs variable to be called when the debuff is active on you. Then you would have the npc's dialogue options check for the active variable. I think i've gotten everything right, but if someone has a simpler way, they can explain it to you.

This isn't copy/pastable btw, so you need to actually look at it.

Armor.cs
Code:
public override void UpdateEquip(Player player)
        {
            //put actual armor effects here

            //This is where the new code starts, Checks for water walking buff
            if (player.HasBuff(BuffID.WaterWalking) > -1)
            {
                player.AddBuff(mod.BuffType("CustomDebuff"), 60);
            }
        }
Debuff.cs
Code:
((CustomPlayer)player.GetModPlayer(mod, "CustomPlayer")).debuffVariable = true;

npc.cs
Code:
if (((CustomPlayer)player.GetModPlayer(mod, "CustomPlayer")).debuffVariable == true; && Main.rand.Next(#) == 0)
            {
                return  "'You've got that debuff!";
            }
Thanks, how do you make an npc say something if you have a custom armor piece on?
 
Last edited:
Hm, can you put your drawing code in a try/catch then log the exception?
So as it turns out, it was a Missing Texture exception... needless to say, it was caused by my dumb mistake :/

Anyway it draws now. After some time of trial of error it even draws in the right place but:
  1. It seems that the sprite isn't affected by light, so at night it's much brighter than the rest of the clothes, even though it's the same color
  2. When my character (for example) jumps, the sprite sometimes "doesn't keep up" and is drawn elsewhere than the character...
(The border of the sleeve is [supposed to be] the same color as the rest of the borders)

Code:
        public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            if (winter)
            {
                try
                {
                    if (npc.direction == -1)
                    {
                        spriteBatch.Draw(mod.GetTexture("NPCs/Enthusiast_Shirt"), npc.Center - Main.screenPosition, new Rectangle(0, npc.frame.Y, 40, 60), Color.White, 0f, new Vector2(20, 30), 1f, SpriteEffects.None, 0f);
                    }
                    else
                    {
                        spriteBatch.Draw(mod.GetTexture("NPCs/Enthusiast_Shirt"), npc.Center - Main.screenPosition, new Rectangle(0, npc.frame.Y, 40, 60), Color.White, 0f, new Vector2(20, 30), 1f, SpriteEffects.FlipHorizontally, 0f);
                    }
                }
                catch (Exception e)
                {
                    Main.NewText(e + "");
                }
            }
        }

Is there a way to completely change which texture is used for the NPC itself? Like - instead of drawing a collar in front of it, I'd make it draw from a spritesheet that already has the shirt. I tried to figure it out, but didn't succeed.
 

Attachments

  • bla.PNG
    bla.PNG
    22.3 KB · Views: 198
Back
Top Bottom