mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-17 05:41:55 +00:00
Tag service module
This commit is contained in:
@@ -14,8 +14,6 @@ type TagProduct = TagsModule.TagProduct
|
||||
type HumanoidRootPart = BasePart
|
||||
type PromptCallback = (Player: Player) -> ()
|
||||
|
||||
type GetButtons = {[string]: Instance}
|
||||
|
||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||
type Impl_Constructor = {
|
||||
__index: Impl_Constructor,
|
||||
@@ -39,17 +37,6 @@ type Constructor_Return_Props = {
|
||||
Buttons: ButtonsTree
|
||||
}
|
||||
|
||||
export type ButtonsTree = {
|
||||
Landing: ButtonProperties,
|
||||
Car: ButtonProperties,
|
||||
Special: ButtonProperties,
|
||||
Relays: ButtonProperties
|
||||
}
|
||||
export type ButtonProperties = {
|
||||
Inst: Instance?,
|
||||
Prompt: ProximityPrompt?,
|
||||
Attachment: Attachment?
|
||||
}
|
||||
export type ButtonsConstructor = ClassConstructor
|
||||
|
||||
local ButtonsModule = {} :: Impl_Constructor
|
||||
@@ -68,30 +55,6 @@ function ButtonsModule.constructor(TagsConstructor, Model)
|
||||
}, ButtonsModule)
|
||||
end
|
||||
|
||||
--Button parsing
|
||||
|
||||
function ButtonsModule:DecodeCarTag(FloorTag)
|
||||
local Match = FloorTag:match('%d+$')
|
||||
return Match and tonumber(Match)
|
||||
end
|
||||
|
||||
function ButtonsModule:Get()
|
||||
local Buttons: GetButtons = {}
|
||||
|
||||
for TagName: string, Inst: TagProduct in self.Tags.__export do
|
||||
local Split = TagName:split('_')
|
||||
if Split[1] == self.Model and (Split[2] == "ElevatorButton" or Split[2] == "RelayButton") then
|
||||
if typeof(Inst) == "Instance" then
|
||||
Buttons[TagName] = Inst
|
||||
else
|
||||
warn("TODO block hit,", debug.traceback())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Buttons
|
||||
end
|
||||
|
||||
--[[
|
||||
CarButton = Model_ElevatorButton_1
|
||||
LandingButton = Model_ElevatorButton_Floor_1_Up
|
||||
|
||||
@@ -17,7 +17,7 @@ type Impl_Constructor = {
|
||||
constructor: Constructor_Fun,
|
||||
Get: (Tags: Tags.TagsConstructor, Model: Enums.ElevatorValues) -> Lanterns,
|
||||
--Class functions
|
||||
__Activate: (self: ClassConstructor, EnabledState: boolean, IsDirectionLantern: boolean, Lantern: Lantern) -> (),
|
||||
Activate: (self: ClassConstructor, EnabledState: boolean, IsDirectionLantern: boolean, Lantern: Lantern) -> (),
|
||||
DirectionUp: (self: ClassConstructor, Enabled: boolean) -> (),
|
||||
DirectionDown: (self: ClassConstructor, Enabled: boolean) -> (),
|
||||
Toggle: (self: ClassConstructor, Enabled: boolean, Floor: number) -> (),
|
||||
@@ -79,49 +79,9 @@ function Lanterns.constructor(MainDisplay, ChimeDirectionID, ChimeLandingID, Lan
|
||||
}, Lanterns)
|
||||
end
|
||||
|
||||
function Lanterns.Get(Tags, Model)
|
||||
local Lanterns = {} :: Lanterns
|
||||
|
||||
for TagName: string, Inst: TagProduct in Tags.__export do
|
||||
local Split = TagName:split('_')
|
||||
if Split[1] == Model and Split[2] == "DirectionIndicator" then
|
||||
local Floor = tonumber(Split[3])
|
||||
if Floor then
|
||||
if not Lanterns[Floor] then
|
||||
Lanterns[Floor] = {
|
||||
Inst = Inst :: BasePart,
|
||||
Light = (Inst :: BasePart).Parent:FindFirstChild("Light") :: BasePart?,
|
||||
Played = false
|
||||
}
|
||||
else
|
||||
warn(`Lanterns: Floor "{tostring(Floor)}" was already wrote while parsing`)
|
||||
end
|
||||
else
|
||||
if Split[3] == "Up" then
|
||||
Lanterns.Up = {
|
||||
Inst = Inst :: BasePart,
|
||||
Light = (Inst :: BasePart).Parent:FindFirstChild("Light") :: BasePart?,
|
||||
Played = false
|
||||
}
|
||||
elseif Split[3] == "Down" then
|
||||
Lanterns.Down = {
|
||||
Inst = Inst :: BasePart,
|
||||
Light = (Inst :: BasePart).Parent:FindFirstChild("Light") :: BasePart?,
|
||||
Played = false
|
||||
}
|
||||
else
|
||||
warn(`Lanterns: Unknown type paired with "DirectionIndicator", {Split[3]}`)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return Lanterns
|
||||
end
|
||||
|
||||
local LanternLight = Tween.constructor(TweenInfo.new(1))
|
||||
|
||||
function Lanterns:__Activate(EnabledState, IsDirectionLantern, Lantern)
|
||||
function Lanterns:Activate(EnabledState, IsDirectionLantern, Lantern)
|
||||
local Tween = LanternLight:Start(Lantern.Light, {
|
||||
Color = EnabledState and self.Colors.Active or self.Colors.Off
|
||||
})
|
||||
@@ -140,11 +100,11 @@ end
|
||||
function Lanterns:Reset()
|
||||
self.LanternsMap.Up.Played = false
|
||||
self.LanternsMap.Down.Played = false
|
||||
self:__Activate(false, true, self.LanternsMap.Up)
|
||||
self:__Activate(false, true, self.LanternsMap.Down)
|
||||
self:Activate(false, true, self.LanternsMap.Up)
|
||||
self:Activate(false, true, self.LanternsMap.Down)
|
||||
|
||||
for n: number = 1, #self.LanternsMap do
|
||||
self:__Activate(false, false, self.LanternsMap[n])
|
||||
self:Activate(false, false, self.LanternsMap[n])
|
||||
self.LanternsMap[n].Played = false
|
||||
end
|
||||
end
|
||||
@@ -152,14 +112,14 @@ end
|
||||
function Lanterns:DirectionUp(Enabled)
|
||||
if not self.LanternsMap.Up.Played then
|
||||
self.LanternsMap.Up.Played = true
|
||||
self:__Activate(Enabled, true, self.LanternsMap.Up)
|
||||
self:Activate(Enabled, true, self.LanternsMap.Up)
|
||||
end
|
||||
end
|
||||
|
||||
function Lanterns:DirectionDown(Enabled)
|
||||
if not self.LanternsMap.Down.Played then
|
||||
self.LanternsMap.Down.Played = true
|
||||
self:__Activate(Enabled, true, self.LanternsMap.Down)
|
||||
self:Activate(Enabled, true, self.LanternsMap.Down)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -167,7 +127,7 @@ function Lanterns:Toggle(Enabled, Floor)
|
||||
local f = self.LanternsMap[Floor]
|
||||
if not f.Played then
|
||||
f.Played = true
|
||||
self:__Activate(Enabled, false, f)
|
||||
self:Activate(Enabled, false, f)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -13,12 +13,6 @@ local Leveling = {
|
||||
[8] = 188.007,
|
||||
[9] = 213.058,
|
||||
[10] = 239.245,
|
||||
|
||||
Between = {}
|
||||
}
|
||||
|
||||
for n: number = 1, #Leveling, 2 do
|
||||
Leveling.Between[n]=(Leveling[n+1]+Leveling[n])/2
|
||||
end
|
||||
|
||||
return Leveling
|
||||
Reference in New Issue
Block a user