mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
Load folder and refactor Lights
This commit is contained in:
@@ -4,8 +4,9 @@
|
||||
|
||||
local ElevatorsDir = script.Parent
|
||||
local MainDir = ElevatorsDir.Parent
|
||||
local LoadDir = MainDir:WaitForChild("Load")
|
||||
|
||||
local Tags = require(MainDir:WaitForChild("Tags"))
|
||||
local Tags = require(LoadDir:WaitForChild("Tags"))
|
||||
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
@@ -26,7 +27,6 @@ type Impl_Constructor = {
|
||||
} & Impl_Static_Props
|
||||
|
||||
type Impl_Static_Props = {
|
||||
ButtonEnum: any,
|
||||
DefaultMaxActivationDistance: number,
|
||||
DefaultHoldDuration: number
|
||||
}
|
||||
@@ -159,6 +159,7 @@ function ButtonsModule:AestheticActivateButton(Button, ActivatedState, Activated
|
||||
Button.Position+=LookVec
|
||||
|
||||
task.wait(.30)
|
||||
|
||||
if Glass then
|
||||
Glass.Position-=LookVec
|
||||
end
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
--!strict
|
||||
|
||||
local ElevatorDir = script.Parent
|
||||
local MainDir = ElevatorDir.Parent
|
||||
local MainDir = ElevatorDir.Parent
|
||||
local LoadDir = MainDir:WaitForChild("Load")
|
||||
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local Tween = require(Storage:WaitForChild("Tween"))
|
||||
local Tags = require(MainDir:WaitForChild("Tags"))
|
||||
local Tags = require(LoadDir:WaitForChild("Tags"))
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
|
||||
type rbxassetid = string
|
||||
@@ -88,7 +89,7 @@ function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern)
|
||||
if IsDirectionLantern then
|
||||
self.AudioChimeDirection:Play()
|
||||
else
|
||||
Tween.Completed:Connect(function()
|
||||
Tween.Completed:Once(function()
|
||||
self.AudioChimeLanding:Play()
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
local Elevators = script.Parent
|
||||
local MainDir = Elevators.Parent
|
||||
local LoadDir = MainDir:WaitForChild("Load")
|
||||
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local RS: RunService = game:GetService("RunService")
|
||||
@@ -20,7 +21,7 @@ local TractionRopes = require(Elevators:WaitForChild("TractionRopes"))
|
||||
local Lanterns = require(Elevators:WaitForChild("Lanterns"))
|
||||
|
||||
local PromptModule = require(MainDir:WaitForChild("Map"):WaitForChild("Prompts"))
|
||||
local Tags = require(MainDir:WaitForChild("Tags"))
|
||||
local Tags = require(LoadDir:WaitForChild("Tags"))
|
||||
|
||||
type rbxassetid = string
|
||||
|
||||
|
||||
108
src/server/main/Load/Tags/Lights.lua
Normal file
108
src/server/main/Load/Tags/Lights.lua
Normal file
@@ -0,0 +1,108 @@
|
||||
--!optimize 2
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
type rbxassetid = string
|
||||
|
||||
type LightProperties = {
|
||||
MaxLightSwitchActivationDistance: number,
|
||||
MaxLightSwitchHoldDuration: number,
|
||||
LightSwitchActivateSoundId: rbxassetid
|
||||
}
|
||||
|
||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||
type Impl_Constructor = {
|
||||
__index: Impl_Constructor,
|
||||
constructor: Constructor_Fun,
|
||||
--Class functions
|
||||
Functionality: (self: ClassConstructor, DefinedProperties: LightProperties?) -> LightAddresses
|
||||
} & Impl_Static_Props
|
||||
|
||||
type Impl_Static_Props = {
|
||||
StaticMaxLightSwitchActivationDistance: number,
|
||||
StaticMaxLightSwitchHoldDuration: number,
|
||||
StaticLightSwitchActivateSoundId: rbxassetid
|
||||
}
|
||||
|
||||
type Constructor_Fun = (Switch: BasePart) -> ClassConstructor
|
||||
type Constructor_Return_Props = {
|
||||
Switch: BasePart
|
||||
}
|
||||
|
||||
export type LightAddresses = {
|
||||
Attachment: Attachment?,
|
||||
Prompt: ProximityPrompt?,
|
||||
ClickSound: Sound?,
|
||||
ColorActivated: Color3?,
|
||||
ColorDeactivated: Color3?,
|
||||
ActivatedMaterial: string?,
|
||||
DeactivatedMaterial: string?,
|
||||
Enabled: boolean?
|
||||
}
|
||||
|
||||
local Lights = {} :: Impl_Constructor
|
||||
Lights.__index = Lights
|
||||
|
||||
Lights.StaticMaxLightSwitchActivationDistance = 3
|
||||
Lights.StaticMaxLightSwitchHoldDuration = .15
|
||||
Lights.StaticLightSwitchActivateSoundId = "rbxassetid://156286438"
|
||||
|
||||
function Lights.constructor(Switch)
|
||||
return setmetatable({
|
||||
Switch = Switch
|
||||
}, Lights)
|
||||
end
|
||||
|
||||
function Lights:Functionality(DefinedProperties)
|
||||
local LightAddresses = {} :: LightAddresses
|
||||
|
||||
local LightProperties = {
|
||||
MaxLightSwitchActivationDistance = Lights.StaticMaxLightSwitchActivationDistance,
|
||||
MaxLightSwitchHoldDuration = Lights.StaticMaxLightSwitchHoldDuration,
|
||||
LightSwitchActivateSoundId = Lights.StaticLightSwitchActivateSoundId,
|
||||
}
|
||||
if DefinedProperties then
|
||||
if DefinedProperties.MaxLightSwitchActivationDistance then
|
||||
LightProperties.MaxLightSwitchActivationDistance = DefinedProperties.MaxLightSwitchActivationDistance
|
||||
end
|
||||
if DefinedProperties.MaxLightSwitchHoldDuration then
|
||||
LightProperties.MaxLightSwitchHoldDuration = DefinedProperties.MaxLightSwitchHoldDuration
|
||||
end
|
||||
if DefinedProperties.LightSwitchActivateSoundId then
|
||||
LightProperties.LightSwitchActivateSoundId = DefinedProperties.LightSwitchActivateSoundId
|
||||
end
|
||||
end
|
||||
|
||||
local Attachment = Instance.new("Attachment") :: Attachment
|
||||
Attachment.Parent = self.Switch
|
||||
|
||||
local Prompt = Instance.new("ProximityPrompt") :: ProximityPrompt
|
||||
Prompt.ObjectText = "Light"
|
||||
Prompt.MaxActivationDistance = LightProperties.MaxLightSwitchActivationDistance
|
||||
Prompt.HoldDuration = LightProperties.MaxLightSwitchHoldDuration
|
||||
Prompt.Parent = Attachment
|
||||
|
||||
local ClickSound = Instance.new("Sound") :: Sound
|
||||
ClickSound.Volume = .1
|
||||
ClickSound.SoundId = LightProperties.LightSwitchActivateSoundId
|
||||
ClickSound.Parent = self.Switch
|
||||
|
||||
LightAddresses.ColorActivated = self.Switch:GetAttribute("Activated")
|
||||
LightAddresses.ColorDeactivated = self.Switch:GetAttribute("Deactivated")
|
||||
LightAddresses.ActivatedMaterial = self.Switch:GetAttribute("ActivatedMaterial")
|
||||
LightAddresses.DeactivatedMaterial = self.Switch:GetAttribute("DeactivatedMaterial")
|
||||
LightAddresses.Enabled = self.Switch:GetAttribute("Enabled")
|
||||
LightAddresses.Attachment = Attachment
|
||||
LightAddresses.Prompt = Prompt
|
||||
LightAddresses.ClickSound = ClickSound
|
||||
|
||||
self.Switch:SetAttribute("Activated", nil)
|
||||
self.Switch:SetAttribute("Deactivated", nil)
|
||||
self.Switch:SetAttribute("Enabled", nil)
|
||||
self.Switch:SetAttribute("ActivatedMaterial", nil)
|
||||
self.Switch:SetAttribute("DeactivatedMaterial", nil)
|
||||
|
||||
return LightAddresses
|
||||
end
|
||||
|
||||
return Lights
|
||||
@@ -4,10 +4,11 @@
|
||||
|
||||
local CS = game:GetService("CollectionService")
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Lights = require(script:WaitForChild("Lights"))
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
|
||||
type Error = never
|
||||
type rbxassetid = string
|
||||
|
||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||
type Impl_Constructor = {
|
||||
@@ -22,10 +23,6 @@ type Impl_Constructor = {
|
||||
} & Impl_Static_Props
|
||||
|
||||
type Impl_Static_Props = {
|
||||
MaxLightSwitchActivationDistance: number,
|
||||
MaxLightSwitchHoldDuration: number,
|
||||
LightSwitchActivateSoundId: rbxassetid,
|
||||
|
||||
Decoders: {
|
||||
CarTag: (FloorTag: string) -> number?
|
||||
}
|
||||
@@ -68,9 +65,24 @@ export type LightSwitchProperties = {
|
||||
ClickSound: Sound?,
|
||||
ColorActivated: Color3?,
|
||||
ColorDeactivated: Color3?,
|
||||
ActivatedMaterial: string?,
|
||||
DeactivatedMaterial: string?,
|
||||
Enabled: boolean?
|
||||
}
|
||||
|
||||
export type LightSwitchPropertiesSafe = {
|
||||
Switch: Instance,
|
||||
Lights: {Instance},
|
||||
LightSources: {Instance},
|
||||
Prompt: ProximityPrompt,
|
||||
ClickSound: Sound,
|
||||
ColorActivated: Color3,
|
||||
ColorDeactivated: Color3,
|
||||
ActivatedMaterial: string,
|
||||
DeactivatedMaterial: string,
|
||||
Enabled: boolean
|
||||
}
|
||||
|
||||
export type LightSwitchTree = {
|
||||
[string]: LightSwitchProperties
|
||||
}
|
||||
@@ -92,17 +104,16 @@ export type ButtonProperties = {
|
||||
Attachment: Attachment?
|
||||
}
|
||||
|
||||
export type TagProduct = Instance | {Instance}
|
||||
export type ExportedTags = {[string]: TagProduct}
|
||||
export type ExportedTags = {
|
||||
[string]: TagProduct
|
||||
}
|
||||
|
||||
export type TagProduct = Instance | {Instance}
|
||||
export type TagsConstructor = ClassConstructor
|
||||
|
||||
local Tags = {} :: Impl_Constructor
|
||||
Tags.__index = Tags
|
||||
|
||||
Tags.MaxLightSwitchActivationDistance = 3
|
||||
Tags.MaxLightSwitchHoldDuration = .15
|
||||
Tags.LightSwitchActivateSoundId = "rbxassetid://156286438"
|
||||
|
||||
Tags.Decoders = {
|
||||
CarTag = function(FloorTag)
|
||||
local Match = FloorTag:match('%d+$')
|
||||
@@ -244,45 +255,18 @@ function Tags:__Interactables()
|
||||
warn(`2 or more light switch tags were present under the same name, using the first index. "{TagName}". This feature is not implemented yet`)
|
||||
end
|
||||
|
||||
local Attachment = Instance.new("Attachment") :: Attachment
|
||||
Attachment.Parent = Switch
|
||||
local Prompt = Instance.new("ProximityPrompt") :: ProximityPrompt
|
||||
Prompt.ObjectText = "Light"
|
||||
Prompt.MaxActivationDistance = Tags.MaxLightSwitchActivationDistance
|
||||
Prompt.HoldDuration = Tags.MaxLightSwitchHoldDuration
|
||||
Prompt.Parent = Attachment
|
||||
local ClickSound = Instance.new("Sound") :: Sound
|
||||
ClickSound.Volume = .1
|
||||
ClickSound.SoundId = Tags.LightSwitchActivateSoundId
|
||||
ClickSound.Parent = Switch
|
||||
local LightConstructor = Lights.constructor(Switch)
|
||||
local LightAddress = LightConstructor:Functionality()
|
||||
|
||||
local ActivatedColor: Color3 = Switch:GetAttribute("Activated")
|
||||
local DeactivatedColor: Color3 = Switch:GetAttribute("Deactivated")
|
||||
local Enabled: boolean = Switch:GetAttribute("Enabled")
|
||||
ptr.Switch = Switch
|
||||
ptr.Prompt = LightAddress.Prompt
|
||||
ptr.Enabled = LightAddress.Enabled
|
||||
ptr.ClickSound = LightAddress.ClickSound
|
||||
ptr.ColorActivated = LightAddress.ColorActivated
|
||||
ptr.ColorDeactivated = LightAddress.ColorDeactivated
|
||||
ptr.ActivatedMaterial = LightAddress.ActivatedMaterial
|
||||
ptr.DeactivatedMaterial = LightAddress.DeactivatedMaterial
|
||||
|
||||
if ActivatedColor then
|
||||
ptr.ColorActivated = ActivatedColor
|
||||
|
||||
print(`LightSwitch: [{Switch}] "Activated" -> "{Switch:GetAttribute("Activated")}"`)
|
||||
else
|
||||
warn(`LightSwitch: [{Switch}] Light switch bounded, but it does not have the ActivatedColor attribute set`)
|
||||
end
|
||||
if DeactivatedColor then
|
||||
ptr.ColorDeactivated = DeactivatedColor
|
||||
|
||||
print(`LightSwitch: [{Switch}] "Deactivated" -> "{Switch:GetAttribute("Deactivated")}"`)
|
||||
else
|
||||
warn(`LightSwitch: [{Switch}] Light switch bounded, but it does not have the DeactivatedColor attribute set`)
|
||||
end
|
||||
|
||||
ptr.Switch = Switch
|
||||
ptr.Prompt = Prompt
|
||||
ptr.ClickSound = ClickSound
|
||||
ptr.Enabled = Enabled
|
||||
|
||||
Switch:SetAttribute("Activated", nil)
|
||||
Switch:SetAttribute("Deactivated", nil)
|
||||
Switch:SetAttribute("Enabled", nil)
|
||||
elseif InteractType == Enums.InteractType.Light then
|
||||
if type(Inst) == "table" then
|
||||
ptr.Lights = Inst
|
||||
@@ -290,6 +274,7 @@ function Tags:__Interactables()
|
||||
ptr.Lights = {}
|
||||
table.insert(ptr.Lights :: {Instance}, Inst)
|
||||
end
|
||||
|
||||
elseif InteractType == Enums.InteractType.LightSource then
|
||||
ptr.LightSources = (type(Inst) == "table" and Inst or {Inst :: Instance}) :: {Instance}
|
||||
end
|
||||
@@ -2,12 +2,13 @@
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
local MapDir = script.Parent.Parent
|
||||
local MapDir = script.Parent.Parent
|
||||
local MainDir = MapDir.Parent
|
||||
local LoadDir = MainDir:WaitForChild("Load")
|
||||
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local TagService = require(MainDir:WaitForChild("Tags"))
|
||||
local TagService = require(LoadDir:WaitForChild("Tags"))
|
||||
local TweenModule = require(Storage:WaitForChild("Tween"))
|
||||
|
||||
local PromptsConstructor = require(MapDir:WaitForChild("Prompts"))
|
||||
@@ -31,7 +32,8 @@ type Constructor_Return_Props = {
|
||||
LightSwitches: TagService.LightSwitchTree
|
||||
}
|
||||
|
||||
export type LightProperties = TagService.LightSwitchProperties
|
||||
export type LightProperties = TagService.LightSwitchProperties
|
||||
export type LightPropertiesSafe = TagService.LightSwitchPropertiesSafe
|
||||
|
||||
local Lights = {} :: Impl_Constructor
|
||||
Lights.__index = Lights
|
||||
@@ -44,50 +46,78 @@ function Lights.constructor(LightSwitches)
|
||||
}, Lights)
|
||||
end
|
||||
|
||||
local function ToggleSwitchLight(EnabledState: boolean, LightObject: BasePart, LightProperties: LightProperties)
|
||||
local Light = LightObject:FindFirstChildWhichIsA("PointLight", true) or LightObject:FindFirstChildWhichIsA("SpotLight", true)
|
||||
|
||||
if Light then
|
||||
Light.Enabled = EnabledState
|
||||
end
|
||||
if EnabledState then
|
||||
if LightProperties.ColorActivated then
|
||||
LightObject.Color = LightProperties.ColorActivated
|
||||
LightObject.Material = Enum.Material.Neon
|
||||
end
|
||||
else
|
||||
if LightProperties.ColorDeactivated then
|
||||
LightObject.Color = LightProperties.ColorDeactivated
|
||||
LightObject.Material = Enum.Material.SmoothPlastic
|
||||
end
|
||||
end
|
||||
local EnumMaterials = Enum.Material:GetEnumItems()
|
||||
--Convert it all to string values, couldnt figure out any hacks to make it a true one liner
|
||||
for k: number, v: Enum.Material in EnumMaterials do
|
||||
EnumMaterials[k] = v.Name
|
||||
end
|
||||
|
||||
local function SwitchState()
|
||||
|
||||
local function ToggleSwitchLight(EnabledState: boolean, LightProperties: LightPropertiesSafe)
|
||||
for n: number = 1, #LightProperties.LightSources do
|
||||
(LightProperties.LightSources[n] :: Light).Enabled = EnabledState
|
||||
end
|
||||
|
||||
for n: number = 1, #LightProperties.Lights do
|
||||
local LightObject = LightProperties.Lights[n] :: BasePart
|
||||
|
||||
if EnabledState then
|
||||
local ActivatedMaterial = table.find(EnumMaterials, LightProperties.ActivatedMaterial) or 1 --Only doing this because it is runtime safe
|
||||
|
||||
LightObject.Color = LightProperties.ColorActivated
|
||||
LightObject.Material = EnumMaterials[ActivatedMaterial]
|
||||
else
|
||||
local DeactivatedMaterial = table.find(EnumMaterials, LightProperties.DeactivatedMaterial) or 1 --Only doing this because it is runtime safe
|
||||
|
||||
LightObject.Color = LightProperties.ColorDeactivated
|
||||
LightObject.Material = EnumMaterials[DeactivatedMaterial]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local LightSwitchTween = TweenModule.constructor(TweenInfo.new(Lights.SwitchAnimationTime, Enum.EasingStyle.Linear))
|
||||
|
||||
local function SwitchAnimation(EnabledState: boolean, LightProperties: LightProperties)
|
||||
local Switch = LightProperties.Switch
|
||||
local Switch = LightProperties.Switch :: BasePart
|
||||
local Prompt = LightProperties.Prompt :: ProximityPrompt
|
||||
|
||||
if Switch then
|
||||
if EnabledState then
|
||||
LightSwitchTween:Start(Switch, {
|
||||
local Tween = LightSwitchTween:Start(Switch, {
|
||||
CFrame = CFrame.new(Switch.Position)*CFrame.Angles(0,math.rad(90),0)+Vector3.new(0,.15,0)
|
||||
})
|
||||
Tween.Completed:Once(function()
|
||||
ToggleSwitchLight(EnabledState, LightProperties :: LightPropertiesSafe)
|
||||
Prompt.ActionText = "Toggle Off"
|
||||
end)
|
||||
else
|
||||
LightSwitchTween:Start(Switch, {
|
||||
local Tween = LightSwitchTween:Start(Switch, {
|
||||
CFrame = CFrame.new(Switch.Position)*CFrame.Angles(0,math.rad(90),math.rad(70))-Vector3.new(0,.15,0)
|
||||
})
|
||||
Tween.Completed:Once(function()
|
||||
ToggleSwitchLight(EnabledState, LightProperties :: LightPropertiesSafe)
|
||||
Prompt.ActionText = "Toggle On"
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function ToggleSwitch(EnabledState: boolean, LightProperties: LightProperties, Sounds: boolean)
|
||||
SwitchAnimation(EnabledState, LightProperties)
|
||||
|
||||
if Sounds and LightProperties.ClickSound then
|
||||
LightProperties.ClickSound:Play()
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
Guide for lights with toggable switches:
|
||||
TODO
|
||||
------
|
||||
Switch ->lever<- tag: "Interact_LightSwitch_ALIASNAME"
|
||||
Switch ->level<- attributes: "Activated" (Color3), "Deactivated" (Color3), "Enabled" (boolean)
|
||||
------
|
||||
Light Bulb tag: "Interact_Light_ALIASNAME"
|
||||
------
|
||||
Light source tag: "Interact_LightSource_ALIASNAME"
|
||||
]]
|
||||
function Lights:Init()
|
||||
for _, LightProperties in self.LightSwitches do
|
||||
@@ -95,28 +125,29 @@ function Lights:Init()
|
||||
local Prompt = PromptsConstructor.constructor(LightProperties.Prompt, LightProperties.Switch)
|
||||
local EnabledState = false
|
||||
|
||||
if LightProperties.ColorDeactivated and LightProperties.ColorActivated and LightProperties.Prompt and LightProperties.Lights then
|
||||
--These must be available for Lights to work
|
||||
if LightProperties.ColorDeactivated and
|
||||
LightProperties.ColorActivated and
|
||||
LightProperties.Prompt and
|
||||
LightProperties.Lights and
|
||||
LightProperties.LightSources and
|
||||
LightProperties.ActivatedMaterial and
|
||||
LightProperties.DeactivatedMaterial then
|
||||
if LightProperties.Enabled then
|
||||
EnabledState = true
|
||||
LightProperties.Prompt.ActionText = "Toggle Off"
|
||||
|
||||
else
|
||||
LightProperties.Prompt.ActionText = "Toggle On"
|
||||
|
||||
end
|
||||
|
||||
ToggleSwitch(EnabledState, LightProperties :: LightPropertiesSafe, false)
|
||||
|
||||
Prompt:AddHookTriggered(function(_Player: Player)
|
||||
EnabledState = not EnabledState
|
||||
|
||||
SwitchAnimation(EnabledState, LightProperties)
|
||||
if LightProperties.ClickSound then
|
||||
LightProperties.ClickSound:Play()
|
||||
end
|
||||
for n: number = 1, #LightProperties.Lights do
|
||||
ToggleSwitchLight(EnabledState, LightProperties.Lights[n], LightProperties)
|
||||
end
|
||||
ToggleSwitch(EnabledState, LightProperties :: LightPropertiesSafe, true)
|
||||
end)
|
||||
else
|
||||
warn(`LightSwitch hook failed, a required field is missing:\n-----\nColorDeactivated = {LightProperties.ColorDeactivated}\nColorActivated = {LightProperties.ColorActivated}\nPrompt = {LightProperties.Prompt}\nLights = {LightProperties.Lights}\n-----`)
|
||||
warn(`LightSwitch hook failed, a required field is missing:\n-----\nColorDeactivated = {LightProperties.ColorDeactivated}\nColorActivated = {LightProperties.ColorActivated}\nPrompt = {LightProperties.Prompt}\nLights = {LightProperties.Lights}\nDeactivatedMaterial = {LightProperties.DeactivatedMaterial}\nActivatedMaterial = {LightProperties.ActivatedMaterial}\n-----`)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
type PromptCallback = (Player: Player) -> ()
|
||||
type HumanoidRootPart = BasePart
|
||||
type PromptCallback = (Player: Player, Root: HumanoidRootPart) -> ()
|
||||
type PromptSignal = RBXScriptSignal<Player>
|
||||
type PromptSignalName = "Triggered" | "TriggerEnded"
|
||||
|
||||
@@ -48,11 +48,11 @@ end
|
||||
|
||||
local function DistanceCheck(self: ClassConstructor, Player: Player)
|
||||
local PlayerCharacter = Player.Character
|
||||
local Root = PlayerCharacter and PlayerCharacter:FindFirstChild("HumanoidRootPart") :: HumanoidRootPart?
|
||||
local Root = PlayerCharacter and PlayerCharacter:FindFirstChild("HumanoidRootPart") :: HumanoidRootPart?
|
||||
|
||||
if Root then
|
||||
if (Root.Position-(self.Instance :: BasePart).Position).Magnitude<=self.Prompt.MaxActivationDistance+1 then
|
||||
(self.__TriggeredCallback :: PromptCallback)(Player)
|
||||
(self.__TriggeredCallback :: PromptCallback)(Player, Root)
|
||||
else
|
||||
warn(`{Player.Name}, {Player.UserId} activated a prompt without being in range of MaxActivationDistance.`)
|
||||
end
|
||||
|
||||
@@ -6,19 +6,23 @@ local ShowEditorEntities = true
|
||||
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local _PlayerAdded = require(script:WaitForChild("PlayerAdded"))
|
||||
local TagsModule = require(script:WaitForChild("Tags"))
|
||||
local HideEditorEntities = require(script:WaitForChild("EditorEntities"))
|
||||
local Lighting_Stuff = require(script:WaitForChild("Lighting"))
|
||||
local Workspace_Stuff = require(script:WaitForChild("Workspace"))
|
||||
local StarterPlayer_Stuff = require(script:WaitForChild("StarterPlayer"))
|
||||
local _PlayerAdded = require(script:WaitForChild("PlayerAdded"))
|
||||
local Lighting_Stuff = require(script:WaitForChild("Lighting"))
|
||||
|
||||
local Elevators = script:WaitForChild("Elevators")
|
||||
local Maps = script:WaitForChild("Map")
|
||||
local Interactions = Maps:WaitForChild("Interactions")
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
local LightSwitches = require(Interactions:WaitForChild("LightSwitches"))
|
||||
local Otis1960_Module = require(Elevators:WaitForChild("Otis1960"))
|
||||
local Load = script:WaitForChild("Load")
|
||||
local TagsModule = require(Load:WaitForChild("Tags"))
|
||||
local HideEditorEntities = require(Load:WaitForChild("EditorEntities"))
|
||||
local Workspace_Stuff = require(Load:WaitForChild("Workspace"))
|
||||
local StarterPlayer_Stuff = require(Load:WaitForChild("StarterPlayer"))
|
||||
|
||||
local Elevators = script:WaitForChild("Elevators")
|
||||
local Maps = script:WaitForChild("Map")
|
||||
|
||||
local Interactions = Maps:WaitForChild("Interactions")
|
||||
local LightSwitches = require(Interactions:WaitForChild("LightSwitches"))
|
||||
local Otis1960_Module = require(Elevators:WaitForChild("Otis1960"))
|
||||
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
|
||||
local TagsConstructor = TagsModule.constructor()
|
||||
print("[DEBUG] Tags=", TagsConstructor.__export)
|
||||
|
||||
Reference in New Issue
Block a user