I've run into a weird situation, I have a robot trying to put items into a machine and retrieve them. I have this set up in a loop that while there is still materials to insert or materials being processed, or materials in the output the robot tries to execute a series of functions. This works flawlessly until the last loop. At this point, there is no more materials within the Robot's inventory, there is no more materials in the input slot of the machine, and only materials in the output slot. If I understand my logic correctly, it should try to pull items out of the machine. In fact when checking the robot logs, it does. It will infinitely loop printing "Sucking items from slot" and then "Sucked items:false". Now keep in mind the robot hasn't changed directions or moved and it has successfully inserted and extracted many resources within this loop. Am I missing something here?
function fillSmasherAndGetShards()local inputSlot =2local outputSlot =3local inputSlotDetails = getExternalSlotDetails(sides.front, inputSlot)local outputSlotDetails = getExternalSlotDetails(sides.front, outputSlot)-- While we still have potash to process or there is something in either the input or output slotwhile findSlotByItem("Potash")~=nilor inputSlotDetails.size >0or outputSlotDetails.size >0do-- Try to put more potash inif inputSlotDetails.size < inputSlotDetails.maxSize thenlocal potashSlot = findSlotByItem("Potash")if potashSlot ~=nilthen
robot_api.select(potashSlot)
inventory.dropIntoSlot(sides.front, inputSlot,1)endend-- Try to take potash shards outif outputSlotDetails.size >0then
print("Sucking items from slot")local suckTest = inventory.suckFromSlot(sides.front, outputSlot, outputSlotDetails.size)
print("Sucked items:".. tostring(suckTest))end-- Update slot details
inputSlotDetails = getExternalSlotDetails(sides.front, inputSlot)
outputSlotDetails = getExternalSlotDetails(sides.front, outputSlot)
os.sleep(1)endend
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.
I've run into a weird situation, I have a robot trying to put items into a machine and retrieve them. I have this set up in a loop that while there is still materials to insert or materials being processed, or materials in the output the robot tries to execute a series of functions. This works flawlessly until the last loop. At this point, there is no more materials within the Robot's inventory, there is no more materials in the input slot of the machine, and only materials in the output slot. If I understand my logic correctly, it should try to pull items out of the machine. In fact when checking the robot logs, it does. It will infinitely loop printing "Sucking items from slot" and then "Sucked items:false". Now keep in mind the robot hasn't changed directions or moved and it has successfully inserted and extracted many resources within this loop. Am I missing something here?
Link to post
Share on other sites