Skip to content

Commit 4ee4171

Browse files
committed
Improvements
1 parent 54850c3 commit 4ee4171

10 files changed

+34
-41
lines changed

functions/Event/addEventHandler.yaml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ shared:
1212
and numerals)**'
1313
- name: attachedTo
1414
type: element
15-
description: The [element](/reference/Element "Element") you wish to attach the handler to. The handler will only
15+
description: The [[element]] you wish to attach the handler to. The handler will only
1616
be called when the event it is attached to is triggered for this element, or
1717
one of its children. Often, this can be the root element (meaning the handler
1818
will be called when the event is triggered for *any* element).
@@ -45,22 +45,14 @@ shared:
4545
description: Returns **true** if the event handler was attached successfully. otherwise **false** if the specified event could not be found or any parameters were invalid.
4646
notes:
4747
- type: info
48-
content: You shouldn't re-use the same name for your handler function as the event
48+
content: |
49+
- You shouldn't re-use the same name for your handler function as the event
4950
name - if multiple handler functions are used, as this can lead to confusion.
5051
On the same note, for multiple reasons, it isn't a good idea to export the same
5152
functions that you use locally as remote event handlers.
52-
- type: info
53-
content: See [Event Source Element](/reference/Event_Source_Element "Event Source Element") for a descriptive visualization of the event
53+
- See [Event Source Element](/reference/Event_Source_Element "Event Source Element") for a descriptive visualization of the event
5454
system handling an event trigger.
55-
- type: important
56-
content: See [Script security](/Script_security "Script security") for how-to prevent cheaters from abusing [event system](/reference/Event_System "Event system").
57-
- type: important
58-
content: Anything bound to a specific element will be run before other handlers
59-
that are bound to something higher in the element tree (like root) This means
60-
that "high+10" bound to root **won't** trigger before "normal" bound directly to
61-
an element.
62-
- type: info
63-
content: Due to the additional set of global variables, the event-trigger specific
55+
- Due to the additional set of global variables, the event-trigger specific
6456
variables it is NOT a good idea to use the same function locally as well as
6557
directly as an event handler . Event handlers often make use of the source element
6658
variable which would often find no use in generic functions. Inside of server-side
@@ -70,3 +62,10 @@ shared:
7062
the same issues. It is recommended to adapt a good-natured distancing principle
7163
between code meant to run from local logic in separation to code meant to run
7264
from remote logic.
65+
- type: important
66+
content: |
67+
- See [Script security](/Script_security "Script security") for how-to prevent cheaters from abusing [event system](/reference/Event_System "Event system").
68+
- Anything bound to a specific element will be run before other handlers
69+
that are bound to something higher in the element tree (like root) This means
70+
that "high+10" bound to root **won't** trigger before "normal" bound directly to
71+
an element.

functions/Event/cancelEvent.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ shared:
66
returns:
77
values:
88
- type: bool
9-
name: value
9+
name: result
1010
description: Always returns **true**.
1111

1212
client:
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
-- Add a new event called onSpecialEvent
21
addEvent ( "onSpecialEvent", true )
3-
-- Define our handler function, that takes a "text" parameter and outputs it to the chatbox
2+
43
function specialEventHandler ( text )
54
outputChatBox ( text )
65
end
7-
-- Add it as a handler for our event
8-
addEventHandler ( "onSpecialEvent", root, specialEventHandler )
9-
-- You can then trigger this event later on using:
10-
triggerEvent ( "onSpecialEvent", root, "test" )
11-
-- This will cause the handler to be triggered, so "test" will be output to the chatbox.
6+
addEventHandler ( "onSpecialEvent", root, specialEventHandler )

functions/Event/getEventHandlers.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ shared:
88
description: The name of the event.
99
- name: attachedTo
1010
type: element
11-
description: The [element](/reference/Element "Element") attached to.
11+
description: The [[element]] attached to.
1212
returns:
1313
values:
1414
- type: table
1515
name: result
16-
description: Returns **table** with attached functions, otherwise **empty table**.
16+
description: Returns [[table]] with attached functions, otherwise empty [[table]].
1717

1818
server:
1919
examples:

functions/Event/getLatentEventHandles.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ shared:
1111
values:
1212
- type: table
1313
name: result
14-
description: Returns a **table** of handles, otherwise **false** if invalid arguments were passed.
14+
description: Returns a [[table]] of handles, otherwise **false** if invalid arguments were passed.
1515

1616
server:
1717
name: getLatentEventHandles
@@ -26,4 +26,4 @@ server:
2626
values:
2727
- type: table
2828
name: result
29-
description: Returns a **table** of handles, otherwise **false** if invalid arguments were passed.
29+
description: Returns a [[table]] of handles, otherwise **false** if invalid arguments were passed.

functions/Event/getLatentEventStatus.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ shared:
99
values:
1010
- type: table
1111
name: result
12-
description: 'Returns a **table** with the following info, otherwise **false** if invalid arguments
12+
description: 'Returns a [[table]] with the following info, otherwise **false** if invalid arguments
1313
were passed:'
1414

1515
server:
@@ -27,8 +27,7 @@ server:
2727
values:
2828
- type: table
2929
name: result
30-
description: 'Returns a **table** with the following info, otherwise **false** if invalid arguments
31-
were passed:'
30+
description: 'Returns a [[table]] with the following info, otherwise **false** if invalid arguments were passed:'
3231

3332
client:
3433
examples:

functions/Event/removeEventHandler.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ shared:
1010
description: The name of the [event](/reference/Event_System "Event") you want to detach the handler function from.
1111
- name: attachedTo
1212
type: element
13-
description: The [element](/reference/Element "Element") the handler was attached to.
13+
description: The [[element]] the handler was attached to.
1414
- name: functionVar
1515
type: function
1616
description: The handler function that was attached.

functions/Event/triggerClientEvent.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ server:
4747
content: It is marginally more efficient to pass one large event than two smaller
4848
ones.
4949
- type: important
50-
content: Non-element MTA data types like [xmlNodes](/reference/xmlnode "XML Node") or resource pointers will not
50+
content: |
51+
- Non-element MTA data types like [xmlNodes](/reference/xmlnode "XML Node") or resource pointers will not
5152
be able to be passed as they do not necessarily have a valid representation
5253
on the client.
53-
- type: important
54-
content: To save client CPU, you should avoid setting theElement to the [root](/reference/root "Root") element
54+
- To save client CPU, you should avoid setting theElement to the [root](/reference/root "Root") element
5555
where possible - it should be used as a last resort (rather questionable thing
5656
to do, limited to very specific tasks, if any). Using target element ( [player](/reference/player "Player")
5757
who should receive event, if expected to be delivered to particular one) is
5858
preferred and highly advisable. [resourceRoot](/reference/resourceRoot "ResourceRoot") can also be used as alternative
5959
choice, if [addEventHandler](/reference/addEventHandler "addEventHandler") is bound to [root](/reference/root "Root") element, or to [resourceRoot](/reference/resourceRoot "ResourceRoot") when
60-
there is need to restrict event to single certain resource.
60+
there is need to restrict event to single certain resource.

functions/Event/triggerEvent.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
shared:
22
name: triggerEvent
33
description: This function will trigger a named [event](/reference/Event_System "Event") on
4-
a specific [element](/reference/Element "Element") in the [element tree](/reference/Element_tree
4+
a specific [[element]] in the [element tree](/reference/Element_tree
55
"Element tree"). See [event system](/reference/Event_System "Event System") for more
66
information on how the event system works.
77
You can use the value returned from this function to determine if the event was cancelled by one of the event handlers. You should determine what your response (if any) to this should be based on the event's purpose. Generally, cancelling an event should prevent any further code being run that is dependent on whatever triggered that event. For example, if you have an onFlagCapture event, cancelling it would be expected to prevent the flag being able to be captured. Similarly, if you have onPlayerKill as an event you trigger, canceling it would either be expected to prevent the player being killed from dying or at least prevent the player from getting a score for it.
@@ -30,10 +30,10 @@ shared:
3030

3131
notes:
3232
- type: info
33-
content: You should avoid triggering events on the [root](/reference/root "Root") element unless you really
33+
content: |
34+
- You should avoid triggering events on the [root](/reference/root "Root") element unless you really
3435
need to. Doing this triggers the event on every element in the element tree,
3536
which is potentially very CPU intensive. Use as specific (i.e. low down the
3637
tree) element as you can.
37-
- type: info
38-
content: See [Event Source Element](/reference/Event_Source_Element "Event Source Element") for a descriptive visualization of the event
38+
- See [Event Source Element](/reference/Event_Source_Element "Event Source Element") for a descriptive visualization of the event
3939
system handling an event trigger.

functions/Event/triggerServerEvent.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ client:
4141
content: It is marginally more efficient to pass one large event than two smaller
4242
ones.
4343
- type: important
44-
content: 'You should use the global variable [client](/reference/Predefined_variables) server-side instead of passing
44+
content: |
45+
- You should use the global variable [client](/reference/Predefined_variables) server-side instead of passing
4546
the localPlayer by parameter or source. Otherwise event faking (passing another
4647
player instead of the localPlayer ) would be possible. For more information
47-
see: [Script security](/Script_security) article.'
48-
- type: important
49-
content: To save server CPU, you should avoid setting **theElement** to the [root](/reference/root "Root") element
48+
see: [Script security](/Script_security) article.
49+
- To save server CPU, you should avoid setting **theElement** to the [root](/reference/root "Root") element
5050
where possible - it should be used as a last resort (rather questionable thing
5151
to do, limited to very specific tasks, if any). Using localPlayer is preferred
5252
and highly advisable. [resourceRoot](/reference/resourceRoot "ResourceRoot") can also be used as alternative choice, if

0 commit comments

Comments
 (0)