|
| 31 Jan 2015 07:45 PM |
So without giving away too much source code, (or any really) this is what my script currently does:
--Creates a userdata --Indexes go to a proxy table full of values --Any nil indexes to the proxy table goes to another table full of different values --Any nil indexes to that goes to a Folder object.
It basically gives 4 levels, an unmodifiable userdata, a read-only table, a writeable table, and a Folder.
Here's the problem, and yes I know neither of these will work:
--Assuming userdata is the created userdata above.
Instance.new("Part", userdata) workspace.Part.Parent = userdata
Alright, so I can pretty much fix problem #1 with a closure and overwriting Instance.new, but problem #2 seems to be MUCH harder.
Is there any way to do this without a custom hierarchy or eLunate's latest version of her wrapper? I don't need it for the whole game, just a simple .Parent script D:
You know, I can't help but want to blame roblox for this. If they'd allow us, I'd have a much simpler method:
--Nil indexes (non-children) through Folder go to proxy --Nil indexes through proxy go to table
But that isn't gonna happen in the near future. |
|
|
| Report Abuse |
|
|
|
| 31 Jan 2015 07:47 PM |
I suppose an inefficient way would be to recurse through everything in game and set up a .Changed event for if the Parent changes.
Actually, that wouldn't work, because .Parent = userdata would error because it isn't an object.
Facepalm* |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 31 Jan 2015 07:49 PM |
I don't know what eLunate did but you can do this (example):
workspace.Part.Parent = userdata
workspace.Part would be a proxy, .Parent = userdata would invoke the __newindex metamethod of the "workspace.Part" proxy. You can use that to your advantage. |
|
|
| Report Abuse |
|
|
|
| 31 Jan 2015 07:51 PM |
@cnt
But I'd need that for every object in the game, meaning a custom hierarchy.
Which is exactly what I didn't want:
"Is there any way to do this without a custom hierarchy" |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 31 Jan 2015 08:24 PM |
| Well uh, I still need help here... |
|
|
| Report Abuse |
|
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 01 Feb 2015 07:04 AM |
Eh,
I'd just go borrow the wrap and unwrap functions from my wrapper, except you'll likely need to change some stuff in the script since I broke my public build (Yay me) |
|
|
| Report Abuse |
|
|
|
| 01 Feb 2015 07:39 AM |
| @eLunate explain how I can do this? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 01 Feb 2015 07:56 AM |
I updated my public build just now, so it should be mostly fixed.
Just put it into a moduleScript and use wrap(thing).Parent = userdata if you give your userdata a behaviour definition, or give your userdata a _Real value and use thing.Parent = unwrap(userdata) |
|
|
| Report Abuse |
|
|
|
| 01 Feb 2015 08:02 AM |
@eLuante, I'd like to NOT have to use a function on it for this stuff.
I just want to run a piece of code which allows me to change what setting the parent does -_- |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 01 Feb 2015 08:05 AM |
| Then give it a behaviour in my wrapper. There's nothing else you can do, short of designing your own wrapper, simply because you can't fake your userdata's identity. |
|
|
| Report Abuse |
|
|
|
| 01 Feb 2015 08:08 AM |
@eLunate
The thing is, I don't want to use your whole wrapper, all I need is to make it so if ANYTHING is parented to it, then it goes to the folder... |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 01 Feb 2015 08:11 AM |
Parent is a tricky one though, since its behaviour lies all the way back in the C layer and what goes on behind the scenes.
You really would have to wrap every Instance so that when you try to set its Parent property it has to identify the type of item it is being parented to. There is very little else that you can do in terms of 'seamlessness' |
|
|
| Report Abuse |
|
|
|
| 01 Feb 2015 08:16 AM |
Wow... This is where the Instance Blank would come in handy (http://www.roblox.com/Forum/ShowPost.aspx?PostID=155068805)
Are you sure there's no other possible way? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 01 Feb 2015 08:27 AM |
| No way to treat it seamlessly without a wrapper, unfortunately. |
|
|
| Report Abuse |
|
|