|
| 26 Apr 2012 08:38 AM |
A property that is a table where you can put anything you want to. It would be really useful to put data directly into models and parts instead of creating a table for each object type to find their data (which are usually in separate scripts so its annoying and messy to access the data)
Liek
Object.UserTable
or something. |
|
|
| Report Abuse |
|
|
BenBonez
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 19362 |
|
|
| 26 Apr 2012 09:39 AM |
Useful? Probably Needed? No |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2012 09:44 AM |
But i dont want to fill stuff with value objects D:
Though i dont make stuff in roblox anymore really o,e |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
VorenKurn
|
  |
| Joined: 18 Jun 2008 |
| Total Posts: 48 |
|
|
| 26 Apr 2012 09:51 AM |
Yes, every object should have something like that. I want for the Parent structure class of roblox to need twice as much CPU to operate every individual brick just because it has to index the children/parent of every object AND an entire list of possibly endless variables of any type.
On a less satiric note, yes it would be useful, no it would be extremely impractical. Just use the ValueTypes, they will work for what you need, just keep it reasonable. |
|
|
| Report Abuse |
|
|
iNigerian
|
  |
| Joined: 17 Apr 2012 |
| Total Posts: 165 |
|
| |
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 26 Apr 2012 11:55 PM |
| Oysi's solution is the best. |
|
|
| Report Abuse |
|
|
iNigerian
|
  |
| Joined: 17 Apr 2012 |
| Total Posts: 165 |
|
|
| 27 Apr 2012 12:07 AM |
| its better if it works on local and server script |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 27 Apr 2012 01:06 AM |
The problem is replication. You can't replicate functions, or even recursive data structures very easily, so it would have to be a copy-by-value scheme. You can't have it pass by reference like a standard table due to GC and replication problems. Every table that's a child of it would have to be a real Roblox object in order to be replicated. See the following:
a = {b = {c=1}} game.Data.Item1 = a
--now, how does Roblox know to replicate the change, this is pure Lua code. The --only option would be to have every table maintain some internal replication code, --which is kind of expensive... and by that I mean really expensive. a.b.c = 5
So, in short, even if it were done it would not be as nice as you're thinking of. |
|
|
| Report Abuse |
|
|
smurf279
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 6871 |
|
|
| 27 Apr 2012 01:56 AM |
special_props = {} local obj = {real_obj = ...}
setmetatable(obj, { __newindex = function(self, prop, val) special_props = coroutine.resume(coroutine.create(function() self.real_obj.prop = val end)) and nil or val end, __index = function(self, prop) return coroutine.resume(coroutine.create(function() return self.real_obj[prop]end)) or special_props[prop] })
Something like that? |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Apr 2012 11:29 AM |
But value objects feel so laggy and i dont want to create 10000 value objects to list some values when i could se a single nonlaggy table :c (no i dont need to do that)
Its just that storing the data separate from the actual objects always gets messy and stoof. |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2012 12:22 PM |
| I'd like to know more about Oysi's solution. Would someone like to explain more about it and give more examples? : ) |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2012 12:27 PM |
He is just using parts as keys in a table, just like you can use strings or numbers or whatever (vectors,cframes... other tables?)
so that you can quickly get the data belonging to the part from a table like PartData[partinstance] |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2012 12:31 PM |
"I'd like to know more about Oysi's solution."
You're joking, right?
It's like possibly one of the most basic things you can do with tables.. :l |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 27 Apr 2012 02:19 PM |
"But value objects feel so laggy and i dont want to create 10000 value objects to list some values when i could se a single nonlaggy table :c (no i dont need to do that)"
The table would feel just as laggy by the time the game had done all of the work to make it have the same semantics as using value object. There is no silver bullet here guys, replication is hard... deal with it. |
|
|
| Report Abuse |
|
|
|
| 27 Apr 2012 03:07 PM |
If you REALLY want to use a table, then...
Use a BindableFunction and make it return the table. |
|
|
| Report Abuse |
|
|