All functions are available on the drone table inside the drone's internal CC:Tweaked computer.
Conventions
- Slots are 1-based in Lua.
- Command-like calls block until completion, and return
trueon success orfalse, "reason"on failure.
drone.move(x, y, z) -> boolean[, string]
- Moves the drone by a relative offset in blocks. Fractions allowed. (eg.
0.5,7.2) - Returns
trueon success orfalse, "Movement took too long"if it cannot complete.
Example: move up 3, forward 5, then back down
assert(drone.move(0, 3, 0))
assert(drone.move(5, 0, 0))
assert(drone.move(0, -3, 0))Please note that it does not have pathfinding, and can hit into blocks and still say that it moved the amount of blocks you specified.
drone.select(slot) -> boolean[, string]
- Selects inventory slot
slot(1..size). Returnsfalse, "Slot out of range"if invalid.
drone.getSelectedSlot() -> number
- Returns currently selected slot (1-based).
drone.getItemDetail([slot]) -> table|nil
- Returns an item detail table (same shape as CC:Tweaked's item details) for
slot, or the selected slot if omitted. Returnsnilif empty.
Examples
-- Pick slot 1 and print its name
assert(drone.select(1))
local detail = drone.getItemDetail()
print(detail and detail.name or "<empty>")
-- Compare two slots for identical item + components
local function same(a, b)
assert(drone.select(a))
return drone.compare(b)
end
print("slots 1 and 2 equal:", same(1, 2))drone.place() -> boolean[, string]
- Uses the currently selected item on the block directly below the drone (places blocks, uses items). Fails if space is blocked or protected.
Example: place a pillar of 5 blocks
for i = 1, 5 do
assert(drone.place())
assert(drone.move(0, 1, 0))
enddrone.suck([quantity]) -> boolean[, string]
- Pulls up to
quantityitems from the block inventory below the drone, or picks up loose items in the block below if no inventory. Defaults to 1. - Possible errors: "No items to take", "No space for items".
Examples
-- Pull a full stack from a chest below
assert(drone.select(1))
assert(drone.suck(64))
-- Vacuum loose drops below one by one
while true do
local ok, err = drone.suck()
if not ok and err == "No items to take" then break end
enddrone.compare(slot) -> boolean
- Compares selected slot with
slotfor same item and components. Returns true if identical.
drone.getRotation() -> yaw, pitch
- Returns the drone's rotation angles (degrees).
Notes
- Movement is eased and may take multiple ticks; code runs after the function returns.
- All APIs make server-side checks (build limits, protection, entities) and surface failures via error strings.