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: Is their a form of wait() in pure Lua?

Previous Thread :: Next Thread 
imcoolfire8 is not online. imcoolfire8
Joined: 23 Nov 2009
Total Posts: 3008
23 May 2012 10:31 PM
Im trying to make a Love2D game.

♪ Can you dig it? ♪
Report Abuse
sam6175 is not online. sam6175
Joined: 16 Aug 2008
Total Posts: 1391
23 May 2012 10:31 PM
Read some tutorials on Love2D or ask on their forums. Before making a game just get down the basics.
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
23 May 2012 10:32 PM
You shouldn't need wait() AT ALL.
Report Abuse
imcoolfire8 is not online. imcoolfire8
Joined: 23 Nov 2009
Total Posts: 3008
23 May 2012 10:34 PM
Im trying to make a slow turning text using love.draw

♪ Can you dig it? ♪
Report Abuse
IAmNotWise is not online. IAmNotWise
Joined: 28 Jul 2011
Total Posts: 1418
23 May 2012 10:46 PM
[ Content Deleted ]
Report Abuse
ENET is not online. ENET
Joined: 01 Jan 2010
Total Posts: 4820
23 May 2012 11:22 PM
you can always check the current time against past time to see if the desired lapsed time has passed. Just sayin'...

Report Abuse
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
24 May 2012 01:13 AM
@Enet,

To check this against 1 frame is ok, but if you're waiting seconds like that it's really inefficient.

lol

I once made a wait() function in pure Lua and showed it to the forum and I got kicked out cuz' it was so rubbish and inefficient :( Mine did exactly what you said.


How come Lua doesn't have something like in other languages os.sleep() or similar? It's annoying.
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
24 May 2012 01:31 AM
Because it shouldn't and it isn't meant to.
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
24 May 2012 07:47 AM
>but if you're waiting seconds like that it's really inefficient

What do you mean?

Simple time check is faster than calling le messy functions..
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
24 May 2012 09:17 AM
[ Content Deleted ]
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
24 May 2012 09:21 AM
>If you do a constant check of the time


I thought that we were talking about the render loop duh



Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
24 May 2012 09:26 AM
[ Content Deleted ]
Report Abuse
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
24 May 2012 09:28 AM
"Because it shouldn't and it isn't meant to."

I disagree. You should be able to pass time without the CPU doing crazy loops and stuff.

What if on a game you want to add pause? :P Or a *simple* countdown.
Report Abuse
nightname is not online. nightname
Joined: 10 Jun 2008
Total Posts: 8960
24 May 2012 12:33 PM
NO. NO. NOOOO!

Never busy wait!! That is practically the most useless thing you can do, not to mention that it freezes your computer.

Anyway, as Mycro said - in Lua you should not need to wait.
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
24 May 2012 12:34 PM
Who talked about busy wait?
Report Abuse
nightname is not online. nightname
Joined: 10 Jun 2008
Total Posts: 8960
24 May 2012 12:36 PM
A couple of people were talking about busy waiting, including you. You just did not use it's real name.
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
24 May 2012 12:39 PM
No, I was talking about checking the time in the render loop.
not laik


function umgwait(seconds)
secs = tick()
repeat until tick()>=secs+seconds
end
Report Abuse
nightname is not online. nightname
Joined: 10 Jun 2008
Total Posts: 8960
24 May 2012 12:42 PM
@Su8

That is busy waiting. You do nothing until the time is right - by while you are waiting, Lua eats up 100% of the CPU to check if the time is right.
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
24 May 2012 12:46 PM
> You do nothing until the time is right


What?


--loopish
if timepassed then
--do stuff
end
windowsish.clear()
windowish.draw(stuff)
windowish.display()
--/loopish
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
24 May 2012 12:48 PM
or whatever love2d uses for drawing
Report Abuse
nightname is not online. nightname
Joined: 10 Jun 2008
Total Posts: 8960
24 May 2012 12:50 PM
Look closely:

"function umgwait(seconds)
secs = tick()
repeat until tick()>=secs+seconds
end"

umgwait(5)

The program checks if the time is tick() + 5 as many times as possible, until the statement is true. Thus eating away your CPU power, because it is using 100% of the CPU. So, depending on your computer, your computer will be frozen until 5 seconds have passed.

More on busy waiting:

http://en.wikipedia.org/wiki/Busy_waiting
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
24 May 2012 12:51 PM
That was my example of what I'm not talking about..

it had
"not laik"

before it
lrn2reeed
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
24 May 2012 12:56 PM
let me repeat i waz talking about having it INSIDE the render loop.. not calling som functs
Report Abuse
nightname is not online. nightname
Joined: 10 Jun 2008
Total Posts: 8960
24 May 2012 12:56 PM
I am confused, however I have to go now - so I can study.

If you are talking about Vanilla Lua:
You cannot wait in Lua without using busy waiting, but you should never use busy waiting.

If you are talking about LOVE Lua:
You can wait in LOVE Lua because it has a sleep function, which is what you need to create a real "wait function". You don't want to use up all the CPU, but allow it to sleep.

Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
24 May 2012 12:58 PM
I was talking about having waits in general..

When you're back read my posts again k?
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