Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not arg[1] then
- error("File not found.",2)
- end
- local file = io.open(arg[1], "r")
- local map = textutils.unserialise(file:read("*a"))
- file:close()
- rednet.open("back")
- print("Welcome to snap.")
- print("To add new intersection stand in the middle and type name or leave blank and press enter.")
- print("After adding new intersection you can add connections by typing index numbers of intersections to connect to. To leave connection mode type -1.")
- print("To save and quit type \":q\".")
- print("If you wish to abort saving just terminate the program.")
- while true do
- local name
- local conn
- local x, z
- write("Name: ")
- name = read()
- x, _, z = gps.locate(2)
- if name == ":q" or x == nil then
- break
- elseif name == "" then
- name = nil
- end
- map.intersections[#map.intersections+1] = {x = x, y = z, name = name}
- print("Index: "..#map.intersections)
- while true do
- write("Connection: ")
- conn = tonumber(read())
- if conn == -1 then
- break
- end
- map.connections[#map.connections+1] = {#map.intersections, conn}
- end
- end
- file = io.open(arg[1],"w")
- file:write(textutils.serialise(map))
- file:close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement