Mod Server API: Difference between revisions

From Eco - English Wiki
[unchecked revision][unchecked revision]
(Updated Player and Player Inventory sections)
(More additions to the player inventory docs.)
Line 6: Line 6:
Or vice-versa:
Or vice-versa:
  player.User
  player.User
=== Accessing the Player's Inventory ===
=== Accessing the Player's Inventory ===
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, action bar, carried items and clothing can be accessed through this object:
The player's backpack, action bar, carried items and clothing can be accessed through this object like this:
  user.Inventory.Backpack
  user.Inventory.Backpack
  user.Inventory.ActionBar
  user.Inventory.ActionBar
  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 here (TBD link to generic inventories section)
<code>user.Inventory.Backpack</code> is an Inventory instance that lists all the stacks of items inside the player's backpack but not their clothes or items on their hotbar.
<code>user.Inventory.ActionBar</code>is an Inventory instance that lists all the standard buttons used to open the backpack, economy viewer, etc. located next to the minimap.
What the action bar looks like in-game:
[[File:ActionBarScreenshot.png|left|thumb|user.Inventory.ActionBar]]
<code>user.Inventory.Carried</code> is an Inventory instance that represents the stack of items the player can carry around such as dirt, stone, or logs.

Revision as of 04:48, 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, action bar, carried items and clothing can be accessed through this object like this:

user.Inventory.Backpack
user.Inventory.ActionBar
user.Inventory.Carried
user.Inventory.Clothing

The items in these inventories can be accessed in a couple different ways as discussed here (TBD link to generic inventories section)

user.Inventory.Backpack is an Inventory instance that lists all the stacks of items inside the player's backpack but not their clothes or items on their hotbar.

user.Inventory.ActionBaris an Inventory instance that lists all the standard buttons used to open the backpack, economy viewer, etc. located next to the minimap.

What the action bar looks like in-game:

File:ActionBarScreenshot.png
user.Inventory.ActionBar




user.Inventory.Carried is an Inventory instance that represents the stack of items the player can carry around such as dirt, stone, or logs.