Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --todo
- --cord system
- --storage system
- --starup code
- --refuel system
- local x,y,z = 0,0,0
- local rotationtable = {North={1,0},South={-1,0},West={0,1},East={0,-1}}
- local rotation = 0
- local buildlimit = 1
- --function gets an item name
- --returns the number of the slot its in and if it cant find it returns 0
- function FindItemSlot(Itemname)
- local slotnum = 1
- while slotnum<17 do
- if string.find(turtle.getItemDetail(slotnum).name,Itemname) then
- return slotnum
- end
- slotnum = slotnum + 1
- end
- return 0
- end
- function Refuelcheck()
- local coalslot = FindItemSlot("coal")
- if coalslot==0 then
- return -1
- end
- if turtle.getFuelLevel()<1000 then
- turtle.refuel(turtle.getItemCount(coalslot)/2)
- end
- end
- function Turn(RightorLeft)
- if RightorLeft=="Right" then
- rotation = rotation + 90
- turtle.turnRight()
- end
- if RightorLeft=="Left" then
- rotation = rotation - 90
- turtle.turnLeft()
- end
- end
- function MoveForwards()
- local temp = rotationtable[math.abs(rotation)/90]
- x = x + temp[1]
- z = z + temp[2]
- turtle.MoveForwards()
- end
- function Setbuildlimit()
- if string.find(turtle.inspectDown().name ,"torch") then
- local is2ndTorchfound = false
- repeat
- MoveForwards()
- buildlimit = buildlimit + 1
- if string.find(turtle.inspectDown().name ,"torch") then
- turtle.digDown()
- is2ndTorchfound=true
- Turn("Left")
- Turn("Left")
- end
- until is2ndTorchfound
- is2ndTorchfound = false
- repeat
- MoveForwards()
- if string.find(turtle.inspectDown().name ,"torch") then
- turtle.digDown()
- is2ndTorchfound=true
- Turn("Left")
- Turn("Left")
- end
- until is2ndTorchfound
- end
- end
- function MoveVertical(UpOrDown)
- if UpOrDown=="Up" then
- turtle.up()
- y = y - 1
- end
- if UpOrDown == "Down" then
- turtle.down()
- y = y + 1
- end
- end
- function FreeSlotsleft()
- local count = 0
- local i = 1
- repeat
- if turtle.getItemCount(i)>0 then
- count = count + 1
- end
- i = i + 1
- until i==16
- return count
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement