Difference between revisions of "Manual:DIL Manual/setbright()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
| + | = setbright() = | ||
| + | '''Procedure.''' Sets how much light a unit gives. | ||
| + | setbright(u : unitptr, light : integer) | ||
| − | < | + | Sets the [[Manual:DIL Manual/bright|bright]] value of <code>u</code>, the light it sheds, and |
| − | + | changes the light around it by the same amount: the room or container it is in, and a | |
| − | + | character who wears or holds it. A torch with 1 or more lights up a dark room; a negative value | |
| − | + | darkens. The <code>bright</code> field can't be assigned; this is how it is changed. | |
| − | + | == Parameters == | |
| − | + | {| class="wikitable" | |
| − | + | ! Name !! Type !! Meaning | |
| + | |- | ||
| + | | u || unitptr || The unit. | ||
| + | |- | ||
| + | | light || integer || The new light value. | ||
| + | |} | ||
| − | + | == Notes == | |
| + | * Works on every kind of unit. With a null unit nothing happens. | ||
| + | * The value is a 16-bit number: outside -32768 to 32767 it wraps around. | ||
| + | * The light inside a unit is the [[Manual:DIL Manual/light|light]] field; whether a room can be seen in, [[Manual:DIL Manual/islight()|islight()]]. | ||
| + | |||
| + | == Example == | ||
| + | <pre> | ||
| + | dilbegin burn_down(minutes : integer); | ||
| + | code | ||
| + | { | ||
| + | heartbeat := PULSE_SEC * 60; | ||
| + | setbright(self, 2); | ||
| + | while (minutes > 0) | ||
| + | { | ||
| + | pause; | ||
| + | minutes := minutes - 1; | ||
| + | } | ||
| + | setbright(self, 0); | ||
| + | quit; | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | A torch that burns for a given number of minutes and then goes out. | ||
| + | |||
| + | == See also == | ||
| + | * [[Manual:DIL Manual/bright|bright]] | ||
| + | * [[Manual:DIL Manual/light|light]] | ||
| + | * [[Manual:DIL Manual/illum|illum]] | ||
| + | * [[Manual:DIL Manual/islight()|islight()]] | ||
Latest revision as of 23:22, 14 November 2026
setbright()
Procedure. Sets how much light a unit gives.
setbright(u : unitptr, light : integer)
Sets the bright value of u, the light it sheds, and
changes the light around it by the same amount: the room or container it is in, and a
character who wears or holds it. A torch with 1 or more lights up a dark room; a negative value
darkens. The bright field can't be assigned; this is how it is changed.
Parameters
| Name | Type | Meaning |
|---|---|---|
| u | unitptr | The unit. |
| light | integer | The new light value. |
Notes
- Works on every kind of unit. With a null unit nothing happens.
- The value is a 16-bit number: outside -32768 to 32767 it wraps around.
- The light inside a unit is the light field; whether a room can be seen in, islight().
Example
dilbegin burn_down(minutes : integer);
code
{
heartbeat := PULSE_SEC * 60;
setbright(self, 2);
while (minutes > 0)
{
pause;
minutes := minutes - 1;
}
setbright(self, 0);
quit;
}
dilend
A torch that burns for a given number of minutes and then goes out.