Skip to content

Commit 8c8203c

Browse files
authored
Some more improvements
Improvements
2 parents 8115323 + 3f983e4 commit 8c8203c

File tree

14 files changed

+36
-29
lines changed

14 files changed

+36
-29
lines changed

docs/Debug/setconstant.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ local function dummy_function()
2929
print(game.Name)
3030
end
3131
32-
-- Overwrite the constant at index 4 with "Players"
3332
debug.setconstant(dummy_function, 4, "Players")
3433
3534
dummy_function() -- Output: Players

docs/Debug/setstack.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function debug.setstack(level: number, index: number, value: any): ()
2626

2727
### Example 1
2828

29-
```luau title="Replacing a function on the stack" linenums="1"
29+
```luau title="Replacing the 'error' function on the stack with our own" linenums="1"
3030
error(debug.setstack(1, 1, function()
3131
return function()
3232
print("Replaced")

docs/Drawing/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ All drawing object types inherit the following fields:
4444

4545
| Method Signature | Description |
4646
|----------------------------------------|---------------------------------------|
47-
| `#!luau Drawing:Destroy()` | Permanently removes the drawing from view. |
47+
| `#!luau Destroy()` | Permanently removes the drawing from view. |
4848

4949
---
5050

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 **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, userdatas, and optionally tables.
44

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

docs/Environment/getgenv.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# `getgenv`
22

33
!!! warning "getgenv polluting"
4+
45
Modifications to a thread's global environment should not affect `#!luau getgenv`.
56

67
`#!luau getgenv` returns the **executor's global environment table**, which is shared across all executor-made threads.
@@ -21,10 +22,14 @@ function getgenv(): { any }
2122

2223
## Example
2324

24-
```luau title="Storing values across scripts using getgenv" linenums="1"
25-
getgenv().shared_var = "hello world"
25+
```luau title="getgenv shouldn't be affected by the global table/getfenv" linenums="1"
26+
getgenv().dummy_val = "value"
27+
getfenv().dummy_val_2 = 1
28+
29+
print(dummy_val, getgenv().dummy_val_2) -- Output: value, 1
30+
31+
getgenv().dummy_val = "value2"
32+
dummy_val = nil
33+
print(dummy_val) -- Output: value2
2634
27-
task.spawn(function()
28-
print(shared_var) -- Output: hello world
29-
end)
3035
```

docs/Instances/getcallbackvalue.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,4 @@ local retrieved = getcallbackvalue(dummy_bindable, "OnInvoke")
3131
retrieved() -- Output: Hello from callback!
3232
3333
print(getcallbackvalue(dummy_remote_function, "OnClientInvoke")) -- Output: nil
34-
getcallbackvalue(dummy_remote_function, "") -- Throws an error
3534
```

docs/Reflection/setscriptable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
!!! warning "Detection risks"
44

5-
`#!luau setscriptable` can expose detection vectors. Games may check whether certain properties are unexpectedly accessible, which can lead to detection.
5+
`#!luau setscriptable` can expose detection vectors. Games may check whether certain properties are unexpectedly accessible, which can lead to detections.
66

77
!!! info "Limited property support"
88

docs/Scripts/getcallingscript.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
!!! info "Notes on `#!luau getcallingscript`"
44

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 the [`#!luau script`](https://create.roblox.com/docs/reference/engine/globals/RobloxGlobals#script) global for said script is set 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 the [`#!luau script`](https://create.roblox.com/docs/reference/engine/globals/RobloxGlobals#script) global for said script is set 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

@@ -26,13 +26,13 @@ local old; old = hookmetamethod(game, "__index", function(self, key)
2626
local caller = getcallingscript()
2727
warn("__index access from script:", caller and caller:GetFullName() or "Unknown")
2828
29-
hookmetamethod(game, "__index", old) -- restore ze original
29+
hookmetamethod(game, "__index", old) -- Restore the original
3030
return old(self, key)
3131
end
3232
33-
return old(self, key) -- ensure executor access still works after ts
33+
return old(self, key)
3434
end)
3535
36-
print(getcallingscript()) -- Output: nil bc called from executor thread
36+
print(getcallingscript()) -- Output: nil, since we called from an executor thread
3737
3838
```

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 compiled from bytecode, not an active one"
3+
!!! info "Closure is compiled from the script's 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 function used by the game script, but has identical metadata. This function is 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 usually used to retrieve constants from a script.
66

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

docs/Scripts/getsenv.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
This environment contains **all global variables, functions** available to the target script, such as custom-defined functions or state values.
1010

1111
```luau
12-
function getsenv(script: Script | LocalScript | ModuleScript): { [any]: any }
12+
function getsenv(script: BaseScript | ModuleScript): { [any]: any }
1313
```
1414

1515
## Parameters

0 commit comments

Comments
 (0)