Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Latest commit

 

History

History
59 lines (46 loc) · 2.08 KB

module-introspection.md

File metadata and controls

59 lines (46 loc) · 2.08 KB
layout title summary module usable image
module
Introspection module
The introspection module allows accessing the inventory of a player, also providing the ability to get basic information about yourself.
plethora:introspection
Manipulator
Neural interface
Pocket computers
Turtle
module-introspection.png

Basic usage

Once the introspection module is equipped and wrapped as a peripheral, you will be able to fetch the current entity/turtle's inventory. With that object you can use [any standard inventory method][item_handler].

local introspection = peripheral.wrap(--[[ whatever ]])

local inv = introspection.getInventory()
local item = inv.getItemMeta(1)
if item then
	print(item.displayName .. " at slot #1")
end

When using the introspection module within a manipulator, you will need to bind it to a player. This can be done by shift + right-clicking it. The module will now function as normal, acting on the bound player's inventory instead.

Note that the introspection module also works on simple mobs and turtles, though you they do not have as large an inventory as players.

Transferring between inventories

If you're unfamiliar with Plethora's item transfer system, I suggest [you read the introduction first][item_transfer].

The introspection module also provides access to the player's ender chest and, if installed, the Baubles inventory. While there are methods to access them (.getEnder() and .getBaubles() respectively), you can also use the item transfer system to move things between them.

local inv = introspection.getInventory()
local ender = introspection.getEnder()

inv.pushItems("ender_chest", 1) -- Move slot 1 into the ender chest
for slot, item in pairs(ender.list()) do
	print(string.format("#%d: %s", slot, item.name))
end

Other functionality

Right-clicking with the introspection module will open the current player's ender chest.

[item_handler]: {{ "methods.html#targeted-methods-net.minecraftforge.items.IItemHandler" | relative_url }} [item_transfer]: {{ "item-transfer.html" | relative_url }}