100 posts
Location
Sublime Text 2
Posted 20 October 2015 - 02:05 PM
I am trying to make a OS/UI, and i need to get a table out of a file what is the best way to do it??
i am now using:
file = fs.open(path,"r") – path is actually a real path!
local Buttons = file.readAll()
file.close()
Any way to fix this??
(If there is any wrong English i am sorry from Holland :D/>)
212 posts
Location
Somewhere in this dimension... I think.
Posted 20 October 2015 - 08:21 PM
textutils.unserialize(Buttons) (American version)
Edited on 20 October 2015 - 06:21 PM
7083 posts
Location
Tasmania (AU)
Posted 20 October 2015 - 10:37 PM
Er, wouldn't that be…?
local Buttons = textutils.unserialise(file.readAll())
The file would need to contain nothing but the table structure. Experiment with textutils.serialise(someTable) for examples of what you can put in it.
212 posts
Location
Somewhere in this dimension... I think.
Posted 20 October 2015 - 11:04 PM
Either way works since buttons would equal the content and as long as my example is set to something it will be reuseable.
3057 posts
Location
United States of America
Posted 20 October 2015 - 11:08 PM
Either way works since buttons would equal the content and as long as my example is set to something it will be reuseable.
…which you didn't show in your post. Your post would imply using textutils.serialize on the variable would make the variable a table, when in fact that is impossible to do in Lua.
212 posts
Location
Somewhere in this dimension... I think.
Posted 20 October 2015 - 11:39 PM
The variable is a string of data that is in this case assumed to be a serialised table.
100 posts
Location
Sublime Text 2
Posted 21 October 2015 - 10:02 AM
Thanks it works !!!