RoboCatz.com
About FLL | Navigation | Playbook | Strategy | Models | Techniques | RobotC | Programming | Robot News |

-- spiralStaircase ModuleScript in the ReplicatedStorage area

-- spiralStaircase ModuleScript in the ReplicatedStorage area
--[[
Updated: 5/24/2023

This module is: spiralStaircase and is stored in the ReplicatedStorage area

This module will demonstrate the steps in creating a spiral staircase
The staircase will be rendered in the baseplateScript

]]
local SpiralStaircase = {}
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local s = require(ReplicatedStorage.genericShapes)
local b = require(ReplicatedStorage.artInstallationRoom)

function SpiralStaircase.straightStaircaseVariesOnX(x, z)
	local exhibitRoom = { room=b.new({x=x, z=z}), name="newQbert", parts={}, onInteraction=nil }
	exhibitRoom.draw = function() 
		for i=1,25 do
			exhibitRoom.parts[i] = s.panel({x=i*3-15,y=i,z=-25, thickness=1, color=Color3.new(math.random()*90,math.random()*90,math.random()*90), rotateby=Vector3.new(0,90,0), material=Enum.Material.Foil})
		end
	end
	exhibitRoom.onInteraction = function(thePart)
		local touchingPartsTable = thePart:GetTouchingParts()
		for i=1,#touchingPartsTable do
			s.fill(touchingPartsTable[i], Color3.new(0.8, 0.8, math.random()))
			s.material(touchingPartsTable[i], Enum.Material.Wood)
		end
	end
	exhibitRoom.defineInteractions = function()
		for i=1,#exhibitRoom.parts do exhibitRoom.parts[i].Touched:Connect(exhibitRoom.onInteraction) end
	end
	exhibitRoom.animate = function(...) 
		for i=1,#exhibitRoom.parts do
			--s.fill(exhibitRoom.parts[i], Color3.new(math.random(),math.random(),math.random()))
		end
	end
	return exhibitRoom
end

function SpiralStaircase.straightStaircaseVariesOnZ(x, z)
	local exhibitRoom = { room=b.new({x=x, z=z}), name="newQbert", parts={}, onInteraction=nil }
	exhibitRoom.draw = function() 
		for i=1,25 do
			exhibitRoom.parts[i] = s.panel({x=0,y=i,z=i*-3-25, thickness=1, color=Color3.new(math.random()*90,math.random()*90,math.random()*90), rotateby=Vector3.new(0,90,0), material=Enum.Material.Foil})
		end
	end
	exhibitRoom.onInteraction = function(thePart)
		local touchingPartsTable = thePart:GetTouchingParts()
		for i=1,#touchingPartsTable do
			s.fill(touchingPartsTable[i], Color3.new(0.8, 0.8, math.random()))
			s.material(touchingPartsTable[i], Enum.Material.Wood)
		end
	end
	exhibitRoom.defineInteractions = function()
		for i=1,#exhibitRoom.parts do exhibitRoom.parts[i].Touched:Connect(exhibitRoom.onInteraction) end
	end
	exhibitRoom.animate = function(...) 
		for i=1,#exhibitRoom.parts do
			--s.fill(exhibitRoom.parts[i], Color3.new(math.random(),math.random(),math.random()))
		end
	end
	return exhibitRoom
end

function SpiralStaircase.straightStaircaseVariesOnXandZ(x, z)
	local exhibitRoom = { room=b.new({x=x, z=z}), name="newQbert", parts={}, onInteraction=nil }
	exhibitRoom.draw = function() 
		for i=1,25 do
			exhibitRoom.parts[i] = s.panel({x=i*-3-25,y=i,z=i*-3-25, thickness=1, color=Color3.new(math.random()*90,math.random()*90,math.random()*90), rotateby=Vector3.new(0,90,0), material=Enum.Material.Foil})
		end
	end
	exhibitRoom.onInteraction = function(thePart)
		local touchingPartsTable = thePart:GetTouchingParts()
		for i=1,#touchingPartsTable do
			s.fill(touchingPartsTable[i], Color3.new(0.8, 0.8, math.random()))
			s.material(touchingPartsTable[i], Enum.Material.Wood)
		end
	end
	exhibitRoom.defineInteractions = function()
		for i=1,#exhibitRoom.parts do exhibitRoom.parts[i].Touched:Connect(exhibitRoom.onInteraction) end
	end
	exhibitRoom.animate = function(...) 
		for i=1,#exhibitRoom.parts do
			--s.fill(exhibitRoom.parts[i], Color3.new(math.random(),math.random(),math.random()))
		end
	end
	return exhibitRoom
end

function SpiralStaircase.spheresInCircle(x, z)
	local exhibitRoom = { room=b.new({x=x, z=z}), name="newQbert", parts={}, onInteraction=nil }
	exhibitRoom.draw = function()
		local numSpheres = 25
		local radiusOfCircle = 30
		for i=1,numSpheres do
			local xCoordinate = radiusOfCircle * math.cos(360*(i/numSpheres) * math.pi/180)
			local zCoordinate = radiusOfCircle * math.sin(360*(i/numSpheres) * math.pi/180)
			exhibitRoom.parts[i] = s.sphere({x=exhibitRoom.room.center.X+xCoordinate,y=i,z=exhibitRoom.room.center.Z+zCoordinate, size=4, color=Color3.new(math.random()*90,math.random()*90,math.random()*90), material=Enum.Material.Foil})
		end
	end
	exhibitRoom.onInteraction = function(thePart)
		local touchingPartsTable = thePart:GetTouchingParts()
		for i=1,#touchingPartsTable do
			s.fill(touchingPartsTable[i], Color3.new(0.8, 0.8, math.random()))
			s.material(touchingPartsTable[i], Enum.Material.Wood)
		end
	end
	exhibitRoom.defineInteractions = function()
		for i=1,#exhibitRoom.parts do exhibitRoom.parts[i].Touched:Connect(exhibitRoom.onInteraction) end
	end
	exhibitRoom.animate = function(...) 
		for i=1,#exhibitRoom.parts do
			--s.fill(exhibitRoom.parts[i], Color3.new(math.random(),math.random(),math.random()))
		end
	end
	return exhibitRoom
end

function SpiralStaircase.panelsInCircle(x, z)
	local exhibitRoom = { room=b.new({x=x, z=z}), name="newQbert", parts={}, onInteraction=nil }
	exhibitRoom.draw = function()
		local numSpheres = 25
		local radiusOfCircle = 30
		for i=1,numSpheres do
			local xCoordinate = radiusOfCircle * math.cos(360*(i/numSpheres) * math.pi/180)
			local zCoordinate = radiusOfCircle * math.sin(360*(i/numSpheres) * math.pi/180)
			exhibitRoom.parts[i] = s.panel({x=exhibitRoom.room.center.X+xCoordinate,y=i,z=exhibitRoom.room.center.Z+zCoordinate, thickness=4, color=Color3.new(math.random()*90,math.random()*90,math.random()*90), material=Enum.Material.Foil})
		end
	end
	exhibitRoom.onInteraction = function(thePart)
		local touchingPartsTable = thePart:GetTouchingParts()
		for i=1,#touchingPartsTable do
			s.fill(touchingPartsTable[i], Color3.new(0.8, 0.8, math.random()))
			s.material(touchingPartsTable[i], Enum.Material.Wood)
		end
	end
	exhibitRoom.defineInteractions = function()
		for i=1,#exhibitRoom.parts do exhibitRoom.parts[i].Touched:Connect(exhibitRoom.onInteraction) end
	end
	exhibitRoom.animate = function(...) 
		for i=1,#exhibitRoom.parts do
			--s.fill(exhibitRoom.parts[i], Color3.new(math.random(),math.random(),math.random()))
		end
	end
	return exhibitRoom
end

function SpiralStaircase.horizontalPanelsInCircle(x, z)
	local exhibitRoom = { room=b.new({x=x, z=z}), name="newQbert", parts={}, onInteraction=nil }
	exhibitRoom.draw = function()
		local numSpheres = 25
		local radiusOfCircle = 30
		for i=1,numSpheres do
			local xCoordinate = radiusOfCircle * math.cos(360*(i/numSpheres) * math.pi/180)
			local zCoordinate = radiusOfCircle * math.sin(360*(i/numSpheres) * math.pi/180)
			exhibitRoom.parts[i] = s.panel({x=exhibitRoom.room.center.X+xCoordinate,y=i,z=exhibitRoom.room.center.Z+zCoordinate, thickness=1, color=Color3.new(math.random()*90,math.random()*90,math.random()*90), rotateBy=Vector3.new(0, 90, 0), material=Enum.Material.Foil})
		end
	end
	exhibitRoom.onInteraction = function(thePart)
		local touchingPartsTable = thePart:GetTouchingParts()
		for i=1,#touchingPartsTable do
			s.fill(touchingPartsTable[i], Color3.new(0.8, 0.8, math.random()))
			s.material(touchingPartsTable[i], Enum.Material.Wood)
		end
	end
	exhibitRoom.defineInteractions = function()
		for i=1,#exhibitRoom.parts do exhibitRoom.parts[i].Touched:Connect(exhibitRoom.onInteraction) end
	end
	exhibitRoom.animate = function(...) 
		for i=1,#exhibitRoom.parts do
			--s.fill(exhibitRoom.parts[i], Color3.new(math.random(),math.random(),math.random()))
		end
	end
	return exhibitRoom
end


function SpiralStaircase.rotatedPanelsInCircle(x, z)
	local exhibitRoom = { room=b.new({x=x, z=z}), name="newQbert", parts={}, onInteraction=nil }
	exhibitRoom.draw = function()
		local numSpheres = 25
		local radiusOfCircle = 30
		for i=1,numSpheres do
			local xCoordinate = radiusOfCircle * math.cos(360*(i/numSpheres) * math.pi/180)
			local zCoordinate = radiusOfCircle * math.sin(360*(i/numSpheres) * math.pi/180)
			exhibitRoom.parts[i] = s.panel({x=exhibitRoom.room.center.X+xCoordinate,y=i,z=exhibitRoom.room.center.Z+zCoordinate, thickness=1, color=Color3.new(math.random()*90,math.random()*90,math.random()*90), rotateBy=Vector3.new(0, -360*(i/numSpheres), 0), material=Enum.Material.Foil})
		end
	end
	exhibitRoom.onInteraction = function(thePart)
		local touchingPartsTable = thePart:GetTouchingParts()
		for i=1,#touchingPartsTable do
			s.fill(touchingPartsTable[i], Color3.new(0.8, 0.8, math.random()))
			s.material(touchingPartsTable[i], Enum.Material.Wood)
		end
	end
	exhibitRoom.defineInteractions = function()
		for i=1,#exhibitRoom.parts do exhibitRoom.parts[i].Touched:Connect(exhibitRoom.onInteraction) end
	end
	exhibitRoom.animate = function(...) 
		for i=1,#exhibitRoom.parts do
			--s.fill(exhibitRoom.parts[i], Color3.new(math.random(),math.random(),math.random()))
		end
	end
	return exhibitRoom
end




function SpiralStaircase.destroy(activeRoom)
	print("Exiting " .. activeRoom.name)
	b.destroy(activeRoom.parts)
	-- Clear the installation of any works of art.  Leave the walls and floor alone.
end

return SpiralStaircase