From 25c5eac5e6ca1035db1eddd7bea9ac78531da57e Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 28 Dec 2023 11:23:49 -0500 Subject: Delete manuals! Good riddance! These are hosted on files.dthompson.us now! --- manuals/chickadee/Agendas.html | 223 ----------------------------------------- 1 file changed, 223 deletions(-) delete mode 100644 manuals/chickadee/Agendas.html (limited to 'manuals/chickadee/Agendas.html') diff --git a/manuals/chickadee/Agendas.html b/manuals/chickadee/Agendas.html deleted file mode 100644 index 51be160..0000000 --- a/manuals/chickadee/Agendas.html +++ /dev/null @@ -1,223 +0,0 @@ - - - - - - -Agendas (The Chickadee Game Toolkit) - - - - - - - - - - - - - - - - - - - -
-

-Next: , Up: Scripting   [Contents][Index]

-
-
-

5.5.1 Agendas

- -

To schedule a task to be performed later, an “agenda” is used. -There is a default, global agenda that is ready to be used, or -additional agendas may be created for different purposes. The -following example prints the text “hello” when the agenda has -advanced to time unit 10. -

-
-
(at 10 (display "hello\n"))
-
- -

Most of the time it is more convenient to schedule tasks relative to -the current time. This is where after comes in handy: -

-
-
(after 10 (display "hello\n"))
-
- -

Time units in the agenda are in no way connected to real time. It’s -up to the programmer to decide what agenda time means. A simple and -effective approach is to map each call of the update procedure -(see Kernel) to 1 unit of agenda time, like so: -

-
-
(define (update dt)
-  (update-agenda 1))
-
- -

It is important to call update-agenda periodically, otherwise -no tasks will ever be run! -

-

In addition to using the global agenda, it is useful to have multiple -agendas for different purposes. For example, the game world can use a -different agenda than the user interface, so that pausing the game is -a simple matter of not updating the world’s agenda while continuing to -update the user interface’s agenda. The current agenda is dynamically -scoped and can be changed using the with-agenda special form: -

-
-
(define game-world-agenda (make-agenda))
-
-(with-agenda game-world-agenda
-  (at 60 (spawn-goblin))
-  (at 120 (spawn-goblin))
-  (at 240 (spawn-goblin-king)))
-
- -
-
Procedure: make-agenda
-

Return a new task scheduler. -

- -
-
Procedure: agenda? obj
-

Return #t if obj is an agenda. -

- -
-
Procedure: current-agenda
-
Procedure: current-agenda agenda
-

When called with no arguments, return the current agenda. When called -with one argument, set the current agenda to agenda. -

- -
-
Syntax: with-agenda agenda body …
-

Evaluate body with the current agenda set to agenda. -

- -
-
Procedure: agenda-time
-

Return the current agenda time. -

- -
-
Procedure: update-agenda dt
-

Advance the current agenda by dt. -

- -
-
Procedure: schedule-at time thunk
-

Schedule thunk, a procedure of zero arguments, to be run at -time. -

- -
-
Procedure: schedule-after delay thunk
-

Schedule thunk, a procedure of zero arguments, to be run after -delay. -

- -
-
Procedure: schedule-every interval thunk [n]
-

Schedule thunk, a procedure of zero arguments, to be run every -interval amount of time. Repeat this n times, or -indefinitely if not specified. -

- -
-
Syntax: at time body …
-

Schedule body to be evaluated at time. -

- -
-
Syntax: after delay body …
-

Schedule body to be evaluated after delay. -

- -
-
Syntax: every interval body …
-
Syntax: every (interval n) body …
-

Schedule body to be evaluated every interval amount of -time. Repeat this n times, or indefinitely if not specified. -

- -

It is also possible to schedule things that are not dependent on how -much time passes. The agenda will periodically poll to see if any -registered conditions are met. -

-
-
Procedure: call-when pred thunk
-

Call thunk sometime in the future when pred is satisfied -(returns a value other than #f.) -

- -
-
-

-Next: , Up: Scripting   [Contents][Index]

-
- - - - - -- cgit v1.2.3