|
| 01 Jun 2015 12:18 AM |
As in, a callable function?
For example
print('One') game['Run Service'].RenderStepped:wait() print('Two')
I heard that you can, but I'm just making sure.
Septamology | R$204 | Tx244,063 | RAP: 36,830 |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2015 12:19 AM |
| You clearly don't know how events work. |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2015 12:22 AM |
> You clearly don't know how events work.
I do know how events work, actually. I'm just wondering if there's any way to actually call upon an event as a function, and yield a result.
Septamology | R$204 | Tx244,063 | RAP: 36,830 |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2015 12:23 AM |
Event:wait() --Waits until the event is fired. Returns the values the event was fired with
RBXScriptConnection Event:connect(callback function listener) --when Event is fired, callback function listener will be called with the arguments that the event is fired with. The userdata RBXScriptConnection that the function returns has a method :disconnect() which disconnects the event, and a bool value connected which indicates whether the listener is currently active, i.e. if it will be called when the event fires. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 01 Jun 2015 12:24 AM |
You did it right in your script. wait is a method of signals that literally: 'Pauses the script until the event is fired and returns any arguments the event returns.'
|
|
|
| Report Abuse |
|
|
|
| 01 Jun 2015 12:25 AM |
Ahh, I see. I was just making sure. Thanks!
Septamology | R$204 | Tx244,063 | RAP: 36,832 |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2015 12:26 AM |
Just do this:
function thisFunctionIsCalledWhenTheEventOccurs() --cool name print("Render stepped") end
game:GetService("RunService").RenderStepped:connect(thisFunctionIsCalledWhenTheEventOccurs) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 01 Jun 2015 12:27 AM |
But you aren't using "RenderStepped as a function", although with a bit of wrapping that can easily be possible so that:
game['Run Service'].RenderStepped() Would just do game['Run Service'].RenderStepped:wait() and game['Run Service'].RenderStepped(func) Would just do game['Run Service'].RenderStepped:connect(func) |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2015 12:28 AM |
> Just do this:
function thisFunctionIsCalledWhenTheEventOccurs() --cool name print("Render stepped") end
game:GetService("RunService").RenderStepped:connect(thisFunctionIsCalledWhenTheEventOccurs)
I'm wanting to create an animation system, so I was just wondering if I could use RenderStepped just like wait(), I should have clarified. Thanks anyway. |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2015 12:29 AM |
@nQ
I dont think thats what he's asking for. For example in my scripts i do Game:GetService("RunService").RenderStepped:wait() to make animations run in 60 fps instead of around 30 when using wait(). |
|
|
| Report Abuse |
|
|