Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function gsplit2(s,sep)
- local lasti, done, g = 1, false, s:gmatch('(.-)'..sep..'()')
- return function()
- if done then return end
- local v,i = g()
- if s == '' or sep == '' then done = true return s end
- if v == nil then done = true return s:sub(lasti) end
- lasti = i
- return v
- end
- end
- rednet.open( "right" )
- while true do
- local sEvent, param1, param2 = os.pullEvent()
- if sEvent == "rednet_message" then
- local p1,p2,p3,p4 = gsplit2(param2," ")
- if p1 == "go" then
- if p2 == "forward" then
- for i=1,p3 do
- turtle.forward()
- end
- elsif p2 == "back" then
- for i=1,p3 do
- turtle.back()
- end
- elsif p2 == "left" then
- turtle.turnLeft()
- for i=1,p3 do
- turtle.forward()
- end
- turtle.turnRight()
- elsif p2 == "right" then
- turtle.turnRight()
- for i=1,p3 do
- turtle.forward()
- end
- turtle.turnLeft()
- elsif p2 == "up" then
- for i=1,p3 do
- turtle.up()
- end
- elsif p2 == "down" then
- for i=1,p3 do
- turtle.down()
- end
- end
- elsif p1 == "excdia" then
- shell.run("excdia", p2)
- else
- print("Unknown command: "..p1.." "..p2.." "..p3)
- end
- end
- if sEvent == "char" and param1 == "q" then
- break
- end
- end
- rednet.close("right")
Add Comment
Please, Sign In to add comment