The inventory module contains all kinds of windows and window parts like inventory, crafting and storage slots.
Generally to create a window you must create a Window object (of specific class derived from Window) and pass arguments like: window ID, player’s inventory, slot’s or tile’s inventory, coordinates etc.
Generic construction (never use in your code :)
window = Window( id, Inventory(), Workbench(), ...)
Please note that player’s inventory window is a special case. It is created when user logins and stays always opened. You probably will never have to create it.
def authenticated(self):
BetaServerProtocol.authenticated(self)
# Init player, and copy data into it.
self.player = yield self.factory.world.load_player(self.username)
...
# Init players' inventory window.
self.inventory = InventoryWindow(self.player.inventory)
...
Every windows have own class. For instanse, to create a workbench window:
i = WorkbenchWindow(self.wid, self.player.inventory)
Furnace:
bigx, smallx, bigz, smallz, y = coords
furnace = self.chunks[x, y].tiles[(smallx, y, smallz)]
window = FurnaceWindow(self.wid, self.player.inventory, furnace.inventory, coords)
Bases: bravo.inventory.SerializableSlots
The class represents Player’s inventory
Attempt to add an item to the inventory.
Parameters: | item (tuple) – a key representing the item |
---|---|
Returns: | quantity of items that did not fit inventory |