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

Get items from chest?

Started by Zyme, 18 September 2012 - 07:04 PM
Zyme #1
Posted 18 September 2012 - 09:04 PM
I just found out about ComputerCraft when playing Tekkit and it seems awesome, if you knew how to code…

I have a warehouse with 200+ chests that is sorted with input pipes. Now I need a way to actually get the items in a easy fashion, instead of running from floor to floor.

A solution was to use a retriever, but to get 64 diamonds I would need 1 diamond and click the button 64 times, or whatever. I need a way to tell the system "I need X amount of Y" sent to me.

The only solution I could think of is ComputerCraft.


Would it be possible to create such an interface? Where you have multiple pages with items in the terminal and you type in a number, (for example 10 for diamonds), and then the amount. That would send a signal to some machine that will get the right amount from the chest into tubes and transported up to floor 1.
Cranium #2
Posted 18 September 2012 - 09:24 PM
Tekkit uses 1.33 version of ComputerCraft. Unfortunately, this version does not interact with chests or inventory. If Tekkit was updated to 1.41 ComputerCraft, then you would be able to do this.

Edit: I reread your post, and noticed you said nothing about turtles. Wait for an update, and I'll have something for you.

Edit 2: Here is the code you can use to pull items out with a redstone pulse.

while true do
term.clear()
term.setCursorPos(1,1)
print("How many items do you want to pull out?")
write("Number: ")
local input = tonumber(read())
for i = 1,input do
rs.setOutput("back",true)
sleep(.1)
rs.setOutput("back",false)
sleep(.1)
end
end

More advanced with menu:

local options = {
"Diamond",
"Iron",
"Gold"
--you can add more in here
}
local function opt(m,mY)
n=1
l=#m
while true do
for i=1, l, 1 do
if i==n then
local x, y = term.getSize()
local b = string.len(">"..m[i].."<")/2
local x = (x/2)-b
term.setCursorPos(x,i+mY)
term.clearLine()
print(">"..m[i].."<")
else
local x, y = term.getSize()
b = string.len(m[i])/2
x = (x/2)-b
term.setCursorPos(x,i+mY)
term.clearLine()
print(m[i]) end
end
a, b= os.pullEventRaw()
if a == "key" then
if b==200 and n>1 then n=n-1 end
if b==208 and n<l then n=n+1 end
if b==28 then break end
end
end
term.clear() term.setCursorPos(1,1)
return n
end


while true do
term.clear()
term.setCursorPos(1,1)
print("What item do you want?")
local item = opt(options,6) --the second parameter is the y position start point
if item == 1 then
term.clear()
term.setCursorPos(1,1)
print("How many items do you want?")
write("Number: ")
local number = tonumber(read())
for i = 1,number do
rs.setBundledOutput("back",colors.white) --change to whatever bundled color you need
sleep(.1)
rs.setBundledOutput("back",0)
sleep(.1)
end
elseif item == 2 then
--same thing for item 2
elseif item == 3 then
--same thing for item 3...and so on
end
end
Zyme #3
Posted 18 September 2012 - 11:22 PM
Thanks, will try this when I get further with the system.

I have problem however figuring out what machine to use to get X amount. When I tried the "filter" machine it takes a full stack on each redstone pulse. Is there another way?

And how would I support 200 chests with one cable?
Cranium #4
Posted 18 September 2012 - 11:25 PM
With the filter, it will only take out the item of a certain stack size. So if using filters on a diamond chest, you would need one in the filter to output one diamond at a time. This is the same for the retreiver.
Zyme #5
Posted 19 September 2012 - 01:06 AM
Thanks got this to work.

Just the last problem, having 200 chests how do I solve the computer sending signals to the correct chests? I can solve 3 chests but this amount?
Matrixmage #6
Posted 19 September 2012 - 01:29 AM
Thanks got this to work.

Just the last problem, having 200 chests how do I solve the computer sending signals to the correct chests? I can solve 3 chests but this amount?

you can use bundled cables to make it use 16 * (however many sides are open on the computer) but for more you could use multiple computers and rednet.
hego555 #7
Posted 19 September 2012 - 01:39 AM
Wait tekkit has a old version of CC?

and the new version could do majical things like pull from chests?

(I SPELLED MAGICAL WRONG ON PURPOSE)
Zyme #8
Posted 19 September 2012 - 01:51 AM
What about using wireless to transmit to another computer that handles one floor and it is connected to wires?

So one computer on each floor. And one main computer with the options. Depending on what item I select it will contact a different computer that in turn sends the correct signal?
uh20 #9
Posted 28 January 2013 - 06:10 PM
hello, because i have 3 factories spread apart, i am creating a chest system in combination with Tekkit lite in which you can send out minecarts with a certain catagory of chest contents from a depot.

do be warned that there is no fast way of bringing items about (my tests from depot to my closest factory about 50 blocks away takes a bit more than a minute, the filling of the cart alone takes about 30 seconds.

my own sorting system is close to being internally done, but i have not started on the touchscreen selection or the failsafes for when you order too many carts, if a cart can collide, when the computer reboots, etc.