Why isn't computercraft script working?

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

theOTTERthatCOULD

New Member
Jul 29, 2019
6
0
0
i get " bios:338: [string "mining"]:82: 'then' expected

although at line 82 there clearly is a 'then'
Code:
function dropping()
turtle.select(1)
turtle.dropUp()
 
turtle.select(2)
turtle.dropUp()
 
turtle.select(3)
turtle.dropUp()
 
turtle.select(4)
turtle.dropUp()
 
turtle.select(5)
turtle.dropUp()
 
turtle.select(6)
turtle.dropUp()
 
turtle.select(7)
turtle.dropUp()
 
turtle.select(8)
turtle.dropUp()
 
turtle.select(9)
turtle.dropUp()
 
turtle.select(10)
turtle.dropUp()
 
turtle.select(11)
turtle.dropUp()
 
turtle.select(12)
turtle.dropUp()
 
turtle.select(13)
turtle.dropUp()
 
turtle.select(14)
turtle.dropUp()
 
turtle.select(15)
turtle.dropUp()
end
 
 
 
 
 
 
 
 
 
 
 
 
function movingdown()
turtle.down()
end
 
 
 
 
 
 
 
 
 
function movedown()
for i = 1, k do
movingdown()
end
end
 
 
 
function kakka()
if emptying = 4 then
  clearinventory()
end
 
if emptying = 8 then
  clearinventory()
end
 
if emptying = 12 then
  clearinventory()
end
 
if emptying = 16 then
  clearinventory()
end
 
if emptying = 20 then
  clearinventory()
end
 
if emptying = 24 then
  clearinventory()
end
end
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fuel()
 
if turtle.getFuelLevel() < 500 then
return true
else
return false
end
end
 
function refuel()
if fuel() then
print "Refuelling the turtle!"
if turtle.getItemCount(16) ~= 0 then
  turtle.select(16)
  turtle.refuel(4)
  turtle.select(1)
  print "Turtle refuelled!"
else
  print "The turtle does not have fuel in inventory, Turtle will re-boot!"
  sleep(3) os.reboot()
end
end
end
 
 
 
 
 
emptying = 0
 
 
function moveup()
turtle.up()
end
 
 
function clearinventory()
for i = 1, b do
  moveup()
end
dropping()
movedown()
end
 
 
 
 
 
 
 
 
 
print "How big of an x and an z you want your area to be?"
 
local a = read()
term.clear()
print("You entered x and z successfully! You entered: ")
print(a)
sleep(2)
term.clear()
print "how big of an y (depth) you want your area to be?"
local b = read()
term.clear()
print("You entered y successfully! You entered: ")
print(b)
sleep(2)
term.clear()
 
 
--a = 5
-- adds 1 to size (a) value
--b = 3
 
c = a - 1
k = b + 1
 
function digforward()
turtle.dig()
turtle.forward()
end
 
function turn1()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
turncount = true
end
 
function turn2()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
turncount = false
end
 
function row()
for i = 1, a do
digforward()
end
if turncount then
  turn2()
else
  turn1()
end
end
 
 
 
function endingrow()
for i = 1 , a do
  digforward()
end
end
 
 
 
function level()
for i = 1, a do
row()
 
end
refuel()
endingrow()
end
 
function down()
turtle.digDown()
turtle.down()
turtle.turnLeft()
turtle.turnLeft()
 
 
end
 
 
 
 
 
 
function mining()
level()
down()
 
emptying = emptying + 1
kakka()
end
 
function new()
for i = 1, b do
mining()
end
end
 
refuel()
new()
 
print "All mining assined has been done!"
 

SkyBoy96

New Member
Jul 29, 2019
100
0
0
I took the liberty of cleaning up your dropping code. Should make your program easier to navigate.
Code:
function dropping()
   for i = 1, 15 do
       turtle.select(i)
       turtle.dropUp()
   end
end
 

theOTTERthatCOULD

New Member
Jul 29, 2019
6
0
0
I took the liberty of cleaning up your dropping code. Should make your program easier to navigate.
Code:
function dropping()
  for i = 1, 15 do
      turtle.select(i)
      turtle.dropUp()
  end
end
thanks!
Damn you guys are fast! ;D lol
Code:
j = 0
 
function dropping()
turtle.select(1)
turtle.dropUp()
 
turtle.select(2)
turtle.dropUp()
 
turtle.select(3)
turtle.dropUp()
 
turtle.select(4)
turtle.dropUp()
 
turtle.select(5)
turtle.dropUp()
 
turtle.select(6)
turtle.dropUp()
 
turtle.select(7)
turtle.dropUp()
 
turtle.select(8)
turtle.dropUp()
 
turtle.select(9)
turtle.dropUp()
 
turtle.select(10)
turtle.dropUp()
 
turtle.select(11)
turtle.dropUp()
 
turtle.select(12)
turtle.dropUp()
 
turtle.select(13)
turtle.dropUp()
 
turtle.select(14)
turtle.dropUp()
 
turtle.select(15)
turtle.dropUp()
end
 
 
 
 
 
 
 
 
 
 
 
 
function movingdown()
turtle.down()
end
 
 
 
 
 
 
 
 
 
function movedown()
for i = 1, j do
movingdown()
end
j = 0
end
 
 
 
 
domining2 = false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fuel()
 
if turtle.getFuelLevel() < 500 then
return true
else
return false
end
end
 
function refuel()
if fuel() then
print "Refuelling the turtle!"
if turtle.getItemCount(16) ~= 0 then
  turtle.select(16)
  turtle.refuel(4)
  turtle.select(1)
  print "Turtle refuelled!"
else
  print "The turtle does not have fuel in inventory, Turtle will re-boot!"
  sleep(3) os.reboot()
end
end
end
 
 
 
 
 
emptying = 0
 
 
function moveup()
if turtle.detectUp() then
print "Emptying"
else
turtle.up()
j = j + 1
end
end
 
 
 
 
 
 
 
 
 
 
print "How big of an x and an z you want your area to be?"
 
local a = read()
term.clear()
print("You entered x and z successfully! You entered: ")
print(a)
sleep(2)
term.clear()
print "how big of an y (depth) you want your area to be?"
local b = read()
term.clear()
print("You entered y successfully! You entered: ")
print(b)
sleep(2)
term.clear()
 
 
 
 
 
 
 
 
 
 
 
function clearinventory()
 
  for i = 1, u do
  moveup()
end
dropping()
movedown()
end
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--a = 5
-- adds 1 to size (a) value
--b = 3
 
c = a - 1
k = b + 1
u = b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function digforward()
if turtle.detect() then
while turtle.detect() ~= false do
  turtle.dig()
  sleep(0.25)
  end
  turtle.forward()
  sleep(0.5)
else
turtle.forward()
end
 
 
 
 
 
 
 
 
 
end
 
function turn1()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
turncount = true
end
 
function turn2()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
turncount = false
end
 
function row()
for i = 1, a do
digforward()
end
if turncount then
  turn2()
else
  turn1()
end
end
 
 
 
function endingrow()
for i = 1 , a do
  digforward()
end
end
 
 
 
function level()
for i = 1, a do
row()
 
end
refuel()
endingrow()
end
 
function down()
turtle.digDown()
turtle.down()
turtle.turnLeft()
turtle.turnLeft()
 
 
end
 
 
 
 
 
 
function mining2()
level()
down()
clearinventory()
domining2 = false
end
 
 
 
 
function mining()
 
level()
down()
 
domining2 = true
end
 
 
 
function actualmining()
if domining2 then
  mining2()
else
  mining()
 
 
end
end
 
function new()
for i = 1, b do
actualmining()
end
end
rednet.open("right")
refuel()
new()
rednet.broadcast("Mark: all mining assined has been done!")
rednet.broadcast("status:good")
print "All mining assined has been done!"
, already kind of made it better, but im having a new problem.

im trying to make the turtle dig up sand and gravel.
when ever it mines gravel with this code (line 223) it digs the first column of gravel, digs the first block of the second column (or block) but then, even if the column of gravel would have gravel still on it, it will bitch out, and turn around and try to escape. >;l damn turtle. if someone could help me, id apri
 

theOTTERthatCOULD

New Member
Jul 29, 2019
6
0
0
sorry.
it was a matter of timing, as the 0.25 second delay wasn't enough for the turtle to detect that the falling sand or gravel turned from an entity to a block (i think)
that still wouldn't explain why it ran off, but it works with a 0.5 sec sleep.
 

Xeollron

New Member
Jul 29, 2019
1
0
0
hey, new here and i keep getting a '=' expected
on this line
turtle.select (2) -- floor building material in slot 2
any help would be greatly appriciated