Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("left")
- os.loadAPI('json')
- function get()
- local object = json.decodeFromFile("bot/cords.json")
- cords = {object["x"], object["y"], object["z"], object["direction"]}
- end
- function add_to_cords(x, y, z)
- old_cords = get()
- old_x = old_cords[1]
- old_y = old_cords[2]
- old_z = old_cords[3]
- dir = old_cords[4]
- x = tostring(tonumber(old_x) + x)
- y = tostring(tonumber(old_y) + y)
- z = tostring(tonumber(old_z) + z)
- obj = "{\n \"x\": \"" .. tostring(x) .. "\",\n \"y\": \"" .. tostring(y) .. "\",\n \"z\": \"".. tostring(z) .. "\",\n \"direction\": \"" .. tostring(dir) .. "\"\n}"
- f = fs.open("bot/cords.json", 'w')
- f.write(obj)
- f.close()
- print(obj)
- sleep(2)
- end
- function turnLeft()
- end
- function turnRight()
- end
- function forward()
- end
- function back()
- end
- while true do
- sender, message, method = rednet.receive()
- if message == "w" then
- turtle.forward()
- elseif message == "s" then
- turtle.back()
- elseif message == "a" then
- turtle.turnLeft()
- elseif message == "d" then
- turtle.turnRight()
- elseif message == "r" then
- turtle.refuel()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement