Re: Simple Slideshow - user skip
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Simple Slideshow - user skip
- From: Asko Kauppi <asko.kauppi@...>
- Date: 2004年4月13日 18:45:02 +0300
hmm.. a quick solution for me would be to:
if Wait(seconds) then do return end
ShowFrame()
...
Injecting the 'return' does not seem very nice.
What you really need is exceptions ála Lua. Consider putting the whole
thing into do-end and then breaking (but I think this isn't much
different from the above):
do
if Wait(seconds) then do break end
ShowFrame()
...
end
-- break takes here
Could 'ShowFrame' itself (inside) check for the abort flag and pass
through automatically if it's on?
-ak
13.4.2004 kello 18:10, Matthew Harmon kirjoitti:
Hey all:
I've implemented a simple slideshow engine in C and exposed control
through
Lua. So, C is "in charge", but the slideshow is described in Lua.
Now, I
want to let the user abort the rest of the slideshow via a keypress
from the
C side, but I'm not sure how to best handle this.
A script essentially looks like this:
function Slideshow()
Initialize()
DoSlideshow()
Cleanup()
end
function DoSlideshow()
ShowFrame()
Wait(seconds)
ShowFrame()
Wait(seconds)
...
end
I figured I could just return from DoSlideshow() upon a user signal
and then
execute whatever cleanup code I need. But I'm not sure how best to do
this.
- Can I "inject" a return into the script via C? (dostring or something
similar)
- Or, do I have to abort my wait and then check a value like this:
Wait(seconds)
if (GetAbortFlag() == 1) then
do return end
ShowFrame()
...
That's a lot of code for the slideshow authors to have to include for
each
frame of the show and seems a little messy. (BTW: the slideshow is in
a
coroutine that yields upon calling Wait() so the game can continue
looping.)
Any ideas?