Use specific words to Exit a room

Diorm
11 Dec 2017, 00:51

Hey all! I would like to be able to enter specific words (one or two) to exit a room and enter a new one.
Exemple: I write Apple. then I teleport to the next too linked to this one. Or I write Big Apple to do the same.
Is it possible?


J_J
11 Dec 2017, 09:47

Could you be a little more specific. Would this be a game where at any point in any room you can type a code to teleport, or would you, say, enter a teleporting device once you've finished the puzzles in a room.


mrangel
11 Dec 2017, 13:43

If you just type the words to go to the next room, then I'd suggest creating a command within the room. You can specify multiple versions in a command's pattern, separating them with a semicolon.


Diorm
11 Dec 2017, 22:36

Enter a specific word in a specific room to teleport to another specific room. Because If I enter another word in the same room, it will teleport me to another specific room tied to that word.

More like a menu you see?

Description of the room:

Welcome to this computer yadda yadda.
Mails
Notes
Pictures

Then if I write Notes, I will teleport to the room with Notes.

Something like MS-DOS.


hegemonkhan
12 Dec 2017, 13:09

I was trying to make a dynamic/universal system for you, but it's too hard/much-work for me to do easily...

you can try looking at this code stuff of mine for some examples:

http://textadventures.co.uk/forum/samples/topic/4988/character-creation-crude-code-and-sample-game

http://textadventures.co.uk/forum/samples/topic/5138/explore-and-travel-code-sample-by-hk

if you need help with anything, let me know


J_J
13 Dec 2017, 06:10

K.V. recently helped me do something similar by creating a function. I modified it to show you how you could use it for your game. I would have the computer have a verb attached to it like "login" which would then run the function.
Here is what the function its self would look like:

get input {
  if (result = "blue") {
    msg ("You choose the blue room.")
    MoveObject (player, Blue Room)
  }
  else if (result = "red") {
    msg ("You choose the red room.")
    MoveObject (player, Red Room)
  }
  else if (result = "log out") {
    msg ("You log out of the computer.")
  }
  else {
    msg ("The computer doesn't understand your command.")
    login
  }
}

J_J
13 Dec 2017, 06:13

Here is what it would look like in a game. I'm not sure if this is helpful, but you can copy and paste this into a new game, so you can see what it would look like in the editor. I'm sure others will have more advice.

<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="test2">
    <gameid>6f5b3407-0f8d-42a2-a6b6-fefbf6ec2849</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="computer">
      <inherit name="editor_object" />
      <login type="script"><![CDATA[
        msg ("You login to the computer. I menu appears:<br/><br/>Type blue to transport to the Blue Room<br/>Type red to transpor to the Red Room<br/>Type log out to exit the computer")
        login
      ]]></login>
    </object>
  </object>
  <object name="Blue Room">
    <inherit name="editor_room" />
  </object>
  <object name="Red Room">
    <inherit name="editor_object" />
  </object>
  <verb>
    <property>log</property>
    <pattern>log</pattern>
    <defaultexpression>"You can't log " + object.article + "."</defaultexpression>
  </verb>
  <verb>
    <property>login</property>
    <pattern>login</pattern>
    <defaultexpression>"You can't login " + object.article + "."</defaultexpression>
  </verb>
  <function name="login">
    get input {
      if (result = "blue") {
        msg ("You choose the blue room.")
        MoveObject (player, Blue Room)
      }
      else if (result = "red") {
        msg ("You choose the red room.")
        MoveObject (player, Red Room)
      }
      else if (result = "log out") {
        msg ("You log out of the computer.")
      }
      else {
        msg ("The computer doesn't understand your command.")
        login
      }
    }
  </function>
</asl>

K.V.
14 Dec 2017, 02:52

mrangel and J_J are shooting you straight.

I use mrangel's method, but J_J's looks pretty cool, too.


I started making a simple example to post here, but it got a little out of hand.

I created a LOGOUT command when in the computer room, which just takes me back to the last room I was in.

I also made a script to do away with all of the commands which weren't computer-related before entering the computer, and another to set them back up correctly upon 'logout'.


Here's the link to the thread (I didn't want to take over this one):

http://textadventures.co.uk/forum/quest/topic/iqkjowkmu0eti6qsw94sdq/quest-dos-work-in-progress



Diorm
15 Dec 2017, 01:31

Interesting, I'm gonna try this script. Look simple enough.


mrangel
15 Dec 2017, 15:05

I also made a script to do away with all of the commands which weren't computer-related before entering the computer, and another to set them back up correctly upon 'logout'.

I believe you can do this by creating a command with pattern #text#. Because commands in the current room take priority over global ones, so any command that doesn't match one of this room's other commands calls that one rather than falling through to the global commands. Not 100% sure about that from memory, but I think it should work. Then you could just have that command do msg ("Unknown command: "+text).


K.V.
15 Dec 2017, 16:01

mrangel,

That sounds much easier than using cmd_jail. I'll test that out.

Thanks!