Jump to content




Program runs and ends without doing functions


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

#1 protexxi

  • Members
  • 51 posts

Posted 10 December 2013 - 05:33 PM

heres the code
function mine()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
turtle.turnLeft()
turtle.turnLeft()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
turtle.turnRight()
times = times + 1
rednet.send(1, "Tunnel is: " ..times" Blocks long")
end
function Empty()
for i=2,9 do
  turtle.select(i)
  turtle.dropDown()
end
end
function refuel()
print ("Please Put Ender Chest In slot 1")
rednet.open(Right)
while true do
turtle.getfuellevel(level)
if level >200 then
refuel()
rednet.send(1, "Refuelling... ")
else
rednet.send(1, "mining... ")
mine()
Empty()
end
end
end

dose not return any errors just runs then ends without moving

#2 awsmazinggenius

  • Members
  • 930 posts
  • LocationCanada

Posted 10 December 2013 - 05:37 PM

Please indent your code. There are obvious mistakes in your code, such as rednet.open("right") (MUST be a string), and turtle.getFuelLevel (MUST be properly capitalized). I'm not sure about the functions however.

#3 protexxi

  • Members
  • 51 posts

Posted 10 December 2013 - 05:46 PM

Iv corrected the caps yet still fails

function mine()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
turtle.turnLeft()
turtle.turnLeft()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
turtle.turnRight()
times = times + 1
rednet.send(1, "Tunnel is: " ..times" Blocks long")
end
function Empty()
for i=2,9 do
turtle.select(i)
turtle.dropDown()
end
end
function refuel()
print ("Please Put Ender Chest In slot 1")
rednet.open(Right)
while true do
turtle.getFuelLevel(level)
  if level >200 then
  refuel()
  rednet.send(1, "Refuelling... ")
   else
   rednet.send(1, "mining... ")
   mine()
   Empty()
  end
end
end

the end from the last function is missing and the whole function is missing

function refuel()
shell.run(refuel(2))
print ("Please Put Ender Chest In slot 1")
rednet.open(Right)
while true do
turtle.getFuelLevel(level)
  if level >200 then
  refuel()
  rednet.send(1, "Refuelling... ")
   else
   rednet.send(1, "mining... ")
   mine()
   Empty()
  end
end
end


should fix it?

Edited by protexxi, 10 December 2013 - 05:44 PM.


#4 protexxi

  • Members
  • 51 posts

Posted 10 December 2013 - 05:54 PM

fixed it however says

rednet:14: invalid side

#5 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 10 December 2013 - 06:14 PM

You're using a variable, not string for the side.
rednet.open(Right)
--should be
rednet.open('right')

Also, I don't think you can use EnderChests. Unless you are using the mod of course.

Edited by oeed, 10 December 2013 - 06:19 PM.


#6 protexxi

  • Members
  • 51 posts

Posted 10 December 2013 - 06:14 PM

i am using the modded chest

#7 MR_nesquick

  • Members
  • 106 posts
  • LocationNorway

Posted 10 December 2013 - 06:33 PM

" turtle.getFuelLevel(level) " should be " level = turtle.getFuelLevel() "

#8 awsmazinggenius

  • Members
  • 930 posts
  • LocationCanada

Posted 10 December 2013 - 06:45 PM

View Postoeed, on 10 December 2013 - 06:14 PM, said:

You're using a variable, not string for the side.
rednet.open(Right)
--should be
rednet.open('right')

Also, I don't think you can use EnderChests. Unless you are using the mod of course.
I have already stated this.

View Postprotexxi, on 10 December 2013 - 05:46 PM, said:

Iv corrected the caps yet still fails

function mine()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.digDown()
turtle.turnLeft()
turtle.turnLeft()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
turtle.turnRight()
times = times + 1
rednet.send(1, "Tunnel is: " ..times" Blocks long")
end
function Empty()
for i=2,9 do
turtle.select(i)
turtle.dropDown()
end
end
function refuel()
print ("Please Put Ender Chest In slot 1")
rednet.open(Right)
while true do
turtle.getFuelLevel(level)
  if level >200 then
  refuel()
  rednet.send(1, "Refuelling... ")
   else
   rednet.send(1, "mining... ")
   mine()
   Empty()
  end
end
end

the end from the last function is missing and the whole function is missing

function refuel()
shell.run(refuel(2))
print ("Please Put Ender Chest In slot 1")
rednet.open(Right)
while true do
turtle.getFuelLevel(level)
  if level >200 then
  refuel()
  rednet.send(1, "Refuelling... ")
   else
   rednet.send(1, "mining... ")
   mine()
   Empty()
  end
end
end


should fix it?

When did I say that it would fix it? I also said something about indentation. Here is an indented version:
function mine()
  turtle.dig()
  turtle.forward()
  turtle.digUp()
  turtle.digDown()
  turtle.turnLeft()
  turtle.dig()
  turtle.forward()
  turtle.digUp()
  turtle.digDown()
  turtle.turnRight()
  turtle.turnRight()
  turtle.forward()
  turtle.dig()
  turtle.forward()
  turtle.digUp()
  turtle.digDown()
  turtle.turnLeft()
  turtle.turnLeft()
  turtle.turnRight()
  turtle.forward()
  turtle.turnRight()
  turtle.turnRight()
  times = times + 1
  rednet.send(1, "Tunnel is: " ..times" Blocks long")
end
function Empty()
  for i=2,9 do
    turtle.select(i)
    turtle.dropDown()
  end
end
function refuel()
  print ("Please Put Ender Chest In slot 1")
  rednet.open(Right)
  while true do
    turtle.getFuelLevel(level)
    if level >200 then
	  refuel()
	  rednet.send(1, "Refuelling... ")
    else
	  rednet.send(1, "mining... ")
	  mine()
	  Empty()
    end
  end
end


#9 civilwargeeky

  • Members
  • 393 posts

Posted 12 December 2013 - 08:01 PM

I'm sorry, but did I miss where someone told him that he wasn't calling any functions?

In this code as far as I have seen it, all you are doing is "declaring" functions. Doing this just makes a function that you can use later, it doesn't run it.
So you have
function doStuff()
  turtle.dig()
  turtle.forward()
end
But this doesn't actually do anything. This however
function doStuff()
  turtle.dig()
  turtle.forward()
end

doStuff() --This is "calling" the function
Will make the turtle dig, then move forward.

That is why your program isn't doing anything. Declaring functions doesn't run them, it just puts them there for you to use later.

Here is a more in depth tutorial if you want: http://computercraft...Function_(type)

Edited by civilwargeeky, 12 December 2013 - 08:02 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users