spacetrack/lib/saveGame.jl

51 lines
882 B
Julia
Raw Permalink Normal View History

2018-12-12 08:17:44 -07:00
module saveGame
export savegame,
user,
saveDir,
saveFile
user = ENV["USER"]
saveDir = "/home/$user/.config/spacetrack"
2018-11-20 17:23:43 -07:00
function savegame(
playerid::String,
playerName::String,
shipName::String,
createSave::Bool
)
2018-12-12 08:17:44 -07:00
io = IOBuffer()
2018-11-20 17:23:43 -07:00
2018-12-12 08:17:44 -07:00
saveFile = ""
2018-11-20 17:23:43 -07:00
if createSave == true
mkpath(saveDir)
print("Name youe save file: ")
saveFileName = readline()
if isempty(saveFileName) == true
2018-12-12 08:17:44 -07:00
global saveFile = "untitled.conf"
2018-11-20 17:23:43 -07:00
else
2018-12-12 08:17:44 -07:00
global saveFile = saveFileName
2018-11-20 17:23:43 -07:00
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
2018-12-12 08:17:44 -07:00
end