Files
Roblox-Elevator-Game/src/server/main/init.server.lua
2024-04-17 23:25:40 -04:00

102 lines
3.4 KiB
Lua

--!optimize 2
--!native
--!strict
local ShowEditorEntities = game:GetService("RunService"):IsServer()
local Storage = game:GetService("ReplicatedStorage")
local Enums = require(Storage:WaitForChild("Enums"))
local Elevators = script:WaitForChild("Elevators")
local Otis1960_Module = require(Elevators:WaitForChild("Otis1960"))
local Map = script:WaitForChild("Map")
local LightSwitchesConstructor = require(Map:WaitForChild("LightSwitches"))
local PromptsConstructor = require(Map:WaitForChild("Prompts"))
local TagsModule = require(script:WaitForChild("Tags"))
local HideEditorEntities = require(script:WaitForChild("EditorEntities"))
local Lighting_Stuff = require(script:WaitForChild("Lighting"))
local Workspace_Stuff = require(script:WaitForChild("Workspace"))
local StarterPlayer_Stuff = require(script:WaitForChild("StarterPlayer"))
local TagsConstructor = TagsModule.constructor()
print("[DEBUG] Tags=", TagsConstructor.__export)
HideEditorEntities.indexAll(ShowEditorEntities)
TagsConstructor:Nuke()
StarterPlayer_Stuff()
Lighting_Stuff()
Workspace_Stuff()
--Map
local Interactables = TagsConstructor:__Interactables()
print("[DEBUG] Interactables=", Interactables)
--Temporary
--[[
Guide for lights with toggable switches:
TODO
]]
local TweenModule = require(Storage:WaitForChild("Tween"))
local LightSwitchTween = TweenModule.constructor(TweenInfo.new(.1, Enum.EasingStyle.Linear))
for _, LightProperties in Interactables.LightSwitches do
if LightProperties.Prompt and LightProperties.Switch then
local Prompt = PromptsConstructor.constructor(LightProperties.Prompt, LightProperties.Switch)
local LightEnabled = false
if LightProperties.ColorDeactivated and LightProperties.ColorActivated and LightProperties.Prompt and LightProperties.Lights then
Prompt:AddHookTriggered(function(_Player: Player)
LightEnabled = not LightEnabled
local Switch = LightProperties.Switch
if LightEnabled then
LightSwitchTween:Start(Switch, {
CFrame = CFrame.new(Switch.Position)*CFrame.Angles(0,math.rad(90),0)+Vector3.new(0,.15,0)
})
else
LightSwitchTween:Start(Switch, {
CFrame = CFrame.new(Switch.Position)*CFrame.Angles(0,math.rad(90),math.rad(70))-Vector3.new(0,.15,0)
})
end
if LightProperties.ClickSound then
LightProperties.ClickSound:Play()
end
for n: number = 1, #LightProperties.Lights do
local LightObj = LightProperties.Lights[n]
local Light = LightObj:FindFirstChildWhichIsA("PointLight", true) or LightObj:FindFirstChildWhichIsA("SpotLight", true)
if Light then
Light.Enabled = LightEnabled
end
if LightEnabled then
LightObj.Color = LightProperties.ColorActivated
LightObj.Material = Enum.Material.Neon
else
LightObj.Color = LightProperties.ColorDeactivated
LightObj.Material = Enum.Material.SmoothPlastic
end
end
end)
else
warn("failed")
end
end
end
--
--local LightSwitches = LightSwitchesConstructor.constructor(Interactables.LightSwitches)
--Start the elevators
local Buttons = TagsConstructor:__ElevatorButtons()
print("[DEBUG] Buttons=", Buttons)
local Lanterns = TagsConstructor:__ElevatorLanterns()
print("[DEBUG] Lanterns=", Lanterns)
local Otis1960Lanterns = Lanterns[Enums.Elevator.Otis1960]
local Otis1960Buttons = Buttons[Enums.Elevator.Otis1960]
local Otis1960 = Otis1960_Module.constructor(TagsConstructor, Otis1960Buttons, Otis1960Lanterns)