-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.lua
127 lines (92 loc) · 4.17 KB
/
utils.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
--[=[
@class Logger
A Util object for nicely logging messages to the output window.
This can be required under `game.ServerStorage.SocketPlugin.Utils.Logger`
]=]
--[=[
@method MacroInfo
@param macro MacroDefinition
@param ... any
@within Logger
For showing general information to the output
]=]
--[=[
@method MacroWarn
@param macro MacroDefinition
@param ... any
@within Logger
For informing the user that an issue with a macro has occured
]=]
-----------------------------------------------------------------------------------------------------------------------------------------------------
--[=[
@class InstanceUtil
A Util object that gives some nice methods for when a macro needs to create instances + place them somewhere in the workspace. It places instances
under a Socket folder, under this specific user - useful for Team Create!
Instances parented using this class will be automatically cleaned up when Socket closes (but only for the specific user in Team Create). You may still want to have a `BindToClose` implementation,
depending on what your macro does and if you need to handle cases where the plugin isn't closed properly (e.g., Studio crash)
This can be required under `game.ServerStorage.SocketPlugin.Utils.InstanceUtil`
]=]
--[=[
@method IntroduceInstance
@param instance Instance
@param dontSetWaypoint boolean|nil
@within InstanceUtil
Brings an instance into the workspace in the context of Socket and the user calling this function. By default, sets a ChangeHistoryService waypoint.
]=]
--[=[
@method ClearInstance
@param instance Instance
@param doDestroy boolean
@within InstanceUtil
Clears an instance from our context of Socket and the user calling this function. Should be an instance that was introduced via `IntroduceInstance`
]=]
-----------------------------------------------------------------------------------------------------------------------------------------------------
--[=[
@class RaycastUtil
Gives some nice methods for raycasting.
]=]
--[=[
@method RaycastMouse
@param distance number
@param raycastParams RaycastParams|nil
@param checkAllCollisionGroups boolean|nil
@within RaycastUtil
Sends a raycast from our camera to the point our mouse is at in the world.
`checkAllCollisionGroups=true` will make sure we raycast against parts that don't collide with the `"Default"` Collision Group (see the ".Locked" macro)
]=]
--[=[
@method Raycast
@param origin Vector3
@param direction Vector3
@param distance number
@param raycastParams RaycastParams|nil
@param checkAllCollisionGroups boolean|nil
@within RaycastUtil
Does a bog standard raycast.
`checkAllCollisionGroups=true` will make sure we raycast against parts that don't collide with the `"Default"` Collision Group (see the ".Locked" macro)
]=]
-----------------------------------------------------------------------------------------------------------------------------------------------------
--[=[
@class SoftRequire
A Util file to help require ModuleScripts and work around cached values.
]=]
--[=[
@method Require
@param moduleScript ModuleScript
@return table
@within SoftRequire
Passed a ModuleScript, will require a Clone() of it. This has the benefit of `softRequire(moduleScript) ~= softRequire(moduleScript)`,
whereas `require(moduleScript) == require(moduleScript)`. This gets round the cached value that require() uses.
This is beneficial, as during development you may be constantly updating your Util files. After a macro uses `require()` on a Util, any further
`require()` calls will use a cached value from the first call. This gets round this issue, and allows us for our macros to always have access to
the most up to date version of our Util files.
]=]
-----------------------------------------------------------------------------------------------------------------------------------------------------
--[=[
@class Promise
See [Promise](https://eryn.io/roblox-lua-promise/)
]=]
--[=[
@class Janitor
See [Janitor](https://github.com/howmanysmall/Janitor)
]=]