Editing Mod Server API

From Eco - English Wiki

Your changes will be displayed to readers once an authorized user accepts them. (help)

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 17: Line 17:
  user.Inventory.Clothing
  user.Inventory.Clothing
  user.Inventory.Toolbar
  user.Inventory.Toolbar
The items in these inventories can be accessed in a couple different ways as discussed in the [[Mod Server API#Inventory|Inventory Section]]. Each of these is an instance of [https://docs.play.eco/api/server/eco.gameplay/Eco.Gameplay.Items.Inventory.html Inventory].
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> represents all the standard buttons used to open the backpack, economy viewer, etc. located next to the minimap.


Line 26: Line 26:


<code>user.Inventory.Clothing</code> represents the items of clothing the player is wearing.
<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.
<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.




=== World Objects - Crafting Tables, Storage, and Vehicles ===
Crafting tables, vehicles, stockpiles, and other placed structures are represented by the <code>WorldObject</code> class. The walls, roof, roads, etc are not considered world objects. To list all the world objects owned by the player use the following static method:
WorldObject.GetOwnedBy(user) //IEnumerable<WorldObject>
Each <code>WorldObject</code> contains components that represent their features. For example, the <code>StorageComponent</code> represents the ability for the object to store items as stacks.
==== Crafting Component ====
The crafting component represents a crafting tables work orders, recipes, etc.


== Inventory ==
== Inventory ==
An [https://docs.play.eco/api/server/eco.gameplay/Eco.Gameplay.Items.Inventory.html Inventory] is a collection of item stacks and is used to represent the items inside various things in Eco including the player's backpack, vehicles, storage chests, stockpiles, and even fuel slots. Each instance of Inventory has a common interface for getting access to the items and stacks inside it. Inventories are also a hierarchy of inventories. For example, the player has a root level inventory <code>user.Inventory</code> which represents all the inventories of the player's character (their backpack, toolbar and clothing). To access child inventories you can use <code>inventory.AllInventories</code> or just by accessing the same stacks <code>IEnumerable</code> properties mentioned below.
An [https://docs.play.eco/api/server/eco.gameplay/Eco.Gameplay.Items.Inventory.html Inventory] is a collection of item stacks and is used to represent the items inside various things in Eco including the player's backpack, vehicles, storage chests, stockpiles, and even fuel slots. Each instance of Inventory has a common interface for getting access to the items and stacks inside it. Inventories are also a hierarchy of inventories. For example, the player has a root level inventory <code>user.Inventory</code> which represents all the inventories of the player's character (their backpack, toolbar and clothing). To access child inventories you can use <code>inventory.AllInventories</code> or just by accessing the same stacks <code>IEnumerable</code> properties mentioned below.
=== Items/Stacks ===
=== Items/Stacks ===
Each slot of the inventory is represented by the [https://docs.play.eco/api/server/eco.gameplay/Eco.Gameplay.Items.ItemStack.html ItemStack] class whether it is empty or not. You can access the individual items through the inventory's stacks. Use <code>inventory.Stacks</code> to access all the stacks or <code>inventory.NonEmptyStacks</code> to access just the slots with any items in them. Both of these are <code>IEnumberable<ItemStack></code> so they can be used with [https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/ Linq] or iterated through in a for-each loop:
Each slot of the inventory is represented by the [https://docs.play.eco/api/server/eco.gameplay/Eco.Gameplay.Items.ItemStack.html ItemStack] class whether it is empty or not. You can access the individual items through the inventory's stacks. Use <code>inventory.Stacks</code> to access all the stacks or <code>inventory.NonEmptyStacks</code> to access just the slots with any items in them. Both of these are <code>IEnumberable<ItemStack></code> so they can be used with [https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/ Linq] or iterated through in a for-each loop:
Please note that all contributions to Eco - English Wiki are considered to be released under the CC BY-NC-SA 4.0 (see Eco:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)