Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --STS
- --load wireless modem
- function loadWireless()
- modem = peripheral.wrap("left")
- wirelessMode = true
- if( modem == nil) then
- wirelessMode = false
- return false
- else
- return true
- end
- end
- local currentX, currentY, currentZ = 0
- local currentFace, startingFace = 0
- pcId = 0
- --face: 0 South; 1 East; 2 North; 3 West
- function sendMsg(msg, channel)
- if not wirelessMode then
- print("Not wireless")
- end
- modem.transmit(channel, pcId, msg)
- end
- function getStartingFace()
- return startingFace
- end
- function initLocation(x, y, z, face, pc)
- currentX = x
- currentY = y
- currentZ = z
- currentFace = face
- pcId = tonumber(pc)
- end
- function getX()
- return currentX
- end
- function getY()
- return currentY
- end
- function getZ()
- return currentZ
- end
- function getFace()
- return currentFace
- end
- function down()
- if turtle.down() then
- currentY = currentY - 1
- return true
- else
- return false
- end
- end
- function up()
- turtle.up()
- currentY = currentY + 1
- end
- function forward()
- while not turtle.forward() do
- turtle.dig()
- end
- --face: 0 South; 1 East; 2 North; 3 West
- if (currentFace == 0) then
- currentZ = currentZ + 1
- elseif currentFace == 1 then
- currentX = currentX + 1
- elseif currentFace == 2 then
- currentZ = currentZ - 1
- else
- currentX = currentX - 1
- end
- end
- function turnLeft()
- turtle.turnLeft()
- if(currentFace == 3) then
- currentFace = 0
- else
- currentFace = currentFace + 1
- end
- end
- function turnRight()
- turtle.turnRight()
- if(currentFace == 0) then
- currentFace = 3
- else
- currentFace = currentFace - 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement