Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local serverUrl = "ws://localhost:3000"
- local ws, err = http.websocket(serverUrl)
- if not ws then
- print("WebSocket connection failed:", err)
- return
- end
- local width = 5
- local height = 5
- local x, y = 1, 1
- local goingRight = true
- for row = 1, height do
- for col = 1, width do
- local success, data = turtle.inspect()
- local block = success and data.name or "minecraft:air"
- local msg = textutils.serializeJSON({
- x = x,
- y = y,
- block = block
- })
- ws.send(msg)
- if col < width then
- turtle.dig()
- turtle.forward()
- x = x + (goingRight and 1 or -1)
- end
- end
- if row < height then
- if goingRight then
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- y = y + 1
- goingRight = not goingRight
- end
- end
- ws.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement