tAPI [Discontinued] tAPI - A Mod To Make Mods

Status
Not open for further replies.
Anyone else getting this error?

LitJson.JsonException: ModInfo Error: The given key was not present in the dictionary. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at tAPI_Builder.MainWindow.<>c__DisplayClass8.<BtnBuild_Click>b__0()
--- End of inner exception stack trace ---
at tAPI_Builder.MainWindow.<>c__DisplayClass8.<BtnBuild_Click>b__0()
 
Anyone else getting this error?

LitJson.JsonException: ModInfo Error: The given key was not present in the dictionary. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at tAPI_Builder.MainWindow.<>c__DisplayClass8.<BtnBuild_Click>b__0()
--- End of inner exception stack trace ---
at tAPI_Builder.MainWindow.<>c__DisplayClass8.<BtnBuild_Click>b__0()
Are you getting that error in the tAPI builder, or is the builder just reporting an error? If the builder itself is erroring, I've got no idea what's happening.
 
Are you getting that error in the tAPI builder, or is the builder just reporting an error? If the builder itself is erroring, I've got no idea what's happening.
I was getting it in tAPI builder, but i've fixed it now, it was just a bug, so i reinstalled tAPI. I just forgot to update that reply saying the error
 
2 Questions:

1) How do I make an item classify as a bullet, and the projectile will give off light like other bullets?
2) How do I override what is shot? For example, I take in a certain type of ammo, but shoot out a completely new projectile?
 
2 Questions:

1) How do I make an item classify as a bullet, and the projectile will give off light like other bullets?
2) How do I override what is shot? For example, I take in a certain type of ammo, but shoot out a completely new projectile?

For question 2, set the "useAmmo" to whatever, and the "shoots" to your projectile. That's how I do it anyway.

EDIT: Yeah, on the ammo you use, set the "ammo" to the name of it. I just did it with an ore ("ammo": "LiricaOreItem") and then on the gun I put "useAmmo": "ModName:LiricaOreItem"
 
2 Questions:

1) How do I make an item classify as a bullet, and the projectile will give off light like other bullets?
2) How do I override what is shot? For example, I take in a certain type of ammo, but shoot out a completely new projectile?

You set your custom bullet's "Ammo" setting in your bullet's .json file to the general bullet ammo, which is 14. For example.

Code:
{
    "displayName": "Example Rounds A",
    "size": [12,12],
    "scale": 1,
    "maxStack": 999,
    "value": [0,0,5,0],  
    "rare": 2,
    "tooltip": ["Example Rounds A"],
    "ammo": 14,
    "shoot": "MPT:ExampleProjectileA",
    "damage": 10,
    "consumable": true,

    "recipes":
    [{
        "items": { "Dirt Block": 1},
        "creates": 111
    }]
}

You can also create your own ammo category, just make sure all your ammo has the same "Ammo" name. This is in my Projectile guide btw.

If you want it to light, then you add a .cs file to your projectile and put in

Code:
public override void AI()
{
projectile.light = 0.9f; //You can set it even higher to even 10 which lights up 3/4 of the screen.
}
 
2) How do I override what is shot? For example, I take in a certain type of ammo, but shoot out a completely new projectile?

Sorry for double post but you can do this by just using the PreShoot method. You make another projectile and then return false so that way only the projectile you name will spawn instead of the ammo's projectile.

Code:
public override bool PreShoot(Player player, Vector2 position, Vector2 velocity, int projType, int damage, float knockback) 
        {
            Projectile.NewProjectile(position.X, position.Y, velocity.X, velocity.Y, "ModInternalName:ModProjectile", damage, knockback, player.whoAmI);
            return false;
        }

The ammo is still used and it fires a custom projectile instead this way.
 
The easiest way imo would be to make 3 different weapons (3 different .json files) that share the same .cs file for switching forms (easily done with the "code" property in the .json files). Then for switching the weapon's form, you'd have to change the item itself in the player's inventory (making sure to preserve the prefix). If you want super custom behavior on one of the forms, then that form could use its own .cs file that extends the one that the others use. As for the part that actually changes the form, I'm not sure how you'd go about doing that in a convenient way.

Ok so i got my 3 different weapon json files done. But what do i need to put in the 'code' property now? I havent found out how to use that.
 
Ok so i got my 3 different weapon json files done. But what do i need to put in the 'code' property now? I havent found out how to use that.
Basically for the code put the name of your class. For example, if WeaponName is in the namespace ModName.Items, then put "ModName.Items.WeaponName". However, if the class name has the same name as the .json file, then you do not need a code property, since it will choose it by default.
 
Basically for the code put the name of your class. For example, if WeaponName is in the namespace ModName.Items, then put "ModName.Items.WeaponName". However, if the class name has the same name as the .json file, then you do not need a code property, since it will choose it by default.
ok so if my namespace were mod and my weapons are named Sword1, Sword2, and Sword3 for example,\. then I would put the code property in all 3 jsons and do "ModName.Items.Sword" for all 3? and then name the cs file "Sword"?
 
I don't actually think you need the ModName part, just the folder name and the .cs file name. It worked for me anyways...
Well its a couple more letters typed. lol.
But i got that working. now im guessing to switch it out, id need to use an if statement correct? How do i make a key press do something with tAPI? im used to working in unity so its usually
"if (input.GetKeyDown(KeyCode.<key>)){ <function> }"

Another question, now that they're all following just one class, how do I make each one have it's own separate class also so when I switch from one to the other, each has their own effects?

im still fairly new to C# but i know a little bit about what im doing but not much. Sorry if im asking all these noob questions.
 
Last edited:
Hm, looking at the source code, you're right. Either way works.
So i loaded terraria after adding the this line of code to my json files:
Code:
WeaponF1

"displayName": "Crescent Rose Scythe Form",
"code": "RWBY.Items.CrescentRose",
Code:
WeaponF2

"displayName": "Crescent Rose Gun Form",
"code": "RWBY.Items.CrescentRose",
Code:
WeaponF3

"displayName": "Crescent Rose Scythe Gun Form",
"code": "RWBY.Items.CrescentRose",


I got this error.
System.InvalidCastException: Unable to cast object of type 'RWBY.Items.CrescentRose' to type 'TAPI.ModItem'.
at TAPI.CodableItem.SetupModEntities()
at Terraria.Item.SetDefaults(System.Int32 Type, System.Boolean noMatCheck = False)
at TAPI.RecipeResolver.Resolve()
at TAPI.ResolverQueue.ResolveAll()
at TAPI.Mods.Load()
 
So i loaded terraria after adding the this line of code to my json files:
Code:
WeaponF1

"displayName": "Crescent Rose Scythe Form",
"code": "RWBY.Items.CrescentRose",
Code:
WeaponF2

"displayName": "Crescent Rose Gun Form",
"code": "RWBY.Items.CrescentRose",
Code:
WeaponF3

"displayName": "Crescent Rose Scythe Gun Form",
"code": "RWBY.Items.CrescentRose",


I got this error.
System.InvalidCastException: Unable to cast object of type 'RWBY.Items.CrescentRose' to type 'TAPI.ModItem'.
at TAPI.CodableItem.SetupModEntities()
at Terraria.Item.SetDefaults(System.Int32 Type, System.Boolean noMatCheck = False)
at TAPI.RecipeResolver.Resolve()
at TAPI.ResolverQueue.ResolveAll()
at TAPI.Mods.Load()
You need to make sure that your CrescentRose class extends TAPI.ModItem.
 
What is wrong with this coding? It's my brothers and I can't find anything wrong with it. Please help.





Code:
{
    "internalName": "DaBomb",
    "displayName": "DaBomb",
    "texture": "Items/DaBomb",
    "size": [20,20],
    "maxStack": 1,
    "value": [99,99,99,99],
    "useStyle": 1,
    "useAnimation": 1,
    "useTime": 1,
    "damage": 900,
    "knockBack": 5,
    "useSound": 1,
    "autoReuse": true,
    "useTurn": true,
    "melee": true,
   
    "recipes":
    [{
        "items": { "Dirt Block": 10 },
        "creates": 1
    }]
   
   
}
 
o.o A friend of mine got a server running up with tAPI? they ran the Dedicated server (which I did so i'm sort of confused) this was of course without me on it. Any ideas? They were only running Thorium and probably a few of Shockah's mods that are compatible.
 
Status
Not open for further replies.
Back
Top Bottom