Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mats = peripheral.wrap("back")
- -- done = peripheral.wrap("left")
- shapeDone = false
- function randomInt(min,max)
- return min + math.floor(math.random() * (max - min +1))
- end
- paper = 9
- firstColor = 1
- lastColor = 8
- firstShape = 10
- lastShape = 13
- firstSpecial = 14
- lastSpecial = 15
- firstGunpowder = 16
- lastGunpowder = 19
- function randomColor()
- return randomInt(firstColor,lastColor)
- end
- function randomGunpowder()
- return randomInt(firstGunpowder,lastGunpowder)
- end
- function randomShape()
- return randomInt(firstShape,lastShape)
- end
- function pull(n,optional)
- if not optional and mats.getStackInSlot(n).qty == nil then
- print("Refill Slot: ",n)
- while mats.getStackInSlot(n).qty == nil do
- sleep(3)
- end
- end
- os.sleep(.1)
- mats.pushItem("west", n, 1)
- end
- function pullThings(first,last,start)
- start = start or 0
- d = last - first
- n = 2^d
- r = randomInt(start,n-1)
- for i = 0,d-1 do
- if bit.band(r,2^i) ~= 0 then
- if first+1 < firstShape and first+i > lastShape then
- pull(first+i, true)
- end
- end
- end
- end
- function repack()
- turtle.select(4)
- turtle.transferTo(9)
- turtle.select(8)
- turtle.transferTo(10)
- turtle.select(1)
- end
- while true do
- turtle.select(1)
- pull(randomColor()) print("color")
- pull(randomGunpowder()) print("gunpowder")
- shapeNum = randomShape() print("shape")
- if shapeNum ~= lastShape then
- pull(shapeNum)
- end
- pullThings(firstSpecial,lastSpecial) print("special")
- if turtle.getItemCount(2) > 1 then
- turtle.select(2)
- turtle.transferTo(9,1)
- turtle.transferTo(10,1)
- turtle.transferTo(11,1)
- end
- repack()
- turtle.craft()
- os.sleep(1)
- for numGun = 1,randomInt(1,3) do
- pull(randomGunpowder()) print("gunpowder")
- end
- pull(paper) print("paper")
- repack()
- if turtle.getItemCount(2) > 1 then
- turtle.select(2)
- turtle.transferTo(9,1)
- turtle.transferTo(10,1)
- turtle.transferTo(11,1)
- end
- turtle.craft()
- turtle.drop() print("dump")
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement