tAPI [Discontinued] tAPI - A Mod To Make Mods

Status
Not open for further replies.
Another quick question shockah: I have created a MBase file that changes textures of default stuff, however at first when I log in npcs don't have the new texture. Reloading mods and returning to the world fixes this, however may be considered inconvenient for some. Is there any reason as to why this would be happening?

MBase.cs
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using TAPI;
using Terraria;
using jLib;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace jMod
{
    public sealed class MBase : ModBase
    {
        internal static MBase BaseInstance;
        public override void OnLoad()
        {
            BaseInstance = this;
            DateTime now = DateTime.Now;
            int day = now.Day;
            int month = now.Month;
            if (day == 20 && month == 10)
            {
                Main.npcTexture[5] = Main.goreTexture[GoreDef.gores["jMod:Stuff"]];
                Main.npcTexture[6] = Main.goreTexture[GoreDef.gores["jMod:Stuff2"]];
            }
        }
    }
}
Is OnLoad not sufficient for what I want?
The reason this will not work is because the game only loads NPC textures once NPCs are actually spawned in the game, if the textures have not been loaded yet - as Shockah mentioned.

What you need to do is set Main.NPCLoaded[type] = true; and make sure Main.npcTexture[type] has a key (specifically via setting it)
(If the npcTexture was not set but you set NPCLoaded to true you'd get a key not found exception in FindFrame because it will look for a texture key that it doesnt have)
 
The reason this will not work is because the game only loads NPC textures once NPCs are actually spawned in the game, if the textures have not been loaded yet - as Shockah mentioned.

What you need to do is set Main.NPCLoaded[type] = true; and make sure Main.npcTexture[type] has a key (specifically via setting it)
(If the npcTexture was not set but you set NPCLoaded to true you'd get a key not found exception in FindFrame because it will look for a texture key that it doesnt have)
Sorry yorai, what do you mean by key/where would I put said key?
 
when i launch terraria.bak it says please launch the game from your steam client. Also i don't have a terraria.exe file. Am I missing something important?
 
When i open terraria.bak it says open the game from your game client.
Right.. sorry , forgot that happens because of Steam's check.
You're going to have to rename the file to Terraria.exe or get Eikester's game launcher for convenience.

Sorry yorai, what do you mean by key/where would I put said key?
Key is how you refer the indexer of a Dictionary object. (the part in the square brackets)
Main.npcTexture is a dictionary, while Main.NPCLoaded is an array.
What you did to the textures in the code you posted (setting textures of key 5 and 6) was fine, and you just need to add Main.NPCLoaded[5] = true; and Main.NPCLoaded[6] = true; in that same area of code.

when i launch terraria.bak it says please launch the game from your steam client. Also i don't have a terraria.exe file. Am I missing something important?
You probably don't have windows set to display file extensions. I'm merely assuming that since you said you try to launch Terraria.bak rather than Terraria.bak.exe.

The files still have '.exe' on them , you just need to rename your "Terraria.bak" to "Terraria" in this case... (and rename "Terraria" to "tAPI" or whatever)
 
Right.. sorry , forgot that happens because of Steam's check.
You're going to have to rename the file to Terraria.exe or get Eikester's game launcher for convenience.


Key is how you refer the indexer of a Dictionary object. (the part in the square brackets)
Main.npcTexture is a dictionary, while Main.NPCLoaded is an array.
What you did to the textures in the code you posted (setting textures of key 5 and 6) was fine, and you just need to add Main.NPCLoaded[5] = true; and Main.NPCLoaded[6] = true; in that same area of code.


You probably don't have windows set to display file extensions. I'm merely assuming that since you said you try to launch Terraria.bak rather than Terraria.bak.exe.

The files still have '.exe' on them , you just need to rename your "Terraria.bak" to "Terraria" in this case... (and rename "Terraria" to "tAPI" or whatever)
Oh man I feel stupid, thanks so much. I feel as though you deserve to see what I was using that for, I'll send a PM:D
 
just a small thing i noticed:
"version": [0,1,0,0] doesn't work, only "version": "some.version" works, gives error
Code:
Key "version" is missing or is not a String!
 
just a small thing i noticed:
"version": [0,1,0,0] doesn't work, only "version": "some.version" works, gives error
Code:
Key "version" is missing or is not a String!
"version": [0.1.0.0]
Full stops rather than commas

woops I meant "version": "0.0.1"
 
i'm refering to the docs http://tapi.axxim.net/docs/ and according to that its either a string ("0.1") or an int array ([0,0,0,0]) so its either removed or a Bug
removed*.
We're likely going to release the r12 update today which contains quite a few bug fixes and new stuff to mess around with , and a changelog to follow it.

Sorry about the lack of tutorials and documentation update and quiet... we're all going through quite a lot of stuff right now.
 
Last edited:
A major glitch happened in tAPI; I opened the crafting window and right-clicked a torch, and it took one out of the crafting interface as if I took it from a chest
Now crafting torches gives me nothing, and the pick-up text says "Vanilla: ".
Is there any way to undo this? Placing the torches back in the crafting window does not work
I tested this with all my characters on all worlds, apparently stealing from the crafting window has a global effect

EDIT: I fixed it by reinstalling tAPI. But I find that this bug may become annoying to those who use the crafting window.
 
Last edited:
A major glitch happened in tAPI; I opened the crafting window and right-clicked a torch, and it took one out of the crafting interface as if I took it from a chest
Now crafting torches gives me nothing, and the pick-up text says "Vanilla: ".
Is there any way to undo this? Placing the torches back in the crafting window does not work
I tested this with all my characters on all worlds, apparently stealing from the crafting window has a global effect

EDIT: I fixed it by reinstalling tAPI. But I find that this bug may become annoying to those who use the crafting window.
Looking into it for r12.
 
Is it alright if i ask you to check my code that i have made for a sword i want to incorporate in the game? When i go into the tAPI Builder to create the mod it just says this:
"Building mod Sword

Validating Jsons...
TheFabledSword.json: Invalid JSON file.
Invalid token ':' in input string
Failed to build Sword"

Also do i still need tAPI Packer to compile the mod? Or is there a new way to compile the mod as of a new update?
 
Status
Not open for further replies.
Back
Top Bottom