Creating exits to rooms that don't exist yet

Hi, I've been reading and trying things from the forum for a while, but this is my first question that I can't seem to crack. There might be a really simple answer.

I want the player to enter a room, and then this creates a new room with an exit so the player can get to the new room. I can create the room OK, but I can't seem to work out how to refer to the new room in the create exit part. I tried doing it like this (I'm naming the rooms based on a coordinate position):

create ("World" + player.nextxn + "" + player.nextyn + "", "New Room")
player.nextroomn = "World" + player.nextxn + "
" + player.nextyn + ""
create exit ("north", player.parent, player.nextroomn)

The problem seems to be that Quest isn't recognising 'player.nextroomn' as an object - even though the wording is the same and it is recognising player.parent as an object - and I can't work out how to define that attribute as an object. I tried referring to the new room directly using the same code as the name:

create exit ("north", player.parent, "World" + player.nextxn + "_" + player.nextyn + "")

but that doesn't seem to work either.

Or am I missing something simple here?
Thanks for your help!


Your second line needs to be this:

player.nextroomn = GetObject("World" + player.nextxn + "" + player.nextyn + "")

As it is you ae setting it to the name of the room (i.e., a string), you need to set it to an object with that name.


Ah - thought it might be something as simple as that, I just didn't know what it was.

Thanks for taking the time to help! Glad I asked!


Follow up question (inevitably):

This creates the exit and the room OK but I'm having trouble getting the room to appear on the map. When you move into it nothing happens on the map at all.

I wondered if this was something to do with the attributes of the new room / exit; using types I tried to define them the same as any other room but the only difference seems to be grid_render - and when I mark this as true it returns a lot of error messages when you move into it.

Any thoughts on getting a newly created room to appear on the map as normal?

Thanks again!


I have never really used the map, but it is likely there are attributes on the room that Quest is expecting to draw it, such as its width and height. Are you creating the rooms of the type "defaultobject"? I would guess that would fix it.

If you are using the desktop version, look at the attributes for any room; all the ones in grey come from "defaultobject", and several look to be grid-related.


Thanks for the reply - I'm afraid that doesn't do it. The new room gets the defaultobject attributes anyway and it doesn't seem to make any difference if I specify all the grid attributes as a new type.

I do think it has something to do with type attributes though as I did get it working for a while, but then somehow lost it again!


Can't you just make exit visible after an event triggers it?


Why does the room not have to exist if the player has never been there? Only you the author,would know anyway.


Yes of course (that would be simpler), but then I would have to define all the rooms and exits before the game runs and that's not quite what I'm after in this case.


If you are using the desktop version, start playing, and click on the Debugger at the top, leftish. Check what attributes a room normally has, compared to those your created rooms have. You can list attributes alphabetically by clicking the top of the column. In particular, check those that start "grid" (there looks to be eleven of them).


Thanks - checked and they're identical, but the new room just isn't on the map. Same for the exits. Is there some internal command to draw the room getting missed or something?


This is the error message I get when grid.render is set as True (and then I think it is trying to draw the room but this happens):
Error running script: Error evaluating expression 'DictionaryItem(coordinates, coordinate)': The given key was not present in the dictionary.
Error running script: Error evaluating expression 'DictionaryItem(coordinates, coordinate)': The given key was not present in the dictionary.
Error running script: Error evaluating expression 'DictionaryItem(coordinates, coordinate)': The given key was not present in the dictionary.
Error running script: Error evaluating expression 'DictionaryItem(coordinates, coordinate)': The given key was not present in the dictionary.
Error running script: Error evaluating expression 'DictionaryItem(coordinates, coordinate)': The given key was not present in the dictionary.
Error running script: Error evaluating expression 'DictionaryItem(coordinates, coordinate)': The given key was not present in the dictionary.

Does this give a clue to anyone?! Appreciate your suggestions.


you could try turning off the map/grid, creating and moving-to the new room, and then turning back on the map, as this comes up when using scripting to move to rooms (no Exit usage) and using the map/grid.


Got it sorted! Turns out the problem was that the script for creating the new room and exits needed to be before entering the previous room and not after. I think that meant the exit wasn't completely created before you tried to use it so it wasn't behaving properly. Don't fully understand why that made a difference but glad to have resolved it! With a bit of extra coding I've now got myself infinite rooms going in one direction which is what I was after.

Thanks for your help!


Don't fully understand why that made a difference

missing pointers. The map didn't have any idea which way it came from/went to until you created the exit.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums