Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local item = turtle.getItemDetail() or error("put modem in current slot.")
- local mainChannel = 21
- local fuelNames = {"minecraft:coal"}
- function refuel(i, fuel)
- local name = turtle.getItemDetail(i).name
- if fuel == name then
- turtle.select(i)
- turtle.refuel()
- turtle.select(1)
- else
- error("not fuel")
- end
- end
- if item.name == "computercraft:peripheral" and item.damage == 1 then
- turtle.equipLeft()
- local modem = peripheral.wrap("left")
- modem.open(mainChannel)
- local event, side, channel, replyChannel, message, distance
- local moved, reason
- while true do
- moved = true
- event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- message = tostring(message)
- if message == "w" then
- moved, reason = turtle.forward()
- elseif message == "s" then
- moved, reason = turtle.back()
- elseif message == "a" then
- moved, reason = turtle.turnLeft()
- elseif message == "d" then
- moved, reason = turtle.turnRight()
- elseif message == "r" then
- for i = 1, 16 do
- for _, fuel in pairs(fuelNames) do
- if pcall(refuel, i, fuel) then break end
- end
- end
- end
- if moved == false then
- modem.transmit(mainChannel, mainChannel, "Didn't move: " .. reason)
- else
- modem.transmit(mainChannel, mainChannel, "Moved")
- end
- end
- else
- error("put modem in current slot.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement