Mod Server API: Difference between revisions
| [unchecked revision] | [unchecked revision] |
More additions to the player inventory docs. |
|||
| Line 9: | Line 9: | ||
All of a player's inventory is referenced by the <code>UserInventory</code> class which is accessed by the Inventory property: | All of a player's inventory is referenced by the <code>UserInventory</code> class which is accessed by the Inventory property: | ||
user.Inventory | user.Inventory | ||
The player's backpack, | The player's backpack, toolbar and clothing can be accessed through this object like this: | ||
user.Inventory.ActionBar | |||
user.Inventory.Backpack | user.Inventory.Backpack | ||
user.Inventory.Carried | user.Inventory.Carried | ||
user.Inventory.Clothing | user.Inventory.Clothing | ||
The items in these inventories can be accessed in a couple different ways as discussed | user.Inventory.Toolbar | ||
The items in these inventories can be accessed in a couple different ways as discussed in the Inventory Section. Each of these is an instance of [https://docs.play.eco/api/server/eco.gameplay/Eco.Gameplay.Items.Inventory.html Inventory]. | |||
[[File:ActionBarScreenshot.png|thumb|user.Inventory.ActionBar]] | |||
<code>user.Inventory.ActionBar</code> represents all the standard buttons used to open the backpack, economy viewer, etc. located next to the minimap. | |||
<code>user.Inventory.ActionBar</code> | |||
<code>user.Inventory.Backpack</code> represents all the stacks of items inside the player's backpack but not their clothes or items on their hotbar. | |||
<code>user.Inventory.Carried</code> | <code>user.Inventory.Carried</code> represents the stack of items the player can carry around such as dirt, stone, or logs. | ||
<code>user.Inventory.Clothing</code> represents the items of clothing the player is wearing. | |||
[[File:ToolbarScreenshot.png|thumb|user.Inventory.Toolbar]] | |||
<code>user.Inventory.Toolbar</code> represents the items on the player's toolbar where they put tools and other items they want quick access to. | |||
Revision as of 20:18, 12 February 2022
Introduction
This page provides some tips for how to interact with the Server API when you create mod that needs to interact with the game's runtime state or behaviour. A full comprehensive list of the entire API can be found at https://docs.play.eco/api/server/index.html.
Player
The User and Player class contain references to information about a specific player. The User class contains references to the player's owned objects, inventories, their stats, professions, etc. While the Player class has references to their location, technical server properties, player name, etc. If you have a User and need to get a Player instance it's as simple as:
user.Player
Or vice-versa:
player.User
Accessing the Player's Inventory
All of a player's inventory is referenced by the UserInventory class which is accessed by the Inventory property:
user.Inventory
The player's backpack, toolbar and clothing can be accessed through this object like this:
user.Inventory.ActionBar user.Inventory.Backpack user.Inventory.Carried user.Inventory.Clothing user.Inventory.Toolbar
The items in these inventories can be accessed in a couple different ways as discussed in the Inventory Section. Each of these is an instance of Inventory.
user.Inventory.ActionBar represents all the standard buttons used to open the backpack, economy viewer, etc. located next to the minimap.
user.Inventory.Backpack represents all the stacks of items inside the player's backpack but not their clothes or items on their hotbar.
user.Inventory.Carried represents the stack of items the player can carry around such as dirt, stone, or logs.
user.Inventory.Clothing represents the items of clothing the player is wearing.
user.Inventory.Toolbar represents the items on the player's toolbar where they put tools and other items they want quick access to.