Add address to Transit System

I'm using the Transit System (http://docs.textadventures.co.uk/quest/transit_system.html)
When someone writes 'Visit address' the script asks 'Where do you want to go?' and then shows the list of available addresses/rooms.
That's fine, but is it possible to just add the address to the 'Visit address' command?
Let's say there is an address called 'D1 01', so the user can write 'Visit address D1' and it takes him to that room. It's okay if the script still shows the list of rooms, but the user should be able to just write 'visit address D1 01'.

This is the 'Visit address' command right now:

  msg ("Der kan du ikke tage hen.")
}
else {
  sl = NewStringList()
  foreach (key, game.destinations) {
    if (not ObjectDictionaryItem(game.destinations, key) = player.parent) {
      list add (sl, key)
    }
  }
  ShowMenu ("Hvilken adresse vil du besøge?", sl, true) {
    dest = ObjectDictionaryItem(game.destinations, result)
    msg ("Du tager til " + result)
    player.parent = dest
  }
}```

Hmm. What are the destinations' aliases?

If D1 01 is also the alias of the destination, you could use the parser to do it for you.

Give the command a pattern like: ^visit address\s*(?<object>\S.*)?$.
Then add a script attribute named changecommandscope to the command:

while (ListCount (items) > 0) {
  list remove (items, ListItem (items, 0))
}
foreach (dest, game.destinations) {
  list add (items, DictionaryItems (game.destinations, dest))
}

This basically uses the parser's object matching system, the same as when the player types the name of an object they can see. It just changes the list of available objects to those that appear in game.destinations.

then you could change the script to:

if (IsDefined("object")) {
  player.parent = object
}
else {
  // this part runs if the player doesn't type a destination
  // put the existing script here
}

If the address the player needs to type is not the same as the room's alias, it would be a little tougher. I'd probably do it by making a room full of objects that map onto the rooms. For example, you could make an object with the alias D1 01 and its to attribute pointing to the actual room. Then you could put all these objects in a room that the player can't reach, and change the scope of the command to that room's name. In that case you don't need a changecommandscope script (but you do need to make a bunch of extra objects)

Hope I got that right :)


mrangel, thank you! I tested your idea and after a bit of tweaking it works, but I actually like your second idea better: Objects that map onto rooms.
Another question, if you don't mind:
Is there a way to insert a command as a button?
For example at the top of every page when they visit a room. Can I insert, using a 'when entering room script', a button with a specific command?


Yes, you can add buttons or links anywhere in your code.
If you want it to appear for every room, there is a script on the game object which is run when entering a room.

As far as adding a button goes, the simplest way would just be to use a command link. For example:

msg ("{command:talk to yourself}")

or whatever command you want to use. Clicking the link is exactly the same as typing in the command.
If you want, you can have two parts separated by a colon:

msg ("{command:wait:hang around for a while}")

The first part ("wait") is the command that is entered when the player clicks it; and the second part ("hang around for a while") is what it says on the link.


Super, thank you for your kind help!
Btw, I asked a question on the forum the other day, about dialogues. Could I ask you to see if it is something you can help me with:
Link.

Carsten.


Sorry, I'm not familiar with the way ConvLib handles things. I'd hope someone who knows it will be able to help you


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

Support

Forums