Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Computer portion!
- function main()
- term.clear()
- x,y = term.getSize()
- term.setCursorPos(1,1)
- term.setCursorBlink(true)
- print("Welcome to turtlemine!")
- OpenAllPorts()
- Input()
- end
- function OpenAllPorts()
- for _,v in ipairs(rs.getSides()) do
- rednet.open(v)
- end
- end
- function Input()
- while true do
- term.write("mine > ")
- local x = read()
- if(string.lower(x)=="exit") then
- break
- end
- rednet.broadcast(x)
- end
- end
- main()
- -- Miner portion!
- function main()
- OpenAllPorts()
- while true do
- local id,request = rednet.receive()
- print(request)
- local args = split(request," ")
- local program = args[1]
- table.remove(args,1)
- shell.run(program,cunpack(args))
- end
- end
- function OpenAllPorts()
- for _,v in ipairs(rs.getSides()) do
- rednet.open(v)
- end
- end
- function split(x,sep)
- local sep, fields = sep or ":", {}
- local pattern = string.format("([^%s]+)", sep)
- x:gsub(pattern, function(c) fields[#fields+1] = c end)
- return fields
- end
- function cunpack(t,pk)
- local k,v = next(t,pk)
- if k ~= nil then
- return v,cunpack(t,k)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment