44
55-- Utility function to safely check if an object has a specific property (key) in its Lua script table.
66-- 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
1515end
1616
1717-- Helper function to validate grapple gun
1818local 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
2929end
3030
3131-- Action for Retract slice in the pie menu.
3232function 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
3737end
3838
3939-- Action for Extend slice in the pie menu.
4040function 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
4545end
4646
4747-- Action for Unhook slice in the pie menu.
4848function 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
5353end
0 commit comments