Skip to content

Commit 574fc18

Browse files
authored
Merge pull request #17 from SecondNewtonLaw/documentation-improvements
Documentation improvements
2 parents d8799ca + 5bf699b commit 574fc18

File tree

10 files changed

+25
-20
lines changed

10 files changed

+25
-20
lines changed

docs/Closures/getfunctionhash.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ local dummy_function_2 = function() end
3939
local dummy_function_3 = function() return "Constant" end
4040
local dummy_function_4 = function() return "Constant2" end
4141
42-
print(is_sha384_hex(getfunctionhash(dummy_function0))) -- Output: true
42+
print(is_sha384_hex(getfunctionhash(dummy_function_0))) -- Output: true
4343
print(getfunctionhash(dummy_function_0) == getfunctionhash(dummy_function_1)) -- Output: false
4444
print(getfunctionhash(dummy_function_0) == getfunctionhash(dummy_function_2)) -- Output: true
4545
print(getfunctionhash(dummy_function_3) == getfunctionhash(dummy_function_4)) -- Output: false

docs/Closures/newcclosure.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77
The wrapped function **must** be yieldable, meaning that the function should be able to call [`#!luau task.wait`](https://create.roblox.com/docs/reference/engine/libraries/task#wait), for example.
88

9+
!!! failure "Error spoofing"
10+
11+
Luau and C errors are different. You must make sure that the error that closures wrapped with `#!luau newcclosure` appear as C closure errors!
12+
13+
!!! info "Upvalues"
14+
15+
The function returned by `#!luau newcclosure` must have no upvalues.
16+
917
`#!luau newcclosure` takes any Lua function and wraps it into a C closure.
1018
When the returned function is called, it invokes the original Luau closure with the provided arguments, then passes the closure's returned values back to the caller.
1119

docs/Environment/getgc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# `getgc`
22

3-
`#!luau getgc` returns a list of all **non-dead garbage-collectable values**. These include functions, userdata, and optionally tables.
3+
`#!luau getgc` returns a list of **non-dead garbage-collectable values**. These include functions, userdata, and optionally tables.
44

55
```luau
66
function getgc(includeTables: boolean?): { { any } | (...any) -> (...any) | userdata }

docs/Environment/getrenv.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# `getrenv`
22

33
!!! warning "Adding `#!luau _G` and `#!luau shared`"
4-
Make sure to properly implement _G and shared into the Roblox environemnt, as poor implementations will lead to detection vectors!
4+
Make sure to properly implement `#!luau _G` and `#!luau shared` into the Roblox environemnt, as poor implementations will result in detection vectors!
55

6-
`#!luau getrenv` returns the **Roblox global environment**, which is used by game scripts. This environment is separate from the executor's environment returned by [`#!luau getgenv`](./getgenv.md).
6+
`#!luau getrenv` returns the **Roblox global environment**, which is used by the entire game. Changes to this environment will affect your executor environment as well.
77

88
```luau
99
function getrenv(): { any }
@@ -24,5 +24,5 @@ getrenv().warn = "Hello!"
2424
print(type(warn)) -- Output: string
2525
2626
getrenv().game = nil
27-
print(game) -- Output: nil (for scripts using the Roblox environment)
27+
print(game) -- Output: nil
2828
```

docs/Scripts/getcallingscript.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# `getcallingscript`
22

3-
!!! info "Notes on `#!luau clonefunction`"
3+
!!! info "Notes on `#!luau getcallingscript`"
44

5-
If a script is executing in a game thread, `#!luau getcallingscript()` must return the proper [`Script`](https://create.roblox.com/docs/reference/engine/classes/Script), [`LocalScript`](https://create.roblox.com/docs/reference/engine/classes/LocalScript), or [`ModuleScript`](https://create.roblox.com/docs/reference/engine/classes/ModuleScript) - even if it has set its global [`#!luau script`](https://create.roblox.com/docs/reference/engine/globals/RobloxGlobals#script) variable to `#!luau nil`.
5+
If a game script is executing and `#!luau getcallingscript` is called it must return the proper [`Script`](https://create.roblox.com/docs/reference/engine/classes/Script), [`LocalScript`](https://create.roblox.com/docs/reference/engine/classes/LocalScript), or [`ModuleScript`](https://create.roblox.com/docs/reference/engine/classes/ModuleScript) - even if it has set its global [`#!luau script`](https://create.roblox.com/docs/reference/engine/globals/RobloxGlobals#script) variable to `#!luau nil`.
66

77
`#!luau getcallingscript` returns the [`#!luau Script`](https://create.roblox.com/docs/reference/engine/classes/Script), [`#!luau LocalScript`](https://create.roblox.com/docs/reference/engine/classes/LocalScript), or [`#!luau ModuleScript`](https://create.roblox.com/docs/reference/engine/classes/ModuleScript) that **triggered the current code execution**.
88

docs/Scripts/getscriptclosure.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# `getscriptclosure`
22

3-
!!! info "Closure is generated, not directly reused"
3+
!!! info "Closure is compiled from bytecode, not an active one"
44

5-
The function returned by `#!luau getscriptclosure` is a **new closure** compiled from the script's bytecode. It is not the same function used by the game, but behaves identically. This function is mostly used to retrieve constants from a script.
5+
The function returned by `#!luau getscriptclosure` is a **new closure** compiled from the script's bytecode. It is not the function used by the game script, but has identical metadata. This function is used to retrieve constants from a script.
66

77
!!! info "Not all scripts have bytecode"
88

docs/Scripts/loadstring.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
Compiles the given string, and returns it runnable in a function. The environment must become unsafe after this function is called due to it allowing the modification of globals uncontrollably (see [setfenv](https://create.roblox.com/docs/reference/engine/globals/LuaGlobals#setfenv)/[getfenv](https://create.roblox.com/docs/reference/engine/globals/LuaGlobals#getfenv) documentation).
66

7-
87
```luau
9-
function loadstring<A...>(source: string, chunkname: string?): ((A...) -> any | nil, string?)
8+
function loadstring<A..., T...>(source: string, chunkname: string?): (((A...) -> T...) | nil, string?)
109
```
1110

1211
## Parameters

docs/Signals/Connection.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# The `Connection` object
22

3-
!!! info "Notes on the `object`."
4-
3+
!!! info "Notes on the `object`"
4+
55
The retrieved connection object will only have the listed methods and fields, since it's a custom object
66

77
A `#!luau Connection` object represents an active link to a signal's callback. These are returned by [`#!luau getconnections`](./getconnections.md) and allow inspection and manipulation over connections/signals.
@@ -20,7 +20,7 @@ A `#!luau Connection` object represents an active link to a signal's callback. T
2020

2121
!!! info "Foreign and C-state behavior"
2222

23-
If the connection originates from a foreign Lua state or is a C-level connection, `#!luau Function` and `#!luau Thread` will be `#!luau nil`, due to these fields being impossible to obtain in this scenario.
23+
If the connection originates from a foreign Lua state or is a C-level connection, `#!luau Function` and `#!luau Thread` will be `#!luau nil` and their `#!luau ForeignState` property will be `#!luau true`. This is due to neither `#!luau Function` nor `#!luau Thread` existing on the current Luau VM.
2424

2525
---
2626

docs/Signals/firesignal.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# `firesignal`
22

3-
`#!luau firesignal` Invokes all Lua [`connections`](https://create.roblox.com/docs/reference/engine/datatypes/RBXScriptConnection) connected to a given [`RBXScriptSignal`](https://create.roblox.com/docs/reference/engine/datatypes/RBXScriptSignal).
3+
!!! info "Firing mode"
44

5+
This function will invoke all the connections of the signal **immediately**, ignoring the [`#!luau Workspace.SignalBehaviour`](https://create.roblox.com/docs/reference/engine/classes/Workspace#SignalBehavior) property.
6+
7+
`#!luau firesignal` Invokes all Lua [connections](https://create.roblox.com/docs/reference/engine/datatypes/RBXScriptConnection) connected to a given [`#!luau RBXScriptSignal`](https://create.roblox.com/docs/reference/engine/datatypes/RBXScriptSignal).
58

69
```luau
710
function firesignal(signal: RBXScriptSignal, ...: any?)

docs/Signals/getconnections.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
# `getconnections`
22

3-
!!! info "C and foreign signals"
4-
5-
Passing a signal that originates from [CoreScripts](https://robloxapi.github.io/ref/class/CoreScript.html), [Actors](https://create.roblox.com/docs/reference/engine/classes/Actor), or is otherwise made in C, will return a valid [`Connection`](./Connection.md) object - but its `#!luau Function` and `#!luau Thread` properties will be `#!luau nil`.
6-
73
`#!luau getconnections` retrieves a list of [`Connection`](./Connection.md) objects currently attached to a given [`RBXScriptSignal`](https://create.roblox.com/docs/reference/engine/datatypes/RBXScriptSignal).
84

9-
105
```luau
116
function getconnections(signal: RBXScriptSignal): {Connection}
127
```

0 commit comments

Comments
 (0)