mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
fix relay offset for prompts
This commit is contained in:
@@ -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,27 +393,11 @@ 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
|
||||||
|
|
||||||
function Otis1960:RequestLevelAsync(RequestedLevel)
|
--This is a little wonky i can improve later
|
||||||
local GoalLevelVEC: number = Leveling[RequestedLevel]
|
local function ToFloorQueue(self: ClassConstructor, InHeadingPath: boolean, RequestedLevel: number, GoalLevelVEC: number)
|
||||||
|
|
||||||
if GoalLevelVEC and GoalLevelVEC ~= Attributes.CurrentFloor.Value then
|
|
||||||
local GoingUp = ElevatorGoingUpDirection(Attributes.CurrentFloor.Value, RequestedLevel)
|
|
||||||
|
|
||||||
if Attributes.Moving.Value then
|
|
||||||
local ElevatorBoxCurrentPos = self.ElevatorBox_1960.Position
|
local ElevatorBoxCurrentPos = self.ElevatorBox_1960.Position
|
||||||
|
|
||||||
if Attributes.GoingUp.Value then
|
if InHeadingPath 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)
|
table.insert(FloorQueue, 1, RequestedLevel)
|
||||||
|
|
||||||
if not Doors.Attributes.DoorsOpen.Value then
|
if not Doors.Attributes.DoorsOpen.Value then
|
||||||
@@ -402,11 +407,26 @@ function Otis1960:RequestLevelAsync(RequestedLevel)
|
|||||||
table.insert(FloorQueue, RequestedLevel)
|
table.insert(FloorQueue, RequestedLevel)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Otis1960:RequestLevelAsync(RequestedLevel)
|
||||||
|
local GoalLevelVEC: number? = Leveling[RequestedLevel]
|
||||||
|
|
||||||
|
if GoalLevelVEC and GoalLevelVEC ~= Attributes.CurrentFloor.Value then
|
||||||
|
local InHeadingPath = ElevatorGoingUpDirection(Attributes.CurrentFloor.Value, RequestedLevel)
|
||||||
|
|
||||||
|
if Attributes.Moving.Value then
|
||||||
|
ToFloorQueue(self, InHeadingPath, RequestedLevel, GoalLevelVEC)
|
||||||
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)}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user