fix relay offset for prompts

This commit is contained in:
2024-05-13 01:31:10 -04:00
parent bb17304cbf
commit 5018a8ef3b

View File

@@ -2,6 +2,22 @@
--!native --!native
--!strict --!strict
--Set relay tags through studio command line
--[[
local s = game.Selection:Get()[1]
for i,v in s:GetChildren() do
if v:IsA("Model") then
local main = v:FindFirstChild("main")
if main then
local label = v:FindFirstChildWhichIsA("TextLabel", true)
if label then
main:AddTag(`Otis1960_RelayButton_{label.Text}`)
end
end
end
end
]]
local Elevators = script.Parent local Elevators = script.Parent
local MainDir = Elevators.Parent local MainDir = Elevators.Parent
local EnumsDir = MainDir:WaitForChild("Enums") local EnumsDir = MainDir:WaitForChild("Enums")
@@ -99,6 +115,7 @@ type Constructor_Return_Props = {
export type Otis1960Constructor = ClassConstructor export type Otis1960Constructor = ClassConstructor
--TODO: Rename Otis1960 to Elevator
local Otis1960 = {} :: Impl_Constructor local Otis1960 = {} :: Impl_Constructor
Otis1960.__index = Otis1960 Otis1960.__index = Otis1960
@@ -173,7 +190,10 @@ local function HookButtons(self: ClassConstructor, ButtonNameType: Enums.ButtonT
elseif ButtonNameType == Enums.ButtonTree.Special then elseif ButtonNameType == Enums.ButtonTree.Special then
elseif ButtonNameType == Enums.ButtonTree.Relays then elseif ButtonNameType == Enums.ButtonTree.Relays then
--Special case-y
if Otis1960.Name == Enums.Elevator.Otis1960 then
end
elseif ButtonNameType == Enums.ButtonTree.Unknown then elseif ButtonNameType == Enums.ButtonTree.Unknown then
else else
@@ -258,9 +278,10 @@ local FloorQueue: {number} = {}
local function CheckQueue(self: ClassConstructor) local function CheckQueue(self: ClassConstructor)
table.remove(FloorQueue, 1) table.remove(FloorQueue, 1)
if #FloorQueue>0 then if #FloorQueue ~= 0 then
--table.sort --table.sort
self:__GoToFloor(Leveling[FloorQueue[1]], ElevatorGoingUpDirection(Attributes.CurrentFloor.Value, FloorQueue[1])) Attributes.GoingUp.Value = ElevatorGoingUpDirection(Attributes.CurrentFloor.Value, FloorQueue[1])
self:__GoToFloor(Leveling[FloorQueue[1]], Attributes.GoingUp.Value)
end end
end end
@@ -372,41 +393,40 @@ function Otis1960:__GoToFloor(GoalLevelVEC, GoingUp)
self.BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, GoalLevelVEC, ElevatorBoxCurrentPos.Z) self.BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, GoalLevelVEC, ElevatorBoxCurrentPos.Z)
end end
--This is a little wonky i can improve later
local function ToFloorQueue(self: ClassConstructor, InHeadingPath: boolean, RequestedLevel: number, GoalLevelVEC: number)
local ElevatorBoxCurrentPos = self.ElevatorBox_1960.Position
if InHeadingPath then
table.insert(FloorQueue, 1, RequestedLevel)
if not Doors.Attributes.DoorsOpen.Value then
self.BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, GoalLevelVEC, ElevatorBoxCurrentPos.Z)
end
else
table.insert(FloorQueue, RequestedLevel)
end
end
function Otis1960:RequestLevelAsync(RequestedLevel) function Otis1960:RequestLevelAsync(RequestedLevel)
local GoalLevelVEC: number = Leveling[RequestedLevel] local GoalLevelVEC: number? = Leveling[RequestedLevel]
if GoalLevelVEC and GoalLevelVEC ~= Attributes.CurrentFloor.Value then if GoalLevelVEC and GoalLevelVEC ~= Attributes.CurrentFloor.Value then
local GoingUp = ElevatorGoingUpDirection(Attributes.CurrentFloor.Value, RequestedLevel) local InHeadingPath = ElevatorGoingUpDirection(Attributes.CurrentFloor.Value, RequestedLevel)
if Attributes.Moving.Value then if Attributes.Moving.Value then
local ElevatorBoxCurrentPos = self.ElevatorBox_1960.Position ToFloorQueue(self, InHeadingPath, RequestedLevel, GoalLevelVEC)
if Attributes.GoingUp.Value then
if GoingUp then
table.insert(FloorQueue, 1, RequestedLevel)
if not Doors.Attributes.DoorsOpen.Value then
self.BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, GoalLevelVEC, ElevatorBoxCurrentPos.Z)
end
else
table.insert(FloorQueue, RequestedLevel)
end
else
if not GoingUp then
table.insert(FloorQueue, 1, RequestedLevel)
if not Doors.Attributes.DoorsOpen.Value then
self.BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, GoalLevelVEC, ElevatorBoxCurrentPos.Z)
end
else
table.insert(FloorQueue, RequestedLevel)
end
end
else else
Attributes.GoingUp.Value = GoingUp if Doors.Attributes.DoorsOpen and #FloorQueue ~= 0 then
--Activated a call while the doors are closing? we need to wait until that is completed to move
repeat
Doors.Attributes.DoorsOpen:GetPropertyChangedSignal("Value"):Wait()
until not Doors.Attributes.DoorsOpen
end
Attributes.GoingUp.Value = InHeadingPath
table.insert(FloorQueue, 1, RequestedLevel) table.insert(FloorQueue, 1, RequestedLevel)
self:__GoToFloor(GoalLevelVEC, GoingUp) self:__GoToFloor(GoalLevelVEC, InHeadingPath)
end end
else else
warn(`[{Otis1960.Name}]: landing out of range or equals the same range as the goal, requested landing: {tostring(RequestedLevel)}`) warn(`[{Otis1960.Name}]: landing out of range or equals the same range as the goal, requested landing: {tostring(RequestedLevel)}`)