Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 26 May 2015 12:25 PM |
Mine currently:
local function wait(waitTime) local time = os.time() local function _() return 1 + 1 end repeat _() until time + waitTime < os.time() end
Made the _ function because you need to do something in the repeat loop.
Any better ways to wait? |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 26 May 2015 12:30 PM |
http://wiki.roblox.com/index.php?title=Thread_scheduler
It has a wait function under the section "Implementation details." |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 26 May 2015 12:35 PM |
| I love it how that crashes corona simulation when I copypasta'd it and replaced tick with os.time |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 26 May 2015 12:40 PM |
| Now that I look closely at instead of "it says it's a wait function so YOLO," I'm pretty sure it would crash ROBLOX too. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 26 May 2015 01:03 PM |
Don't busy wait. Just schedule other tasks and run them
Alternatively, os.execute for the appropriate system-specific command. |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 26 May 2015 01:50 PM |
"Just schedule other tasks and run them" qq, could you explain this a bit? :s
What about sleep functions? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 26 May 2015 01:57 PM |
os.execute("sleep 1") would wait 1 second on most Unix based systems. As for the scheduler? Same behaviour as wait+spawn, but you'd have to remember that if a scheduled function waits then it needs to transfer to the next scheduled function, or the top yielding function if the wait is finished |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 May 2015 01:58 PM |
Use coroutines and implement wait with coroutine.yield. So basically a scheduler with a queue of coroutines.
|
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 26 May 2015 01:59 PM |
| I tried coroutine.yield() outside of a coroutine and it flipped out on me. |
|
|
| Report Abuse |
|
|
|
| 26 May 2015 02:00 PM |
Why not just use ROBLOX's wait() function?
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 26 May 2015 02:03 PM |
| Because I am not using roblox. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 May 2015 02:04 PM |
elun I meant that you'd have to create a "spawn" function, not just right outside. I'd write something but I'm on a phone. |
|
|
| Report Abuse |
|
|
|
| 26 May 2015 02:04 PM |
Oh. :P
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784
|
|
|
| Report Abuse |
|
|