|
| 21 Nov 2011 06:22 PM |
We need some kind of TableValue. To reduce lag, I took a script of mine that does hundreds of calculations in a very short period of time. I made it do all of the calculations, and then wrote it to a table. I need some way to save this table to the place. I can't type all of them out, because there's way too many values.
Anyway, we should have a TableValue object that you can write tables to. |
|
|
| Report Abuse |
|
|
| |
|
LocalChum
|
  |
| Joined: 04 Mar 2011 |
| Total Posts: 6906 |
|
|
| 21 Nov 2011 06:35 PM |
| Check out the RbxUtility.EncodeJSON (not sure of exact name) function? |
|
|
| Report Abuse |
|
|
Varp
|
  |
| Joined: 18 Nov 2009 |
| Total Posts: 5333 |
|
|
| 21 Nov 2011 06:40 PM |
Tables are difficult to store, and even more difficult to replicate across the server. I mean, if you have primitive indexes and values (numbers, strings, booleans) it's relatively easy, but when you start nesting tables or having weird indexes (like functions, other tables, coroutines, etc.) it becomes very difficult, if not impossible to serialize. Worse, if you have the code:
local x = 0 local t = {} function t:embiggen() x = x + 1 return x end
You have to serialize the function somehow! Unfortunately, this function's closure contains a reference to the local value x. In fact, the function's closure contains every value in the script _by reference_. It is not possible to share that function between scripts without rewriting Lua, thus general tables cannot be shared.
You can write specific code which makes a series of Value objects that represents the table you output. Roblox cannot provide a general implementation for you. However, before you try to do something like this, you should try to find an alternative, since this is an expensive, and for the most part, needless operation. |
|
|
| Report Abuse |
|
|
bombpaw
|
  |
| Joined: 15 Mar 2009 |
| Total Posts: 3484 |
|
|
| 21 Nov 2011 06:41 PM |
| ._. Local, how long has that been out? |
|
|
| Report Abuse |
|
|
LocalChum
|
  |
| Joined: 04 Mar 2011 |
| Total Posts: 6906 |
|
|
| 21 Nov 2011 06:45 PM |
| About since plugins were released. |
|
|
| Report Abuse |
|
|
|
| 21 Nov 2011 06:49 PM |
I don't see anything about it in the wiki or object browser.
more info/link pl0x? |
|
|
| Report Abuse |
|
|
|
| 21 Nov 2011 08:01 PM |
:O
And there's the MakeWedge function there too...
Why don't they use it in the terrain generator and all of these, instead of just putting it separately? They could just load the library. T_T
Woah, I gotta love these libraries.. well, nah, because we can't register our own libraries yet.
Yet, I have some libraries that I want to transfer to this system. I'm tired of using _G to store my libraries.. |
|
|
| Report Abuse |
|
|
|
| 21 Nov 2011 08:06 PM |
"I don't see anything about it in the wiki or object browser.
more info/link pl0x?"
local RbxUtility = LoadLibrary "RbxUtility" -- Loads the library and stores it in the variable 'RbxUtility'.
-- Print the current content of the library. for _, name in pairs(RbxUtility:GetApi()) do print(name) end
Current Output: MakeWedge Help EncodeJSON DecodeJSON
To get help on a function, use RbxUtility.Help(functionName).
Example:
local RbxUtility = LoadLibrary "RbxUtility"
print(RbxUtility.Help("MakeWedge"))
Output: Function MakeWedge. Arguments: (x, y, z, [default material]). Description: Makes a wedge at location x, y, z. Sets cell x, y, z to default material if parameter is provided, if not sets cell x, y, z to be whatever material it previously was. Returns true if made a wedge, false if the cell remains a block |
|
|
| Report Abuse |
|
|
|
| 21 Nov 2011 08:10 PM |
>print(ut:MakeWedge())
20:09:50 - 'TerrainService' is not a valid Service name
ಠ_ಠ |
|
|
| Report Abuse |
|
|
|
| 21 Nov 2011 08:13 PM |
*looking at RbxUtility's source*
"Copyright 2007 Shaun Brown"
roblox
y u so incapable of making your own stuff |
|
|
| Report Abuse |
|
|
Aaaboy97
|
  |
| Joined: 05 Apr 2009 |
| Total Posts: 6612 |
|
|
| 21 Nov 2011 08:17 PM |
print(LoadLibrary('RbxUtility').EncodeJSON({[999]='hai'})) > [null null null null... |
|
|
| Report Abuse |
|
|
ENET
|
  |
| Joined: 01 Jan 2010 |
| Total Posts: 4820 |
|
|
| 21 Nov 2011 09:31 PM |
| Lua needs to be able to store and index the addresses of certain objects. Then you could have pointers to a table. |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 21 Nov 2011 11:17 PM |
Serialize it to a string of Lua data, which you can loadstring later. (why would you use JSON when you get free loading with loadstring, from a format which is almost identical to JSON?)
Eg: Save: someStringValue.Value = "return {"..doSerialize(myData).."}"
Load: myData = loadstring(someStringValue.Value)() |
|
|
| Report Abuse |
|
|
|
| 23 Nov 2011 08:06 PM |
Ah, great idea stravant:
t = Workspace.SomeStringValue example = {1, 2, 3}
t.Text = "example = {" for _, v in pairs(example) do t.Value = t.Value..v..", " end t.Value = t.Value:sub(1, #t.Value - 2).."}" |
|
|
| Report Abuse |
|
|
|
| 23 Nov 2011 08:20 PM |
I thought that when Lua dumped a table it dumped the table's memory. :/
I personally wouldn't want ROBLOX sending raw table memory over an insecure connection. |
|
|
| Report Abuse |
|
|
GoldenUrg
|
  |
| Joined: 23 Aug 2009 |
| Total Posts: 6428 |
|
|
| 23 Nov 2011 11:41 PM |
@popin
The whole game to played over an insecure connection. Why would the table contents matter anyway?
|
|
|
| Report Abuse |
|
|
|
| 23 Nov 2011 11:45 PM |
| They don't even encrypt the BC purchase page for crying out loud :P |
|
|
| Report Abuse |
|
|
|
| 24 Nov 2011 07:44 AM |
lol i send my tables to client and server by doing a tree of
MODEL (=Pair of key and value) *Key (some ____Value object) *Data (some ____Value object, or contains more of these pairs if the value is table)
Efficient, eh? |
|
|
| Report Abuse |
|
|