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 » Scripting Helpers
Home Search
 

Re: luaforwindows

Previous Thread :: Next Thread 
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
01 Oct 2012 04:48 PM
Since theres no inbuilt function to wait() or sleep(),
i made this, and Im wondering if the math is correct:

function wait(t)
   local old = os.time()
   repeat
   until os.time() > old + t
end

wait(4)
print("hi")
Report Abuse
Uuvinu is not online. Uuvinu
Joined: 19 Apr 2012
Total Posts: 2206
01 Oct 2012 05:12 PM
Does ROBLOX allow use of os.time?

Never knew that.
Report Abuse
nairod7 is not online. nairod7
Joined: 26 Mar 2010
Total Posts: 869
01 Oct 2012 05:18 PM
"luaforwindows" = Lua for windows.
That's not RBX.Lua

Personally, I don't like the repeat until :/
This function would work but maybe there is another way to do this.
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
01 Oct 2012 05:39 PM
It waited until the time + 1.
This is fixed, however, only works with integer values. How might I make it work with decimals?


function wait(t)
   local old = os.time()
   repeat
   until os.time() == old + t
end
Report Abuse
nairod7 is not online. nairod7
Joined: 26 Mar 2010
Total Posts: 869
01 Oct 2012 05:43 PM
If os.time() returns an integer, I think you'll have to use something else. But I can't help you, I don't know lua libraries out of roblox.
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
01 Oct 2012 05:45 PM
Out of roblox? Its embedded in the standard lua. Oh well, back to the Lua 5.2 reference page :D
Report Abuse
nairod7 is not online. nairod7
Joined: 26 Mar 2010
Total Posts: 869
01 Oct 2012 06:00 PM
I mean I use lua only on roblox, We can't use io or even os so why would I learn this if I don't have to use them ? I script in lua in roblox only and in C++ in general ( still learning it ).

By the way, I found this, it may helps you: http://lua-users.org/wiki/SleepFunction
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
01 Oct 2012 06:27 PM
That will simply stall the thread for the right time.

In real-world applications (as in outside of Roblox) you shouldn't ever ever ever need to use wait.
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
01 Oct 2012 06:37 PM
How do you explain weapon rate of fire then? :P
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
01 Oct 2012 06:53 PM
In roblox? wait(), but this is roblox.

Outside of roblox, most games generally have a thread that is constantly running. Instead of using wait(), you use somewhat clever math and time to make things happen.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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