Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function handle(res)
- local actions = {
- w = turtle.forward,
- a = turtle.turnLeft,
- s = turtle.back,
- d = turtle.turnRight,
- l = turtle.place,
- j = turtle.dig,
- i = turtle.up,
- k = turtle.down
- }
- if actions[res] ~= nil then
- actions[res]()
- end
- end
- while true do
- http.request("http://localhost:8080")
- local event, url, res = os.pullEvent()
- if event == 'http_success' then
- handle(res:readAll())
- elseif event == 'http_failure' then
- printError("HTTP request failed.")
- return
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment