Ask A Character About An Object That's Elsewhere.

If Player is in same room with a character, you can ask him about an object that is also in that room. And you can get a different response depending on whether Player is carrying the object or not. But can you ask a character about an object that's not in the room??

This code doesn't give an error msg:

  <command name="asking">
    <pattern>ask #object# about #object_one#</pattern>
    <unresolved>He ain't here.</unresolved>
    <script>
      switch (object_one) {
        case (pistol) {
          if (object_one not here) {
            msg ("Yo")
          }
        }
      }
    </script>
  </command>

But it also doesn't work. Gives the message "He ain't here (pistol)"

Any ideas??


You want to set the scope for the command to something like object=room|object_one=world.

That means that when trying to match the player's input to an object, for object it considers objects in the room, and for object_one it considers objects anywhere in the world.

Other values you can use include all (all visible objects; same as room;inventory), room or notheld (those two are the same), inventory (objects in the inventory), container (visible containers; used for the "put in" command), and contents (objects that are in a visible container, whether or not they are visible)

If you want to stop the autocomplete suggesting the names of things the player hasn't even seen, it would be a bit more complex. You could give the player object an objectlist attribute named something like things_seen and add objects to the list when the player encounters them; and then set the command's scope to object=room|object_one=things_seen. You can do whatever you want with that; adding all objects visible when the player enters a new room, or just the things that are worth asking about.

A more powerful option would be giving the command a script attribute named changecommandscope. That script is run before trying to match the player's input to an object. Within the script, you will have the following variables available:

  • items - the items list generated by the normal scope attribute. You can add and remove objects on this list to change which objects the game considers as valid candidates.
  • command - the command itself (not really useful in this case)
  • variable - will be "object" or "object_one", so the script knows which command we're matching against
  • objtype - "object", "exit", or "text"
  • matched - a dictionary containing any objects that have already been matched for this command.

Mr. Angel, I hate being so dumb, but I can't figure out WHERE to put the scope instruction.

 <command name="asking">
    <pattern>ask #object# about #object_one#</pattern>
    <unresolved>He ain't here.</unresolved>
    <script>
      if (object = Bob) {
        switch (object_one = world) { // _Gets error msg below_
          case (pen) {
            msg ("Nice pen.")
          }
          case (pistol) {
            msg ("Good gun.")
          }
        }
      }
    </script>
  </command>

Error running script: Error compiling expression 'object_one = world': Unknown object or variable 'world'

I tried it in the first line of the command:

    <pattern>ask #object# about #object_one# = world</pattern>

Doesn't get an error msg, but it doesn't work. It says, "He does not reply" no matter if the object I ask him about is in the room or not.

So I'm baffled.


In the GUI there's a separate box for scope. In full code view it would be:

  <command name="asking">
    <pattern>ask #object# about #object_one#</pattern>
    <scope>object=room|object_one=world</scope>
    <unresolved>He ain't here.</unresolved>
    <script>
      if (object = Bob) {
        switch (object_one = world) {
          case (pen) {
            msg ("Nice pen.")
          }
          case (pistol) {
            msg ("Good gun.")
          }
          case (player) {
            msg ("I think you're a nice guy.")
          }
        }
      }
    </script>
  </command>

One thing to be careful about if using world: It includes all objects, whether or not they're reachable by the player. So it would be a good idea to consider sensible messages for rooms and the player. I used the 'player' as an example, just for the players who will try "ask Bob about myself".


Yeah, I was pretty dumb to not figure that out. Thanks.


ASK/TELL panel : ask ; ask about

"ask character about object" for nearly all objects or other characters in your game is easy.

Just add another "ask about object script"

Objects, words or characters you ask about don't have to be in the same room or visible at all! After all , it is just a question.


Thanks, iantommo.


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

Support

Forums