tAPI tAPI Community Resources - Development assistance for developers, by developers.

How would I find the players current health and mana? I want to make an accessory that heals the player while their heath and mana are at certain values
I would probably just do the value check in the effects of the accessories, sort of something like this.

Code:
public override void Effects(Player player)
{
     if(player.statLife < 200 && player.statMana < 200)
     {
        //Does something.
     }
}
 
Hello all.
I''m trying to modify the dialogue that's said by town NPCs, but I can't get it to work. It seems like the PostSetChat hook isn't working, even after I reduced the coode to it's bare minimum.
Code:
public override string PostSetChat(string chat) //called after chat has been set.
{
    Main.NewText("Type: " + npc.type);
    return "Hello World";
}
I have this in my MNPC class, which I know works because I'm successfully using the PostSetupShop hook in the same class.

Could anyone tell me what I might be doing wrong? Thanks.
 
This probably doesn't belong here, but i can't get tAPI to even run anymore
It crashes with no message before it even opens up
I found some sort of crash log that says:

Microsoft.Xna.Framework.Content.ContentLoadException: Error loading "Images\CraftButton". File not found.
at Microsoft.Xna.Framework.Content.ContentManager.OpenStream(System.String assetName)
at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset(System.String assetName, System.Action`1[[System.IDisposable, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] recordDisposableObject)
at Microsoft.Xna.Framework.Content.ContentManager.Load(System.String assetName)
at Terraria.Main.LoadContent()
at Microsoft.Xna.Framework.Game.Initialize()
at Terraria.Main.Initialize()
at Microsoft.Xna.Framework.Game.RunGame(System.Boolean useBlockingRun)
at Terraria.Program.Main(System.String[] args)
System.IO.FileNotFoundException: Error loading "Content\Images\CraftButton.xnb". File not found.
at Microsoft.Xna.Framework.TitleContainer.OpenStream(System.String name)
at Microsoft.Xna.Framework.Content.ContentManager.OpenStream(System.String assetName)
 
This probably doesn't belong here, but i can't get tAPI to even run anymore
It crashes with no message before it even opens up
I found some sort of crash log that says:

Microsoft.Xna.Framework.Content.ContentLoadException: Error loading "Images\CraftButton". File not found.
at Microsoft.Xna.Framework.Content.ContentManager.OpenStream(System.String assetName)
at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset(System.String assetName, System.Action`1[[System.IDisposable, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] recordDisposableObject)
at Microsoft.Xna.Framework.Content.ContentManager.Load(System.String assetName)
at Terraria.Main.LoadContent()
at Microsoft.Xna.Framework.Game.Initialize()
at Terraria.Main.Initialize()
at Microsoft.Xna.Framework.Game.RunGame(System.Boolean useBlockingRun)
at Terraria.Program.Main(System.String[] args)
System.IO.FileNotFoundException: Error loading "Content\Images\CraftButton.xnb". File not found.
at Microsoft.Xna.Framework.TitleContainer.OpenStream(System.String name)
at Microsoft.Xna.Framework.Content.ContentManager.OpenStream(System.String assetName)
Sounds like you might need to verify your games cache.
 
Am i seriously the only person in existence that can't launch tAPI?
Terraria 1.2.4.1 and earlier had a file named 'CraftButton.xnb' in the folder 'SteamApps\common\Terraria\Content\Images'.

Terraria 1.3 and newer have files named 'Craft_Toggle_0.xnb' through 'Craft_Toggle_3.xnb' in the folder 'SteamApps\common\Terraria\Content\Images\UI'.

tAPI is made for Terraria 1.2.4.1, and thus uses the images Terraria 1.2.4.1 uses.

It seems as though you updated Terraria to 1.3, which deletes the old CraftButton file, and creates the 4 new Craft_Toggle buttons. And now you're trying to run tAPI and it can't find the CraftButton file. If you were to get this file, and any other files the 1.3 update may have deleted, you should be able to run tAPI again. Just ask around in the forums for someone that hasn't updated yet to share that file with you. And make sure to put it in the folder I mentioned above.

Edit:
I used a file recovery program to undelete the file. I'll post it here. If it violates some rule to post it, I'll remove the link.
 

Attachments

  • CraftButton.zip
    588 bytes · Views: 288
Last edited:
This probably doesn't belong here, but i can't get tAPI to even run anymore
It crashes with no message before it even opens up
I found some sort of crash log that says:

Microsoft.Xna.Framework.Content.ContentLoadException: Error loading "Images\CraftButton". File not found.
at Microsoft.Xna.Framework.Content.ContentManager.OpenStream(System.String assetName)
at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset(System.String assetName, System.Action`1[[System.IDisposable, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] recordDisposableObject)
at Microsoft.Xna.Framework.Content.ContentManager.Load(System.String assetName)
at Terraria.Main.LoadContent()
at Microsoft.Xna.Framework.Game.Initialize()
at Terraria.Main.Initialize()
at Microsoft.Xna.Framework.Game.RunGame(System.Boolean useBlockingRun)
at Terraria.Program.Main(System.String[] args)
System.IO.FileNotFoundException: Error loading "Content\Images\CraftButton.xnb". File not found.
at Microsoft.Xna.Framework.TitleContainer.OpenStream(System.String name)
at Microsoft.Xna.Framework.Content.ContentManager.OpenStream(System.String assetName)

Terraria 1.2.4.1 and earlier had a file named 'CraftButton.xnb' in the folder 'SteamApps\common\Terraria\Content\Images'.

Terraria 1.3 and newer have files named 'Craft_Toggle_0.xnb' through 'Craft_Toggle_3.xnb' in the folder 'SteamApps\common\Terraria\Content\Images\UI'.

tAPI is made for Terraria 1.2.4.1, and thus uses the images Terraria 1.2.4.1 uses.

It seems as though you updated Terraria to 1.3, which deletes the old CraftButton file, and creates the 4 new Craft_Toggle buttons. And now you're trying to run tAPI and it can't find the CraftButton file. If you were to get this file, and any other files the 1.3 update may have deleted, you should be able to run tAPI again. Just ask around in the forums for someone that hasn't updated yet to share that file with you. And make sure to put it in the folder I mentioned above.

Edit:
I used a file recovery program to undelete the file. I'll post it here. If it violates some rule to post it, I'll remove the link.

It's more that just the craft button that was replaced. A whole bunch more like the rain, cursor and player .xnb files were renamed. With some, you could make an educated guess what the old filename was and create a duplicate file with the old name, but the player files have completely different names, like "Skin_Arm" became "Player_0_7".

Fortunately, I have a computer with the previous version of Terraria. Tomorrow, I'll find out which files were renamed and - if I'm allowed - upload them here.
 
Tried to make an invasion event, made an NPC to test it with, got this error right here
>>> Singleplayer: 00:25:56 <<<
TAPI.Mods+LoadException: ThatMod.tapi: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'ThatMod.OmicronianMoon' threw an exception. ---> System.Collections.Generic.KeyNotFoundException: No key "ThatMod:OmicronianProbe" found
at TAPI.WrapperDictionary`2.get_Item(TKey key) in x:\tAPI Core\tAPI\DataStructures\WrapperDictionary.cs:line 45
at ThatMod.OmicronianMoon..cctor() in c:\Users\Ursus Persus Mersus\Documents\My Games\Terraria\tAPI\Mods\Sources\ThatMod\OmicronianMoon.cs:line 21
--- End of inner exception stack trace ---
at ThatMod.OmicronianMoon..ctor()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at TAPI.ReflectionHelper.Instantiate(Type type, Type[] argTypes, Object[] args) in x:\tAPI Core\tAPI\Util\ReflectionHelper.cs:line 41
at TAPI.ReflectionHelper.Instantiate(Type type, Object[] args) in x:\tAPI Core\tAPI\Util\ReflectionHelper.cs:line 31
at TAPI.Mod.<Load>b__0(BinBuffer bb) in x:\tAPI Core\tAPI\Mod\Mod.cs:line 157
at TAPI.Mods.HandleTapiModFile(FPath path, Action`1 action) in x:\tAPI Core\tAPI\Mod\Mods.cs:line 449
at TAPI.Mods.HandleModFile(FPath path, Action`1 action) in x:\tAPI Core\tAPI\Mod\Mods.cs:line 427
at TAPI.Mod.Load() in x:\tAPI Core\tAPI\Mod\Mod.cs:line 107
at TAPI.Mods.Load() in x:\tAPI Core\tAPI\Mod\Mods.cs:line 539
at Mods.Load()

Mods used:
How would i solve this?
 
Tried to make an invasion event, made an NPC to test it with, got this error right here

How would i solve this?
The error message indicates where the problem occurs:

>>> Singleplayer: 00:25:56 <<<
TAPI.Mods+LoadException: ThatMod.tapi: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'ThatMod.OmicronianMoon' threw an exception. ---> System.Collections.Generic.KeyNotFoundException: No key "ThatMod:OmicronianProbe" found
at TAPI.WrapperDictionary`2.get_Item(TKey key) in x:\tAPI Core\tAPI\DataStructures\WrapperDictionary.cs:line 45
at ThatMod.OmicronianMoon..cctor() in c:\Users\Ursus Persus Mersus\Documents\My Games\Terraria\tAPI\Mods\Sources\ThatMod\OmicronianMoon.cs:line 21
--- End of inner exception stack trace ---
at ThatMod.OmicronianMoon..ctor()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at TAPI.ReflectionHelper.Instantiate(Type type, Type[] argTypes, Object[] args) in x:\tAPI Core\tAPI\Util\ReflectionHelper.cs:line 41
at TAPI.ReflectionHelper.Instantiate(Type type, Object[] args) in x:\tAPI Core\tAPI\Util\ReflectionHelper.cs:line 31
at TAPI.Mod.<Load>b__0(BinBuffer bb) in x:\tAPI Core\tAPI\Mod\Mod.cs:line 157
at TAPI.Mods.HandleTapiModFile(FPath path, Action`1 action) in x:\tAPI Core\tAPI\Mod\Mods.cs:line 449
at TAPI.Mods.HandleModFile(FPath path, Action`1 action) in x:\tAPI Core\tAPI\Mod\Mods.cs:line 427
at TAPI.Mod.Load() in x:\tAPI Core\tAPI\Mod\Mod.cs:line 107
at TAPI.Mods.Load() in x:\tAPI Core\tAPI\Mod\Mods.cs:line 539
at Mods.Load()

Start by looking at the highlighted line.
 
Back
Top Bottom