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: wait() in Love2D?

Previous Thread :: Next Thread 
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
26 May 2012 06:18 PM
Is there a similar function in Love2D to the wait() function here? Although I understand that you can use coroutines and a number of other methods to do this, I would've thought that they had something like that.

love.timer.sleep doesn't work since it actually 'puts the program to sleep'.

Is there any other methods?

I tried..

whatever = ""
starttime = love.timer.getTime()
repeat whatever = "a" until love.timer:getTime() - starttime == 1

However that crashed and I'm assuming other loops like that would fail just as badly.

So is there any other way?
Report Abuse
nickmaster24 is not online. nickmaster24
Joined: 04 Oct 2008
Total Posts: 8906
26 May 2012 06:28 PM
Why would you want to put the program to sleep?
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
26 May 2012 06:51 PM
I don't?
Report Abuse
nickmaster24 is not online. nickmaster24
Joined: 04 Oct 2008
Total Posts: 8906
26 May 2012 06:52 PM
Wait; then what do you want to do?
Report Abuse
imcoolfire8 is not online. imcoolfire8
Joined: 23 Nov 2009
Total Posts: 3008
26 May 2012 06:54 PM
There is no wait.

♪ Can you dig it? ♪
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
26 May 2012 06:56 PM
>Wait; then what do you want to do?

Make something similar to the wait() function in RBX.Lua

>There is no wait.

I understand, which is why I'm trying to find a way to create one. Coroutines are the solution I've been able to think of, and in this case I don't think it'll work since I'm using love.mousepressed and the thread ends relatively fast.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
26 May 2012 08:03 PM
Darkkiller, I want to ask.

How come you're not asking these questions to the LOVE2D forum?
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
26 May 2012 08:08 PM
I posted this in the Love2D forums already. The roblox 'Scripting Helpers' forum is quite a bit more active than the Love2D forum.

I post in both spots hoping to get a reply faster.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
26 May 2012 08:10 PM
Must you use Love2D libraries to achieve this? I'm not familiar with Love2D, but if it includes the os.time library, then this will suffice:

    function wait(seconds)
        local start = os.time()
        local end = start+seconds
        while end ~= os.time() do
        end
    end
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
26 May 2012 08:11 PM
Oops, I failed. Naming a variable "end" will confuse the interpreter.

 function wait(seconds)
    local start = os.time()
    local _end = start+seconds
    while _end ~= os.time() do
    end
end
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
26 May 2012 09:50 PM
Thanks! Although is there a way to make it so that it doesn't generate so much lagg?
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
26 May 2012 09:59 PM
Well, I'm running it in SciTE, so there's no lag. Again, I'm not familiar with Love2D, so their graphics engine is your problem. :P
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
26 May 2012 10:04 PM
@ElectricBlaze

Please look up "busy waiting" on Wikipedia. It'll benefit you a lot.

You do realize that's going to take 100% of the CPU by checking as much as it can, right?

It'd be much more efficient to just check every time the [ function of which I forgot the name ] is called.
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
26 May 2012 10:33 PM
Yeah, the loop would run every possible moment to check. If I were to do wait(10) with that function it'd pretty much crash the application.

@Julien; I think I may have an idea. Thanks.
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
26 May 2012 11:48 PM
love.timer.sleep(seconds)

That is for 0.8.0. Anything lower is the same, but the argument is milliseconds.

Of course, this makes the whole program sleep, so it's not entirely useful.
Report Abuse
crazyman32 is online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
26 May 2012 11:49 PM
Wow, just ignore my post. Apparently I fail at reading.

Currently there's no really good way to do this. It would be nice if they had a sleep method for threads.
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
27 May 2012 10:54 AM
Well I was thinking about using coroutine.yield and some other messing around with coroutines, but along with math, coroutines are my weak spot.

I tried using love.update() to count up to 1 but unless I put the function inside the love.update function it wouldn't work right. And if it was inside the love.update function it wouldn't work at all.

So I guess I'm just giving up on this until love has a feature added that makes this possible.
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
27 May 2012 11:09 AM
I found it! Someone made a library for this! Amazing!

Go onto their wiki.

After the /wiki in the url address, put in

cron.lua


This is a timed library with the functions we need! Praise this guy!
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