aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--loading.lua15
-rw-r--r--settings.lua4
-rw-r--r--virus1.lua2
-rw-r--r--virus2.lua3
4 files changed, 18 insertions, 6 deletions
diff --git a/loading.lua b/loading.lua
index 49af6bd..26657c2 100644
--- a/loading.lua
+++ b/loading.lua
@@ -47,9 +47,15 @@ function drawPause()
love.graphics.setBackgroundColor(0, 128, 128)
end
end
+function saveGameFile()
+ love.filesystem.write("savegame.txt","v1.complete = ".. bool2str(v1.complete) ..";virus1Lose = " .. virus1Lose .. ";v2.complete = ".. bool2str(v2.complete) ..";virus2Lose = " .. virus2Lose .. ";")
+end
+function resetGameFile()
+ love.filesystem.write("savegame.txt","v1.complete = false;virus1Lose = 0;v2.complete = false;virus2Lose = 0;")
+end
function loadSave()
if love.filesystem.exists("savegame.txt") == false then
- love.filesystem.write("savegame.txt", "")
+ saveGameFile()
else
loadGame = love.filesystem.load("savegame.txt")
loadGame()
@@ -60,3 +66,10 @@ function loadSave()
profile.setup = true
end
end
+function bool2str(bool)
+ if bool == false then
+ return "false"
+ else
+ return "true"
+ end
+end
diff --git a/settings.lua b/settings.lua
index cdb0484..68db83b 100644
--- a/settings.lua
+++ b/settings.lua
@@ -111,7 +111,7 @@ end
function updateSettings()
if mouseClick(win[6].x+8, win[6].y+467, 384/2-4, 23) == true and layer[1] == 6 then
love.audio.stop()
- love.filesystem.remove("savefile.txt")
+ resetGameFile()
loadRe()
end
if mouseClick(win[6].x+8, win[6].y+492, 384/2-4, 23) == true and layer[1] == 6 then
@@ -121,7 +121,7 @@ function updateSettings()
end
if mouseClick(win[6].x+8, win[6].y+517, 384/2-4, 23) == true and layer[1] == 6 then
love.audio.stop()
- love.filesystem.remove("savefile.txt")
+ resetGameFile()
love.filesystem.remove("profile.txt")
loadRe()
end
diff --git a/virus1.lua b/virus1.lua
index 2746eed..d6f2177 100644
--- a/virus1.lua
+++ b/virus1.lua
@@ -543,7 +543,6 @@ function drawVirusFight1()
if v1.explodeEndFrame >= 20 then
v1.yes = false
if v1.c.chat.msgs == 47 then
- love.filesystem.write("savegame.txt", "v1.complete = true;virus1Lose = " .. virus1Lose .. ";")
win[4].w = 200
antivirus.status = "Virus Defeated"
win[4].update = true
@@ -556,6 +555,7 @@ function drawVirusFight1()
virus1Lose = virus1Lose + 1
scene = 666
end
+ saveGameFile()
end
end
end
diff --git a/virus2.lua b/virus2.lua
index 317c8e4..18e3e29 100644
--- a/virus2.lua
+++ b/virus2.lua
@@ -322,8 +322,6 @@ function drawVirusFight2()
if v1.explodeEndFrame >= 20 then
v2.start = false
if v2.c.health == -20 then
- local prevSave = love.filesystem.read("savegame.txt")
- love.filesystem.write("savegame.txt", prevSave .. "v2.complete = true;virus2Lose = " .. virus2Lose .. ";")
scene = 1
win[4].w = 200
antivirus.status = "Virus Defeated"
@@ -336,6 +334,7 @@ function drawVirusFight2()
scene = 666
virus2Lose = virus2Lose + 1
end
+ saveGameFile()
end
end
end