Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
nosho

Help with accessing inventory

Question

I am trying to write a program for making a wither. Programming a robot that can access a chest to grab specific number of items from two different slots and then place them in the wither spawning formation. I can't figure out how to select the second slot in the chest to grab 3 wither skeleton skulls. I use robot.suck to get items from the first slot in the chest. What is the command for a robot to get items from a chest in a specific slot?

 

thanks Molinko, didn't know i need to put require inventory controller and put ic. in front of suckFromSlot.  thank you

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 1
  • Solution

Your robot will need an inventory_controller upgrade to pull items from specific slots in a chest.

local component = require "component"
local ic = component.inventory_controller

ic.suckFromSlot(side:number, slot:number, [count:number])-- 3, 2, 10
-- take (10) items from slot (2) in front (3) of the robot. sides.front == 3

suckFromSlot(side:number, slot:number[, count:number]):boolean
Takes up to count items from the specified slot of the inventory at the specified side and puts them into the currently selected slot.
side - a valid side.
slot - the slot to take the item from.
count - how many items to transfer.
Returns: true if at least one item was moved, false otherwise.
If the currently selected slot is occupied, then the items will be stacked with similar items in the robot's inventory or moved to the next free slot if available. If no slot is available this operation will fail.
Note that the robot cannot suck items from it's own inventory, attempting to do so will cause this to throw an error. You need to use robot.transferTo from the Robot API to do so.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.