View difference between Paste ID: ii6RQaDv and FDLZ8YBv
SHOW: | | - or go back to the newest paste.
1
2
function loadTable(tableName)
3
4
    local data = nil
5
    if fs.exists(tableName) then
6
        local f = io.open(tableName, 'rb')
7
        local dat = f:read('*all')
8
        f:close()
9
        data = textutils.unserialise(dat)
10
    end
11
    return data
12
end
13
    
14
function writeTable(tableName, data)
15
16
    local f = io.open(tableName, 'wb')
17
    f:write(textutils.serialise(data))
18
    f:flush()
19
    f:close()
20
end
21
   
22
tables = {}
23
tables['load'] = loadTable
24
tables['write'] = writeTable