diff options
Diffstat (limited to 'manuals/chickadee/Scripts.html')
-rw-r--r-- | manuals/chickadee/Scripts.html | 70 |
1 files changed, 35 insertions, 35 deletions
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 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> -<!-- Copyright (C) 2017-2021 David Thompson davet@gnu.org +<!-- Copyright (C) 2017-2023 David Thompson dthompson2@worcester.edu Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 @@ -17,25 +17,25 @@ Foundation Web site at http://www.gnu.org/licenses/fdl.html. The document was typeset with http://www.texinfo.org/ (GNU Texinfo). - --> -<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ --> + --> +<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ --> <head> -<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Scripts (The Chickadee Game Toolkit)</title> -<meta name="description" content="Scripts (The Chickadee Game Toolkit)"> -<meta name="keywords" content="Scripts (The Chickadee Game Toolkit)"> -<meta name="resource-type" content="document"> -<meta name="distribution" content="global"> -<meta name="Generator" content="makeinfo"> -<link href="index.html" rel="start" title="Top"> -<link href="Index.html" rel="index" title="Index"> -<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> -<link href="Scripting.html" rel="up" title="Scripting"> -<link href="Tweening.html" rel="next" title="Tweening"> -<link href="Agendas.html" rel="prev" title="Agendas"> +<meta name="description" content="Scripts (The Chickadee Game Toolkit)" /> +<meta name="keywords" content="Scripts (The Chickadee Game Toolkit)" /> +<meta name="resource-type" content="document" /> +<meta name="distribution" content="global" /> +<meta name="Generator" content="makeinfo" /> +<link href="index.html" rel="start" title="Top" /> +<link href="Index.html" rel="index" title="Index" /> +<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents" /> +<link href="Scripting.html" rel="up" title="Scripting" /> +<link href="Tweening.html" rel="next" title="Tweening" /> +<link href="Agendas.html" rel="prev" title="Agendas" /> <style type="text/css"> -<!-- +<!-- a.summary-letter {text-decoration: none} blockquote.indentedblock {margin-right: 0em} div.display {margin-left: 3.2em} @@ -72,9 +72,9 @@ ul.no-bullet {list-style: none} } } ---> +--> </style> -<link rel="stylesheet" type="text/css" href="https://dthompson.us/css/dthompson.css"> +<link rel="stylesheet" type="text/css" href="https://dthompson.us/css/dthompson.css" /> </head> @@ -84,7 +84,7 @@ ul.no-bullet {list-style: none} <p> Next: <a href="Tweening.html" accesskey="n" rel="next">Tweening</a>, Previous: <a href="Agendas.html" accesskey="p" rel="prev">Agendas</a>, Up: <a href="Scripting.html" accesskey="u" rel="up">Scripting</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p> </div> -<hr> +<hr /> <span id="Scripts-1"></span><h4 class="subsection">5.5.2 Scripts</h4> <p>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: </p> -<div class="example"> -<pre class="example">(script - (while #t - (display "mom!") - (newline) - (sleep 60))) ; where 60 = 1 second of real time -</pre></div> +<div class="lisp"> +<pre class="lisp"><span class="syntax-open">(</span><span class="syntax-symbol">script</span> + <span class="syntax-open">(</span><span class="syntax-symbol">while</span> <span class="syntax-symbol">#t</span> + <span class="syntax-open">(</span><span class="syntax-symbol">display</span> <span class="syntax-string">"mom!"</span><span class="syntax-close">)</span> + <span class="syntax-open">(</span><span class="syntax-symbol">newline</span><span class="syntax-close">)</span> + <span class="syntax-open">(</span><span class="syntax-symbol">sleep</span> <span class="syntax-symbol">60</span><span class="syntax-close">)</span><span class="syntax-close">)</span><span class="syntax-close">)</span> <span class="syntax-comment">; where 60 = 1 second of real time +</span></pre></div> <p>This code runs in an endless loop, but the <code>sleep</code> 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. </p> -<div class="example"> -<pre class="example">(define script (script (while #t (display "hey\n") (sleep 60)))) -;; sometime later -(cancel-script script) +<div class="lisp"> +<pre class="lisp"><span class="syntax-open">(</span><span class="syntax-special">define</span> <span class="syntax-symbol">script</span> <span class="syntax-open">(</span><span class="syntax-symbol">script</span> <span class="syntax-open">(</span><span class="syntax-symbol">while</span> <span class="syntax-symbol">#t</span> <span class="syntax-open">(</span><span class="syntax-symbol">display</span> <span class="syntax-string">"hey\n"</span><span class="syntax-close">)</span> <span class="syntax-open">(</span><span class="syntax-symbol">sleep</span> <span class="syntax-symbol">60</span><span class="syntax-close">)</span><span class="syntax-close">)</span><span class="syntax-close">)</span><span class="syntax-close">)</span> +<span class="syntax-comment">;; sometime later +</span><span class="syntax-open">(</span><span class="syntax-symbol">cancel-script</span> <span class="syntax-symbol">script</span><span class="syntax-close">)</span> </pre></div> <dl> @@ -187,10 +187,10 @@ procedure <var>handler</var>. <dt id="index-wait_002duntil">Syntax: <strong>wait-until</strong> <em>condition</em></dt> <dd><p>Wait until <var>condition</var> is met before resuming the current script. </p> -<div class="example"> -<pre class="example">(script - (wait-until (key-pressed? 'z)) - (display "you pressed the Z key!\n")) +<div class="lisp"> +<pre class="lisp"><span class="syntax-open">(</span><span class="syntax-symbol">script</span> + <span class="syntax-open">(</span><span class="syntax-symbol">wait-until</span> <span class="syntax-open">(</span><span class="syntax-symbol">key-pressed?</span> <span class="syntax-symbol">'z</span><span class="syntax-close">)</span><span class="syntax-close">)</span> + <span class="syntax-open">(</span><span class="syntax-symbol">display</span> <span class="syntax-string">"you pressed the Z key!\n"</span><span class="syntax-close">)</span><span class="syntax-close">)</span> </pre></div> </dd></dl> @@ -200,7 +200,7 @@ procedure <var>handler</var>. <dd><p>Evaluate <var>body</var> in an endless loop. </p></dd></dl> -<hr> +<hr /> <div class="header"> <p> Next: <a href="Tweening.html" accesskey="n" rel="next">Tweening</a>, Previous: <a href="Agendas.html" accesskey="p" rel="prev">Agendas</a>, Up: <a href="Scripting.html" accesskey="u" rel="up">Scripting</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p> |