Calling the 'look' command as part of a script

Hi!

I have an object in my game which changes the state of the room when used. Specifically, I have a "cord" which you can (verb: pull) to light up the room, using the built in light/dark scripts. The room in question starts dark.

After pulling the cord and the associated script running with the description and lighting the room, I want the game to wait until a key is pressed - no problem - and then clear the screen and automatically 'look' to get the 'room is light' description.

Nothing groundbreaking I know, but it's my first time working with Quest - the last text adventure I made was on the C64 in BASIC V2 in 1995 - and for the life of me I can't get the game to use the 'look' command.

To be honest, just knowing how to invoke commands in the fashion would be a big help in general!

If anyone could help, I'd be really grateful. I'm sure it's something obvious I'm missing - I feel like I can see the solution, like when a word is stuck on the tip of your tongue - I'm just looking everywhere except at it!

Here's my script in code format. The object is Cord, the room is Shack Interior:

  SetLight (Shack Interior)
  SetObjectFlagOn (Cord, "used")
  msg ("Dislodging several layers of dust, you tentatively pull on the cord. Much to your relief, it <i>is</i> a light switch - it even works! The whole of the shack is bathed in a nicotine glow from a bare bulb above your head.")
  msg ("Press any key to continue")
  wait {
    ClearScreen
  }
}
else {
  msg ("The light is already on, and you're keeping it that way.")
}```

Sorry, the first line of my code was missing. For clarity:

if (not GetBoolean(Cord, "used")) {
  SetLight (Shack Interior)
  SetObjectFlagOn (Cord, "used")
  msg ("Dislodging several layers of dust, you tentatively pull on the cord. Much to your relief, it <i>is</i> a light switch - it even works! The whole of the shack is bathed in a nicotine glow from a bare bulb above your head.")
  msg ("Press any key to continue")
  wait {
    ClearScreen
  }
}
else {
  msg ("The light is already on, and you're keeping it that way.")
}

There's 3 obvious ways to do this.

Best solution

There's already a function to show the room description. The code you want is simploy:

ShowRoomDescription()

Alternative solution

In case you want to call other commands from a script at some point in the future, I'll explain how you do that.

Commands are objects, and their scripts are stored in a script attribute named "script". So to run the look command, you could use:

do (look, "script")

If you wanted to script a command that takes an object name (like "look cord") you'd put it in a dictionary like this:

do (lookat, "script", QuickParams ("object", Cord))

(worth noting that in the core commands, "look" and "lookat" are separate commands.


Less polished solution

If you want to call a command without messing about with objects, you can do:

HandleSingleCommand ("look")

That will act exactly as if the player typed in that command (including asking them which one they meant if there are two objects with the same name). This is probably the worst solution, because it's rather inefficient and may also mess with your turnscripts. But if you want to run a command as if the player typed it, this is a lot easier to work with.


Every bit of that information is useful - thank you so much! In this case, the 'best solution' you note really is. Occam's Razor and all that.

Thank you so much!


Log in to post a reply.

Support

Forums