The recent thread on flipping the map in Inform 7 got me thinking that this is a perfect use case for the way Dialog lets you assign conditions to any rule. So here’s my take on doing the same in Dialog; I’d be curious to know if anyone else has an alternate way of doing it.
(current player #player)
(#player is #in #lab)
#lab
(room *)
(name *) Lab
(look *) An untidy laboratory. The workshop is to
the south and a small closet is to the (west flippable).
(from * go west flippable to #closet)
(from * go #south to #workshop)
#closet
(room *)
(name *) Closet
(look *) A cramped storage closet. The exit is to
the (east flippable).
(from * go east flippable to #lab)
#workshop
(room *)
(name *) Workshop
(look *) A dusty workshop. The lab lies north and a
small doorway opens to the (east flippable).
(from * go #north to #lab)
(from * go east flippable to #kitchenette)
#kitchenette
(room *)
(name *) Kitchenette
(look *) A small kitchenette. The only exit is
(west flippable).
(from * go west flippable to #workshop)
~(world is flipped)
(west flippable)
(if) (world is flipped) (then) east
(else) west (endif)
(east flippable)
(if) (world is flipped) (then) west
(else) east (endif)
(from $A go #west to $B)
(from $A go west flippable to $B)
~(world is flipped)
(from $A go #west to $B)
(from $A go east flippable to $B)
(world is flipped)
(from $A go #east to $B)
(from $A go east flippable to $B)
~(world is flipped)
(from $A go #east to $B)
(from $A go west flippable to $B)
(world is flipped)
(perform [jump])
(if) ~(world is flipped) (then)
(now) (world is flipped)
(else)
(now) ~(world is flipped)
(endif)
Everything looks different!
(try [look])
Woah,I didn’t know you could do this in Dialog. It’s a super interesting lamguage - I always thought of it as a branch of Inform 7, but this feels very different!
Very nice! It definitely shows off one of Dialog’s strengths: it lets many things be computed that Inform requires to be assigned.
This is also one of its weaknesses: unlike Inform, it’s very hard to rewrite arbitrary exits on the fly in Dialog (e.g. if you can tunnel through walls). But overall I think it’s a good tradeoff.
It’s good! Nevertheless I will suggest some minor tweaks…
(current player #player)
(#player is #in #lab)
#lab
(room *)
(name *) Lab
(look *) An untidy laboratory. The workshop is to
the south and a small closet is to the (dir from * to #closet).
(from * go #west flippable to #closet)
(from * go #south to #workshop)
#closet
(room *)
(name *) Closet
(look *) A cramped storage closet. The exit is to
the (dir from * to #lab).
(from * go #east flippable to #lab)
#workshop
(room *)
(name *) Workshop
(look *) A dusty workshop. The lab lies north and a
small doorway opens to the (dir from * to #lab).
(from * go #north to #lab)
(from * go #east flippable to #kitchenette)
#kitchenette
(room *)
(name *) Kitchenette
(look *) A small kitchenette. The only exit is
(dir from * to #workshop).
(from * go #west flippable to #workshop)
~(world is flipped)
(dir from $A to $B)
(from $A go $Dir to $B)
(name $Dir)
(from $A go $Dir to $B)
~(world is flipped)
(from $A go $Dir flippable to $B)
(from $A go #east to $B)
(world is flipped)
(from $A go #west flippable to $B)
(from $A go #west to $B)
(world is flipped)
(from $A go #east flippable to $B)
(perform [jump])
(if) ~(world is flipped) (then)
(now) (world is flipped)
(else)
(now) ~(world is flipped)
(endif)
Everything looks different!
(try [look])
(Most of what I did there is replace some hardcoded predicates, like (east flippable), with slightly more dynamic ones – in that case, querying the direction between two rooms and printing it. I don’t think it makes a ton of difference in your example, but would help if eg. you had passages north-east that ought to become north-west when the world is flipped. As always up to personal taste of course!)