#Room generation problem
13 messages · Page 1 of 1 (latest)
Room script:
local room = {}
room.Info = require(script.RoomInfo)
room.LastTurnDirection = nil
room.random = Random.new()
function room.GetRandom(prevRoom)
local possibleRooms = workspace.Rooms:GetChildren()
local randomRoom = possibleRooms[room.random:NextInteger(1, #possibleRooms)]
--[1] Next room MUST be different than the previous
--[2] If corner then next turn must turn other way
--[3] If prev room had stairs, then the next room cannot
local direction = room.Info[randomRoom.Name]["Direction"]
local hasStairs = room.Info[randomRoom.Name]["Stairs"]
local prevHadStairs = room.Info[randomRoom.Name]["Direction"]
if (prevRoom.Name == randomRoom.Name)
or (direction and direction == room.LastTurnDirection)
or (hasStairs and prevHadStairs)
then
return room.GetRandom(prevRoom)
else
if direction then
room.LastTurnDirection = direction
end
return randomRoom
end
end
function room.Generate(prevRoom)
local randomRoom = room.GetRandom(prevRoom)
local newRoom = randomRoom:Clone()
newRoom.PrimaryPart = newRoom.Entrance
newRoom:PivotTo(prevRoom.Exit.CFrame)
newRoom.Entrance.Transparency = 1
newRoom.Parent = workspace.GeneratedRooms
return newRoom
end
return room
.
Roominfo script:
local roomInfo = {
["StartRoom"] = {
},
["LavaChoice"] = {
},
["SimpleRoom"] = {
},
["RightTurn"] = {
["Direction"] = "Right"
}
}
--["LeftTurn"] = {
--["Direction"] = "Left"
--},
--["Downstairs"] = {
--["Stairs"] = true
--},
return roomInfo
Room generation problem
if you dont know just don't talk
you are just useless
nobody loves you
you are just a useless kid that has no life
just shut the fck up
