tAPI Getting Started with Modding

Status
Not open for further replies.
That is what i thought had happened. You see, the placement of that code is wrong.
You placed it in the wrong folder. You had created the file in your "Tiles" folder when you should've placed it in your
Testmod folder. - This is where you should create a new file ( name it whatever you want) and paste in the following code
Code:
using Terraria;
using TAPI;

namespace Test
{
    public class Test : ModWorld
    {
        public override void WorldGenPostGen()
        {
            ModifyWorld();
        }

public void ModifyWorld()
{
Main.statusText = "Adding Linite..."; //feel free to tweak
int Amount_Of_Spawns = 100+(int)(Main.maxTilesY/5); //feel free to tweak
for(int i=0;i<Amount_Of_Spawns;i++) AddMyOres();
}
public void AddMyOres()
{
int LowX = 200; //after ocean on left edge of map
int HighX = Main.maxTilesX-200; //before ocean on right edge of map
int LowY = (int)Main.worldSurface; //where the brown background and the sky background meets
int HighY = Main.maxTilesY-200; //where hell and the grey background meets

int X = WorldGen.genRand.Next(LowX,HighX); //don't touch
int Y = WorldGen.genRand.Next(LowY,HighY); //don't touch

int OreMinimumSpread = 5; //feel free to tweak
int OreMaximumSpread = 15; //feel free to tweak

int OreMinimumFrequency = 10; //feel free to tweak
int OreMaximumFrequency = 20; //feel free to tweak

int OreSpread = WorldGen.genRand.Next(OreMinimumSpread,OreMaximumSpread+1); //don't touch
int OreFrequency = WorldGen.genRand.Next(OreMinimumFrequency,OreMaximumFrequency+1); //don't touch

WorldGen.OreRunner(X, Y, (double)OreSpread, OreFrequency, TileDef.byName["Test:Linite"]);
}
    }
}
-Tiles - This is where you place the tile ITSELF, not the code to generate it.
 
That is what i thought had happened. You see, the placement of that code is wrong.
You placed it in the wrong folder. You had created the file in your "Tiles" folder when you should've placed it in your
Testmod folder. - This is where you should create a new file ( name it whatever you want) and paste in the following code
Code:
using Terraria;
using TAPI;

namespace Test
{
    public class Test : ModWorld
    {
        public override void WorldGenPostGen()
        {
            ModifyWorld();
        }

public void ModifyWorld()
{
Main.statusText = "Adding Linite..."; //feel free to tweak
int Amount_Of_Spawns = 100+(int)(Main.maxTilesY/5); //feel free to tweak
for(int i=0;i<Amount_Of_Spawns;i++) AddMyOres();
}
public void AddMyOres()
{
int LowX = 200; //after ocean on left edge of map
int HighX = Main.maxTilesX-200; //before ocean on right edge of map
int LowY = (int)Main.worldSurface; //where the brown background and the sky background meets
int HighY = Main.maxTilesY-200; //where hell and the grey background meets

int X = WorldGen.genRand.Next(LowX,HighX); //don't touch
int Y = WorldGen.genRand.Next(LowY,HighY); //don't touch

int OreMinimumSpread = 5; //feel free to tweak
int OreMaximumSpread = 15; //feel free to tweak

int OreMinimumFrequency = 10; //feel free to tweak
int OreMaximumFrequency = 20; //feel free to tweak

int OreSpread = WorldGen.genRand.Next(OreMinimumSpread,OreMaximumSpread+1); //don't touch
int OreFrequency = WorldGen.genRand.Next(OreMinimumFrequency,OreMaximumFrequency+1); //don't touch

WorldGen.OreRunner(X, Y, (double)OreSpread, OreFrequency, TileDef.byName["Test:Linite"]);
}
    }
}
-Tiles - This is where you place the tile ITSELF, not the code to generate it.
Well, I 've tried and I get the same error ... do not know what can happen ..
Code:
System.Collections.Generic.KeyNotFoundException: No key "Test:Linite" found
  at TAPI.WrapperDictionary`2.get_Item( key)
  at Test.Test.AddMyOres() in \Testmod\Linite.cs at line 38
  at Test.Test.ModifyWorld() in \Testmod\Linite.cs at line 17
  at Test.Test.WorldGenPostGen() in \Testmod\Linite.cs at line 10
  at TAPI.Hooks.Call(System.Action[] ts)
  at Terraria.WorldGen.generateWorld(System.Int32 seed = -1)
  at Terraria.WorldGen.worldGenCallBack(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()
 
[how would you/is it possible to] do an item like boots of ostra(i mean like an "on step on change block type" thing) or some kind of accessory that produces ice on water surface you touch, ect?

is there a "block property" thing that lets you tag something as climbable, kill fall damage or perhaps make it bouncy?

also how about something like lefthanded boulders to roll the other way?
(sorry lot of questions, theres gotta be a tutorial somewhere i missed)
 
Last edited:
Here you go! If this code does not work, then there is an error on the tile end of things.
Just place it in your mods main folder, and edit with your information. Its case and space sensitive!
 

Attachments

  • Hereyougofriend.zip
    718 bytes · Views: 131
I know I already posted about this, but has anyone figured out yet why I'm getting the error: "'TAPI.Defs' does not contain a definition for 'npcs'" from this?
http://pastebin.com/bHRpH218
Try this, i just put this into the builder and it worked
Code:
using Terraria;
using System;
using System.Diagnostics;
using Microsoft.Xna.Framework;

using TAPI;

namespace LifeCrystals.Items
{
public class Soo : ModItem
    {
        public override bool? UseItem(Player p)
        {
            if(Main.netMode != 1)
            {
                //int mX = (int)(Main.screenPosition.X + Main.mouseX);
                //int mY = (int)(Main.screenPosition.Y + Main.mouseY);
                int npcID = NPC.NewNPC((int)p.Center.X, (int)p.Center.Y - 200, NPCDef.byName["LifeCrystals:CrystalGuardian"].type, 0);
                if (Main.netMode == 2)
                    NetMessage.SendData(23, -1, -1, "", npcID, 0.0f, 0.0f, 0.0f, 0);
            }
            if(Main.netMode != 2)
            {
                Main.PlaySound(2, (int)p.Center.X, (int)p.Center.Y, 37);
                Vector2 npcPos = p.position - new Vector2(0, 200);
                for (int m = 0; m < 15; m++)
                {
                    int dustID = Dust.NewDust(npcPos, p.width, p.height, 60, Main.rand.Next(-10, 10) * 1f, Main.rand.Next(-10, 10) * 1f, 100, Color.White, 3.5f);
                    Main.dust[dustID].noGravity = true;
                }
            }
            return true;
        }
    }
}
 
Here you go! If this code does not work, then there is an error on the tile end of things.
Just place it in your mods main folder, and edit with your information. Its case and space sensitive!
God !! at last !!! Thank you so much , now I just have to look and confirm that appears
 
Inside of your tiles code, did you put in "drop": "Internalmodname:Oreinitemfoldersname", ?
 
The ore item that you want it to drop should be in the items folder.
we will see that I am not clarifying ..
I have the "tiles " folder PNG and json , which has this code
Code:
{
   "displayName": "Calcium Ore",
   "size": [18,18],
   "frameWidth": 16,
   "frameHeight": 16,
   "solid": true,
   "blocksLight": true,
   "blocksSun": true,
   "mergeDirt": true,
   "drop": "Test:CalciumOre",
   "dust": 61,
   "sound": 1,
   "soundGroup": 21,
   "tileMerge": ["#NormalTiles", "#!Ores"],  /* Can be an array comprising of ints or strings, #NormalTiles makes it blend with all non-special tiles, ! inverts it */
   "mapColor": [126, 160, 142],
   "mapHoverText": "Calcium Ore"
}
and then have another png with mineral alone, where I have to put that image? must have a .json ?
 
You put a seperate Json and picture of the singular ore (the one you see in your inventory) inside of the "Items" Folder.
Name it CalciumOre.json (so your tile will drop it)
Code:
{
    "displayName": "Calcium Ore",
    "size": [#,#],
    "maxStack": 999,
    "value": [0,0,200,0],
    "rare": 1,
    "tooltip": "'Insertwordshere'",
}
For size that is the size of the image. so if it was 16 x 16 you would put 16,16 in the brackets.
 
You put a seperate Json and picture of the singular ore (the one you see in your inventory) inside of the "Items" Folder.
Name it CalciumOre.json (so your tile will drop it)
Code:
{
    "displayName": "Calcium Ore",
    "size": [#,#],
    "maxStack": 999,
    "value": [0,0,200,0],
    "rare": 1,
    "tooltip": "'Insertwordshere'",
}
For size that is the size of the image. so if it was 16 x 16 you would put 16,16 in the brackets.
I separated the ore alone ( .png) and created the " .json " copying what you left me and changed the size, but when compiling gives me this error.
Code:
========================================
Building mod Testmod

Validating Jsons...
CalciumOre.json: Invalid JSON file.
Invalid token '}' in input string
Failed to build Testmod.

========================================

Built 0 mods.
EDIT: Solved this error :D
 
Status
Not open for further replies.
Back
Top Bottom