Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local status = "walk"
- os.unloadAPI("wirelessAPI")
- os.loadAPI("wirelessAPI")
- wirelessAPI.init(false, "right", "messendiger", status)
- function fw()
- if status == "mining" then
- while turtle.detect() do
- turtle.dig()
- end
- end
- turtle.forward()
- end
- function bw()
- if status == "mining" then
- turtle.turnLeft()
- turtle.turnLeft()
- fw()
- else
- turtle.back()
- end
- end
- function up()
- if status == "mining" then
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- turtle.up()
- end
- function down()
- if status == "mining" then
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- turtle.down()
- end
- function place()
- for i = 1, 16, 1 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- turtle.place()
- return
- end
- end
- end
- repeat
- local event, sID, msg, dist, prot = wirelessAPI.listen(1)
- if event == "rednet_message" then
- print("Message received: "..textutils.serialize(msg))
- if msg == "forward" then
- fw()
- end
- if msg == "backward" then
- bw()
- end
- if msg == "up" then
- up()
- end
- if msg == "down" then
- down()
- end
- if msg == "left" then
- turtle.turnLeft()
- end
- if msg == "right" then
- turtle.turnRight()
- end
- if msg == "place" then
- place()
- end
- if msg == "mining" or msg == "walking" then
- status = msg
- end
- end
- until msg == "offline"
- os.unloadAPI("wirelessAPI")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement