FANDOM


The information in this article is for Terraria v1.0.6.1.

The chest class is responsible for handling all the chests in the game. Their contents are stored in an Item[] array, and there are a number of functions to deal with them. Interestingly, vendor inventories are considered chests, so this class also handles transactions as well.
Chests

A variety of different default chests

Read More


PropertiesEdit

Name Type Description
item Item[]

An array of Item instances that fuctions as the contents of the chest.

  • Array size is equal to maxItems
x int The x-coordinate of the chest in the world.
y int The y-coordinate of the chest in the world.

Static PropertiesEdit

Name Type Description
maxItems int

The maximum number of items all chests may hold. As this affects every chest in a profound way, changing it may produce unexpected behavior!

  • Default value is 20

MethodsEdit

Method Name Description
AddShop()
public void AddShop(Item newItem)
{
}

Adds newItem to the chest's item array. This is typically invoked when you sell an item to a store.

  • Returns no value
Clone()
public object Clone()
{
}

Returns a copy of the instance. This allows you to make changes to the object's data without affecting the original.

  • Returns a copy of the instance
SetupShop()
public void SetupShop(int type)
{
}

Pre-populates the chest with buyable items. The items that appear depend on the type provided.

  • Returns no value

  • 0: Nothing / default
  • 1: Merchant
  • 2: Arms Dealer
  • 3: Dryad
  • 4: Demolitionist
  • 5: Old Man

Static MethodsEdit

Method Name Description
CreateChest()
public static int CreateChest(int X, int Y)
{
}

Creates a chest at the given location, and returns the chest's index value in the Main.chest[] array.

  • -1: Could not create chest
  • Any other number: The index value of the chest
DestroyChest()
public static bool DestroyChest(int X, int Y)
{
}

Removes the chest at the given location.

  • true: The chest is empty and will be destroyed
  • false: The chest has items and cannot be destroyed
FindChest()
public static int FindChest(int X, int Y)
{
}

Returns the index of Main.chest[] for the chest at the given location.

  • -1: Could not find chest
  • Any other number: The index value of the chest
Unlock()
public static void Unlock(int X, int Y)
{
}

Unlocks the chest at the given location. Does not check the inventory for keys, so if you have any conditional statements, you should check them before calling this method.

  • Returns no value
UsingChest()
public static int UsingChest(int i)	
{
}

When supplied with an index for Main.chest[], this method returns the whoAmI of the player currently using that chest.

  • -1: Nobody is using the chest
  • Any other number: whoAmI of the player using the chest

NotesEdit

None yet

Classes in Terraria

Chest | Cloud | Collision | Dust | Gore | Item | Lighting | Liquid | Main | NPC | Player | Projectile | Recipe | Sign | Star | WorldGen

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.