Unlocking an exit with a keycard

So I have this game where several doors need a key card to open. But not just possessing the key card but actually swiping it. Not sure how to do this, would it a verb and the item? Also there will be several doors that require the key card, so it need to use the card to open a specific door at a time. Also some of the doors are in the same room, so just coding it so using the key card in a specific room, would open all the doors that require in in the room.


K.V.

Maybe something like this (with verbs and a fake key):

<!--Saved by Quest 5.7.6726.930-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Doors and Keycards">
    <gameid>8374474a-df18-4e5a-99d2-30a6d61ddb8d</gameid>
    <version>2.0</version>
    <firstpublished>2018</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <isroom />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
      <object name="keycard1">
        <inherit name="editor_object" />
        <alias>green keycard</alias>
        <take />
        <look>A green keycard.</look>
        <swipe type="script">
          choices = NewObjectList()
          foreach (o, FilterByAttribute(ScopeReachable(), "keycard", this)) {
            list add (choices, o)
          }
          ShowMenu ("Swipe it where?", choices, true) {
            obj = GetObject(result)
            if (not GetBoolean (obj, "locked")) {
              msg ("It is already unlocked.")
            }
            else {
              obj.locked = false
              obj.isopen = true
              msg ("Done.  The door slides open.")
            }
          }
        </swipe>
      </object>
    </object>
    <object name="door">
      <inherit name="editor_object" />
      <inherit name="openable" />
      <inherit name="container_lockable" />
      <feature_container />
      <look>A green door with number 1 etched onto it.</look>
      <takemsg>It's fixed in place.</takemsg>
      <alias>green door (1)</alias>
      <keycount type="int">1</keycount>
      <keycard type="object">keycard1</keycard>
      <key type="object">fake_key</key>
    </object>
    <object name="door1">
      <inherit name="editor_object" />
      <inherit name="openable" />
      <inherit name="container_lockable" />
      <feature_container />
      <alias>green door (2)</alias>
      <look>A green door with number 2 etched onto it.</look>
      <takemsg>It's fixed in place.</takemsg>
      <keycount type="int">1</keycount>
      <keycard type="object">keycard1</keycard>
      <key type="object">fake_key</key>
    </object>
    <object name="door2">
      <inherit name="editor_object" />
      <inherit name="openable" />
      <inherit name="container_lockable" />
      <feature_container />
      <look>A yellow door.</look>
      <takemsg>It's fixed in place.</takemsg>
      <alias>yellow door</alias>
      <keycount type="int">1</keycount>
      <keycard type="object">keycard2</keycard>
      <key type="object">fake_key</key>
    </object>
  </object>
  <verb>
    <property>swipe</property>
    <pattern>swipe</pattern>
    <defaultexpression>"You can't swipe " + object.article + "."</defaultexpression>
  </verb>
  <object name="keycard2">
    <inherit name="editor_object" />
    <take />
    <look>A yellow keycard.</look>
  </object>
  <object name="fake_key">
    <inherit name="editor_object" />
  </object>
</asl>

Each door has a "keycard" object attribute set to the appropriate keycard.


I think I’m X2 I simply used the “use other object on this” script. For the correct key I would obviously unlock/open the door. For incorrect keys I used the else if script here and commented ‘that didn’t seem to work on this door.’ For the else part of the script, I simply scripted a comment like ‘that obviously won’t work.’

If you don’t like the use this bit, simply add a verb like ‘swipe’ to the door/keypad and run the same scripts.

I’m sure KVs code works fine too but just in case you like the “dumbed down” version like me. :)


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

Support

Forums