ComputerCraft Forums

ComputerCraft => Ask a Pro => Topic started by: timstrym on Dec 10, 2019, 05:58 PM

Title: Error Bios:338:
Post by: timstrym on Dec 10, 2019, 05:58 PM
Hello everyone, I have a problem with my crafty turtle. If this continues I will soon have no hair on my head anymore. I play FTB light on a server and built myself an automatic solar panel farm. The turtle should pull the items from the chest out of the chest above it. In the chest is gold which comes from an oven. This should be further processed with a miniumstone to iron and then spent down in a chest. A friend has written everything I know, but it does not work and now the friend is in the holidays and I can not reach him.
I have to:
1. Give the turtle a label
2. then "edit startup"
3. write
while true do
turtle.select(2)
turtle.suckUp()
turtle.craft()
if turtlegetItemCount(3)> 0 then
turtle.select(3)
turtle.dropDown()
end
if turtlegetItemCount(2) > 7 then
turtle.select(2)
turtle.dropDown()
end

4. save, exit and reboot
But I get the error message "bios: 338: [string" startup "]: 12:` end`
expected (to close `while` at line 1)
Can someone help me get my turtle to work before I run out of hair?
Regards Tim Strym and google Translate
Title: Error Bios:338:
Post by: SquidDev on Dec 10, 2019, 06:29 PM
As the message suggests, you just need to add another "end" at the end of your program. This is a little easier to see if you mark up each if/while block like so:

while true do
  turtle.select(2)
  turtle.suckUp()
  turtle.craft()
  if turtlegetItemCount(3)> 0 then
    turtle.select(3)
    turtle.dropDown()
  end
  if turtlegetItemCount(2) > 7 then
    turtle.select(2)
    turtle.dropDown()
  end
end -- This one was missing
Title: Error Bios:338:
Post by: timstrym on Dec 10, 2019, 07:43 PM
Thanks so much!

Two more things:

First, this last end complete my whole program and this other end`s only end my subprogram?

Second, do you know good information sources for learn Computercraft/Lua? It should not be writen in the "hardest" english.
Title: Error Bios:338:
Post by: Lupus590 on Dec 10, 2019, 10:29 PM
if you are lucky you might find a version in your language: https://www.lua.org/docs.html

computercraft uses lua 5.1
Title: Error Bios:338:
Post by: timstrym on Dec 12, 2019, 09:30 PM
My language ist available.

But my program has a Bug... After a certain time the error message appears.. turtle:18: Too long without yielding some idea how i can fix this?
Title: Error Bios:338:
Post by: Lupus590 on Dec 13, 2019, 09:19 AM
Call os.pullevent in you loops
Title: Error Bios:338:
Post by: timstrym on Dec 13, 2019, 04:00 PM
Where i need to edit os.pullevent?
Title: Error Bios:338:
Post by: Lupus590 on Dec 13, 2019, 04:44 PM
try this
while true do
  sleep(0.1) -- contains an os.pullEvent and won't stop your program is there are no events
  turtle.select(2)
  turtle.suckUp()
  turtle.craft()
  if turtlegetItemCount(3)> 0 then
    turtle.select(3)
    turtle.dropDown()
  end
  if turtlegetItemCount(2) > 7 then
    turtle.select(2)
    turtle.dropDown()
  end
end
Title: Error Bios:338:
Post by: SquidDev on Dec 13, 2019, 04:45 PM
@Lupus590 That shouldn't be needed - (most) turtle calls will yield internally.

@timstrym Can you post your full/updated program? I'm assuming there's a little bit more than what was in the OP?
Title: Error Bios:338:
Post by: timstrym on Dec 13, 2019, 06:13 PM
@timstrym Can you post your full/updated program? I'm assuming there's a little bit more than what was in the OP?
[/quote]

Sure, but i only change the "end"
while true do
  turtle.select(2)
  turtle.suckUp()
  turtle.craft()
  if turtlegetItemCount(3)> 0 then
    turtle.select(3)
    turtle.dropDown()
  end
  if turtlegetItemCount(2) > 7 then
    turtle.select(2)
    turtle.dropDown()
  end
end

The gold comes irregularly. Depends on how much is produced.