Main Menu

Error Bios:338:

Started by timstrym, Dec 10, 2019, 05:58 PM

Previous topic - Next topic

timstrym

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

SquidDev

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
GitHub | CC:Tweaked: A ComputerCraft fork | Plethora: A peripheral mod

timstrym

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.

Lupus590

#3
if you are lucky you might find a version in your language: https://www.lua.org/docs.html

computercraft uses lua 5.1

timstrym

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?

Lupus590

Call os.pullevent in you loops

timstrym

#6
Where i need to edit os.pullevent?

Lupus590

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

SquidDev

@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?
GitHub | CC:Tweaked: A ComputerCraft fork | Plethora: A peripheral mod

timstrym

@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.