4
4
5
5
-- Utility function to safely check if an object has a specific property (key) in its Lua script table.
6
6
-- This is useful for checking if a script-defined variable exists on an MO.
7
- function HasScriptProperty (obj , propName )
8
- if type (obj ) ~= " table" or type (propName ) ~= " string" then
9
- return false
10
- end
11
- -- pcall to safely access potentially non-existent script members.
12
- -- This is more about checking Lua script-defined members rather than engine properties.
13
- local status , result = pcall (function () return rawget (obj , propName ) ~= nil end )
14
- return status and result
7
+ local function HasScriptProperty (obj , propName )
8
+ if type (obj ) ~= " table" or type (propName ) ~= " string" then
9
+ return false
10
+ end
11
+ -- pcall to safely access potentially non-existent script members.
12
+ -- This is more about checking Lua script-defined members rather than engine properties.
13
+ local status , result = pcall (function () return rawget (obj , propName ) ~= nil end )
14
+ return status and result
15
15
end
16
16
17
17
-- Helper function to validate grapple gun
18
18
local function ValidateGrappleGun (pieMenuOwner )
19
- if not pieMenuOwner or not pieMenuOwner .EquippedItem then
20
- return nil
21
- end
22
-
23
- local gun = ToMOSRotating (pieMenuOwner .EquippedItem )
24
- if gun and gun .PresetName == " Grapple Gun" then
25
- return gun
26
- end
27
-
28
- return nil
19
+ if not pieMenuOwner or not pieMenuOwner .EquippedItem then
20
+ return nil
21
+ end
22
+
23
+ local gun = ToMOSRotating (pieMenuOwner .EquippedItem )
24
+ if gun and gun .PresetName == " Grapple Gun" then
25
+ return gun
26
+ end
27
+
28
+ return nil
29
29
end
30
30
31
31
-- Action for Retract slice in the pie menu.
32
32
function GrapplePieRetract (pieMenuOwner , pieMenu , pieSlice )
33
- local gun = ValidateGrappleGun (pieMenuOwner )
34
- if gun then
35
- gun :SetNumberValue (" GrappleMode" , 1 ) -- 1 signifies Retract
36
- end
33
+ local gun = ValidateGrappleGun (pieMenuOwner )
34
+ if gun then
35
+ gun :SetNumberValue (" GrappleMode" , 1 ) -- 1 signifies Retract
36
+ end
37
37
end
38
38
39
39
-- Action for Extend slice in the pie menu.
40
40
function GrapplePieExtend (pieMenuOwner , pieMenu , pieSlice )
41
- local gun = ValidateGrappleGun (pieMenuOwner )
42
- if gun then
43
- gun :SetNumberValue (" GrappleMode" , 2 ) -- 2 signifies Extend
44
- end
41
+ local gun = ValidateGrappleGun (pieMenuOwner )
42
+ if gun then
43
+ gun :SetNumberValue (" GrappleMode" , 2 ) -- 2 signifies Extend
44
+ end
45
45
end
46
46
47
47
-- Action for Unhook slice in the pie menu.
48
48
function GrapplePieUnhook (pieMenuOwner , pieMenu , pieSlice )
49
- local gun = ValidateGrappleGun (pieMenuOwner )
50
- if gun then
51
- gun :SetNumberValue (" GrappleMode" , 3 ) -- 3 signifies Unhook
52
- end
49
+ local gun = ValidateGrappleGun (pieMenuOwner )
50
+ if gun then
51
+ gun :SetNumberValue (" GrappleMode" , 3 ) -- 3 signifies Unhook
52
+ end
53
53
end
0 commit comments