Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Operate 2 frame motors moving the mining station LEFT & RIGHT
- local movChannel = 12
- local movRespChannel = 13
- local followChannel = 14
- local followRespChannel = 15
- local modem = peripheral.wrap("right")
- modem.open(movChannel)
- function unsetAll(sigSide)
- rs.setBundledOutput(sigSide,0)
- end
- function move(side,dist)
- local signalSide
- local followerCmd
- if (side == "left") then
- signalSide = "front"
- followerCmd = "follow_Left"
- else
- if (side == "right") then
- signalSide = "back"
- followerCmd = "follow_Right"
- else
- return false
- end
- end
- for i=1,dist do
- modem.transmit(followChannel ,followRespChannel ,followerCmd)
- rs.setBundledOutput(signalSide,colors.red)
- sleep(0.5)
- unsetAll(signalSide)
- sleep(1)
- rs.setBundledOutput(signalSide,colors.black)
- sleep(0.5)
- unsetAll(signalSide)
- sleep(1)
- end
- end
- while true do
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- local op=textutils.unserialize(message)
- --print(op.name)
- --print("__"..op.direction)
- --print("__"..op.iter)
- if (op.name == "lateral") then
- move(op.direction, tonumber(op.iter))
- modem.transmit(movRespChannel,movChannel,"lateral OK")
- end
- sleep(3)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement