Let's Code: Mini-Cluedo

Let’s keep it in one place then!

I’ve not done any Gruescript before, but the docs are pretty readable, and the most structurally unusual thing (the division of logic into blocks that may either fail or succeed, with blocks run in order until one succeeds) is pretty reminiscent of Dialog. So I’m not certain that all of this counts as precisely idiomatic, but I don’t think I’ve done anything too ridiculous.

We start with a block of generic metadata:

game Mini-Cluedo
id minicluedo
author Adam Biltcliffe
version 1.0.0
person 2
examine off
conversation off
wait on
say This should have been the perfect society gathering ... until MURDER reared its ugly head! Three suspects remain at large, but can you pinpoint which of them is the guilty party before time runs out?

examine off means that we can’t examine things by clicking their names, which saves us writing some descriptions for this simple example. conversation off disables the built-in ASK/TELL topic system, which means we can focus on just the limited verb set specified in the description of the problem.

We need to create some rooms; Gruescript (following its parser heritage) has built-in syntax for creating a map based on compass directions, but we’re going to do as @Draconis did and just provide a verb for moving directly to each of the rooms in our rather simple map.

room foyer You're in the grand foyer.

room billiards_room You're in the billiards room.

room library You're in the library.

verb go_to_the_foyer
goto foyer

setverb go_to_the_foyer intransitive
!at foyer

verb go_to_the_billiards_room
goto billiards_room

setverb go_to_the_billiards_room intransitive
!at billiards_room

verb go_to_the_library
goto library

setverb go_to_the_library intransitive
!at library

The verb blocks tell us how to carry out the verb (which uses a single Gruescript command to move the player to the room in question). The setverb blocks tell us when the verb is available (in this case, when the player is not already in the desired room). The choice that is actually displayed to the player is the internal name of the verb with underscores converted to spaces, e.g. go to the foyer, which is fine for our purposes (I’m not sure if there’s a way to change this).

Now we can wander between our three rooms, and also wait, since that’s built into Gruescript and we opted into it by including wait on in our game block. Next: the NPCs.