Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local swflag = false
- local initFlag = false
- local bkslot = 2
- local placerOrient = "NULL"
- local placeLock = false
- local moveLock = false
- local moveOrient = "NULL"
- local nowKey = nil
- -- local mModule = peripheral.find("")
- local mModule = peripheral.wrap("right")
- local ID = os.getComputerID()
- local procPlacer = "placer_proc"..ID
- local hostName = "placer_host_"..ID
- rednet.open("left")
- print("my Proc is:\n ",procPlacer)
- rednet.host(procPlacer,hostName)
- local moveLockMap = {
- ['up']=(function () turtle.up() end),
- ['down']=(function () turtle.down() end),
- ['font']=(function () turtle.forward() end),
- ['back']=(function () turtle.back() end),
- ['NULL']=(function () end)
- }
- local keyMap = {
- ["w"]=(function ()
- moveOrient = "font"
- turtle.forward() end),
- ["s"]=(function ()
- moveOrient = "back"
- turtle.back() end),
- ["a"]=(function () turtle.turnLeft() end),
- ["d"]=(function () turtle.turnRight() end),
- ["space"]=(function ()
- moveOrient = "up"
- turtle.up() end),
- ["leftShift"]=(function ()
- moveOrient = "down"
- turtle.down() end),
- ["q"]=(function () turtle.digUp() end),
- ["e"]=(function () turtle.digDown() end),
- ["f"]=(function () turtle.dig() end),
- ["c"]=(function ()
- moveOrient = "NULL"
- placerOrient = "null" end),
- ["x"]=(function () placerOrient = "font" end),
- ["l"]=(function () os.shutdown() end),
- ["g"]=(function () mModule.savePoint("back") end),
- ["t"]=(function () mModule.warpToPoint("back") end),
- ["h"]=(function () moveLock = not moveLock end),
- }
- local function mainloop()
- while(not initFlag) do
- os.sleep(2)
- end
- while 1 do
- turtle.select(bkslot)
- if(nowKey ~= nil) then
- if(keyMap[nowKey]~= nil) then keyMap[nowKey]() end
- nowKey = nil
- else
- --cruise
- if(moveLock) then
- moveLockMap[moveOrient]()
- end
- end
- -- check space
- while (turtle.getItemCount() == 0) do
- bkslot = bkslot + 1
- if(turtle.getItemCount(2) ~= 0) then
- bkslot = 2
- break
- end
- if(bkslot > 16) then
- os.shutdown()
- end
- turtle.select(bkslot)
- end
- -- place
- -- if(placeLock == true) then
- -- placeMap(placerOrient)
- -- end
- -- turn if block
- -- check fuel
- if(turtle.getFuelLevel() < 100) then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- end
- local function netCheck()
- while 1 do
- local event, sender, message, protocol = os.pullEvent("rednet_message")
- initFlag = true
- if(protocol == procPlacer) then
- print(nowKey)
- nowKey = message
- end
- end
- end
- -- local function shutdownCheck()
- -- os.pullEvent("redstone")
- -- print("shutdown !")
- -- end
- -- parallel.waitForAny(main_frame,netCheck)
- parallel.waitForAll(mainloop,netCheck)
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement