generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Best way of recreating roblox's wait function?

Previous Thread :: Next Thread 
Trioxide is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
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 is not online. Trioxide
Joined: 29 Mar 2011
Total Posts: 32902
26 May 2015 02:03 PM
Because I am not using roblox.
Report Abuse
cntkillme is not online. 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
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image