mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-17 05:51:54 +00:00
light switch work and new prompt system
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
local Elevators = script.Parent
|
||||
local ElevatorsDir = script.Parent
|
||||
local MainDir = ElevatorsDir.Parent
|
||||
local TagService = require(MainDir:WaitForChild("TagService"))
|
||||
|
||||
local RS: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local TagsModule = require(RS:WaitForChild("Tags"))
|
||||
local Enums = require(Elevators:WaitForChild("Enums"))
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local TagsModule = require(Storage:WaitForChild("Tags"))
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
|
||||
type TagsConstructor = TagsModule.TagsConstructor
|
||||
type TagProduct = TagsModule.TagProduct
|
||||
@@ -20,9 +21,7 @@ type Impl_Constructor = {
|
||||
constructor: Constructor_Fun,
|
||||
--Class functions
|
||||
DecodeCarTag: (self: ClassConstructor, FloorTag: string) -> number?,
|
||||
Get: (self: ClassConstructor) -> GetButtons,
|
||||
CreatePromptButtons: (self: ClassConstructor) -> ButtonsTree,
|
||||
HookPromptButtonsGroup: (self: ClassConstructor, Prompt: ProximityPrompt?, Inst: BasePart?, PromptCallback: PromptCallback) -> (),
|
||||
CreatePromptButtons: (self: ClassConstructor) -> TagService.ButtonsTree,
|
||||
AestheticActivateButton: (self: ClassConstructor, Button: BasePart, ActivatedState: boolean, ActivatedColor: Color3) -> ()
|
||||
} & Impl_Static_Props
|
||||
|
||||
@@ -34,7 +33,7 @@ type Constructor_Fun = (TagsConstructor: TagsConstructor, Model: Enums.ElevatorV
|
||||
type Constructor_Return_Props = {
|
||||
Tags: TagsConstructor,
|
||||
Model: Enums.ElevatorValues,
|
||||
Buttons: ButtonsTree
|
||||
Buttons: TagService.ButtonsTree
|
||||
}
|
||||
|
||||
export type ButtonsConstructor = ClassConstructor
|
||||
@@ -118,12 +117,6 @@ function ButtonsModule:CreatePromptButtons()
|
||||
Attachment = Attachment
|
||||
}
|
||||
elseif ButtonType == Enums.Button.Relay then
|
||||
--RelayButton_F1
|
||||
|
||||
if self.Model == Enums.Elevator.Otis1960 then --This is bad...
|
||||
Attachment.Position-=Vector3.new(.1,.3,0)
|
||||
end
|
||||
|
||||
Prompt.MaxActivationDistance = 4
|
||||
Prompt.Exclusivity = Enum.ProximityPromptExclusivity.OneGlobally --why does this not work...
|
||||
Prompt.ActionText = `Relay {tostring(Split[3])}`
|
||||
@@ -146,29 +139,6 @@ function ButtonsModule:CreatePromptButtons()
|
||||
return self.Buttons
|
||||
end
|
||||
|
||||
function ButtonsModule:HookPromptButtonsGroup(Prompt, Inst, PromptCallback)
|
||||
if Prompt then
|
||||
if Inst then
|
||||
Prompt.Triggered:Connect(function(Player)
|
||||
local PlayerCharacter = Player.Character
|
||||
local Root = PlayerCharacter and PlayerCharacter:FindFirstChild("HumanoidRootPart") :: HumanoidRootPart?
|
||||
|
||||
if Root then
|
||||
if (Root.Position-Inst.Position).Magnitude<=Prompt.MaxActivationDistance+1 then
|
||||
PromptCallback(Player)
|
||||
else
|
||||
warn(`{Player.Name}, {Player.UserId} activated a prompt without being in range of MaxActivationDistance.`)
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
warn("Button Hook Error! Inst is missing", debug.traceback())
|
||||
end
|
||||
else
|
||||
warn("Button Hook Error! Prompt is missing", debug.traceback())
|
||||
end
|
||||
end
|
||||
|
||||
function ButtonsModule:AestheticActivateButton(Button, ActivatedState, ActivatedColor)
|
||||
task.spawn(function()
|
||||
local Glass = Button:FindFirstChild("Glass") :: BasePart
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local Tween = require(Storage:WaitForChild("Tween"))
|
||||
local Tags = require(Storage:WaitForChild("Tags"))
|
||||
|
||||
local Enums = require(script.Parent:WaitForChild("Enums"))
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
|
||||
type rbxassetid = string
|
||||
type TagProduct = Tags.TagProduct
|
||||
@@ -42,7 +41,7 @@ type Lantern = {
|
||||
Played: boolean
|
||||
}
|
||||
|
||||
export type Lanterns = {
|
||||
type Lanterns = {
|
||||
[number]: Lantern,
|
||||
Up: Lantern,
|
||||
Down: Lantern
|
||||
|
||||
@@ -3,23 +3,26 @@
|
||||
--!strict
|
||||
|
||||
local Elevators = script.Parent
|
||||
local MainDir = Elevators.Parent
|
||||
|
||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local RS: RunService = game:GetService("RunService")
|
||||
|
||||
local TagsModule = require(Storage:WaitForChild("Tags"))
|
||||
local Easings = require(Storage:WaitForChild("Algebra"))
|
||||
local Enums = require(Storage:WaitForChild("Enums"))
|
||||
|
||||
local Leveling = require(script:WaitForChild("Leveling"))
|
||||
local Doors = require(script:WaitForChild("Doors"))
|
||||
local MovingObjects = require(script:WaitForChild("MovingObjects"))
|
||||
|
||||
local Enums = require(Elevators:WaitForChild("Enums"))
|
||||
local ElevatorMover = require(Elevators:WaitForChild("Mover"))
|
||||
local ButtonTags = require(Elevators:WaitForChild("Buttons"))
|
||||
local TractionRopes = require(Elevators:WaitForChild("TractionRopes"))
|
||||
local Lanterns = require(Elevators:WaitForChild("Lanterns"))
|
||||
|
||||
local PromptModule = require(MainDir:WaitForChild("Map"):WaitForChild("Prompts"))
|
||||
local TagService = require(MainDir:WaitForChild("TagService"))
|
||||
|
||||
type rbxassetid = string
|
||||
|
||||
type Tags = TagsModule.ExportedTags
|
||||
@@ -46,7 +49,7 @@ type Impl_Static_Props = {
|
||||
__CurrentFloor: number
|
||||
}
|
||||
|
||||
type Constructor_Fun = (TagsConstructor: TagsConstructor) -> ClassConstructor
|
||||
type Constructor_Fun = (TagsConstructor: TagsConstructor, TagServiceConstructor: TagService.TagsServiceConstructor) -> ClassConstructor
|
||||
type Constructor_Return_Props = {
|
||||
Tags: Tags,
|
||||
MOConstructor: MovingObjects.MovingObjectsConstructor,
|
||||
@@ -92,14 +95,15 @@ local ButtonFunctions: {[Enums.ButtonTreeValues]: ButtonFunction} = {
|
||||
end,
|
||||
|
||||
[Enums.ButtonTree.Car] = function(self, ButtonName, ButtonsConstructor, ButtonTree)
|
||||
local DecodedFloor = ButtonsConstructor:DecodeCarTag(ButtonName)
|
||||
local DecodedFloor = TagService.Decoder.CarTag(ButtonName)
|
||||
if not DecodedFloor then
|
||||
|
||||
end
|
||||
|
||||
ButtonsConstructor:HookPromptButtonsGroup(ButtonTree.Prompt, ButtonTree.Inst :: BasePart?, function(_Player: Player)
|
||||
local Prompt = PromptModule.constructor(ButtonTree.Prompt, ButtonTree.Instance)
|
||||
|
||||
Prompt:AddHookTriggered(function(Player: Player)
|
||||
if DecodedFloor then
|
||||
--ButtonTree.Prompt.Enabled = false
|
||||
ButtonsConstructor:AestheticActivateButton(ButtonTree.Inst :: BasePart, false, Otis1960.ButtonActivatedColor)
|
||||
self:GoToLevel(DecodedFloor)
|
||||
end
|
||||
@@ -130,13 +134,13 @@ local function HookButtons(self: ClassConstructor, ButtonsConstructor: ButtonTag
|
||||
end
|
||||
end
|
||||
|
||||
function Otis1960.constructor(TagsConstructor)
|
||||
function Otis1960.constructor(TagsConstructor, TagServiceConstructor)
|
||||
local self = {} :: Constructor_Return_Props
|
||||
self.ElevatorBox_1960 = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
|
||||
self.ElevatorDoor1 = TagsConstructor:Request("ElevatorDoor_1960_1") :: BasePart
|
||||
self.ElevatorDoor2 = TagsConstructor:Request("ElevatorDoor_1960_2") :: BasePart
|
||||
self.ElevatorDoorSensor = TagsConstructor:Request("ElevatorDoor_Sensor_1960") :: Folder
|
||||
self.Ropes = TagsConstructor:Request("1960_ElevatorPulleyRope") :: {Instance}
|
||||
self.ElevatorBox_1960 = TagsConstructor:Request("ElevatorMover_1960") :: UnionOperation
|
||||
self.ElevatorDoor1 = TagsConstructor:Request("ElevatorDoor_1960_1") :: BasePart
|
||||
self.ElevatorDoor2 = TagsConstructor:Request("ElevatorDoor_1960_2") :: BasePart
|
||||
self.ElevatorDoorSensor = TagsConstructor:Request("ElevatorDoor_Sensor_1960") :: Folder
|
||||
self.Ropes = TagsConstructor:Request("1960_ElevatorPulleyRope") :: {Instance}
|
||||
|
||||
--Rotation objects
|
||||
self.MachineRoom = {_CFrame = {}} :: MovingObjects.MachineRoom
|
||||
@@ -151,8 +155,8 @@ function Otis1960.constructor(TagsConstructor)
|
||||
self.MOConstructor = MovingObjects.constructor({MachineRoom = self.MachineRoom} :: MovingObjects.InstanceTree)
|
||||
|
||||
--Audio
|
||||
local LanternDisplay = TagsConstructor:Request("Otis1960_LanternDisplayMain") :: UnionOperation
|
||||
local LaternTags = Lanterns.Get(TagsConstructor, Enums.Elevator.Otis1960) :: Lanterns.Lanterns
|
||||
local LanternDisplay = TagsConstructor:Request("Otis1960_LanternDisplayMain") :: UnionOperation
|
||||
local LaternTags = TagServiceConstructor:Lanterns(Enums.Elevator.Otis1960) :: TagService.Lanterns
|
||||
|
||||
self.LanternsConstructor = Lanterns.constructor(LanternDisplay, Otis1960.LanternChimeDirection, Otis1960.LanternChimeLanding, LaternTags, {
|
||||
Active = Otis1960.LanternDisplayColorOn,
|
||||
|
||||
Reference in New Issue
Block a user