Skip to content

nut.item

rebel1324 edited this page Dec 22, 2014 · 1 revision

This library contains all function to handle items and inventories. You can do any item and inventory manipulation/assignment with this library. If you understand how it works, Item and Inventory Script is going to be real easiest part in NutScript.

Tables

  • nut.item.list
  • Stores all Item Classes Objects in this table. You can get the item's information by calling nut.item.list[uniqueID].
  • nut.item.base
  • Stores all Item Base Classes Objects in this table.
  • nut.item.instances
  • Stores all "Loaded" Items Objects on the server. "Loaded" means, Once item saved in the database and got wiped on instance table, you must initiate the item on the server before you use it for your own purpose. "Item Index" is related with this table. You can get specific item's data with nut.item.instances[itemIndex]. Remember, If it does not exist, It needs to be loaded from the database or it just does not exist.
  • nut.item.inventories
  • Stores all "Loaded" Inventory Objects on the server. Meaning of "Loaded" is explained on the previous element, Item Instances.

Methods

  • nut.item.instance()
  • Purpose: Creates new instance of Item Object on the server. This function does not returns any value. You need to put your post function calls on "callback" parameter.
  • nut.item.registerInv()
  • Purpose: Creates new type of inventory. Creating new inventory type allows you to sync inventory's size without sending extra information about the storage on the client.
  • nut.item.newInv()
  • Purpose: Creates new instance of Inventory Object on the server. This function does not returns any value. You need to put your post function calls on "callback" parameter.
  • nut.item.load()
  • Purpose: Load and register item from lua file from the provided path. This function is for internal use.
  • nut.item.register()
  • Purpose: Creates new Item Class on the server. You can create/generate new items with this function. But, For External use of this function, You need to provide "true" on luaGenerated parameter.
  • nut.item.new()
  • Purpose: Creates new Item Object. This function is for internal use.
  • nut.item.createInv()
  • Purpose: Creates new Inventory Object. This fucntioin is for internal use.
  • nut.item.restoreInv()
  • Purpose: Load Inventory Contents from the server. This function get called when invnetory is exist but it has no content. This function is for internal use.

Structures

Objects

Item Structure

  • uniqueID - A String that displays Class ID of the Item. The information of generic item data can be identified with this string.
  • index - A String that displays Index of the Item. The information of unique item data can be identified with this string.
  • data - A Table contains unique data of the item.
  • hooks - A Table contains unique hooks of the item. Usually hooks are added on the item that has base but has unique ability or requires small unique feature.
  • functions - A Table contains list of actions for the item. All actual functions are stored in this table.