Posted 04 November 2018 - 05:54 AM
I'd like to get a solid understand on how I could pass a variable between two different programs. For example, taking variable x = 5 and sending it to another program by sending it and running the other program. os.run({}, "other_program.lua").
I did some research and came across this but even after copying it word for word it's not working. I try some of my own experimentation too, and once again I come up short.
If you could explain in detail why this isn't working or another solution that works that'd be very helpful. I already understand the textutils.serialize just breaks a table up so that you can actually play with the variables but that's all I really gather.
I did some research and came across this but even after copying it word for word it's not working. I try some of my own experimentation too, and once again I come up short.
Spoiler
function serialize(data, name)
if not fs.exists('/data') then
fs.makeDir('/data')
end
local f = fs.open('/data/'..name, 'w')
f.write(textutils.serialize(data))
f.close()
end
function unserialize(name)
if fs.exists('/data/'..name) then
local f = fs.open('/data/'..name, 'r')
data = textutils.unserialize(f.readAll())
f.close()
end
return data
end