pausing the script.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Trappingnoobs
Citizen
Posts: 95
Joined: Tue Oct 12, 2010 8:52 pm

pausing the script.

Post by Trappingnoobs »

Apologies if I seem realy dumb, I've never realy escaped from all preset functions all layed out ready for you. I'm trying to make a wait function, so if I typed wait(int number) it pauses for, well milliseconds ro seconds whichever, mine is VERY inefficient.

function wait(num)
num2=0
repeat
os.execute("errorcmd")
num2=num2+1
until num2==num
end

Any way of properly making it pause for a set amount of time without installing anything (I already have LOVE.)
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: pausing the script.

Post by zac352 »

Trappingnoobs wrote:Apologies if I seem realy dumb, I've never realy escaped from all preset functions all layed out ready for you. I'm trying to make a wait function, so if I typed wait(int number) it pauses for, well milliseconds ro seconds whichever, mine is VERY inefficient.

function wait(num)
num2=0
repeat
os.execute("errorcmd")
num2=num2+1
until num2==num
end

Any way of properly making it pause for a set amount of time without installing anything (I already have LOVE.)
Wait sounds roblox-ish. :P
http://love2d.org/wiki/love.timer.sleep
Hello, I am not dead.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: pausing the script.

Post by Robin »

That is not a very smart thing, zac. It would freeze the entire game for the entire duration of the sleep.

Trappingnoobs: a better way would be to do something like:

Code: Select all

time_to_sleep = 1 -- one second
And in your love.update(dt):

Code: Select all

if time_to_sleep > 0 then
    time_to_sleep = time_to_sleep - dt
else
    -- do your awesome things here
end
Help us help you: attach a .love.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: pausing the script.

Post by nevon »

Robin wrote:That is not a very smart thing, zac. It would freeze the entire game for the entire duration of the sleep.
It is exactly what the OP is asking for though, even if it isn't what you'd normally use in a game.
User avatar
Trappingnoobs
Citizen
Posts: 95
Joined: Tue Oct 12, 2010 8:52 pm

Re: pausing the script.

Post by Trappingnoobs »

I'll do what Robin posted, thanks!

And zac, yes I learnt Lua from roblox, it's clearly a lot easier when it's all made for you XP
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: pausing the script.

Post by Robin »

Apologies to zac, I shouldn't have been so hard on you. I just think it's better to help people with what they need, not what they think they need. ;)
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 60 guests