• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Legacy GM Many problems with Room functions

I

Irish_Jigger

Guest
Sorry this is a long post, but its by far the worst experience I've had with GMS functions. Other than this, I've had little to no issues with the engine other than some nitpicks/preferences.

Here are the functions I've used, with little to no success, or just have problems with
room_assign(ind, room)
room_instance_clear(id)
room_duplicate(id)

Context:
Im making dungeon generation, which does floors at a time, with many rooms per floor (think isaac or pokemon dungeon). I figured that creating rooms on the fly would be appropriate use of these functions.
I've already decided on an alternate way to do this without using the room functions, so this isn't for help. It's more of a report.

Closest Success: room_duplicate (functionality isn't that bad)
For each room in the floor I called room duplicate on a prebuilt room that I've made in editor, when I visit the newly created room, it looks the same as the duplicated room.
However, room_duplicate always creates a new room, which in the case of how my dungeons floors are temporary, and once moving on, the game will never reuse it, this is not ideal as memory is constantly leaking as I loose references to these rooms.
At first I thought this was no problem as I could call room_delete, but that function doesn't exists -- there's no way to delete a room from what I could find (why? even if rooms are stored in a container type with a slow delete, it should still be an option. Or just use a different container).
Somebody suggested that I use room_instance_clear to reduce the memory use of these lost rooms, but even under a simple test of instantly clearing instances from these freshly duplicated rooms, they still appeared the same; actually I found that they cleared the source room that they duplicated from (although not in every case I tested).
So I scrapped the idea of using room_duplicate due to inefficient memory usage.

Actually Confused: room_assign() (what is even going on with this)
So for this test, I created 3 rooms (created in editor, not with duplicate or add), lets call them room1, room2, and room3.
room1 and room2 only contain objects with the default variables (so its basically just a sprite on screen).
room3 contains objects I use for my game, so its similar to any room you'd expect to find in a game- the objects have unique variables for their use ie. z, timer, etc.
Here are some test results:
room_assign(room1, room2) overwrites room1 to appear as room2, room2 remains the same (which contradicts the order of the documentation?)
likewise, room_assign(room2, room1) overwrites room2 to appear as room1
also, room_assign(room3, room2) overwrites room3 with room2
So, minus the confusion of the parameter's ordering, its working as I thought.
However, copying FROM room3 causes issues.
as soon as I call room_assign(room2, room3) the game crashes.
It specifically crashes because the objects are referencing undeclared variables (ones that I clearly declare in their respective create event).
So I suspect that room_assign bypasses the create function for whatever reason??
I've tried different test cases on when I call the function, before/after visiting room3, calling it inside of room3, calling it inside of the room its assigning to (not recommended apparently, but I recommend not using this).

I honestly don't know if I'm misusing these functions- but given the quantity of documentation given to them, they are seemingly "intuitive" to use, so I really don't see my situation being an edge case.

A "simple" example which doesn't seem to work

var pRoom = room_duplicate(Room_Sampler);
room_instance_clear(pRoom);
room_goto(pRoom);

This goes to a room identical to Room_Sampler, not one with "cleared instances"
 
I encounter the same problem about room_assign(ind source) like you . I get a error report says that I have used variable undefined in step but I have set it in create before . Have you solve that ?
 

tylorlilley

Member
I am encountering these same issues as well... it's a shame these bugs weren't fixed. You mentioned having a work around for these issues that worked for you; would you mind letting me know what you did? It may or may not work for me, but I definitely feel a bit stuck at the moment without being able to use these functions as intended...
 

renex

Member
couldn't you just add a room if you need a room with nothing on it?

if you need views and stuff you can set them after going to the room.
 
Top