Listing Exits in Game (FYI)

Forgewright
15 Mar 2018, 04:23

When we say the four directions in conversations with people, we will say, "North, South, East and West". Right? So, it looks better if the same goes for listing them in-game. The game will list them in the order we created them and this will look odd.(at least it does to me).
I have been using Quest for several years and up until recently I would move all the exits to another room and then move them back in the order I wanted.
Then a few days ago I noticed on the exit tab of whatever room your in, at the bottom of the page it show a list of exits. The header of this list allows you to edit them but finally I noticed the 'Move' option with up and down arrows.

Sheesh. Always a nugget of unnoticed convenience hiding in there somewhere...

Figured If I did it then someone else might need to know.


Doctor Agon
15 Mar 2018, 07:45

@Forgewright.
I second your 'Sheesh'


K.V.
18 Mar 2018, 19:14

You could add this modified FormatExitList() to your game in full code view.


I'm accustomed to north, east, west, south, but this is in the order you described.


EDITED

<function name="FormatExitList" parameters="preList, list, preFinal, postList" type="string"><![CDATA[
    result = ""
    sortedlist = NewList()
    // You can change the order inside of this split:
    dirs = Split("north;northeast;northwest;south;southeast;southwest;east;west;fore;aft;starboard;port;in;out;up;down")
    foreach (d, dirs) {
      foreach (exit, list) {
        if (exit.alias = d) {
          list add (sortedlist, exit)
        }
      }
    }
    list = sortedlist
    listLength = ListCount(list)
    if (listLength > 0) {
      count = 0
      result = preList + " "
      foreach (item, list) {
        result = result + GetDisplayNameLink(item, "exit")
        count = count + 1
        if (count = listLength - 1) {
          result = result + " " + preFinal + " "
        }
        else if (count < listLength) {
          result = result + ", "
        }
      }
      result = result + postList
    }
    return (result)
  ]]></function>

Forgewright
18 Mar 2018, 19:18

KV
What if you made it a type script inherited by all rooms. Wouldn't it be automatic?


K.V.
18 Mar 2018, 19:24

What if you made it a type script inherited by all rooms. Wouldn't it be automatic?

You can't return a list of rooms in a published game unless you manually add an attribute (or type) to each room beforehand.

Adding that one modified function to your code would make it automatically list exits in the order set inside of that Split() everywhere in the game, without fiddling with anything else.

// You can change the order inside of this split:
dirs = Split("north;northeast;northwest;south;southeast;southwest;east;west;fore;aft;starboard;port;in;out;up;down")

Not to say that you couldn't do it with types, but this just seems easier.