-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataControl.lua
More file actions
51 lines (42 loc) · 1.24 KB
/
dataControl.lua
File metadata and controls
51 lines (42 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
fs = love.filesystem
dataControl = {}
--savefile should be in the registry
saveFile,fileError = fs.newFile("tree2.txt")
function dataControl.draw()
if DEBUG_MODE then
love.graphics.setColor(0,255,0)
love.graphics.print("Debug:",0,0)
local y = 30
for name,data in pairs(rawData) do
love.graphics.print(name..": "..tostring(data),0,y)
y=y+30
end
end
end
function dataControl.save()
local data = {}
--allocate variables to the data object here, that will be saved
data.branches = tree.branches
--end variable alloation
rawData = tree.branches
if saveFile:open("w") then
local raw = serialize(data)
saveFile:write(raw)
saveFile:close()
end
end
function dataControl.load()
if saveFile:open("r") then
local raw = saveFile:read()
local data = deserialize(raw)
if type(data)=='table' then
--allocate variables to load and where to assign them
--where numbers are required use tonumber!! else BUGS
tree.branches = data.branches
--end variable allocation
rawData = data.branches
end
saveFile:close()
end
end
return dataControl