From 03072ef67af0623758a660e2cd3fb5e153133efa Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 24 May 2023 08:09:03 -0400 Subject: Update chickadee manual. --- manuals/chickadee/Scripts.html | 70 +++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'manuals/chickadee/Scripts.html') diff --git a/manuals/chickadee/Scripts.html b/manuals/chickadee/Scripts.html index bc82c5f..b62bb2d 100644 --- a/manuals/chickadee/Scripts.html +++ b/manuals/chickadee/Scripts.html @@ -1,6 +1,6 @@ - - + --> + - + Scripts (The Chickadee Game Toolkit) - - - - - - - - - - - + + + + + + + + + + + - + @@ -84,7 +84,7 @@ ul.no-bullet {list-style: none}

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

-
+

5.5.2 Scripts

Now that we can schedule tasks, let’s take things to the next level. @@ -98,13 +98,13 @@ turn and prevent blocking the game loop. Building on top of the scheduling that agendas provide, here is a script that models a child trying to get their mother’s attention:

-
-
(script
-  (while #t
-    (display "mom!")
-    (newline)
-    (sleep 60))) ; where 60 = 1 second of real time
-
+
+
(script
+  (while #t
+    (display "mom!")
+    (newline)
+    (sleep 60))) ; where 60 = 1 second of real time
+

This code runs in an endless loop, but the sleep procedure suspends the script and schedules it to be run later by the agenda. @@ -125,10 +125,10 @@ been started. For example, when an enemy is defeated their AI routine needs to be shut down. When a script is spawned, a handle to that script is returned that can be used to cancel it when desired.

-
-
(define script (script (while #t (display "hey\n") (sleep 60))))
-;; sometime later
-(cancel-script script)
+
+
(define script (script (while #t (display "hey\n") (sleep 60))))
+;; sometime later
+(cancel-script script)
 
@@ -187,10 +187,10 @@ procedure handler.
Syntax: wait-until condition

Wait until condition is met before resuming the current script.

-
-
(script
-  (wait-until (key-pressed? 'z))
-  (display "you pressed the Z key!\n"))
+
+
(script
+  (wait-until (key-pressed? 'z))
+  (display "you pressed the Z key!\n"))
 
@@ -200,7 +200,7 @@ procedure handler.

Evaluate body in an endless loop.

-
+

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

-- cgit v1.2.3