Skip to content

How to modify the inventory

ChristophLHR edited this page Sep 25, 2024 · 1 revision

How to modify the inventory

Adding an item to the inventory (e.g. of a turtle) is very easy At first You define the item.

Each item needs a "name"

local turtleEmulator = require("turtleEmulator")
_G.turtle = turtleEmulator:createTurtle()

local itemToAdd = {name = "minecraft:coal", count = 64, fuelgain = 16}
local addToSlotNo = 2

turtle.addItemToInventory(itemToAdd, addToSlotNo) -- adds the item(s) to the slot 
turtle.removeItem(addToSlotNo, 64) -- removes 64 item(s) from the slot

Additional modifiers:

  1. count Type: number

    how many items are within the items-entity

  2. maxcount Type: number

    Defines how many items each slot can hold. E.g. Ender Perals can only hold 16

  3. fuelgain Type: number

    Allows the turtle to refuel by consuming the item, by the specified amount

  4. placeAble Type: boolean

    Defines weither or not the item can be placed as a block within the world (default: false).

    Will be overshadowed if the following function is defined:

  5. placeAction Type: function

    Is the optional action, which will be called when the item attempts to be placed as a block.

    Parameters: Turtle (selfReference), Item (currentItem), Vector (position)

    Return (Expected): Success Type: boolean

  6. equipable Type: boolean

    Defines if weither or not the item is equipable (default: false).

  7. tags Type: table

    Any tags you might require. E.g. in the geoScanner

Clone this wiki locally