IsTriggerAt
From Spheriki
Check if a trigger is at the given map pixel coordinates.
Contents |
Usage
- x number. Pixel X coordinate to check on the map.
- y number. Pixel Y coordinate to check on the map.
- layer number, non-negative. Index of the layer to check.
- boolean is returned,
trueif there is a trigger at the given location,falseotherwise.
Examples
To make the mouse trigger events, place this in an update script:
if (IsMouseButtonPressed(MOUSE_LEFT)) {
var x = GetMouseX();
var y = GetMouseY();
var layer = 0;
x = ScreenToMapX(layer, x);
y = ScreenToMapY(layer, y);
if (IsTriggerAt(x, y, layer))
ExecuteTrigger(x, y, layer);
}
This code will run when the left mouse button is held down. The last two lines are the important part: the if condition uses IsTriggerAt() to find whether or not there's a trigger to run at the mouse cursor location. If so, ExecuteTrigger() is called at the same location.
Notes
- At the time of writing, the
layerparameter is ignored, but it must still be valid.
- This function only has well-defined behaviour while the Sphere map engine is running.
- Triggers take up a whole tile. Be aware of this, since person locations are represented as the center of the base, while events trigger even if the person's base box overlaps the trigger.