Jump to content




[Help] Function wont do nothing [turtles]


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

#1 sjele

  • Members
  • 334 posts
  • LocationSomewhere on the planet called earth

Posted 13 August 2012 - 06: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.

#2 ardera

  • Members
  • 503 posts
  • LocationGermany

Posted 13 August 2012 - 06:49 PM

If noStop = nil and stop = nil, then while inf ~= stop do is the same as while nil~=nil do

#3 sjele

  • Members
  • 334 posts
  • LocationSomewhere on the planet called earth

Posted 13 August 2012 - 06:55 PM

Ermm?
Could you tell me how i should use the while loop in this case?

#4 ardera

  • Members
  • 503 posts
  • LocationGermany

Posted 13 August 2012 - 07: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

#5 sjele

  • Members
  • 334 posts
  • LocationSomewhere on the planet called earth

Posted 13 August 2012 - 07:16 PM

My original plan was not to make it stop, sort of a troll mode.

Thanks.

#6 ardera

  • Members
  • 503 posts
  • LocationGermany

Posted 13 August 2012 - 07:17 PM

np :P/>





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users