[Solved] The Compass doesn't show diagonal exits/directions

I'm playing around with random room generations. As the player moves rooms generate in all 8 directions: N, S, E, W, NE, SE, NW, SW

Problem is, the compass don't show: NE, SE, NW, SW
They stay grayed out.

Also weird, the Places and Objects pane doesn't show: N, S, E, W
... but it shows: NE, SE, NW, SW
(Though I don't plan to use that pane. Just activated it to see if it is the same as the compass)

The exit list in the automatic room description shows all 8 directions.

My main problem is the compass!

Here is how the rooms and exits are generated and connected:

Before first enter script:

// ### CHECKS IF the room to the NORTH is already created and creates it if not.
gen_n = true
foreach (ar, GetDirectChildren(z_world_map_1)) {
  // ### CHECKS X/Y
  if (ar.coord_y = this.coord_y + 1 and ar.coord_x = this.coord_x) {
    gen_n = false
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(this), "alias", "north")) {
      RemoveObject (xt)
    }
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(ar), "alias", "south")) {
      RemoveObject (xt)
    }
    create exit ("north", this, ar, "northdirection")
    newexit = GetObject(GetExitByLink(this, ar))
    newexit.grid_length = 0
    create exit ("south", ar, this, "southdirection")
    newexit = GetObject(GetExitByLink(ar, this))
    newexit.grid_length = 0
  }
  // ### CREATES A ROOM IF the room to the NORTH is Not EXISTING.
  if (gen_n = true) {
    new_area = CloneObjectAndMove (PickOneObject(GetDirectChildren(z_random_room_generation)), z_world_map_1)
    do (new_area, "gen_n")
    gen_n = false
  }
}
// ### CHECKS IF the room to the SOUTH is already created and creates it if not.
gen_s = true
foreach (ar, GetDirectChildren(z_world_map_1)) {
  // ### CHECKS X/Y
  if (ar.coord_y = this.coord_y - 1 and ar.coord_x = this.coord_x) {
    gen_s = false
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(this), "alias", "south")) {
      RemoveObject (xt)
    }
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(ar), "alias", "north")) {
      RemoveObject (xt)
    }
    create exit ("south", this, ar, "southdirection")
    newexit = GetObject(GetExitByLink(this, ar))
    newexit.grid_length = 0
    create exit ("north", ar, this, "northdirection")
    newexit = GetObject(GetExitByLink(ar, this))
    newexit.grid_length = 0
  }
  // ### CREATES A ROOM IF the room to the SOUTH is Not EXISTING.
  if (gen_s = true) {
    new_area = CloneObjectAndMove (PickOneObject(GetDirectChildren(z_random_room_generation)), z_world_map_1)
    do (new_area, "gen_s")
    gen_s = false
  }
}
// ### CHECKS IF the room to the EAST is already created and creates it if not.
gen_e = true
foreach (ar, GetDirectChildren(z_world_map_1)) {
  // ### CHECKS X/Y
  if (ar.coord_y = this.coord_y and ar.coord_x = this.coord_x + 1) {
    gen_e = false
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(this), "alias", "east")) {
      RemoveObject (xt)
    }
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(ar), "alias", "west")) {
      RemoveObject (xt)
    }
    create exit ("east", this, ar, "eastdirection")
    newexit = GetObject(GetExitByLink(this, ar))
    newexit.grid_length = 0
    create exit ("west", ar, this, "westdirection")
    newexit = GetObject(GetExitByLink(ar, this))
    newexit.grid_length = 0
  }
  // ### CREATES A ROOM IF the room to the EAST is Not EXISTING.
  if (gen_e = true) {
    new_area = CloneObjectAndMove (PickOneObject(GetDirectChildren(z_random_room_generation)), z_world_map_1)
    do (new_area, "gen_e")
    gen_e = false
  }
}
// ### CHECKS IF the room to the WEST is already created and creates it if not.
gen_w = true
foreach (ar, GetDirectChildren(z_world_map_1)) {
  // ### CHECKS X/Y
  if (ar.coord_y = this.coord_y and ar.coord_x = this.coord_x - 1) {
    gen_w = false
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(this), "alias", "west")) {
      RemoveObject (xt)
    }
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(ar), "alias", "east")) {
      RemoveObject (xt)
    }
    create exit ("west", this, ar, "westdirection")
    newexit = GetObject(GetExitByLink(this, ar))
    newexit.grid_length = 0
    create exit ("east", ar, this, "eastdirection")
    newexit = GetObject(GetExitByLink(ar, this))
    newexit.grid_length = 0
  }
  // ### CREATES A ROOM IF the room to the WEST is Not EXISTING.
  if (gen_w = true) {
    new_area = CloneObjectAndMove (PickOneObject(GetDirectChildren(z_random_room_generation)), z_world_map_1)
    do (new_area, "gen_w")
    gen_w = false
  }
}
// ### CHECKS IF the room to the NORTH-EAST is already created and creates it if not.
gen_ne = true
foreach (ar, GetDirectChildren(z_world_map_1)) {
  // ### CHECKS X/Y
  if (ar.coord_y = this.coord_y + 1 and ar.coord_x = this.coord_x + 1) {
    gen_ne = false
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(this), "alias", "north-east")) {
      RemoveObject (xt)
    }
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(ar), "alias", "south-west")) {
      RemoveObject (xt)
    }
    create exit ("north-east", this, ar, "northeastdirection")
    newexit = GetObject(GetExitByLink(this, ar))
    newexit.grid_length = 0
    create exit ("south-west", ar, this, "southwestdirection")
    newexit = GetObject(GetExitByLink(ar, this))
    newexit.grid_length = 0
  }
  // ### CREATES A ROOM IF the room to the NORTH-EAST is Not EXISTING.
  if (gen_ne = true) {
    new_area = CloneObjectAndMove (PickOneObject(GetDirectChildren(z_random_room_generation)), z_world_map_1)
    do (new_area, "gen_ne")
    gen_ne = false
  }
}
// ### CHECKS IF the room to the SOUTH-EAST is already created and creates it if not.
gen_se = true
foreach (ar, GetDirectChildren(z_world_map_1)) {
  // ### CHECKS X/Y
  if (ar.coord_y = this.coord_y - 1 and ar.coord_x = this.coord_x + 1) {
    gen_se = false
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(this), "alias", "south-east")) {
      RemoveObject (xt)
    }
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(ar), "alias", "north-west")) {
      RemoveObject (xt)
    }
    create exit ("south-east", this, ar, "southeastdirection")
    newexit = GetObject(GetExitByLink(this, ar))
    newexit.grid_length = 0
    create exit ("north-west", ar, this, "northwestdirection")
    newexit = GetObject(GetExitByLink(ar, this))
    newexit.grid_length = 0
  }
  // ### CREATES A ROOM IF the room to the SOUTH-EAST is Not EXISTING.
  if (gen_se = true) {
    new_area = CloneObjectAndMove (PickOneObject(GetDirectChildren(z_random_room_generation)), z_world_map_1)
    do (new_area, "gen_se")
    gen_se = false
  }
}
// ### CHECKS IF the room to the NORTH-WEST is already created and creates it if not.
gen_nw = true
foreach (ar, GetDirectChildren(z_world_map_1)) {
  // ### CHECKS X/Y
  if (ar.coord_y = this.coord_y + 1 and ar.coord_x = this.coord_x - 1) {
    gen_nw = false
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(this), "alias", "north-west")) {
      RemoveObject (xt)
    }
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(ar), "alias", "south-east")) {
      RemoveObject (xt)
    }
    create exit ("north-west", this, ar, "northwestdirection")
    newexit = GetObject(GetExitByLink(this, ar))
    newexit.grid_length = 0
    create exit ("south-east", ar, this, "southeastdirection")
    newexit = GetObject(GetExitByLink(ar, this))
    newexit.grid_length = 0
  }
  // ### CREATES A ROOM IF the room to the NORTH-WEST is Not EXISTING.
  if (gen_nw = true) {
    new_area = CloneObjectAndMove (PickOneObject(GetDirectChildren(z_random_room_generation)), z_world_map_1)
    do (new_area, "gen_nw")
    gen_nw = false
  }
}
// ### CHECKS IF the room to the SOUTH-WEST is already created and creates it if not.
gen_sw = true
foreach (ar, GetDirectChildren(z_world_map_1)) {
  // ### CHECKS X/Y
  if (ar.coord_y = this.coord_y - 1 and ar.coord_x = this.coord_x - 1) {
    gen_sw = false
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(this), "alias", "south-west")) {
      RemoveObject (xt)
    }
    foreach (xt, FilterByAttribute (ScopeExitsForRoom(ar), "alias", "north-east")) {
      RemoveObject (xt)
    }
    create exit ("south-west", this, ar, "southwestdirection")
    newexit = GetObject(GetExitByLink(this, ar))
    newexit.grid_length = 0
    create exit ("north-east", ar, this, "northeastdirection")
    newexit = GetObject(GetExitByLink(ar, this))
    newexit.grid_length = 0
  }
  // ### CREATES A ROOM IF the room to the SOUTH is Not EXISTING.
  if (gen_sw = true) {
    new_area = CloneObjectAndMove (PickOneObject(GetDirectChildren(z_random_room_generation)), z_world_map_1)
    do (new_area, "gen_sw")
    gen_sw = false
  }
}

Script Attributes that runs after a random room is cloned.

this.gen_n => {
  this.coord_x = player.parent.coord_x
  this.coord_y = player.parent.coord_y + 1
  create exit ("north", player.parent, this, "northdirection")
  newexit = GetObject(GetExitByLink(player.parent, this))
  newexit.grid_length = 0
  create exit ("south", this, player.parent, "southdirection")
  newexit = GetObject(GetExitByLink(this, player.parent))
  newexit.grid_length = 0
  do (this, "set_alias")
}
this.gen_s => {
  this.coord_x = player.parent.coord_x
  this.coord_y = player.parent.coord_y - 1
  create exit ("south", player.parent, this, "southdirection")
  newexit = GetObject(GetExitByLink(player.parent, this))
  newexit.grid_length = 0
  create exit ("north", this, player.parent, "northdirection")
  newexit = GetObject(GetExitByLink(this, player.parent))
  newexit.grid_length = 0
  do (this, "set_alias")
}
this.gen_e => {
  this.coord_x = player.parent.coord_x + 1
  this.coord_y = player.parent.coord_y
  create exit ("east", player.parent, this, "eastdirection")
  newexit = GetObject(GetExitByLink(player.parent, this))
  newexit.grid_length = 0
  create exit ("west", this, player.parent, "westdirection")
  newexit = GetObject(GetExitByLink(this, player.parent))
  newexit.grid_length = 0
  do (this, "set_alias")
}
this.gen_w => {
  this.coord_x = player.parent.coord_x - 1
  this.coord_y = player.parent.coord_y
  create exit ("west", player.parent, this, "westdirection")
  newexit = GetObject(GetExitByLink(player.parent, this))
  newexit.grid_length = 0
  create exit ("east", this, player.parent, "eastdirection")
  newexit = GetObject(GetExitByLink(this, player.parent))
  newexit.grid_length = 0
  do (this, "set_alias")
}
this.gen_ne => {
  this.coord_x = player.parent.coord_x + 1
  this.coord_y = player.parent.coord_y + 1
  create exit ("north-east", player.parent, this, "northeastdirection")
  newexit = GetObject(GetExitByLink(player.parent, this))
  newexit.grid_length = 0
  create exit ("south-west", this, player.parent, "southwestdirection")
  newexit = GetObject(GetExitByLink(this, player.parent))
  newexit.grid_length = 0
  do (this, "set_alias")
}
this.gen_se => {
  this.coord_x = player.parent.coord_x + 1
  this.coord_y = player.parent.coord_y - 1
  create exit ("south-east", player.parent, this, "southeastdirection")
  newexit = GetObject(GetExitByLink(player.parent, this))
  newexit.grid_length = 0
  create exit ("north-west", this, player.parent, "northwestdirection")
  newexit = GetObject(GetExitByLink(this, player.parent))
  newexit.grid_length = 0
  do (this, "set_alias")
}
this.gen_nw => {
  this.coord_x = player.parent.coord_x - 1
  this.coord_y = player.parent.coord_y + 1
  create exit ("north-west", player.parent, this, "northwestdirection")
  newexit = GetObject(GetExitByLink(player.parent, this))
  newexit.grid_length = 0
  create exit ("south-east", this, player.parent, "southeastdirection")
  newexit = GetObject(GetExitByLink(this, player.parent))
  newexit.grid_length = 0
  do (this, "set_alias")
}
this.gen_sw => {
  this.coord_x = player.parent.coord_x - 1
  this.coord_y = player.parent.coord_y - 1
  create exit ("south-west", player.parent, this, "southwestdirection")
  newexit = GetObject(GetExitByLink(player.parent, this))
  newexit.grid_length = 0
  create exit ("north-east", this, player.parent, "northeastdirection")
  newexit = GetObject(GetExitByLink(this, player.parent))
  newexit.grid_length = 0
  do (this, "set_alias")
}

I believe the decision on whether to display an exit in the "compass" or "placesandobjects" pane is determined by whether its alias is in this JS array:

var _compassDirs = ["northwest", "north", "northeast", "west", "east", "southwest", "south", "southeast", "up", "down", "in", "out"];

You seem to be creating exits with aliases like "north-east", which isn't in the list.

You can change this array by doing (presumably in your UI initialisation script):

JS.setCompassDirections ("north-west;north;north-east;west;east;south-west;south;south-east;up;down;in;out")

(EDIT: corrected the separator symbol)
I've not tested this method; so I could be missing something, but I think it should work.


You can change this array by doing (presumably in your UI initialisation script):
JS.setCompassDirections ("north-west/north/north-east/west/east/south-west/south/south-east/up/down/in/out")
I've not tested this method; so I could be missing something, but I think it should work.

This script made all directions in the Compass disappear (grayed out)
but now all directions appear in the Places and Objects Pane. (before it showed only the 4 missing directions from the Compass.)


Sorry, should be ; rather than / in the list.

The argument to setCompassDirections is a string containing all direction names (in that specific order) with ; between them. The argument to updateCompass (automatically called by Quest) is a string containing the aliases of all currently visible exits, with / between them.
It's hard to remember what the separator is for all the JS functions; sorry about that.


Sorry, should be ; rather than / in the list.

Thanks, that's a bit closer...
Now the compass shows all directions, but when clicking on NW, SW, NE, SE, the game says: "I don't understand your command."


That's because "north-west" isn't a command.
You'll need to change the pattern of the go command if you want to use nonstandard direction names.

Or replace the function:

JS.eval("compassClick = function(direction) {sendCommand('go '+direction)};")

(off the top of my head)


...if you want to use nonstandard direction names.

Funny, now when I think about it, I don't need to keep the nonstandard names. I'm not going to use the room description's exit list, anyway.

Or replace the function:

JS.eval("compassClick = function(direction) {sendCommand('go '+direction)};")

This script is working, too. Though, I think I just gonna change the names to the standard names. May mess less things up down the road.

You'll need to change the pattern of the go command...

BTW, earlier I used the expression {command:go north-east:NE} and it worked. A bit weird that it doesn't work for the UI..


Log in to post a reply.

Support

Forums