This file is indexed.

/usr/share/doc/sludge/SLUDGEDevKitHelp/Setting_Default_Events.html is in sludge-doc 2.2.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<TITLE>Setting Default Events</TITLE>
  <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<BODY>
<HR>
<div align="center"><img id="headerGraphic" src="images/sludge300.png" alt="SLUDGE"/></div>
<h2>Setting Default Events</h2>
<HR>


<P>
In the <a href="Object_Types_and_Events.html">Object Types and Events</a> section of this help file this code was given as an example:
</P>

<P>
<pre>objectType ego (&quot;&quot;) {
}

objectType lookAt (&quot;Look at&quot;) {
}

objectType pickUp (&quot;Pick up&quot;) {
}

objectType box (&quot;box&quot;) {
   event lookAt {
      say (ego, &quot;It's full of junk, none of which looks useful.&quot;);
   }
}

objectType hat (&quot;old battered top hat&quot;) {
}</pre>
</P>

<P>
However, if your code was to call one of the following lines:
</P>

<P>
<pre>callEvent (lookAt, hat);

callEvent (pickUp, box);

callEvent (pickUp, hat);</pre>
</P>

<P>
...nothing would happen, as there are no events specified which match the parameters given. Therefore, in order to provide default reactions it is a good idea to create a default object type as follows:
</P>

<P>
<pre>objectType default (&quot;&quot;) {
}</pre>
</P>

<P>
The lookAt and pickUp object types could then be expanded to include default code:
</P>

<P>
<pre>objectType lookAt (&quot;Look at&quot;) {
   event default {
      say (ego, &quot;Nothing interesting to look at there.&quot;);
   }
}

objectType pickUp (&quot;Pick up&quot;) {
   event default {
      say (ego, &quot;I can't pick that up.&quot;);
   }
}</pre>
</P>

<P>
Of course, the <a href="callEvent.html">callEvent</a> function doesn't know how to resort to this default behaviour, so it's best to provide your own function instead, such as this:
</P>

<P>
<pre>sub findEvent (action, object) {

   # callEvent returns a value of TRUE if it's worked, so...
   if (callEvent (action, object) != TRUE) {
      callEvent (default, action);
   }
}</pre>
</P>

<P>
Of course, you'll probably want to combine objects with other objects - and sooner or later you'll probably forget a default event somewhere. Also, combining object A with object B should probably have the same effect as combining object B with object A. So, let's make our findEvent function even more complicated...
</P>

<P>
<pre>sub findEvent (action, object) {
   if (callEvent (action, object)) return;
   if (callEvent (object, action)) return;
   if (callEvent (default, action)) return;
   if (callEvent (default, object)) return;
   say (ego, &quot;I can't use these things together.&quot;);
}</pre>
</P>

<P>
So let's say your function called:
</P>

<P>
<pre>findEvent (box, hat);</pre>
</P>

<P>
First it would try to use the box with the hat. Then, because there was no event for that, it would try to use the hat with the box. Then it would try to use the default action in the box object type. Then the default action in the hat object type. Finally, because none of those events exist, the script would resort to making the ego say the immortal line &quot;I can't use these things together.&quot;
</P>

<P class="copyright-notice">SLUDGE and this SLUDGE documentation are <A HREF="Copyright.html">copyright</A> Hungry Software and contributors 2000-2012
</P>

<HR>
</BODY>
</html>