Ordering exits

OK, I'm using a randomly-generated area (specific rooms, but arranged randomly). Almost every "room" in the forest has 4 exits for the cardinal compass points. And it's turned out to be oddly distracting when I play the game: Every room displays the exits in a different order. I'm assuming that ScopeExits() returns the exits in the order they were created or something, and the default ShowRoomDescription() just lists them in that order.

Is there a way to change the order of exits in a room? Is there a flag somewhere that I've missed to sort them?
If ScopeExits() orders them by the order they were added to the room, I guess I could loop over the exits, move them into a temporary room and then move them back in a consistent order. But if it's ordering them by name, there's not much I can do about it. Is it worth experimenting; or is this something with a known solution?


Would it be easier to turn off rom exits list while in the forest? Just wondering.


I did something similar in Deeper, which is a randomly generated dungeon. I had the exits described in the text as part of the room description, so I could add flavour text ("there is a broken wooden door to the north and a narrow passge east").

I'm assuming that ScopeExits() returns the exits in the order they were created or something, and the default ShowRoomDescription() just lists them in that order.

I think that that is the case. Objects definitely work like that, and I assume exits do too.


I think that that is the case. Objects definitely work like that, and I assume exits do too.

Have now confirmed that the exits are listed in order of creation, not the order they were added to the room. It shouldn't be a big deal, but it looks ugly. I guess the only way to fix it is to remove the automatic exit list and make my own; which would be way more trouble than it's worth.


If you are generating them, can you not generate them in order?


Can you use:

StringListSort
http://docs.textadventures.co.uk/quest/functions/stringlistsort.html

Or
ObjectListSort
http://docs.textadventures.co.uk/quest/functions/objectlistsort.html


Doctor Agon: If I was writing a script that needed a list, yes. But on the web version it would be a big pain to add a line in the middle of one of the core functions. It would likely mean adding code to almost every room, which would likely make it harder if I have other rooms that want to do something complex later on.

Unless… I could disable game.autodescription_youcango; then create a dummy scenery object. Have the player's changedparent script move the dummy object to the room you're in, and set its inroomdescription to a "You can go :" line with the exits sorted. Does that seem like it would work?


Sorry, only trying to help. I thought the answer might lie in the function ShowRoomDescription, and by altering the way the exits are formatted into their list, you might be able to list the exits alphabetically.

exits = FormatExitList(game.pov.parent.exitslistprefix, GetExitsList(), Template("Or"), ".")

Sorry, didn't intend to sound sarcastic there.

I'd be interested to hear what you have in mind: Where would I put the modified code? Can you suggest anything better than a scenery object acting as an exit list? (which seems clunky, but possible)


Not really sure. I've looked at the code but I can't seem to get it to work the way I thought it should. I mean, after all, everything in the game from the objects you can pick up, to the exits, even the player itself, is an object, so you should in theory, be able to order the exit list into alphabetical order, if you can find the right coded function, without resorting to some cluncky clumsy bodge.


Well, I tried the bodge. It works, but it's really ugly and likely to break other things.

The other option seems to be making a complete copy of the OnEnterRoom() and ShowRoomDescription() functions from the core code, and then making a couple of changes to them. That's looking simpler than I initially thought; it's just a huge copy-paste. Just have to make sure I modify everywhere those functions are called from to make sure it always uses my version.


K.V.
x = ScopeUnlockedExitsForRoom(game.pov.parent)
y = NewStringList()
foreach (o, x) {
  list add (y, o.name)
}
y = (StringListSort(y))
game.exits = NewObjectList()
foreach (exit, y) {
  list add (game.exits, GetObject(exit))
}
DisplayList (game.exits, false)

KV ... I'm not sure what you're trying to do there. Turn a list of objects into a list of strings and back again?

The question is whether there's an easier way to get custom output into the room description; do I really have to make custom functions replicating the entire behaviour of OnEnterRoom(oldvalue) and ShowRoomDescription(), just to change the order of one list?


K.V.

Oh!

I thought we wanted the exits in alphabetical order by name for some reason.

I'll go play with the correct thing, and I shall return.


Actually, I think I'm going to make a custom player.changedparent, that calls my own OnRoomEnter and ShowRoomDescription(). The implementation of that function is kind of awkward, and I think I can come up with a version that deals more sanely with onenter scripts that move you to a different location. And also tweak the room description script so that ticking "new line after …" doesn't result in multiple consecutive line breaks if the sections don't exist.


K.V.

I don't like multiple consecutive line breaks!

I also don't like it when ShowMenu clears a long menu!!!

...okay. I'm done complaining now.


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

Support

Forums