[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scripting
Steve Baker <sjbaker1@airmail.net> writes:
> Well, that doesn't reproduce what my switch does - which is to make
> it impossible to turn the light switch off for ten seconds after you
> turned it on...but in any case, this was just a silly example - real
> scripts get much more complex.
With the event-approach you could also emulate your while() loop:
def my_while_loop():
if (check_some_condition())
do_something()
# Wait 30 Seconds
timed_hook.register(my_while_loop, 30sec)
else
timed_hook.register(my_while_loop, 10sec)
# Start my_while_loop after 10 seconds
timed_hook.register(my_while_loop, 10sec)
The only problem I see with this is that it will get ugly when you
have large sequences of hook-stuff (a person walking around and
talking to different other person), but a simple pre-compiler or
macros should help here.
I actually can't really imagine a situation where that shouldn't work,
could you give a more complex example?
--
| Ingo Ruhnke <grumbel@gmx.de> | Advent: http://advent.sf.net/ |
|==============================| Pingus: http://pingus.seul.org/ |
| JabberID: grumbel@jabber.org | Feuerkraft: http://feuerkraft.sf.net/ |
| ICQ: 59461927 | Home: http://pingus.seul.org/~grumbel/ |