mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
Tag service module
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -95,9 +95,8 @@ function StudioEntities.indexAll(enabled: boolean)
|
|||||||
end
|
end
|
||||||
elseif Item:IsA("LuaSourceContainer") then --Cant allow scripts outside of the framework
|
elseif Item:IsA("LuaSourceContainer") then --Cant allow scripts outside of the framework
|
||||||
--mini algIsAorthim to see if the script is part of the rhpid-framework character or not
|
--mini algIsAorthim to see if the script is part of the rhpid-framework character or not
|
||||||
--[[
|
|
||||||
local Model = Item:FindFirstAncestorOfClass("Model")
|
local Model = Item:FindFirstAncestorOfClass("Model")
|
||||||
|
|
||||||
if Model and not Players:GetPlayerFromCharacter(Model) then
|
if Model and not Players:GetPlayerFromCharacter(Model) then
|
||||||
if Item:IsA("Script") or Item:IsA("LocalScript") then
|
if Item:IsA("Script") or Item:IsA("LocalScript") then
|
||||||
Item.Enabled = false
|
Item.Enabled = false
|
||||||
@@ -105,7 +104,6 @@ function StudioEntities.indexAll(enabled: boolean)
|
|||||||
Item:Destroy()
|
Item:Destroy()
|
||||||
warn(`Script: "{Item.Name}" ({Item.ClassName}) was removed because it was outside of the rhpid-framework boundries,`, Item:GetFullName())
|
warn(`Script: "{Item.Name}" ({Item.ClassName}) was removed because it was outside of the rhpid-framework boundries,`, Item:GetFullName())
|
||||||
end
|
end
|
||||||
]]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if table.find(CS:GetTags(Item), "ServerGuard_Physics") then
|
if table.find(CS:GetTags(Item), "ServerGuard_Physics") then
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ type TagProduct = TagsModule.TagProduct
|
|||||||
type HumanoidRootPart = BasePart
|
type HumanoidRootPart = BasePart
|
||||||
type PromptCallback = (Player: Player) -> ()
|
type PromptCallback = (Player: Player) -> ()
|
||||||
|
|
||||||
type GetButtons = {[string]: Instance}
|
|
||||||
|
|
||||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
type Impl_Constructor = {
|
type Impl_Constructor = {
|
||||||
__index: Impl_Constructor,
|
__index: Impl_Constructor,
|
||||||
@@ -39,17 +37,6 @@ type Constructor_Return_Props = {
|
|||||||
Buttons: ButtonsTree
|
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
|
export type ButtonsConstructor = ClassConstructor
|
||||||
|
|
||||||
local ButtonsModule = {} :: Impl_Constructor
|
local ButtonsModule = {} :: Impl_Constructor
|
||||||
@@ -68,30 +55,6 @@ function ButtonsModule.constructor(TagsConstructor, Model)
|
|||||||
}, ButtonsModule)
|
}, ButtonsModule)
|
||||||
end
|
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
|
CarButton = Model_ElevatorButton_1
|
||||||
LandingButton = Model_ElevatorButton_Floor_1_Up
|
LandingButton = Model_ElevatorButton_Floor_1_Up
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type Impl_Constructor = {
|
|||||||
constructor: Constructor_Fun,
|
constructor: Constructor_Fun,
|
||||||
Get: (Tags: Tags.TagsConstructor, Model: Enums.ElevatorValues) -> Lanterns,
|
Get: (Tags: Tags.TagsConstructor, Model: Enums.ElevatorValues) -> Lanterns,
|
||||||
--Class functions
|
--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) -> (),
|
DirectionUp: (self: ClassConstructor, Enabled: boolean) -> (),
|
||||||
DirectionDown: (self: ClassConstructor, Enabled: boolean) -> (),
|
DirectionDown: (self: ClassConstructor, Enabled: boolean) -> (),
|
||||||
Toggle: (self: ClassConstructor, Enabled: boolean, Floor: number) -> (),
|
Toggle: (self: ClassConstructor, Enabled: boolean, Floor: number) -> (),
|
||||||
@@ -79,49 +79,9 @@ function Lanterns.constructor(MainDisplay, ChimeDirectionID, ChimeLandingID, Lan
|
|||||||
}, Lanterns)
|
}, Lanterns)
|
||||||
end
|
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))
|
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, {
|
local Tween = LanternLight:Start(Lantern.Light, {
|
||||||
Color = EnabledState and self.Colors.Active or self.Colors.Off
|
Color = EnabledState and self.Colors.Active or self.Colors.Off
|
||||||
})
|
})
|
||||||
@@ -140,11 +100,11 @@ end
|
|||||||
function Lanterns:Reset()
|
function Lanterns:Reset()
|
||||||
self.LanternsMap.Up.Played = false
|
self.LanternsMap.Up.Played = false
|
||||||
self.LanternsMap.Down.Played = false
|
self.LanternsMap.Down.Played = false
|
||||||
self:__Activate(false, true, self.LanternsMap.Up)
|
self:Activate(false, true, self.LanternsMap.Up)
|
||||||
self:__Activate(false, true, self.LanternsMap.Down)
|
self:Activate(false, true, self.LanternsMap.Down)
|
||||||
|
|
||||||
for n: number = 1, #self.LanternsMap do
|
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
|
self.LanternsMap[n].Played = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -152,14 +112,14 @@ end
|
|||||||
function Lanterns:DirectionUp(Enabled)
|
function Lanterns:DirectionUp(Enabled)
|
||||||
if not self.LanternsMap.Up.Played then
|
if not self.LanternsMap.Up.Played then
|
||||||
self.LanternsMap.Up.Played = true
|
self.LanternsMap.Up.Played = true
|
||||||
self:__Activate(Enabled, true, self.LanternsMap.Up)
|
self:Activate(Enabled, true, self.LanternsMap.Up)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Lanterns:DirectionDown(Enabled)
|
function Lanterns:DirectionDown(Enabled)
|
||||||
if not self.LanternsMap.Down.Played then
|
if not self.LanternsMap.Down.Played then
|
||||||
self.LanternsMap.Down.Played = true
|
self.LanternsMap.Down.Played = true
|
||||||
self:__Activate(Enabled, true, self.LanternsMap.Down)
|
self:Activate(Enabled, true, self.LanternsMap.Down)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -167,7 +127,7 @@ function Lanterns:Toggle(Enabled, Floor)
|
|||||||
local f = self.LanternsMap[Floor]
|
local f = self.LanternsMap[Floor]
|
||||||
if not f.Played then
|
if not f.Played then
|
||||||
f.Played = true
|
f.Played = true
|
||||||
self:__Activate(Enabled, false, f)
|
self:Activate(Enabled, false, f)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,6 @@ local Leveling = {
|
|||||||
[8] = 188.007,
|
[8] = 188.007,
|
||||||
[9] = 213.058,
|
[9] = 213.058,
|
||||||
[10] = 239.245,
|
[10] = 239.245,
|
||||||
|
|
||||||
Between = {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for n: number = 1, #Leveling, 2 do
|
|
||||||
Leveling.Between[n]=(Leveling[n+1]+Leveling[n])/2
|
|
||||||
end
|
|
||||||
|
|
||||||
return Leveling
|
return Leveling
|
||||||
134
src/server/main/TagService.lua
Normal file
134
src/server/main/TagService.lua
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
--!optimize 2
|
||||||
|
--!native
|
||||||
|
--!strict
|
||||||
|
|
||||||
|
local ParentDir = script.Parent
|
||||||
|
local Elevators = ParentDir:WaitForChild("Elevators")
|
||||||
|
local ElevatorEnums = Elevators:WaitForChild("Enums")
|
||||||
|
|
||||||
|
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
|
local Tags = Storage:WaitForChild("Tags")
|
||||||
|
|
||||||
|
type TagsConstructor = Tags.TagsConstructor
|
||||||
|
type TagProdcut = Tags.TagProdcut
|
||||||
|
|
||||||
|
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||||
|
type Impl_Constructor = {
|
||||||
|
__index: Impl_Constructor,
|
||||||
|
constructor: Constructor_Fun,
|
||||||
|
--Class functions
|
||||||
|
Lanterns: (self: ClassConstructor, ElevatorModel: ) -> Lanterns
|
||||||
|
} & Impl_Static_Props
|
||||||
|
|
||||||
|
type Impl_Static_Props = {
|
||||||
|
Volume: number
|
||||||
|
}
|
||||||
|
type Constructor_Fun = (Tags: TagsConstructor) -> ClassConstructor
|
||||||
|
type Constructor_Return_Props = {
|
||||||
|
Tags: TagsConstructor,
|
||||||
|
}
|
||||||
|
|
||||||
|
type Lantern = {
|
||||||
|
Inst: BasePart,
|
||||||
|
Light: BasePart?,
|
||||||
|
Played: boolean
|
||||||
|
}
|
||||||
|
type GetButtons = {[string]: Instance}
|
||||||
|
|
||||||
|
export type Lanterns = {
|
||||||
|
[number]: Lantern,
|
||||||
|
Up: Lantern,
|
||||||
|
Down: Lantern
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ButtonsTree = {
|
||||||
|
Landing: ButtonProperties,
|
||||||
|
Car: ButtonProperties,
|
||||||
|
Special: ButtonProperties,
|
||||||
|
Relays: ButtonProperties
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ButtonProperties = {
|
||||||
|
Inst: Instance?,
|
||||||
|
Prompt: ProximityPrompt?,
|
||||||
|
Attachment: Attachment?
|
||||||
|
}
|
||||||
|
|
||||||
|
local TagService = {} :: Impl_Constructor
|
||||||
|
TagService.__index = TagService
|
||||||
|
|
||||||
|
function TagService.constructor(Tags)
|
||||||
|
return setmetatable({
|
||||||
|
Tags = Tags
|
||||||
|
}, TagService)
|
||||||
|
end
|
||||||
|
|
||||||
|
TagService.Decoders = {}
|
||||||
|
|
||||||
|
function TagService.Decoders:CarTag(FloorTag)
|
||||||
|
local Match = FloorTag:match('%d+$')
|
||||||
|
return Match and tonumber(Match)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TagService:Lanterns(ElevatorModel)
|
||||||
|
local Lanterns = {} :: Lanterns
|
||||||
|
|
||||||
|
for TagName: string, Inst: TagProduct in self.Tags do
|
||||||
|
local Split = TagName:split('_')
|
||||||
|
if Split[1] == ElevatorModel 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
|
||||||
|
|
||||||
|
function TagService:Buttons(ElevatorModel)
|
||||||
|
local Buttons: GetButtons = {}
|
||||||
|
|
||||||
|
for TagName: string, Inst: TagProduct in self.Tags 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
|
||||||
|
|
||||||
|
function TagService:Interactables()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return TagService
|
||||||
Reference in New Issue
Block a user