Posted 03 September 2017 - 07:42 PM
So, I am having issues when loading the current values of a table into the 'RAM' of the computer I currently assume that a table inside a program cannot be edited and saved without loading it externally so, I set it so that there are two functions and by default the program has an empty white list.
These two functions are to save and load any changes to the white list within the program. to an external program called WL I figured that after I saved a name to a white list it would have no effect as I did not update or load the permanent white list into the white list "RAM" and therefore save another empty file.
So what I am asking is how do I use the load function to load the serialised table from the external file into the whitelist variable within the program to create a working table add and remove system.
whitelist = {}
function save(whitelist,WL)
local file = fs.open("WL","w")
file.write(textutils.serialize(whitelist))
file.close()
end
function load(WL)
local file = fs.open("WL","r")
local data = file.readAll()
file.close()
return textutils.unserialize(data)
end
These two functions are to save and load any changes to the white list within the program. to an external program called WL I figured that after I saved a name to a white list it would have no effect as I did not update or load the permanent white list into the white list "RAM" and therefore save another empty file.
term.clear()
term.setCursorPos(2,2)
write("Insert Player IGN > ")
local IGN = read()
table.insert(whitelist,IGN)
save(whitelist,WL)
term.clear()
term.setCursorPos(2,2)
write(IGN.." has been whitelisted.")
sleep(2)
term.clear()
for i = 1,3 do
term.setCursorPos(2,i+3)
textutils.slowPrint(whitelist[i])
sleep(0.3)
end
So what I am asking is how do I use the load function to load the serialised table from the external file into the whitelist variable within the program to create a working table add and remove system.
Edited on 03 September 2017 - 05:44 PM