generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Player:SaveTable()?

Previous Thread :: Next Thread 
Davidii is not online. Davidii
Joined: 17 Jul 2008
Total Posts: 1282
24 Sep 2012 08:04 PM
Does :SaveInstance() work for saving tables? For instance, I'm creating an OOP powered RPG and I would like players to be able to save their "instance," which is a table with various numbers, functions, and metatables stored in it (how you OOP in RBX.Lua). How do I attach this to a player with DP?
Report Abuse
Seranok is not online. Seranok
Joined: 12 Dec 2009
Total Posts: 11083
24 Sep 2012 08:06 PM
Please explain what you are trying to do. It is not possible to serialize a function in RBX.Lua. What I would do is serialize the table as a string "{ someIndex = \"someValue\" }"and use Player:SaveString and Player:LoadString
Report Abuse
Davidii is not online. Davidii
Joined: 17 Jul 2008
Total Posts: 1282
24 Sep 2012 08:20 PM
Have you ever made a custom object in RBX.Lua?

self = {}

self.name = "Derp"

self.printName = function()

print(self.name)

end

self.epicnessLevel = 1337

I want to be able to save "self."
Report Abuse
Seranok is not online. Seranok
Joined: 12 Dec 2009
Total Posts: 11083
24 Sep 2012 08:25 PM
Then write a function that serializes a table. But you will have to ignore functions, as they cannot be serialized.
Report Abuse
Davidii is not online. Davidii
Joined: 17 Jul 2008
Total Posts: 1282
24 Sep 2012 08:34 PM
Is there a way I can transform the table into a userdata and use SaveInstance()?
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
24 Sep 2012 08:46 PM
i have no idea what im talking about, but i know that newproxy creates a userdata and you can give it a metatable

cooleo = newproxy(true)
setmetatable(newproxy, {"cool", "data"})


???
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
24 Sep 2012 09:16 PM
"Is there a way I can transform the table into a userdata and use SaveInstance()?"

I don't understand why you would want to do that.

When you call SaveInstance it's just really saving a string. It just uses the same serialization code that it does to read / write .rbx files.
Report Abuse
Seranok is not online. Seranok
Joined: 12 Dec 2009
Total Posts: 11083
24 Sep 2012 09:41 PM
Player:SaveInstance only works on instances (i.e. Parts, IntValues, etc)
Report Abuse
chickenman158 is not online. chickenman158
Joined: 18 Jan 2011
Total Posts: 915
24 Sep 2012 10:10 PM
Use JSON. RbxUtility library.
Report Abuse
coolbob44 is not online. coolbob44
Joined: 26 Nov 2009
Total Posts: 1649
24 Sep 2012 11:54 PM
^
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
24 Sep 2012 11:55 PM
JSON hardly saves anything...
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
25 Sep 2012 01:57 AM
1. Serialise table into a string, or multiple strings
2. Use SaveString to save the table
3. Deserialise the table on LoadString
4. ???
5. Profit
Report Abuse
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
25 Sep 2012 02:38 PM
Table = {1,2,3,4}
String = "{"..table.concat(Table,",").."}"

Pyr:SaveString("key",String)

--

String = Pyr:LoadString("key")

Table = loadstring("return "..String)()



TADA!

but i would really want to save tables *properly*. It'd be very useful and save time. It's annoying loading every single thing seperately on like 50 lines















Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
25 Sep 2012 04:52 PM
Keep the data separate from the methods that handle it.
Report Abuse
Davidii is not online. Davidii
Joined: 17 Jul 2008
Total Posts: 1282
25 Sep 2012 06:54 PM
Hrm... okay then. :/
Report Abuse
Parthax is not online. Parthax
Joined: 27 Apr 2011
Total Posts: 6941
25 Sep 2012 09:26 PM
Save all of it as a string then use loadstring after on it? I'm pretty sure you can still use loadstring but not bytecode with it. Just a guess :/

or

You could convert all the characters into a number then for each number save it as a unique number, then just decode it afterwards... I really don't know.
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
26 Sep 2012 07:07 AM
player.saveinstance.new(table) = {lol hi]
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image