Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin get gDJQ15HN startup
- left = function()
- return turtle.turnLeft()
- end
- right = function()
- return turtle.turnRight()
- end
- up = function()
- return turtle.up()
- end
- down = function()
- return turtle.down()
- end
- back = function()
- return turtle.back()
- end
- go = function()
- return turtle.forward()
- end
- fuel = function()
- return turtle.getFuelLevel()
- end
- select = function(id)
- return turtle.select(id)
- end
- count = function(id)
- return turtle.getItemCount(id)
- end
- move = function(id, nb)
- return turtle.transferTo(id, nb)
- end
- --coucou coucou- -------------------------------------------
- function testFuel()
- if(fuel() < 100)then
- print('Plus de coco, test de refuel')
- j = 1
- if (count(j)>0) then
- select(j)
- end
- flagstop = false
- while(flagstop == false)do
- if(count(j)>0 and turtle.refuel(3)==true)then
- print('refuel 3, slot '..j)
- return true
- end
- if(j==16)then
- print('imposible de refuel, exit')
- return false
- end
- j=j+1
- if(count(j)>0) then
- select(j)
- end
- end
- end
- end
- function httpGet()
- local request
- request = http.get("http://192.168.1.18:88/ctrl.php")
- txt = request.readAll()
- request.close()
- return txt;
- end
- function init()
- return testFuel();
- end
- stop=false
- if(init()==false) then
- stop=true
- end
- while(stop==false)do
- testFuel()
- order = httpGet()
- if(order=="Forward") then
- for i = 1, 10 do
- go()
- end
- end
- if(order=="Up") then
- up()
- end
- if(order=="Left") then
- left()
- end
- if(order=="Stop") then
- print("Stop")
- sleep(10)
- end
- if(order=="Right") then
- right()
- end
- if(order=="Half Turn") then
- right()
- right()
- end
- if(order=="Back") then
- for i = 1, 10 do
- back()
- end
- end
- if(order=="Down") then
- down()
- end
- sleep(1)
- end
- print('End')
- if(fuel() == 0) then
- print('Ya plus de coco mon coco !')
- end
Add Comment
Please, Sign In to add comment