Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m=peripheral.wrap("right")
- t=peripheral.wrap("top")
- -- If chunk unloads or server resets, this will reorient to the proper facing and makes sure the inv is clear
- local function firstRun()
- while turtle.detect() do
- turtle.turnLeft()
- end
- turtle.turnRight()
- for i=1,16 do
- turtle.select(i)
- turtle.drop()
- end
- end
- -- This is a replacement for sleep()
- function wait( _nsec )
- local timer = os.startTimer( _nsec )
- repeat
- local sEvent, param = os.pullEvent("timer")
- until param == timer
- end
- -- Prints out current actin on the monitor
- local function monitorControl()
- local t=peripheral.wrap("top")
- t.setTextScale(1)
- t.clear()
- t.setCursorPos(x,y)
- t.write(status)
- end
- -- Pull the pearls out of the ME system. If the ME system is out of pearls it will shut down.
- local function getPearls()
- turtle.select(1)
- turtle.suck()
- if turtle.getItemCount(1) < 9 then
- status="Out of Pearls!"
- x=2
- y=1
- monitorControl()
- turtle.drop()
- wait(30)
- os.reboot()
- end
- end
- -- Convert enderpears to iron
- local function endtoiron()
- turtle.select(1)
- for a=1,8 do
- wait(.5)
- m.transmuteItem(1)
- end
- turtle.transferTo(2)
- end
- -- Convert iron to gold
- local function irontogold()
- turtle.select(2)
- for a=1,4 do
- m.transmuteItem(8)
- wait(.5)
- end
- turtle.select(2)
- turtle.transferTo(3)
- end
- -- Convert gold to diamonds
- local function goldtodia()
- turtle.select(3)
- m.transmuteItem(4)
- end
- -- Pulls a fresh minium stone out of the ME system and recharges. Shuts down if there are no stones in the ME
- local function chargeUp()
- if m.getMiniumCharge() < 25 then
- turtle.turnRight()
- turtle.select(1)
- turtle.suck()
- if turtle.getItemCount(1) < 1 then
- status="Out of Minium"
- x=2
- y=1
- monitorControl()
- wait(30)
- os.reboot()
- end
- m.rechargeMinium()
- turtle.turnLeft()
- end
- end
- -- Reads the level emitters to determine what to make.
- local function readLevels()
- mode=1
- if not redstone.getInput("bottom") then
- mode=2
- end
- if not redstone.getInput("back") then
- mode=3
- end
- end
- -- Puts it all together and makes it run
- firstRun()
- while true do
- readLevels()
- chargeUp()
- if mode==3 then
- x=2
- y=1
- status="Making Diamonds"
- monitorControl()
- getPearls()
- endtoiron()
- irontogold()
- goldtodia()
- end
- if mode==2 then
- x=2
- y=1
- status="Making Gold"
- monitorControl()
- getPearls()
- endtoiron()
- irontogold()
- end
- if mode==1 then
- x=2
- y=1
- status="Making Iron"
- monitorControl()
- getPearls()
- endtoiron()
- end
- for a=1,4 do
- turtle.select(a)
- turtle.drop()
- end
- turtle.select(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement