From 8b350eb9a2de0ab1767bfcb1663feec55b60f9c1 Mon Sep 17 00:00:00 2001 From: mollusk Date: Wed, 12 Dec 2018 08:17:44 -0700 Subject: [PATCH] try to fix scope issue --- lib/player.jl | 1 + lib/saveGame.jl | 22 +++++++++++++++------- src/spacetrack.jl | 3 +++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/player.jl b/lib/player.jl index c2d3c04..80fb446 100755 --- a/lib/player.jl +++ b/lib/player.jl @@ -1,6 +1,7 @@ #!/usr/bin/julia include("saveGame.jl") +using Main.saveGame mutable struct Pilot Name::String diff --git a/lib/saveGame.jl b/lib/saveGame.jl index 5503201..3ff09bb 100644 --- a/lib/saveGame.jl +++ b/lib/saveGame.jl @@ -1,4 +1,13 @@ -saveDir = "~/.config/spacetrack" +module saveGame + +export savegame, + user, + saveDir, + saveFile + + +user = ENV["USER"] +saveDir = "/home/$user/.config/spacetrack" @@ -9,9 +18,9 @@ function savegame( createSave::Bool ) - local io = IOBuffer() + io = IOBuffer() - + saveFile = "" if createSave == true mkpath(saveDir) @@ -21,10 +30,10 @@ function savegame( if isempty(saveFileName) == true - global saveFile = untitled.conf + global saveFile = "untitled.conf" else - saveFile = saveFileName + global saveFile = saveFileName end open("$saveDir/$saveFile", "w") do io @@ -39,5 +48,4 @@ function savegame( return saveFile end - -saveFile = saveFile \ No newline at end of file +end \ No newline at end of file diff --git a/src/spacetrack.jl b/src/spacetrack.jl index ba0da8f..8248ccc 100755 --- a/src/spacetrack.jl +++ b/src/spacetrack.jl @@ -1,6 +1,9 @@ #!/usr/bin/julia include("../lib/player.jl") +include("../lib/saveGame.jl") + + function main_menu() create_pilot()