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

Retrieving items

Started by Crecket, 14 October 2012 - 08:00 PM
Crecket #1
Posted 14 October 2012 - 10:00 PM
Hello, I'm kinda new to computercraft but since I already program a bit in C++, Java and some other languages I though I should give it a try.

The program I made is a system to retrieve and deposit from multiple chest. When depositing it just sends everything to a sorting system so thats no problem. I set the program as the startup file so it should start autmoticaly but when I reboot my pc it says:
startup:2: attempt to index ? (a nil value)

Also, if there is a way to make it work beter than it would now than please tell me :)/>/>

Here is the program in pastebin: http://pastebin.com/0gE4TGMe

while true do
terminal.clear()
terminal.setCursorPos(1.1)
itemType = read()
if itemType == "ingots"then
print("clearing chest")
rs.setBundledOutput("back", color.gray)
sleep(40.0)
rs.setBundledOutput("back", colors.white)
elseif itemType == "special" then
print("clearing chest")
rs.setBundledOutput("back", color.gray)
sleep(40.0)
print("Getting the special items.")
rs.setBundledOutput("back", colors.orange)
elseif itemType == "crap" then
print("clearing chest")
rs.setBundledOutput("back", color.gray)
sleep(40.0)
print("Getting the converted crap.")
rs.setBundledOutput("back", colors.magenta)
elseif itemType == "ores"then
print("clearing chest")
rs.setBundledOutput("back", color.gray)
sleep(40.0)
print("Getting the ores.")
rs.setBundledOutput("back", colors.lightBlue)
elseif itemType == "rest" then
rs.setBundledOutput("back", color.gray)
sleep(40.0)
rs.setBundledOutput("back", colors.yellow)
print("Getting the 'rest' items.")
elseif itemType == "clear" then
print("clearing chest")
rs.setBundledOutput("back", color.gray)
sleep(40.0)
else
print("Available commands: ingots, clear, special, crap, ores and rest")
sleep(2.0)
terminal.clear()
end
rs.setBundledOutput("back", 0)
sleep(2.0)
terminal.clear()
end
The gray bundled cable is to deposit all the items and the other ones to get from certain chests.
Lyqyd #2
Posted 14 October 2012 - 10:12 PM
It's term.whatEverFunction(), not terminal.whatEverFunction().
Crecket #3
Posted 14 October 2012 - 11:31 PM
Ah thanks, didn't know that. But meh, I'm here to learn :)/>/>
Crecket #4
Posted 15 October 2012 - 12:08 PM
I started working on it today and it gave the same error but for a line that is completely diffrent.
itemSorter:7: attempt to index ? (a nil value)
Can the person who knows what is wrong also tell me what it means? Because else ill keep making this mistake.

Btw I wont respond to this thread for a while since Im going on a holiday.


while true do
term.clear()
term.setCursorPos(1.1)
itemType = read()
if itemType == "ingots"then
print("clearing chest")
rs.setBundledOutput("back", color.gray)
sleep(40.0)
rs.setBundledOutput("back", colors.white)
elseif itemType == "special" then
print("clearing chest")
rs.setBundledOutput("back", color.gray)
sleep(40.0)
print("Getting the special items.")
rs.setBundledOutput("back", colors.orange)
elseif itemType == "crap" then
print("clearing chest")
rs.setBundledOutput("back", color.gray)
sleep(40.0)
print("Getting the converted crap.")
rs.setBundledOutput("back", colors.magenta)
elseif itemType == "ores"then
print("clearing chest")
rs.setBundledOutput("back", color.gray)
sleep(40.0)
print("Getting the ores.")
rs.setBundledOutput("back", colors.lightBlue)
elseif itemType == "rest" then
rs.setBundledOutput("back", color.gray)
sleep(40.0)
rs.setBundledOutput("back", colors.yellow)
print("Getting the 'rest' items.")
elseif itemType == "clear" then
print("clearing chest")
rs.setBundledOutput("back", color.gray)
sleep(40.0)
else
print("Available commands: ingots, clear, special, crap, ores and rest")
sleep(2.0)
term.clear()
end
rs.setBundledOutput("back", 0)
sleep(2.0)
term.clear()
end
JoshhT #5
Posted 15 October 2012 - 12:13 PM
The error is in the itemSorter file, not startup :D/>/>
Fatal_Exception #6
Posted 15 October 2012 - 12:31 PM
Everywhere you have color.gray needs to be colors.gray