This file is indexed.

/usr/share/doc/sludge/SLUDGEDevKitHelp/Reusing_Code_for_or_from_Events.html is in sludge-doc 2.2.1-2build2.

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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<TITLE>Reusing Code for or from 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>Reusing Code for or from Events</h2>
<HR>


<P>
When an event is defined inside an object type and a new set of commands are defined:
</P>

<P>
<pre>objectType someObject (&quot;whatever&quot;) {
   event someAction {
      # Do stuff here
   }
}</pre>
</P>

<P>
...this is equivalent to the following code:
</P>

<P>
<pre>sub myFunction () {
   # Do stuff here
}

objectType someObject (&quot;whatever&quot;) {
   event someAction = myFunction;
}</pre>
</P>

<P>
Using the second method, the name of the function is obviously myFunction. Using the first method, with the code defined inside the object type itself, the code is stored in a function with no parameters, the name of which is the name of the object, followed by a period, followed by the name of the action. So, in the first example, the function is created with the name doorFromAToB.lookAt. This makes it possible to access events directly without using the <a href="callEvent.html">callEvent</a> command and to reuse predefined actions for new events:
</P>

<P>
<pre>objectType doorFromAToB (&quot;big metal door&quot;) {
   event lookAt {
      say (ego, &quot;It's only a door. Never seen a door before?&quot;);
   }
}

objectType doorFromCToD (&quot;tiny wooden door&quot;) {
   event lookAt = doorFromAToB.lookAt;
}

objectType doorFromEToF (&quot;purple door&quot;) {
   event lookAt {
      doorFromAToB.lookAt ();
      say (ego, &quot;The hinges are a bit rusty...&quot;);
   }
}</pre>
</P>

<P>
Or, as is perhaps clearer to read:
</P>

<P>
<pre>sub lookAtDoor {
   say (ego, &quot;It's only a door. Never seen a door before?&quot;);
}

objectType doorFromAToB (&quot;big metal door&quot;) {
   event lookAt = lookAtDoor;
}

objectType doorFromCToD (&quot;tiny wooden door&quot;) {
   event lookAt = lookAtDoor;
}

objectType doorFromEToF (&quot;purple door&quot;) {
   event lookAt {
      lookAtDoor ();
      say (ego, &quot;The hinges are a bit rusty...&quot;);
   }
}</pre>
</P>

<P>
(Note that because the events in the first two object types above reuse an existing function, there are no new functions created called either doorFromAToB.lookAt or doorFromCToD.lookAt.)
</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>