-
Notifications
You must be signed in to change notification settings - Fork 77
Item
The item object is pretty important object in the NutScript framework. If you're making some item based roleplay like STALKER, Metro or CityRP, You must look at this document pretty well.
The item object can be accessed by traversal of inventory object or by specifiyng the id of the item. Remember, Item is "Object". It's not just group of table just like NS 1.0.
By having the Item Object, Each item in the gamemode is very unqiue, which means you can make every item special without making another items in a row. But, To make more awesome stuffs with NS 1.1's Item System, You need to understand how it's working first.
To get specific item Object's data = nut.item.instances[Item Index ID]
To get specific item Class's data = nut.item.list[Item Class ID]
id- This is the numeric key for the item in the database. This is unique for each item and is shared.
uniqueID- This is the string for the item in the database. This is referring the actual item data.
data- This is the table for the item in the database. You can access/set variables on the specific item with ItemObject:getData(key), ItemObject:setData(key, value).
invID- This is the numeric value for the item in the database. This value displays where is item is parented. If the invID is 0 or nil, The item is on the ground or in the virtual space. The position value is gridX and gridY
item:getID()- Returns the
idproperty. item:getDesc()- Returns the description of the item.
item:print(isDetail)- Prints simple data of object. (tostring only returns id).
item:printData()- Prints all data of the item object.
item:call(method, client, entity, ...)- Calls the function of the item.
item:hook(name, func)- Calls the hook of the function of the item.
item:getOwner()- Returns the actual owner(player) of the item.
item:setData(key, value, receivers, noSave, checkEntity)- Sets persisting value to the item object.
- Example 1
item:getData(key, [default])- Gets persisting value of the item object.
item:remove()- Removes Item Object.
item:spawn(spawnPosition, spawnAngles)- Spawn item on the world.
item:getEntity()- Gets the current entity that the item object is posessing on.
item:transfer(invID, x, y, client, noReplication, isLogical)- Transfers the item to the other Inventory Object.