turtle inventory (event)

From ComputerCraft Wiki
Revision as of 10:55, 4 October 2013 by Cranium (Talk | contribs) (Created page)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



Grid Modem.png  Event turtle_inventory
Fired when the inventory of the turtle is altered in any slot.
Returned Object 1 The slot of the turtle in which the inventory has changed.

Examples

Grid paper.png  Example
Returns the slot number when the inventory in slot 1 is changed.
Code
while true do
  local event, p1 = os.pullEvent("turtle_inventory")
  print("Inventory has change in slot number "..p1)
end
Output If the inventory in slot 1 used to be 0, and is now 1 or any other amount, the output is thus: "Inventory has changed in slot number 1".



Note: This event can fire even if the inventory has not changed, such as if the player has clicked on an empty slot. This can allow for very interesting interactions with the turtles, such as a turtle keycode for a door lock.