|
| 05 Apr 2017 08:56 PM |
| Does renderstep use too much resources ? |
|
|
| Report Abuse |
|
|
| |
|
|
| 05 Apr 2017 09:05 PM |
| no it just runs every frame and waits for all events to execute before continuing |
|
|
| Report Abuse |
|
|
| |
|
|
| 05 Apr 2017 09:09 PM |
| ye but u should use heartbeat unless you immediately need the next frame (for stuff like camera manipulation or local transparency) because it will delay everything else that runs on the client until its done |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:16 PM |
Can you explain heartbeat to me? I don't understand it that much. |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:17 PM |
http://wiki.roblox.com/index.php?title=API:Class/RunService/Heartbeat
|
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:17 PM |
it runs around 60 fps, similar to renderstepped except it runs at the end and does not influence the rest of the events here is a visual example of event order
goo.gl/U17VgB |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:24 PM |
Wait what is the wait() resume for?
Does that mean I can pause the wait's ? This is stupid XD |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:25 PM |
| you cant pause waits, you would have to use your own custom sleeping function for that |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:25 PM |
| wait() resume is when it fires wait() on the server |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:26 PM |
| i mean its when wait() is done waiting when used on the server |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:31 PM |
local sleep sleep = setmetatable( {active = true}, { __call = function( s ) local elapsed, current = 0, 0 local waitlapsed = 0 repeat elapsed, current = wait() if sleep.active then waitlapsed = waitlapsed + elapsed end until waitlapsed >= s return waitlapsed, current end } )
sleep( 1 ) print( "hi" ) spawn( function() sleep( 2 ) print( "test" ) end) wait() sleep.active = false wait( 2 ) sleep.active = true
|
|
|
| Report Abuse |
|
|
| |
|
|
| 05 Apr 2017 09:34 PM |
thats an example of a 'pausable' wait but keep in mind that active is for the entire sleeping function
to make separate ones you do
local function newSleep() return --the setmetatable junk end
local sleep = newSleep() --use sleep here, makes a new version of sleep with its own 'active' |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:37 PM |
Jeez thanks m8
BTW renders. is the fastest of all right ?
|
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:38 PM |
you should not be using it for anything that you don't immediately need as i said camera motion, gui movement, and local modifiers should take priority and belong there a lot of other things should not be there such as changing character speed, animations, etc |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:40 PM |
heres the fixed example
local newSleep do local meta = { __call = function( sleep, s ) local elapsed, current = 0, 0 local waitlapsed = 0 repeat elapsed, current = wait() if sleep.active then waitlapsed = waitlapsed + elapsed end until waitlapsed >= s return waitlapsed, current end } newSleep = function() return setmetatable( {active = true}, meta ) end end
local sleep = newSleep() local sleep2 = newSleep() sleep( 1 ) print( "hi" ) spawn( function() sleep( 1 ) --waits more than one second because paused print( "test" ) end) wait() sleep.active = false sleep2( 1 ) --waits 1 second sleep.active = true |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 05 Apr 2017 09:51 PM |
wow you're bad at lua learn how closures work pls |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:52 PM |
| ### wat u mean lol if its for the repeat, i used it because i wanted to implement waiting for 0 time similar to calling wait() |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:53 PM |
| Pls ### Its hard to type with all the roblox filtering |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 05 Apr 2017 09:53 PM |
| Yeah by writing the world's worst code |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:54 PM |
| wat so bad about it, its a pausable wait xd |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 09:59 PM |
| Lol I was talking about kill |
|
|
| Report Abuse |
|
|
|
| 05 Apr 2017 10:00 PM |
| and if u talking about y i made elapsed and current in the functions scope instead of just current its because i didnt want to make it harder to assign both of them |
|
|
| Report Abuse |
|
|