Jump to content




bios:206: [string "bore"]:18: ')' expected?


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

#1 digpoe

  • Members
  • 92 posts

Posted 08 September 2012 - 04:39 PM

I have this program for making my RedPower frame quarry work - and I used ComputerCraft since Lua is a LOT easier than Forth - but I got the error in the title. Can anyone help me? Here's the script:

I forgot how you do the code thingy - the button didn't like me.
function usage()
print 'Usage:'
print 'bore 10  -  bores a hole 10 blocks deep'
print 'type bore followed by a number to bore a hole'
end
tArgs = { ... }
if #tArgs == 1 then
if tonumber(tArgs[1]) then
  digHeight = tArgs[1]
  boreDown()
else
  usage()
end
else
usage()
end
function boreDown()
while ( digHeight =~ 0 ) do
  redstone.SetBundledOutput('back', 1)
  sleep(0.800)
  redstone.SetBundledOutput('back', 2)
  sleep(0.800)
  redstone.setBundledOutput('back', 4)
  sleep(0.800)
  digHeight = (digHeight - 1)
end
print 'Completed tunnel boring'
end
Wait. First error I noticed: it's redstone.setBundledOutput, not redstone.SetBundledOutput...

#2 Lettuce

  • Members
  • 210 posts
  • LocationIn your fridge.

Posted 08 September 2012 - 04:45 PM

Remove the perenthesis on your while statement. You don't need parenthesis there. And I agree, Lua is easier to use AND more widespread than FORTH.

#3 digpoe

  • Members
  • 92 posts

Posted 08 September 2012 - 04:46 PM

View PostLettuce, on 08 September 2012 - 04:45 PM, said:

Remove the perenthesis on your while statement. You don't need parenthesis there. And I agree, Lua is easier to use AND more widespread than FORTH.
I tried that and now i'm getting the error expecting a do in the same line

#4 Lettuce

  • Members
  • 210 posts
  • LocationIn your fridge.

Posted 08 September 2012 - 04:49 PM

Is there a 'do' on that line?

#5 digpoe

  • Members
  • 92 posts

Posted 08 September 2012 - 04:50 PM

View PostLettuce, on 08 September 2012 - 04:49 PM, said:

Is there a 'do' on that line?
I meant -
function usage()
print 'Usage:'
print 'bore 10  -  bores a hole 10 blocks deep'
print 'type bore followed by a number to bore a hole'
end
tArgs = { ... }
if #tArgs == 1 then
if tonumber(tArgs[1]) then
  digHeight = tArgs[1]
  boreDown()
else
  usage()
end
else
usage()
end
function boreDown()
while digHeight =~ 0 do --Here it is expecting the do
  redstone.setBundledOutput('back', 1)
  sleep(0.800)
  redstone.setBundledOutput('back', 2)
  sleep(0.800)
  redstone.setBundledOutput('back', 4)
  sleep(0.800)
  digHeight = (digHeight - 1)
end
print 'Completed tunnel boring'
end


#6 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 08 September 2012 - 04:53 PM

Your inequality sign is backwards.
while digHeight =~ 0 do

should be
while digHeight ~= 0 do


#7 digpoe

  • Members
  • 92 posts

Posted 08 September 2012 - 04:54 PM

View PostKingdaro, on 08 September 2012 - 04:53 PM, said:

Your inequality sign is backwards.
while digHeight =~ 0 do

should be
while digHeight ~= 0 do
Ah. Thanks. I actually forgot howto do the inequality signs since i haven't used Lua for a long time.
>.< Now it's erroring that :
bore:10: attempt to call nil
which is where the function to start tunnel boring is.. it's saying the function is nonexistant? Oh wait. I can guess why. The function needs to be at the start?

Edited by digpoe, 08 September 2012 - 04:56 PM.


#8 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 08 September 2012 - 04:57 PM

I used to make the mistake all the time too. When I use them, I usually think "is almost equal to" since that's what I was taught the symbol meant before I knew about lua.

"is almost (~) equal (=) to" helped me distinguish the order.

Hope this helps in the future :D/>

You could always replace "almost" with "not" to make things less confusing though, that's just my backwards logic, haha.

#9 cant_delete_account

  • Members
  • 484 posts

Posted 08 September 2012 - 06:26 PM

Here ya go:
tArgs = { ... }
function usage()
print 'Usage:'
print 'bore 10  -  bores a hole 10 blocks deep'
print 'type bore followed by a number to bore a hole'
end
function boreDown()
while digHeight ~= 0 do
  redstone.setBundledOutput('back', 1)
  sleep(0.800)
  redstone.setBundledOutput('back', 2)
  sleep(0.800)
  redstone.setBundledOutput('back', 4)
  sleep(0.800)
  digHeight = digHeight-1
end
print 'Completed tunnel boring'
end
if #tArgs == 1 then
if tonumber(tArgs[1]) then
  digHeight = tonumber(tArgs[1])
  boreDown()
else
  usage()
end
else
usage()
end






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users