This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
sjele's profile picture

[Help] Function wont do nothing [turtles]

Started by sjele, 13 August 2012 - 05:44 PM
sjele #1
Posted 13 August 2012 - 07:44 PM
So made this, This is in the cc version witch comes with tekkit, the newset rec build. I don't think it is the newest CC out there.


function derpMode()
local inf = noStop
  while inf ~= stop do
    way = math.random(1, 6)
    if way == 1 then
	  turtle.forward()
	  sleep(.1)
	  print("test")
    elseif way == 2 then
	  turtle.back()
	  sleep(.1)
	  print("test")
    elseif way == 3 then
	  turtle.turnLeft()
	  turtle.forward()
	  sleep(.1)
	  print("test")
    elseif way == 4 then
	  turtle.turnLeft()
	  turtle.forward()
	  sleep(.1)
	  print("test")
    elseif way == 5 then
	  turtle.up()
	  sleep(.1)
	  print("test")
    elseif way == 6 then
	  turtle.down()
	  sleep(.1)
	  print("test")
    end
  end
end
function content()
  print ("Content List")
  print ("Name:		   Usage:")
  print ("RandomWalk()    sjTurtle.derpMode()")
end
I added a ton of test's to see were it failed. (This is an api) But it wont show anything. It wont do anything either.
ardera #2
Posted 13 August 2012 - 07:49 PM
If noStop = nil and stop = nil, then while inf ~= stop do is the same as while nil~=nil do
sjele #3
Posted 13 August 2012 - 07:55 PM
Ermm?
Could you tell me how i should use the while loop in this case?
ardera #4
Posted 13 August 2012 - 08:14 PM
what about:

function derpMode()
local inf = "noStop"
  while inf ~= "stop" do
    way = math.random(1, 6)
    if way == 1 then
          turtle.forward()
          sleep(.1)
          print("test")
    elseif way == 2 then
          turtle.back()
          sleep(.1)
          print("test")
    elseif way == 3 then
          turtle.turnLeft()
          turtle.forward()
          sleep(.1)
          print("test")
    elseif way == 4 then
          turtle.turnLeft()
          turtle.forward()
          sleep(.1)
          print("test")
    elseif way == 5 then
          turtle.up()
          sleep(.1)
          print("test")
    elseif way == 6 then
          turtle.down()
          sleep(.1)
          print("test")
    end
  end
end
function content()
  print ("Content List")
  print ("Name:            Usage:")
  print ("RandomWalk()    sjTurtle.derpMode()")
end
But it won't stop because you didn't add any 'inf="stop" ' now
sjele #5
Posted 13 August 2012 - 08:16 PM
My original plan was not to make it stop, sort of a troll mode.

Thanks.
ardera #6
Posted 13 August 2012 - 08:17 PM
np :P/>/>