coplox
|
  |
| Joined: 07 Jun 2008 |
| Total Posts: 3252 |
|
|
| 25 Nov 2013 01:51 PM |
I made a camera reset plugin, it snaps your camera (clones it and keeps the clone in memory), and lets you snap back to the same settings it had (sets the important properties in your CurrentCamera to the one in memory).
I had a problem, the place was loading up the plugin before everything was set and the plugin was snapping a newly created camera with default settings, AFTER which studio would set the properties of the camera to the one in the place.
I solved it, and I want to give it to you guys so you can use it in your plugins if you need to wait for the place to be completely loaded before your plugin wants to mess with things.
Here's the code:
-------- local ChangedTime = tick(); local UpdateChangedTime = function() ChangedTime = tick(); end; local Listeners = {}; local ChangeListen = Game:GetService("Workspace").DescendantAdded:connect(function(d) UpdateChangedTime(); table.insert(Listeners, d.Changed:connect(UpdateChangedTime)); end); repeat wait(); until (tick() - ChangedTime) > 0.5 for i, L in pairs(Listeners) do L:disconnect(); end; Listeners = {}; --------
Take it, use it, talk about the concept in this thread and possibly show everyone your crazy method that does the same thing! |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 25 Nov 2013 02:14 PM |
Here's my method.
game.Loaded:wait()
:) |
|
|
| Report Abuse |
|
|
coplox
|
  |
| Joined: 07 Jun 2008 |
| Total Posts: 3252 |
|
|
| 25 Nov 2013 02:26 PM |
:O
I'm dumb..
..wait..
I just tried it in my plugin and it isn't firing at all. MY CODE IS SUPERIOR |
|
|
| Report Abuse |
|
|
coplox
|
  |
| Joined: 07 Jun 2008 |
| Total Posts: 3252 |
|
|
| 25 Nov 2013 02:35 PM |
Well this is embarrassing..
I forgot to include the strip of code to disconnect the original listener, oh well..
Sorry for being dumb, code v1.0.1:
-------- local ChangedTime = tick(); local UpdateChangedTime = function() ChangedTime = tick(); end; local Listeners = {}; table.insert(Listeners, Game:GetService("Workspace").DescendantAdded:connect(function(d) UpdateChangedTime(); table.insert(Listeners, d.Changed:connect(UpdateChangedTime)); end)); repeat wait(); until (tick() - ChangedTime) > 0.5 for i, L in pairs(Listeners) do L:disconnect(); end; Listeners = {}; -------- |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2013 03:14 PM |
guys omg
if game:IsLoaded() == false then game.Loaded:wait() end |
|
|
| Report Abuse |
|
|