Complex Room Generation - Doors Game Tutorial #2
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
Пікірлер: 1 300
I love how frequently you upload these new parts! It helps me alot with making this game while being short on time!
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.
@swiimer-the-topphat
Жыл бұрын
same
Wow, that's great! Keep up the good work!
@BoniDev
Жыл бұрын
Hi IULITMx !
@zeroplix
Жыл бұрын
IULITMx!
@tkn1ght493
Жыл бұрын
ayo, Why are you here wasnt expecting you lol
@Trazor_
Жыл бұрын
yo waddup
@jenjen2776
Жыл бұрын
yo
This is AWSOME and I can't wait for episode 3! I love your tutorials! ❤
just setting a stamp to remind myself: 5:20 Love your stuff! Keep up the great work!
This series is great! Can't wait for the next part :)
Love these videos gnome! Keep up the great work ❤
When he says” hello my fellow gnomes!” That is the best part Edit: thx for 35 likes!
@godzil7
Жыл бұрын
correct
@theunknowns999
Жыл бұрын
I'm actually not super late to a video
@despwned_PL
Жыл бұрын
I agree
@JJJ-ti2ys
Жыл бұрын
True
@KaylonPlayz
Жыл бұрын
Agreed
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!
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 have been waiting for this! Thanks gnomecode!
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
@BenGodot
Жыл бұрын
What do you mean?
@Erolsaurus
Жыл бұрын
@@BenGodot He means building the rooms on camera.
@andy-gamer
2 ай бұрын
Do u lack creativity or something
@doomsdomain
Ай бұрын
@@andy-gamer Yes i do
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.
@seojun1512
Жыл бұрын
Korean?
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!
@PsychoSigmaCat
Жыл бұрын
Just copy the exit part in ur room and put in a place
Another great Video for my doors at home Thank you GnomeCode For your great Work !
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.
@TheRageCommenter
Жыл бұрын
100%
@Sevznxy
Жыл бұрын
LSPLASH used Attributes for rooms, for example ["Weight"].
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"
@thatdogewithvr
Жыл бұрын
Which way is the orientation supposed to face?
@Pix_Ule
Жыл бұрын
i think it should be facing the same orientation as all the other models and parts
@HeldByStrings
Жыл бұрын
what happens with rooms that change orientation; Nvm, I got all Figured out, just make parts face the WAY to the exit.
@Nicolas99998
9 ай бұрын
Man you saved my ass❤❤
@Treviolation
21 күн бұрын
@@Nicolas99998 💀
I once made a random Road generator, These kind of systems are super fun to make!
Your room design looks beautiful.
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)?
@GnomeCode
Жыл бұрын
Lol! Somebody is actually paying attention. That is an excellent point...
@MonkyYoutube
Жыл бұрын
true
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.
@diamondcommandergaming
Жыл бұрын
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.
@arandomartist4341
Жыл бұрын
this isn't generation tho, it's just a room, no changes basically. which defeats the point of making every run to be unique
@OMGREALDUMMYFROMDVN
Жыл бұрын
@@arandomartist4341 It's generation that picks which room not manually it's literally the same as coding in
Really Thanks bro. Im waiting for the 3part
Keep them coming!! Thank you!!
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.
@syntaxicalecho8281
Жыл бұрын
Makes sense. Might also help with speed.
@akiprox7
Жыл бұрын
what
@syntaxicalecho8281
Жыл бұрын
@@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.
@jaydonNEWi
Жыл бұрын
1: lua does not need ";" 2: i tried to convert it to my vars but it did not work.
@me_ghxst
Жыл бұрын
@@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.
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.
@theoriginalandtrueamazonman
9 ай бұрын
gnome code ded :skull:
Thank you for explaining this thoroughly!
I've been waiting for this!
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.
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!
@RandomStickGuy
Жыл бұрын
yeah
@5d4a5
Жыл бұрын
@@RandomStickGuy yes please
@alessandrom.662
Жыл бұрын
yes please!
@KoalaOnYT_
Жыл бұрын
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
@RandomStickGuy
Жыл бұрын
@@KoalaOnYT_ plz make a model
ngl this is the best tutorial i have seen in years
cant wait for the new episode im alreadty excited!
Episode twooooo!
@notduck2110
Жыл бұрын
🥚
@Averageidiot1014
Жыл бұрын
ayee its Stroyosh!!
is there a video of you making the rooms ? i want to see the stairs part
@user-nh9pl9zj6z
10 ай бұрын
yeah same idk how to make those
@ArabGamesDeveloper
10 ай бұрын
@@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
Been watching you since a long time. You make the best tutorials!!!
@GnomeCode
Жыл бұрын
Thanks for sticking around!
@notcardi
Жыл бұрын
@@GnomeCode part 3 when
@fire.maniac.
Жыл бұрын
@@notcardi true 👀
Great work mate!
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.
@Fulion222
Жыл бұрын
same
@MasterGX_YT
3 ай бұрын
Same, I’ve even tried making a new game to restart and it keeps overlapping
Could you also add X-Sections? so 4 different directions. So its more like a maze rather than a long path.
@paopaothemaocow
Жыл бұрын
just make your own and change the property in the table to "XSection" or something
@GreenDragonGaming
Жыл бұрын
An 'x' or a '+' because a '+' is way easier.
@dallor714
Жыл бұрын
@@GreenDragonGaming essentially the same thing
TYSMMM, was waiting for this!
It's always a great day when you upload a vid!:)
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)
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
@XtraContent
Жыл бұрын
@thekittenisonfire I fixed it too, i forgor the long room 💀
@PickleGobler
Жыл бұрын
@Figure the T poser WAIT you guys mean the "attempt to index nil with "Stairs" ?? pleas tell how to solve
@beandevv
Жыл бұрын
@@PickleGobler i have the same problem... 17:59:56.819 ServerScriptService.Server.RoomModule:17: attempt to index nil with 'Stairs' - Server - RoomModule:17
@PickleGobler
Жыл бұрын
@@beandevv I kinda found the problem it was becuase I didnt add the start room to the room info module script
@PickleGobler
Жыл бұрын
@@beandevv quick tip when watching gnomce code or other youtubers that eplain code, you dont wanna skip any part
thanks this is helping me make my own doors spinoff i wanted and i am learning too
Yess ive been waiting for this
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)
@kthulu2
Жыл бұрын
he definitely will since that’s a core part of the game
@jtcrafty9204
Жыл бұрын
@@kthulu2 ya
@rosamariamaldonado6397
Жыл бұрын
Yeah
@ImReallyLemoBloxROFL
Жыл бұрын
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
@jtcrafty9204
Жыл бұрын
@@ImReallyLemoBloxROFL Have you done it before?
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
@Corrupie
Жыл бұрын
what does weight even mean
@Colognn
Жыл бұрын
@@Corrupie bruh didn't you saw the video?
@Corrupie
Жыл бұрын
@@Colognn nvm one of my friends helped me
@Colognn
Жыл бұрын
@@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
Yes! Part #2!!!! I love you
amazing im gonna rewrite my entire code for room generation cuz this is way more optimised and configurable
bruh i literally followed the script and the script just died it stopped generating rooms 😭 literally it is just the startroom
@zaydtruck3496
5 ай бұрын
Me too
@Rob3rt_YT
4 ай бұрын
Same
@Gumworm
4 ай бұрын
Go to view and press output and then run it to see the error
@MrocznyOpiekun
3 ай бұрын
Did you fix it?
@mythosarchive
3 ай бұрын
@@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"
Bruh. I need the models but I can't create it. But I'll attempt! :3
@redlight0502
5 ай бұрын
Me too
I remember watching your first teddy tutorial when it came out I enjoy your vids Gnome
Wow Great Work! Keep Making Tutorial Your AWESOME!
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 👍
@GnomeCode
Жыл бұрын
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
@TarokaWaste
Жыл бұрын
@@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?
@name-fr8rx
Жыл бұрын
@@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?
@RealDippy
Жыл бұрын
@@name-fr8rx same I’m confused on what to do
@name-fr8rx
Жыл бұрын
@@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.
I am making a game with random gen. THANK YOU MAN I NEED THIS
Amazing tutorial ❤
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. 💀
@GreenDragonGaming
Жыл бұрын
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?
@Kaizentry
Жыл бұрын
@@GreenDragonGaming mine line up perfectly fine, it's just the rooms that turn right and left cause it to generate in a full circle.
@fire.maniac.
Жыл бұрын
@@Kaizentry you scripted something wrong then
@Kaizentry
Жыл бұрын
@@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.
@PumpyGT
Жыл бұрын
@@Kaizentry I'm going to bet that these have something to do with your builds
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
@DarkTheDeveloper
7 ай бұрын
Oh, I forgot to remove that line of code too Thanks!
@cokomishi
4 ай бұрын
lol this was my issue as well, youre a godsend, was about to give up
thank you so much gnomecode!
Just Saving My Spot So I Can Continue 12:23 And Also Thanks Ive Wanted To Make A Doors Game For A While Now!
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?
@christinepak
Жыл бұрын
yeah
@HeldByStrings
Жыл бұрын
also making doors style rooms is very easy (We do not talk about the stairs)
this is a GOD tutorial, it really is something hard but nothing impossible
Thanks for the monster tutorial i got it and made my gam e looks cool !
Thank you, it works perfect!
No WAIT you are doing toturial doors game, bro you're very good at what you do I'm inspired by you !!!
Nice tutorial.... Very helpful
This is useful! you've earned a sub fr fr
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
Amazing Work! I Am Definitely Subscribing! :)
Thank you so much! I’m doing very well, your tutorials are amazing!
@ruslansmirnov9006
4 ай бұрын
lua scripts are not the best suitable tool for generating anything that large
Can't wait to the next episode where we get introduced to doors!!!!! :D
I was so happy when I saw this
That was great. Thank you.
Finally, its out!
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
This is rlly talented 😮
i knew this would be uploaded
Very cool, thank you for your work) By the way, i made a spiral-like generation (like tower, you know) based on your tutorial!)
not only you have to deal with corners when generating labyrinths, but also manage their traceability - the potential possibility to reach the exit, in short
Pretty nice,thank you soooo much
ITS REALLY WORKED LOL THANK YOU DUDE
@ProdByJuice.
Жыл бұрын
Fr you got no error?
Let's say the truth: GnomeCode is the best delevoper!
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
@dominicdurant5075
Жыл бұрын
but he changes it next episode
OMG I JUST NEEDED PART 2 THANK YOU FOR THIS PLEASE MAKE TUTORIAL FOR RUSHING ENTITIES NEXT PLEASE
@fan0
Жыл бұрын
YESSSSSS PEOPLE ARE MAKING CAPS CHAIN
@SusMystery
Жыл бұрын
@@fan0 YESSSSSSSSS PEOEPLE ARE SUPPORTING CAPTIALISM MAYBE NOT
@5d4a5
Жыл бұрын
YESSSSSSSSSSSSSSSSSSSSSSSSSS SUSPICIOUS MYSTERY SPELLED PEOPLE WRONG
@SusMystery
Жыл бұрын
@@5d4a5 YESSSSSS YOUR GONNA DIE 🎲?
@5d4a5
Жыл бұрын
@@SusMystery YESSSSSSSSSSSSSSS I USED MY UNO REVERSE CARD AND I USED ALL MY CARDS SO YOU CANT PLAY A UNO REVERSE CARD ANYMORE
This is pretty cool I like it. (:
great video!
I love how the comments are generating... Well done
Yo this is so helpful I’m gonna make a doors game soon thanks :)
Gnomecode uploading is the best thing ever! Will next episode have monsters btw?
@GamingMakesFun
Жыл бұрын
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!
Man, when I saw this I was like “He made another one!?!” And clicked on it immediately. Lol
for some reason on line 14 i get this error in the Room Module: ServerScriptService.Server.Room:14: attempt to index nil with 'Direction' can you help me with this?
Best yt channel
Bruh I always forget these are tutorials, I usually treat your videos as if I'm watching fundy showing off some random thing he made.
Are you going to be doing an load/unload, as having a ton of rooms loaded can het a bit laggy
Good job!
@CrazyNoobb
Жыл бұрын
Also I’m wondering how do I make a game like rainbow friends?
I got 2 15 second ads that I couldn’t skip and I was not happy that I wasn’t able to watch gnomecode
Thank you gnomecode you really good at coding, I belive I will become pro like you
@Ilike_brains
Жыл бұрын
I mean, you will.
Thanks Gnome Thanks
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?
Thank you so much