Jump to content




Retrieving items


  • You cannot reply to this topic
5 replies to this topic

#1 Crecket

  • New Members
  • 3 posts

Posted 14 October 2012 - 09: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.

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 14 October 2012 - 09:12 PM

It's term.whatEverFunction(), not terminal.whatEverFunction().

#3 Crecket

  • New Members
  • 3 posts

Posted 14 October 2012 - 10:31 PM

Ah thanks, didn't know that. But meh, I'm here to learn :)/>

#4 Crecket

  • New Members
  • 3 posts

Posted 15 October 2012 - 11:08 AM

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


#5 JoshhT

  • New Members
  • 64 posts
  • LocationAustralia

Posted 15 October 2012 - 11:13 AM

The error is in the itemSorter file, not startup :D/>

#6 Fatal_Exception

  • New Members
  • 105 posts

Posted 15 October 2012 - 11:31 AM

Everywhere you have color.gray needs to be colors.gray





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users