Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local stream = dofile("stream.lua")
- stream.aiStream = function(max_n)
- ret = stream.Stream()
- tStorage = {}
- function next()
- return table.remove(tStorage, 1)
- end
- function generate(target_amt)
- local i = #tStorage
- repeat
- i = i+1
- tStorage[i] = roll()
- until i == target_amt
- end
- function hasNext()
- return #tStorage > 0
- end
- ret.next = next
- ret.generate = generate
- ret.hasNext = hasNext
- return ret
- end
- function roll()
- local n = math.random(1,8)
- return n
- end
- function boundaries()
- local t,n = turtle.inspect()
- if t then
- if n['name'] == "minecraft:planks" or n['name'] == "minecraft:glass" then
- return true
- else
- return false
- end
- else
- return false
- end
- end
- local function fuel()
- if turtle.getFuelLevel() < 10 then
- turtle.select(16)
- turtle.refuel()
- turtle.select(1)
- end
- end
- local ai = stream.aiStream()
- ai.generate(20)
- while ai.hasNext() do
- local touching = boundaries()
- local act = ai.next()
- fuel()
- if act == 1 then
- turtle.up()
- elseif act == 2 then
- turtle.down()
- elseif act == 3 then
- turtle.turnLeft()
- elseif act == 4 then
- turtle.turnRight()
- elseif act == 5 then
- turtle.forward()
- elseif act == 6 then
- turtle.back()
- elseif act == 7 and touching == false then
- turtle.dig()
- else
- turtle.place()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment