spacetrack/lib/saveGame.jl
2018-12-12 08:17:44 -07:00

51 lines
882 B
Julia

module saveGame
export savegame,
user,
saveDir,
saveFile
user = ENV["USER"]
saveDir = "/home/$user/.config/spacetrack"
function savegame(
playerid::String,
playerName::String,
shipName::String,
createSave::Bool
)
io = IOBuffer()
saveFile = ""
if createSave == true
mkpath(saveDir)
print("Name youe save file: ")
saveFileName = readline()
if isempty(saveFileName) == true
global saveFile = "untitled.conf"
else
global saveFile = saveFileName
end
open("$saveDir/$saveFile", "w") do io
write(io, "player-id = ", playerid, "\n")
write(io, "pilot-name = ", playerName, "\n");
write(io, "ship-name = ", shipName, "\n");
end;
close(io)
end
return saveFile
end
end