diff --git a/docs/config/events.md b/docs/config/events.md index 81f9ba3f..ea740807 100644 --- a/docs/config/events.md +++ b/docs/config/events.md @@ -8,6 +8,13 @@ const example = `event MyEvent = { bar: u8, }, }` + +const dataExample = `event MyEvent = { + from: Server, + type: Reliable, + call: ManyAsync, + data: (boolean, u32, string) +}` # Events @@ -56,3 +63,8 @@ Use synchronous events with extreme caution. ### `data` This field determines the data that is sent with the event. It can be any [Zap type](./types.md). + +- If the event does not require any data, the `data` field should be excluded. +- You can pass multiple arguments to the event by using a tuple: + + \ No newline at end of file diff --git a/docs/config/functions.md b/docs/config/functions.md index d7341a5d..0ede5595 100644 --- a/docs/config/functions.md +++ b/docs/config/functions.md @@ -7,6 +7,12 @@ const example = `funct Test = { }, rets: enum { Success, Fail } }` + +const tupleExample = `funct Tuples = { + call: Async, + args: (boolean, u8), + rets: (boolean, string) +}` # Functions @@ -41,6 +47,16 @@ Use synchronous functions with extreme caution. This field determines the data that is sent to the server. It can be any [Zap type](./types.md). +- If the client doesn't send any data, the `args` field should be excluded. +- You can pass multiple arguments to the function by using a tuple: + + + ### `rets` This field determines the data that is sent back to the client from the server. It can be any [Zap type](./types.md). + +- If the server doesn't return any data, the `rets` field should be excluded. +- The function can return multiple values by using a tuple: + + diff --git a/docs/usage/events.md b/docs/usage/events.md index e7b9b325..79f3f481 100644 --- a/docs/usage/events.md +++ b/docs/usage/events.md @@ -13,9 +13,7 @@ event AnotherEvent = { from: Client, type: Reliable, call: SingleAsync, - data: struct { - baz: boolean, - }, + data: (boolean, u8) }` @@ -50,7 +48,7 @@ If your event's [call field](../config/events.md#call) is `SingleAsync` or `Sing local Zap = require(Path.To.Zap) -- only server listeners are given the player argument -Zap.AnotherEvent.SetCallback(function(Player, Data) +Zap.AnotherEvent.SetCallback(function(Player, Bool, Number) -- Do something with the player and data end) ``` @@ -81,14 +79,12 @@ Use `Sync` events only when performance is critical. ## Firing From the Client -The client only has a single function for firing events, `Fire`. This function takes the event's data as its only argument. +The client only has a single function for firing events, `Fire`. This function takes the event's data as it arguments. ```lua local Zap = require(Path.To.Zap) -Zap.AnotherEvent.Fire({ - baz = true, -}) +Zap.AnotherEvent.Fire(true, 32) ``` ## Firing From the Server @@ -116,7 +112,7 @@ Zap.MyEvent.Fire(Player, { ### FireAll -The `FireAll` function takes the event's data as its only argument. It will fire the event to all players. +The `FireAll` function takes the event's data as its arguments. It will fire the event to all players. ```lua local Zap = require(Path.To.Zap)