> > |
%META:TOPICINFO{author="ElminI" date="1079043199" format="1.0" version="1.1"}%
%META:TOPICPARENT{name="MakingZippyObjects"}%
Passages are areas on a map that can be watched for character entry and exit. They may also be "blocked", so that characters are prevented from entering.
To create a rectangular passage, use the Passage{} function:
pass = Passage{
shape = PASS_RECT,
x = x_position,
y = y_position,
width = some_width,
height = some_height
}
This passage will have one corner at and the opposite corner at .
Passages may also be octagonal:
oct_pass = Passage{
shape = PASS_OCT,
x = x_position,
y = y_position,
radius = octagon_radius
}
This passage will be centered at and have the radius given.
You may also specify a set of functions to be called when different events occur. Example:
pass = Passage{
[...]
alerts = {
exit = function (self, who)
print(who.name .. " left the passage")
end
}
}
This passage would print a message every time a character left it. The following alerts are supported (the initial "self" argument is implied):
name | arguments | meaning |
entrance | who_entered: character | A character entered the passage |
exit | who_exited: character | A character left the passage |
crush | who_crushed: character | A character was in the passage when it became blocked, and has been crushed |
It is also possible to add alert handlers to an already-created passage. This is done with the "watch" member function:
pass:watch("watch_key", { exit = function(self, deserter) [do stuff] end })
You may modify any set of alerts added by this method by calling the method again with the same "watch key". If the watch key is not supplied (i.e. only one argument is given), the entries in the table replace those in the original alert table supplied in the creation of the passage. You may remove any watch with the "blind" method:
pass:blind("watch_key")
-- ElminI - 11 Mar 2004 |