Complex Room Generation - Doors Game Tutorial #2
Вставка
- Опубліковано 7 чер 2024
- In this episode we improve our room generation to allow for corners, stairs, and control probability with extra rare rooms.
DISCORD ► / discord
TWITCH ► / gnomecode
TWITTER ► / gnomecoderblx
WEBSITE ► gnome.codes/
TIMESTAMPS ►
0:00 Intro
01:45 Creating GetRandom function
04:57 Creating RoomInfo Module
08:07 Filtering Room Types
14:49 Room Generation Probability
22:00 Outro
I love how frequently you upload these new parts! It helps me alot with making this game while being short on time!
Wow, that's great! Keep up the good work!
Hi IULITMx !
IULITMx!
ayo, Why are you here wasnt expecting you lol
yo waddup
yo
Bro this is exactly what I needed! I was worried I wouldn't be able to release my game before Halloween, but you got it here quick. Thanks!
I can't wait to see how this game is going to be at the end. Enjoying the whole series so far.
same
This series is great! Can't wait for the next part :)
just setting a stamp to remind myself: 5:20
Love your stuff! Keep up the great work!
Love these videos gnome! Keep up the great work ❤
This is AWSOME and I can't wait for episode 3! I love your tutorials! ❤
Gnomecode, ever since I found you via the piggy stuff, You've been amazing! You've helped me understand so many things And I can't THANKYOU enough! I am so excited to see where the rest of these videos go, you have a amazing future ahead!
I was really hoping he would design the rooms on camera too, kinda ruined my motivation but the tutorials have been incredible! Cant wait to see how this pans out
What do you mean?
@@BenGodot He means building the rooms on camera.
Do u lack creativity or something
@@andy-gamer Yes i do
I have been waiting for this! Thanks gnomecode!
Another great Video for my doors at home
Thank you GnomeCode For your great Work !
You made so awesome tutorials, you have a clear voice and on the most videos i learned a lot of coding.
Thank you for your work.
Did you plan more tutorials on this series ? I love this game.
Korean?
When he says” hello my fellow gnomes!” That is the best part
Edit: thx for 35 likes!
correct
I'm actually not super late to a video
I agree
True
Agreed
Good tutorial! It gives me just enough information that if I make a mistake in the code or in orientation I can fix it with relative ease.
I've been waiting for this!
In my opinion, for tutorials like this, I feel like spreading the usage of Attributes would be extremely beneficial for teaching this new generation of developers as attributes help narrow down the divide between artists and programmers; it allows almost anyone on the team to declare HasStairs to true or Direction to Left or Right.
100%
LSPLASH used Attributes for rooms, for example ["Weight"].
won't it be impossible to get the art gallery in your code currently? if the random weight is between 1 - ? then how will the 0.1 weight of the gallery be < or = than the minimum in the randomizer (1)?
Lol! Somebody is actually paying attention. That is an excellent point...
true
Keep them coming!! Thank you!!
Really Thanks bro. Im waiting for the 3part
Hi gnomecode! I like your videos a lot! You have taught me a lot of coding. For your next tutorial series can you do a game like specter 2? Please reply yes or no.
gnome code ded :skull:
Episode twooooo!
🥚
ayee its Stroyosh!!
Been watching you since a long time. You make the best tutorials!!!
Thanks for sticking around!
@@GnomeCode part 3 when
@@notcardi true 👀
Wow Great Work! Keep Making Tutorial Your AWESOME!
is there a video of you making the rooms ? i want to see the stairs part
yeah same idk how to make those
@@user-nh9pl9zj6z i already finished and published my own doors version . just think about it for a little bit and you will be able to make them
If you want something super rare to spawn, You might have a problem with putting the weight under 1, It cant go under 1 cuz gnomecode did something wrong so if you want it to be rarer, Make the other room value's higher.
Great work mate!
TYSMMM, was waiting for this!
Fun fact: You can make the room generation chances manually with duplicating the rooms, meaning they have more chance. The less duplicated the room is, the rarier it is.
This can clutter the workspace which can get annoying quickly so sometimes it’s better to code it in for games like this with many many rooms.
this isn't generation tho, it's just a room, no changes basically. which defeats the point of making every run to be unique
@@arandomartist4341 It's generation that picks which room not manually it's literally the same as coding in
guys, the orientation of the exit and entrance is EXTREMELY IMPORTANT otherwise everything will just glitch out. to check it, just right click on the entrance or exit and select "show orientation indicator"
Which way is the orientation supposed to face?
i think it should be facing the same orientation as all the other models and parts
what happens with rooms that change orientation; Nvm, I got all Figured out, just make parts face the WAY to the exit.
Man you saved my ass❤❤
@@Nicolas99998 💀
It's always a great day when you upload a vid!:)
cant wait for the new episode im alreadty excited!
Hey GnomeCode, loved this video but i have one problem. My turns and stair rooms are overlapping on each other. I checked the front orientation so many times but it still does not work. Please help me fix this error.
same
Same, I’ve even tried making a new game to restart and it keeps overlapping
Idea: Instead of making it repeat the function until it finds a random room that obeys the rules (which could take a while depending on "luck"), it would be better if we just created an array and inserted all the rooms that follow the rules, and then select a random room of the ones inside the array.
For example:
Local possible_rooms = {};
for _, room in pairs(workspace.Rooms:GetChildren()) do
if room == obbey the rules and all that stuff then
table.insert(possible_rooms, v)
end;
end;
local selected_room = possible_rooms[math.random(1,#possible_rooms)];
I hope this is understandable.
Makes sense.
Might also help with speed.
what
@@akiprox7 Essentially, what he's saying is instead of repeatedly selecting a random room until you find a valid one, instead just select a random valid room by storing all the valid rooms in one array, then picking one from that array.
1: lua does not need ";"
2: i tried to convert it to my vars but it did not work.
@@jaydonNEWi 1. It really doesn't, I just got used to it.
2. That simply means you don't know what you're doing or how to insert that code to your script.
yay thanks for doing this! all i need now is to make rooms with multiple exits, hopefully you can show us how to do that next vid. Great work too!
Just copy the exit part in ur room and put in a place
ngl this is the best tutorial i have seen in years
Hey Gnome Code, I have a problem. When I set the variables for the "direction", "hasStairs" and "prevHadStairs" (8:58 - 10:07) it stops the script and says there is none. Which is true because I didn't set the variables to some of the rooms (like you said to). This is preventing me form continuing, any help would be appreciated.
✂EDIT: I also have a problem where the prevRoom Becomes nil after a while
@thekittenisonfire I fixed it too, i forgor the long room 💀
@Figure the T poser WAIT you guys mean the "attempt to index nil with "Stairs" ?? pleas tell how to solve
@@PickleGobler i have the same problem... 17:59:56.819 ServerScriptService.Server.RoomModule:17: attempt to index nil with 'Stairs' - Server - RoomModule:17
@@beandevv I kinda found the problem it was becuase I didnt add the start room to the room info module script
@@beandevv quick tip when watching gnomce code or other youtubers that eplain code, you dont wanna skip any part
Could you also add X-Sections? so 4 different directions. So its more like a maze rather than a long path.
just make your own and change the property in the table to "XSection" or something
An 'x' or a '+' because a '+' is way easier.
@@GreenDragonGaming essentially the same thing
Thank you for explaining this thoroughly!
Your room design looks beautiful.
I have a suggestion you should do: Make the Rooms a model so people can use them, the reason i needed this is for people who are bad at building and a easy start off to do, so if you could make it a model for people to use, that would be great!
yeah
@@RandomStickGuy yes please
yes please!
i was able to make them with the basic long and short room ive never done model making but iv done coding and it was simple
@@KoalaOnYT_ plz make a model
for people with issues in the script that says "Index nil with stairs" or "index nil with direction".... Just add StartRoom into the Rooms folder, But In the roominfo Put the StartRoom with 0 weight, soo it won't spawn! it fixed my script, idk if it will work for you guys
what does weight even mean
@@corrupie bruh didn't you saw the video?
@@Colognn nvm one of my friends helped me
@@corrupie bro "Weigth" is what gnomecode used to make a "Chance" to the rooms, you just got straight into the comment you didn't even watched the video dammy
Yess ive been waiting for this
Yes! Part #2!!!! I love you
After generating a bunch of rooms they still cross through eachother, just a lot less often. I was thinking of doing something like deleting the 6th oldest room.
I also need to make my stairs a bit higher since they barley graze the floors and ceilings or straight up covers the entire room. 💀
Are your start positions and end positions lined up if not then that might be causing the issue because I had an issue like this aswell?
@@GreenDragonGaming mine line up perfectly fine, it's just the rooms that turn right and left cause it to generate in a full circle.
@@Kaizentry you scripted something wrong then
@@fire.maniac. nope I did everything exactly as said, I'm just saying some of these things are inevitable with the right and left snakes.
@@Kaizentry I'm going to bet that these have something to do with your builds
Can you make a part in the series where it has rooms that only generate once at the same number doors? (Room 50 for example)
he definitely will since that’s a core part of the game
@@kthulu2 ya
Yeah
Just create that room, put it in a folder, give the info in the info script, add a room counter, and add an if statement. Should be able to do that
@@ImReallyLemoBloxROFL Have you done it before?
I once made a random Road generator, These kind of systems are super fun to make!
Amazing tutorial ❤
well, you don't have to eliminate all of the generation bugs, just make it super rare. when it happens, you could just add an entity that teleports you to the next room
(referring to glitch)
everything works, but sometimes at like the first few rooms, they tend to spawn inside of eachother. Please help
Edit: i figured it out! apparently in the server script i put prevRoom= room.Generate(prevRoom) twice
Oh, I forgot to remove that line of code too
Thanks!
lol this was my issue as well, youre a godsend, was about to give up
Thank you so much! I’m doing very well, your tutorials are amazing!
lua scripts are not the best suitable tool for generating anything that large
thank you so much gnomecode!
Bruh. I need the models but I can't create it. But I'll attempt! :3
Me too
I had some trouble with rooms spawning on top of eachother, and stairs hardly generated correctly. If you could do a quick bit on how you made each of the off-camera rooms that would be p cool 👍
Same rules apply as the rooms I created in ep 1. Just make sure you have the entrance/exit parts all facing the same way using the OrientationIndicator
@@GnomeCode Hello my fellow gnome is it normal that when i take the weight value on one of my rooms under 1 it dosent spawn?
@@GnomeCode I did this, but some rooms keep spawning in the center of the exit parts and sort of overlapping. It's a bit like a corner of the door takes up the corner of the exit and it keeps doing that sometimes. Also two rooms keep spawning at the starter room. Any idea what I should do?
@@name-fr8rx same I’m confused on what to do
@@RealDippy Ok so I found a solution but you may not necessarily like it. I decided to just get rid of the left & right turns entirely because everything is lined up on the indicator so I just got rid of them, and also got rid of the stairs. So it kind of just relies on the snakes and my imagination to make it interesting.
As for two spawning at the starter room, you wanna get rid of the room.Generate(prevRoom) on the second line in the script.
Hope I helped! If you need any more help, just send me your script and I'll see what's wrong.
Nice tutorial.... Very helpful
Amazing Work!
I Am Definitely Subscribing! :)
bruh i literally followed the script and the script just died it stopped generating rooms 😭 literally it is just the startroom
Me too
Same
Go to view and press output and then run it to see the error
Did you fix it?
@@MrocznyOpiekun i remember i just modified it and since i suck then thats why, anyways i canceled that game already lol please dont feel like offended by my comment tho with the "bruh"
This is useful! you've earned a sub fr fr
I am making a game with random gen. THANK YOU MAN I NEED THIS
incase if this script on the video doesnt work as expected (if it works then ill delete this comment)
room(module):
local room = {}
room.random = Random.new()
function room.Generate(prevRoom)
local possibleRooms = workspace.Rooms:GetChildren()
local randomRoom = possibleRooms[room.random:NextInteger(1, #possibleRooms)]
local newRoom = randomRoom:Clone()
newRoom.PrimaryPart = newRoom.Entrance
newRoom:PivotTo(prevRoom.Exit.CFrame)
newRoom.Parent = workspace.GeneratedRooms
return newRoom
end
return room
Server:
local room = require(script.Room)
local prevRoom = workspace.StartRoom
for i= 1, 15 do
prevRoom = room.Generate(prevRoom)
end
GnomeCode can you add a model in creator marketplace for the rooms so people that are bad at building/beginners can use them please?
yeah
also making doors style rooms is very easy (We do not talk about the stairs)
thanks this is helping me make my own doors spinoff i wanted and i am learning too
Thank you, it works perfect!
Thanks for the monster tutorial i got it and made my gam e looks cool !
amazing im gonna rewrite my entire code for room generation cuz this is way more optimised and configurable
this is a GOD tutorial, it really is something hard but nothing impossible
This is rlly talented 😮
I remember watching your first teddy tutorial when it came out I enjoy your vids Gnome
Finally, its out!
Best yt channel
great video!
That was great. Thank you.
This is pretty cool I like it. (:
I was so happy when I saw this
No WAIT you are doing toturial doors game, bro you're very good at what you do I'm inspired by you !!!
Can't wait to the next episode where we get introduced to doors!!!!! :D
i knew this would be uploaded
Pretty nice,thank you soooo much
Yo this is so helpful I’m gonna make a doors game soon thanks :)
ITS REALLY WORKED LOL THANK YOU DUDE
Fr you got no error?
Let's say the truth: GnomeCode is the best delevoper!
Very cool, thank you for your work)
By the way, i made a spiral-like generation (like tower, you know) based on your tutorial!)
I am sad that i cant make the Weight part but i will just copy rooms inside of Rooms folder lol. Also i am happy you made this episode insted of doors that will be ep3 cuz sometimes i generate only 10 rooms and i got blockades lol. GREAT work, continue working
Good job!
Also I’m wondering how do I make a game like rainbow friends?
Thanks Gnome Thanks
Are you going to be doing an load/unload, as having a ton of rooms loaded can het a bit laggy
at 17:30 I think it's best not to use float number because what you get from randomWeight (19:00) is always an integer
but he changes it next episode
Gnomecode uploading is the best thing ever! Will next episode have monsters btw?
No, the next episode will have doors, he said it at the end of the video. although I'm also looking forward to the "adding monsters" episode!
Gnome i have a question that if i make model in blender and rig it when i put the model in is it still rig? or if it still will it work?
Wow
Ima make this tomorrow
Im using these tutorials as a baseline for a horror game im making involving an abandoned house and like a monstror or something
Ive got room generation (no compleks) and woeking on a note system to expand the L O R E
Thank you gnomecode you really good at coding, I belive I will become pro like you
I mean, you will.
Thank you so much
YAY I WAITED AGES OMGOMG😄😄😄😄
Man, when I saw this I was like “He made another one!?!” And clicked on it immediately. Lol
I love how the comments are generating... Well done
I dont want (or have the time) to build the rooms, is there some sort of model that I can use, is what you used on your profile?
Hey, ik its a different topic but do you know how to make a button that makes you slide, i can't seem to find anywhere how to do it
cool dungeon generator!
Looking foward for when u add rush, screech etc
can u tell me how u made the new rooms?