mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2026-02-04 03:56:50 +00:00
relay work and source map
This commit is contained in:
@@ -5,24 +5,23 @@
|
||||
local Elevators = script.Parent
|
||||
|
||||
local RS: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local TagsModule = require(RS:WaitForChild("Tags"))
|
||||
local Enums = require(Elevators:WaitForChild("Enums"))
|
||||
local Enums = require(Elevators:WaitForChild("Enums"))
|
||||
|
||||
type Tags = TagsModule.ExportedTags
|
||||
|
||||
type GetButtons = {[string]: Instance}
|
||||
type ButtonTree = {
|
||||
Inst: Instance,
|
||||
Prompt: ProximityPrompt
|
||||
type ButtonProperties = {
|
||||
Inst: Instance?,
|
||||
Prompt: ProximityPrompt?
|
||||
}
|
||||
type ButtonsTree = {
|
||||
Landing: ButtonTree,
|
||||
Car: ButtonTree,
|
||||
Special: ButtonTree,
|
||||
Unknown: {
|
||||
Inst: Instance,
|
||||
Prompt: ProximityPrompt?
|
||||
}
|
||||
Landing: ButtonProperties,
|
||||
Car: ButtonProperties,
|
||||
Special: ButtonProperties,
|
||||
Relays: ButtonProperties,
|
||||
Unknown: ButtonProperties
|
||||
}
|
||||
|
||||
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
|
||||
@@ -42,25 +41,24 @@ type Impl_Static_Props = {
|
||||
type Constructor_Fun = (Tags: Tags, Model: string) -> ClassConstructor
|
||||
type Constructor_Return_Props = {
|
||||
Tags: Tags,
|
||||
Model: string
|
||||
}
|
||||
|
||||
export type ButtonsEnum = {
|
||||
Car: string,
|
||||
Landing: string,
|
||||
Special: string,
|
||||
Unknown: string
|
||||
Model: string,
|
||||
Buttons: ButtonsTree
|
||||
}
|
||||
|
||||
local ButtonsModule = {} :: Impl_Constructor
|
||||
ButtonsModule.__index = ButtonsModule
|
||||
|
||||
local ButtonsEnum = Enums.ButtonsEnum
|
||||
|
||||
function ButtonsModule.constructor(Tags, Model)
|
||||
return setmetatable({
|
||||
Tags = Tags,
|
||||
Model = Model
|
||||
Model = Model,
|
||||
Buttons = {
|
||||
Landing = {},
|
||||
Car = {},
|
||||
Special = {},
|
||||
Relays = {},
|
||||
Unknown = {}
|
||||
}
|
||||
}, ButtonsModule)
|
||||
end
|
||||
|
||||
@@ -71,7 +69,7 @@ function ButtonsModule:Get()
|
||||
|
||||
for TagName: string, Inst: Instance | {Instance} in self.Tags do
|
||||
local Split = TagName:split('_')
|
||||
if Split[1] == self.Model and Split[2] == "ElevatorButton" then
|
||||
if Split[1] == self.Model and (Split[2] == "ElevatorButton" or Split[2] == "RelayButton") then
|
||||
if typeof(Inst) == "Instance" then
|
||||
Buttons[TagName] = Inst
|
||||
else
|
||||
@@ -82,15 +80,15 @@ function ButtonsModule:Get()
|
||||
return Buttons
|
||||
end
|
||||
|
||||
--[[
|
||||
CarButton = Model_ElevatorButton_1
|
||||
LandingButton = Model_ElevatorButton_Floor_1_Up
|
||||
SpecialButton = Model_ElevatorButton_Open
|
||||
RelayButton = Model_RelayButton_F1
|
||||
]]
|
||||
function ButtonsModule:CreatePromptButtons()
|
||||
local ModelButtons = self:Get()
|
||||
local Buttons = {
|
||||
Landing = {},
|
||||
Car = {},
|
||||
Special = {},
|
||||
Unknown = {}
|
||||
} :: ButtonsTree
|
||||
|
||||
|
||||
for TagName: string, Inst: Instance in ModelButtons do
|
||||
local Attachment = Instance.new("Attachment") :: Attachment
|
||||
Attachment.Parent = Inst
|
||||
@@ -98,56 +96,64 @@ function ButtonsModule:CreatePromptButtons()
|
||||
Prompt.MaxActivationDistance = 3
|
||||
Prompt.Parent = Attachment
|
||||
|
||||
--CarButton = Model_ElevatorButton_1
|
||||
--LandingButton = Model_ElevatorButton_Floor_1_Up
|
||||
--SpecialButton = Model_ElevatorButton_Open
|
||||
local Split = TagName:split('_')
|
||||
local ButtonType = tonumber(Split[3]) and
|
||||
ButtonsEnum.Car
|
||||
or Split[3] == "Floor" and Split[4]:match('%d') and
|
||||
ButtonsEnum.Landing
|
||||
or Split[2] == "ElevatorButton" and
|
||||
ButtonsEnum.Special
|
||||
local ButtonType = if tonumber(Split[3]) then
|
||||
Enums.Buttons.Car
|
||||
elseif Split[3] == "Floor" and Split[4]:match('%d') then
|
||||
Enums.Buttons.Landing
|
||||
elseif Split[2] == "ElevatorButton" then
|
||||
Enums.Buttons.Special
|
||||
elseif Split[2] == "RelayButton" then
|
||||
Enums.Buttons.Relay
|
||||
else
|
||||
nil
|
||||
|
||||
ButtonsEnum:Match(ButtonType, {
|
||||
[ButtonsEnum.Car] = function()
|
||||
--ElevatorButton_1
|
||||
Buttons.Car[`{Split[2]}_{Split[3]}`] = {
|
||||
Inst = Inst,
|
||||
Prompt = Prompt
|
||||
}
|
||||
Prompt.ActionText = tostring(Split[3])
|
||||
Prompt.ObjectText = "Floor"
|
||||
end,
|
||||
if ButtonType == Enums.Buttons.Car then
|
||||
--ElevatorButton_1
|
||||
|
||||
[ButtonsEnum.Landing] = function()
|
||||
--ElevatorButton_Floor_1_Up
|
||||
Buttons.Landing[`{Split[2]}_{Split[3]}_{Split[4]}_{Split[5]}`] = {
|
||||
Inst = Inst,
|
||||
Prompt = Prompt
|
||||
}
|
||||
Prompt.ActionText = tostring(Split[5])
|
||||
Prompt.ObjectText = `Floor {tostring(Split[4])}`
|
||||
end,
|
||||
self.Buttons.Car[`{Split[2]}_{Split[3]}`] = {
|
||||
Inst = Inst,
|
||||
Prompt = Prompt
|
||||
}
|
||||
Prompt.ActionText = tostring(Split[3])
|
||||
Prompt.ObjectText = "Floor"
|
||||
elseif ButtonType == Enums.Buttons.Landing then
|
||||
--ElevatorButton_Floor_1_Up
|
||||
|
||||
[ButtonsEnum.Special] = function()
|
||||
--ElevatorButton_Open
|
||||
Buttons.Special[`{Split[2]}_{Split[3]}`] = {
|
||||
Inst = Inst,
|
||||
Prompt = Prompt
|
||||
}
|
||||
Prompt.ActionText = tostring(Split[3])
|
||||
Prompt.ObjectText = "Floor"
|
||||
end,
|
||||
self.Buttons.Landing[`{Split[2]}_{Split[3]}_{Split[4]}_{Split[5]}`] = {
|
||||
Inst = Inst,
|
||||
Prompt = Prompt
|
||||
}
|
||||
Prompt.ActionText = tostring(Split[5])
|
||||
Prompt.ObjectText = `Floor {tostring(Split[4])}`
|
||||
elseif ButtonType == Enums.Buttons.Special then
|
||||
--ElevatorButton_Open
|
||||
|
||||
["_"] = function()
|
||||
warn(`{self.Model}: Door tag was present but couldnt specify its type for use "{TagName}"`)
|
||||
end
|
||||
})
|
||||
print(`{self.Model}: created a ProximityPrompt @ "{Inst:GetFullName()}"`)
|
||||
self.Buttons.Special[`{Split[2]}_{Split[3]}`] = {
|
||||
Inst = Inst,
|
||||
Prompt = Prompt
|
||||
}
|
||||
Prompt.ActionText = tostring(Split[3])
|
||||
Prompt.ObjectText = "Floor"
|
||||
elseif ButtonType == Enums.Buttons.Relay then
|
||||
--RelayButton_F1
|
||||
|
||||
Attachment.Position-=Vector3.new(.1,.3,0)
|
||||
|
||||
self.Buttons.Relays[`{Split[2]}_{Split[3]}`] = {
|
||||
Inst = Inst,
|
||||
Prompt = Prompt
|
||||
}
|
||||
Prompt.ActionText = `Relay {tostring(Split[3])}`
|
||||
Prompt.ObjectText = "Activate"
|
||||
else
|
||||
warn(`{self.Model}: Door tag was present but couldnt specify its type for use "{TagName}"`)
|
||||
end
|
||||
|
||||
print(`[{tostring(ButtonType)}] {self.Model}: created a ProximityPrompt @ "{Inst:GetFullName()}"`)
|
||||
end
|
||||
|
||||
return Buttons
|
||||
return self.Buttons
|
||||
end
|
||||
|
||||
function ButtonsModule:HookPromptButtonsGroup()
|
||||
|
||||
Reference in New Issue
Block a user