Jump to content




From file to table?


  • You cannot reply to this topic
6 replies to this topic

#1 ReBraLaCC

  • Members
  • 100 posts
  • LocationSublime Text 2

Posted 20 October 2015 - 01: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)

#2 TYKUHN2

  • Members
  • 210 posts
  • LocationSomewhere in this dimension... I think.

Posted 20 October 2015 - 07:21 PM

textutils.unserialize(Buttons) (American version)

Edited by TYKUHN2, 20 October 2015 - 07:21 PM.


#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 20 October 2015 - 09: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.

#4 TYKUHN2

  • Members
  • 210 posts
  • LocationSomewhere in this dimension... I think.

Posted 20 October 2015 - 10: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.

#5 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 20 October 2015 - 10:08 PM

View PostTYKUHN2, on 20 October 2015 - 10:04 PM, said:

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.

#6 TYKUHN2

  • Members
  • 210 posts
  • LocationSomewhere in this dimension... I think.

Posted 20 October 2015 - 10:39 PM

The variable is a string of data that is in this case assumed to be a serialised table.

#7 ReBraLaCC

  • Members
  • 100 posts
  • LocationSublime Text 2

Posted 21 October 2015 - 09:02 AM

Thanks it works !!!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users