OnMarkerHit: Difference between revisions
Jump to navigation
Jump to search
m (→Example) |
(Add important note regarding weird behavior) |
||
(15 intermediate revisions by 9 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server event}} | {{Server event}} | ||
This event is triggered when | This event is triggered when an element enters a marker created using [[createMarker]]. | ||
{{Important Note|The event is not triggered when only the dimension changes of the player. So, if you use the `matchingDimension` when teleporting players into existing markers you should always first set their dimension/interior and only then the position}} | |||
==Parameters== | ==Parameters== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
element hitElement, bool matchingDimension | |||
</syntaxhighlight> | </syntaxhighlight> | ||
*''' | *'''hitElement''': the [[element]] that hit the [[marker]]. | ||
*'''matchingDimension''': | *'''matchingDimension''': a [[boolean]] representing whether the [[element]] is in the same dimension as the [[marker]]. | ||
==Source== | ==Source== | ||
The [[event system#Event source|source]] of this event is the [[marker]] that got hit by the | The [[event system#Event source|source]] of this event is the [[marker]] that got hit by the element. | ||
==Example== | ==Example== | ||
<!-- Explain what the example is in a single sentance --> | <!-- Explain what the example is in a single sentance --> | ||
This will output | This example will output a message what type of element has entered a marker. | ||
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --> | <!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | local playerMarker = createMarker(0, 0, 2, "cylinder", 5, 10, 244, 23, 200, root) | ||
outputChatBox ( " | |||
function handlePlayerMarker(hitElement) | |||
local elementType = getElementType(hitElement) | |||
outputChatBox("Element ("..elementType..") has entered marker.") | |||
end | end | ||
addEventHandler("onMarkerHit", | addEventHandler("onMarkerHit", playerMarker, handlePlayerMarker) | ||
</syntaxhighlight> | |||
==Issues== | |||
{{Issues| | |||
{{Issue|551|If a marker was attached to another element, onMarkerHit won't be triggered}} | |||
{{Issue|519|onMarkerHit not always triggered in interiors}} | |||
{{Issue|923|Server side markers with size < 1.5 don't trigger event}} | |||
}} | |||
{{See also/Server event|Marker events}} | {{See also/Server event|Marker events}} |
Latest revision as of 20:40, 20 September 2023
This event is triggered when an element enters a marker created using createMarker.
Important Note: The event is not triggered when only the dimension changes of the player. So, if you use the `matchingDimension` when teleporting players into existing markers you should always first set their dimension/interior and only then the position |
Parameters
element hitElement, bool matchingDimension
- hitElement: the element that hit the marker.
- matchingDimension: a boolean representing whether the element is in the same dimension as the marker.
Source
The source of this event is the marker that got hit by the element.
Example
This example will output a message what type of element has entered a marker.
local playerMarker = createMarker(0, 0, 2, "cylinder", 5, 10, 244, 23, 200, root) function handlePlayerMarker(hitElement) local elementType = getElementType(hitElement) outputChatBox("Element ("..elementType..") has entered marker.") end addEventHandler("onMarkerHit", playerMarker, handlePlayerMarker)
Issues
Issue ID | Description |
---|---|
#551 | If a marker was attached to another element, onMarkerHit won't be triggered |
#519 | onMarkerHit not always triggered in interiors |
#923 | Server side markers with size < 1.5 don't trigger event |
See Also
Marker events
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled