This commit is contained in:
2024-03-11 02:17:24 -04:00
parent df86e6efb6
commit fc1f2bd9ee
2 changed files with 89 additions and 17 deletions

View File

@@ -0,0 +1,82 @@
--!optimize 2
--!native
--!strict
type GetButtons = {[string]: Instance}
type ButtonTypes = {
Landing: GetButtons,
Car: GetButtons,
Special: GetButtons,
Unknown: GetButtons
}
local ButtonTags = {}
ButtonTags.__index = ButtonTags
function ButtonTags.constructor(Tags, Model)
return setmetatable({
Tags = Tags,
Model = Model
}, ButtonTags)
end
function ButtonTags:Get()
local Buttons: GetButtons = {}
for TagName: string, Inst: Instance in self.Tags do
local Split = TagName:split('_')
if Split[1] == self.Model and Split[2] == "ElevatorButton" then
Buttons[TagName] = Inst
end
end
return Buttons
end
function ButtonTags:CreatePromptButtons()
local ModelButtons = self:Get()
local Buttons: ButtonTypes = {
Landing = {},
Car = {},
Special = {},
Unknown = {}
}
for TagName: string, Inst: Instance in ModelButtons do
local Attachment = Instance.new("Attachment") :: Attachment
Attachment.Parent = Inst
local Prompt = Instance.new("ProximityPrompt") :: ProximityPrompt
Prompt.MaxActivationDistance = 3
Prompt.Parent = Attachment
local Split = TagName:split('_')
--CarButton = Model_ElevatorButton_1
--LandingButton = Model_ElevatorButton_Floor_1_Up
--SpecialButton = Model_ElevatorButton_Open
local ButtonType = tonumber(Split[3]) and "CarButton" or (Split[3] == "Floor" and Split[4]:match('%d')) and "LandingButton" or Split[3] and "SpecialButton"
if ButtonType == "CarButton" then
--ElevatorButton_1
Buttons.Car[`{Split[2]}_{Split[3]}`] = Inst
Prompt.ActionText = tostring(Split[3])
Prompt.ObjectText = "Floor"
elseif ButtonType == "LandingButton" then
--ElevatorButton_Floor_1_Up
Buttons.Landing[`{Split[2]}_{Split[3]}_{Split[4]}_{Split[5]}`] = Inst
Prompt.ActionText = tostring(Split[5])
Prompt.ObjectText = `Floor {tostring(Split[4])}`
elseif ButtonType == "SpecialButton" then
--ElevatorButton_Open
else
warn(`{self.Model}: Door tag was present but couldnt specify its type for use "{TagName}"`)
end
print(`{self.Model}: created a ProximityPrompt @ "{Inst:GetFullName()}"`)
end
return Buttons
end
return ButtonTags