This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
civilwargeeky's profile picture

Suck functions return how many items were sucked.

Started by civilwargeeky, 29 December 2013 - 08:30 PM
civilwargeeky #1
Posted 29 December 2013 - 09:30 PM
That would be nice if the suck function returned how many items it picked up. I read the "read first" post, and know this could be made by hand fairly easily (which in fact I'm using now:)
Spoiler
local function getInvTable()
  local toRet = {}
  for i=1, 16 do
	toRet[i] = turtle.getItemCount(i)
  end
  return toRet
end
local function compareChangedSlots(input1, input2)
  for i=1,16 do
	if input1[i] ~= input2[i] then
	  return math.abs(input1[i]-input2[i])
	end
  end
  return 0
end
local snapshot = getInvTable()
turtle.suck()
print(compareChangedSlots(snapshot, getInvTable))
However, I think that this would be a nice addition, as (I would think) it would be simple to code in. (I'm new to modding, but couldn't you just give lua the value of ItemStack.stackSize returned by the ItemStack added to the inventory?)
awsmazinggenius #2
Posted 29 December 2013 - 09:52 PM
If itis an enhancement, locking is likely. However, I do think this would be good.
Zudo #3
Posted 30 December 2013 - 06:50 AM
This idea sucks

I like the idea of this, but as it can be coded, it probably won't be implemented.
Cranium #4
Posted 30 December 2013 - 10:41 AM
Agreed, as it can be coded in by the end user, it falls into the 'enhancements' provision.