tAPI [Discontinued] tAPI - A Mod To Make Mods

Status
Not open for further replies.
Validating Jsons...
DuckBone.json: Invalid JSON file.
Invalid token '"' in input string
Failed to build DuckMod.

Ive checked my json file several times and everything is fine
Code:
{
  "displayName": "Deal with it", 
  "size": [52,8],
  "maxStack": 1, 
  "value": [0,0,50,0], 
  "rare": 1, 
  "tooltip": "'Sells for a good price.'",
  "recipes":
  [{
  "items": { "Dirt Block": 5, "Fallen Star": 1}, 
  "tiles": [ "Work Bench" ], 
  "creates": 1 
  }]
} [/spoiler]
 
randomly while playing it crashes with this error.
49dq5tL.png

i couldn't copy the error since it also gives the "XXX stopped working" error.
help?
 
Hitting Save and Exit from a world with no player placed objects (vanilla or modded) works just fine, but doing the same from a world with modded objects (in chests, not even placed) and NPCs gives me a crash error on world saving. Player has modded items in inventory, but doesn't seem to affect anything judging from the blank world saving fine.

Couldn't copy the log because tAPI crashed, but here's a screenshot
tumblr_inline_nkcmiqx6uy1qfenm6.png


A little help? Sorry if this kind of issue has been asked before.
 
well you use the AI method for that.
Code:
public override void AI()
{
//your stuff here
}
That doesn't seem to work. It does work if I put it in Initialize instead of AI, but then it only works when the NPC spawns, and after that doesn't update.
Edit: it's because I'm doing it in MNPC, not in an actual NPC's .cs file. Can you help me with that?
How do you make a weapon make a noise on use?
How do you make mobs naturally spawn?
How do you make mobs produce a particle effect?
I can't really help you with the third and the first one, but as for the second, you can use the CanSpawn method.
Code:
public override bool CanSpawn(int x, int y, int type, Player player)
{
      if(player.zone["Jungle"] && Main.dayTime && Main.rand.Next(7) == 1) return true;
      else return false;
}
That one, for example, would have a 1 in 7 chance of spawning in the jungle at day.
Some zones are (amongst others, probably): Jungle (as used in the example), Corruption, Crimson, Snow, Overworld (AKA purity or the forest) and Hallow (these all are actual biomes and include eventual underground variants) but also Sky, Surface, Cavern and Hell (those of course depend on how deep the player is on the map, and are regardless of the biome the player is in). Some examples:
Code:
if(player.zone["Corruption"]) return true;
The monster can spawn in surface and underground Corruption.
Code:
if(player.zone["Hallow"] && player.zone["Cavern"]) return true;
The monster spawns in the underground Hallow only.
Code:
if(player.zone["Jungle"] && player.zone["Surface"]) return true;
The monster only spawns in the Jungle on the surface.
 
Last edited:
That doesn't seem to work. It does work if I put it in Initialize instead of AI, but then it only works when the NPC spawns, and after that doesn't update.

I can't really help you with the third and the first one, but as for the second, you can use the CanSpawn method.
Code:
public override bool CanSpawn(int x, int y, int type, Player player)
{
      if(player.zone["Jungle"] && Main.dayTime && Main.rand.Next(7) == 1) return true;
      else return false;
}
That one, for example, would have a 1 in 7 chance of spawning in the jungle at day.
Some zones are (amongst others, probably): Jungle (as used in the example), Corruption, Crimson, Snow, Overworld (AKA purity or the forest) and Hallow (these all are actual biomes and include eventual underground variants) but also Sky, Surface, Cavern and Hell (those of course depend on how deep the player is on the map, and are regardless of the biome the player is in). Some examples:
Code:
if(player.zone["Corruption"]) return true;
The monster can spawn in surface and underground Corruption.
Code:
if(player.zone["Hallow"] && player.zone["Cavern"]) return true;
The monster spawns in the underground Hallow only.
Code:
if(player.zone["Jungle"] && player.zone["Surface"]) return true;
The monster only spawns in the Jungle on the surface.
Or you can do it more easily like this:
Code:
public override bool CanSpawn(int x, int y, int type, Player player)
{
      return (player.zone["Jungle"] && Main.dayTime && Main.rand.Next(7) == 1);
}
This way it directly returns whether or not the proper conditions are met, instead of using "if" and "else" statements.

Edit:
Like is there a everywhere option ?
Yes, simply:
Code:
return (Main.rand.Next(7) == 1);
You can change the chances of it to your likings, just as Chadwick explained it. Or you can just use "return true;" but that would make that npc keep spawning and not give a chance for any other npcs to spawn.
 
Validating Jsons...
DuckBone.json: Invalid JSON file.
Invalid token '"' in input string
Failed to build DuckMod.

Ive checked my json file several times and everything is fine
Code:
{
  "displayName": "Deal with it",
  "size": [52,8],
  "maxStack": 1,
  "value": [0,0,50,0],
  "rare": 1,
  "tooltip": "'Sells for a good price.'",
  "recipes":
  [{
  "items": { "Dirt Block": 5, "Fallen Star": 1},
  "tiles": [ "Work Bench" ],
  "creates": 1
  }]
}
Are you sure this is the right file? The json validator detects no errors. You may have copied the wrong file, or not the whole thing. The file with the error will likely have an extra pair of quotes somewhere where they are unnecessary.

how do you have it spawn everywhere but restrained some?
If you mean have it spawn less, then you would just increase the number (to decrease the chance of spawning.) to increase its chance of spawning, make the number smaller.

ex:
Less chance to spawn:
Code:
return (Main.rand.Next(200) == 1);
(1 in 200 chance to spawn)

More chance to spawn:
Code:
return (Main.rand.Next(3) == 1);
(1 in 3 chance to spawn)
 
I don't believe this has already been documented, but when equipped with full shroomite armor, any ranged weapon's knockback will increase to "Insane" while cloaked. First off, Shroomite Armor is not supposed to increase Knockback. Second, when decloaked, knockback will not reduce to normal. I've tested this over a fresh install of tAPI (With no mods enabled, or even in my Mods/Local folder.), and it does not happen in vanilla.
 
how do you have it spawn everywhere but restrained some?
If you mean you want to prevent it spawning in a specific biome, then you put a ! before the condition you want to check.

The following example will spawn everywhere in the cavern except for the Hallow biome.
Code:
if(!player.zone["Hallow"] && player.zone["Cavern"]) return true;
 
If you mean you want to prevent it spawning in a specific biome, then you put a ! before the condition you want to check.

The following example will spawn everywhere in the cavern except for the Hallow biome.
Code:
if(!player.zone["Hallow"] && player.zone["Cavern"]) return true;
you don't need the if and return true, you can just put the conditions after "return" since return accepts any value that matches the type of method (int, bool, string etc...)

oh and BTW:
randomly while playing it crashes with this error.
49dq5tL.png

i couldn't copy the error since it also gives the "XXX stopped working" error.
help?
 
How would i make a boomerang that does the magnet sphere effect when thrown? Zapping enemies as it goes by. Or a boomerang that spawns the same homing bubbles that flairon spawns.
 
I got this error:
>>> 11:12:23 <<<
System.NullReferenceException: Object reference not set to an instance of an object.
at Shockah.ItemSuffixes.MItem.CanGetSuffixes(Terraria.Item item)
at Shockah.ItemSuffixes.MItem.Save(TAPI.BinBuffer bb)
at Terraria.Item.WriteCustomData(TAPI.BinBuffer bb, System.Boolean byName = True)
at Terraria.Item.Write(TAPI.BinBuffer bb, System.Boolean byName = True)
at TAPI.BinBuffer.Write(Terraria.Item i, System.Boolean byName = True)
at Terraria.Player.SavePlayer(Terraria.Player p, System.String playerPath, System.Boolean skipMapSave = False)
at Terraria.WorldGen.saveToonWhilePlayingCallBack(System.Object threadContext)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object state)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
and then my game crashed. When I restarted, my character wouldn't show up in the character screen, and the backup file didn't work either D:
 
Status
Not open for further replies.
Back
Top Bottom