Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- map = {}
- X = 0
- Y = 0
- Z = 0
- angle = 0
- function setmapblock(x,y,solid)
- if map[x] == nil then
- map[x] = {}
- end
- map[x][y] = solid
- end
- function getmapblock(x,y)
- if map[x] == nil then
- return nil
- elseif map[x][y] == nil then
- return nil
- end
- return map[x][y]
- end
- function drawmap()
- --location = gps.locate(1, false)
- term.clear()
- term.setCursorPos(1,1)
- print(location)
- for y = Y-8, Y+16 do
- term.setCursorPos(1,y-Y+5)
- for x = X-6,X+12 do
- block = getmapblock(x,y)
- if x-X == 0 and y-Y == 0 then
- term.write("@")
- elseif block == nil then
- term.write("o")
- elseif block == 1 then
- term.write("#")
- else--block == 0
- term.write("_")
- -- term.setTextColor(colors.gray)
- -- term.write("x")
- end
- end
- term.write("/n")
- end
- end
- function chop()
- shell.run("note-ai","happy")
- turtle.select(1)
- while turtle.detect() do
- updatefuel()
- turtle.dig()
- turtle.digUp()
- turtle.up()
- end
- while not turtle.detectDown() do
- updatefuel()
- turtle.down()
- end
- if turtle.getItemCount(3) > 1 then
- turtle.select(3)
- turtle.place()
- rotate()
- end
- end
- function rotate()
- if math.random(0,1) == 1 then
- turtle.turnLeft()
- angle = angle + 1
- else
- turtle.turnRight()
- angle = angle - 1
- end
- if angle > 3 then angle = angle - 4
- elseif angle < 0 then angle = angle + 4 end
- end
- function updatefuel()
- if turtle.getFuelLevel() == 0 then
- turtle.select(1)
- turtle.refuel(1)
- happyness = happyness + 2.5
- sleep(1)
- end
- end
- happyness = 10
- while true do
- happyness = happyness - 0.125
- if happyness <= 0 then
- for i=1,4 do
- shell.run("note-ai", "angry")
- sleep(5)
- end
- happyness = 5
- elseif happyness > 10 then
- happyness = 10
- end
- updatefuel()
- xx = 0
- yy = 0
- if angle == 0 or angle == 2 then
- xx = 1-angle
- elseif angle == 1 or angle == 3 then
- yy = 1-angle+1
- end
- turtle.select(3)
- if turtle.suck() or turtle.suckUp() or turtle.suckDown() then
- shell.run("note-ai","happy")
- happyness = happyness + 1
- end
- if turtle.getItemCount(3) > 2 and math.random(0,3) == 0 then
- shell.run("note-ai","happy")
- happyness = happyness + 1
- turtle.place()
- rotate()
- end
- if turtle.detect() then
- issolid = false
- turtle.select(2)
- issolid = turtle.compare()
- turtle.select(3)
- issolid = issolid or turtle.compare()
- if not issolid then
- happyness = happyness + 2
- chop()
- else
- happyness = happyness - 0.1
- setmapblock(X+xx,Y+yy, 1)
- rotate()
- end
- elseif not turtle.detectDown() then
- setmapblock(X,Y, 1)
- turtle.back()
- rotate()
- else
- setmapblock(X+xx,Y+yy, 0)
- turtle.forward()
- X = X + xx
- Y = Y + yy
- if math.random(0,3) == 1 then
- rotate()
- end
- end
- drawmap()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement