Friday, June 26, 2015

automatic door unlocking/opening

So, in posting that "Vault of Hugo" transcript the other day, I was reminded my dissatisfaction over the messaging in my first attempt at automatic door unlocking.  Here's the applicable part again:


>dig ground
You find a rusty iron key!
(Taken.)

>e
(unlocking the vault door first)
(with the rusty iron key)
Unlocked.
(opening the vault door first)
Opened.
It's pitch black in here. Stumbling around in the dark isn't such a hot idea: you're liable to be eaten by a grue.

>

Now, the automatic-door-unlocking was one of the first things ever added to Roodylib so, of course, I've learned a lot since then and I thought it was worth taking another swing at it.  Here is a transcript of what would happen now:

>dig ground
You find a rusty iron key!
(Taken.)

>e
(unlocking the vault door with the rusty iron key first)
Unlocked.

(and then opening it)
Opened.

It's pitch black in here. Stumbling around in the dark isn't such a hot idea: you're liable to be eaten by a grue.

>
As you can see, it now combines information where it can, and I added some spacing to make it prettier.  The "(and then opening it)" message was especially tricky to do, but I think the code I threw together should work well enough (it relies on checking the parser_data[PARSER_STATUS] value, and I don't see that changing anytime soon).

I also threw in an option where, if the key object is set quiet, a regular >UNLOCK DOOR asks the player to be more specific or in something like the instance above, does:

>dig ground
You find a rusty iron key!
(Taken.)

>e
The vault door is locked.

>unlock door with key
Unlocked.

>lock door
(with the rusty iron key)
Locked.

>e
(unlocking the vault door with the rusty iron key first)
Unlocked.

(and then opening it)
Opened.

It's pitch black in here. Stumbling around in the dark isn't such a hot idea: you're liable to be eaten by a grue.

>

 I figure there might be instances where you want the player to figure out which key is correct.  After being used correctly once, it'll do automatic unlocking/locking no problem from then on.

Anyhow, I wanted to put the feature there, but I doubt many people will use it so I won't even go to the trouble of aliasing quiet to another more-apt attribute name to be used in these instances.

Wednesday, June 24, 2015

Attachables

In preparation of the next official release of Nikos Chantziaras' Hugor, I've been playing through Kent Tessman's Future Boy! again as it is basically the only Hugo game in existence that uses Hugo's movie feature.

In one late scene, there is a rope and a wheelbarrow (the wheelbarrow isn't especially important- I get the feeling it mostly exists just to show off Hugo's capabilities) and I found some inconsistent behavior.  This got me looking at Hugo's attachables code, in particular how it works with pushable items (like Roodylib's USE_ROLLABLES switch).

It took a couple attempts, but I eventually got Roodylib working as I would like it.  To test it out, I made the mine car in "Vault of Hugo" a pushable object.  Here is a transcript with the new code in place:

You brace yourself, check your flashlight, and, with source code in hand, prepare to enter...

THE VAULT OF HUGO
An Interactive Example
Hugo v3.1 / Library 31031

Outside a vault
Kind of that 1930s, Bela Lugosi, graveyardy motif at work here. It's a pretty creepy place. Directly in front of you is the giant door to an even more giant vault. Above the door hangs a rusty sign.

>dig ground
You find a rusty iron key!
(Taken.)

>e
(unlocking the vault door first)
(with the rusty iron key)
Unlocked.
(opening the vault door first)
Opened.
It's pitch black in here. Stumbling around in the dark isn't such a hot idea: you're liable to be eaten by a grue.

>turn on light
A beam of serviceable light appears from your flashlight.

Inside the vault
Standing in the middle of this dimly lit chamber, you realize that just maybe you should've splurged on a more expensive flashlight. You also realize that there are four ways you can go: a marble archway to the north, a muddy cave opening to the east, an oak door set in a brick frame to the southeast, and west back outside where you came from.
An old mine car sits abandoned to one side.

>push car n
Something seems to be stopping the mine car from rolling.

>look under car
You find a big rock lodged between the wheels, which you manage to wrestle out of the way.

>push car n
You push the mine car over to the...

Object Room
This room contains a collection of objects with different properties, attributes, and associated routines in order to give some idea of basic object design. In addition to the various furnishings, you notice a dartboard hanging on one wall.
A large drum--not the musical kind--is here. Attached to it is a warning note.
Lying in the corner of the room is a non-descript, unnamed object.
An old mine car sits abandoned to one side.
A wooden chair, a card table, a transparent box, and an opaque box are here.
A deck of playing cards has been placed appropriately on the table.
Also sitting on the card table are three shiny gold coins and a pad of paper.
A green dart is sticking out of the old dartboard.
A heavy rope is tied to the wooden chair.

The mine car slows to a stop.

>tie rope to car
You tie the heavy rope to the mine car.

>push car s
You can't move the mine car while the heavy rope is still tied to to the wooden chair.

>enter car
You get in the mine car.

Object Room, in a mine car
This room contains a collection of objects with different properties, attributes, and associated routines in order to give some idea of basic object design. In addition to the various furnishings, you notice a dartboard hanging on one wall.
The old mine car is loaded with a pencil.
A large drum--not the musical kind--is here. Attached to it is a warning note.
Lying in the corner of the room is a non-descript, unnamed object.
A wooden chair, a card table, a transparent box, and an opaque box are here.
A deck of playing cards has been placed appropriately on the table.
Also sitting on the card table are three shiny gold coins and a pad of paper.
A green dart is sticking out of the old dartboard.
A heavy rope is tied to the wooden chair and the mine car.

>drive s
You can't go anywhere while the heavy rope is still tied to the wooden chair and the mine car.

>out
You get out of the mine car.

>untie rope from chair
You untie the heavy rope from the wooden chair.

>push car s
(with the heavy rope tied to the mine car)
You push the mine car over to the...

Inside the vault
Standing in the middle of this dimly lit chamber, you realize that just maybe you should've splurged on a more expensive flashlight. You also realize that there are four ways you can go: a marble archway to the north, a muddy cave opening to the east, an oak door set in a brick frame to the southeast, and west back outside where you came from.
A big rock and a mine car are here. The old mine car is loaded with a pencil.
A heavy rope is tied to the mine car.

The mine car slows to a stop.

>enter car
You get in the mine car.

Inside the vault, in a mine car
Standing in the middle of this dimly lit chamber, you realize that just maybe you should've splurged on a more expensive flashlight. You also realize that there are four ways you can go: a marble archway to the north, a muddy cave opening to the east, an oak door set in a brick frame to the southeast, and west back outside where you came from.
The old mine car is loaded with a pencil.
A big rock is here.
A heavy rope is tied to the mine car.

>drive n
(with the heavy rope tied to the mine car)

Object Room, in a mine car
This room contains a collection of objects with different properties, attributes, and associated routines in order to give some idea of basic object design. In addition to the various furnishings, you notice a dartboard hanging on one wall.
The old mine car is loaded with a pencil.
A large drum--not the musical kind--is here. Attached to it is a warning note.
Lying in the corner of the room is a non-descript, unnamed object.
A wooden chair, a card table, a transparent box, and an opaque box are here.
A deck of playing cards has been placed appropriately on the table.
Also sitting on the card table are three shiny gold coins and a pad of paper.
A green dart is sticking out of the old dartboard.
A heavy rope is tied to the mine car.

>get rope
Taken.

>push car s
To walk, you will have to get out of the mine car. Otherwise, try "roll" or "drive" and a direction.

>drive s

Inside the vault, in a mine car
Standing in the middle of this dimly lit chamber, you realize that just maybe you should've splurged on a more expensive flashlight. You also realize that there are four ways you can go: a marble archway to the north, a muddy cave opening to the east, an oak door set in a brick frame to the southeast, and west back outside where you came from.
The old mine car is loaded with a pencil.
A big rock is here.
The heavy rope that you're holding is tied to the mine car.

>out
You get out of the mine car.

>push car n
You push the mine car over to the...

Object Room
This room contains a collection of objects with different properties, attributes, and associated routines in order to give some idea of basic object design. In addition to the various furnishings, you notice a dartboard hanging on one wall.
A large drum--not the musical kind--is here. Attached to it is a warning note.
Lying in the corner of the room is a non-descript, unnamed object.
A wooden chair, a card table, a transparent box, an opaque box, and a mine car are here.
A deck of playing cards has been placed appropriately on the table.
Also sitting on the card table are three shiny gold coins and a pad of paper. The old mine car is loaded with a pencil.
A green dart is sticking out of the old dartboard.
The heavy rope that you're holding is tied to the mine car.

The mine car slows to a stop.

>enter car
You get in the mine car.

Object Room, in a mine car
This room contains a collection of objects with different properties, attributes, and associated routines in order to give some idea of basic object design. In addition to the various furnishings, you notice a dartboard hanging on one wall.
The old mine car is loaded with a pencil.
A large drum--not the musical kind--is here. Attached to it is a warning note.
Lying in the corner of the room is a non-descript, unnamed object.
A wooden chair, a card table, a transparent box, and an opaque box are here.
A deck of playing cards has been placed appropriately on the table.
Also sitting on the card table are three shiny gold coins and a pad of paper.
A green dart is sticking out of the old dartboard.
The heavy rope that you're holding is tied to the mine car.

>drive e
You can't roll that way.

>drive s

Inside the vault, in a mine car
Standing in the middle of this dimly lit chamber, you realize that just maybe you should've splurged on a more expensive flashlight. You also realize that there are four ways you can go: a marble archway to the north, a muddy cave opening to the east, an oak door set in a brick frame to the southeast, and west back outside where you came from.
The old mine car is loaded with a pencil.
A big rock is here.
The heavy rope that you're holding is tied to the mine car.

>drive e

Character Room, in a mine car
The Character Room provides a couple of good examples of character scripts and events. Exits are north and west.
The old mine car is loaded with a pencil.
A burly guard is here.
The heavy rope that you're holding is tied to the mine car.

The guard lifts his big boot up to the mine car and gives you a firm shove back out the door. "Not in that thing, you don't, pal!"

Inside the vault, in a mine car
Standing in the middle of this dimly lit chamber, you realize that just maybe you should've splurged on a more expensive flashlight. You also realize that there are four ways you can go: a marble archway to the north, a muddy cave opening to the east, an oak door set in a brick frame to the southeast, and west back outside where you came from.
The old mine car is loaded with a pencil.
A big rock is here.
The heavy rope that you're holding is tied to the mine car.

>drop rope outside car
Dropped.

>drive e
(with the heavy rope tied to the mine car)

Character Room, in a mine car
The Character Room provides a couple of good examples of character scripts and events. Exits are north and west.
The old mine car is loaded with a pencil.
A burly guard is here.
A heavy rope is tied to the mine car.

The guard lifts his big boot up to the mine car and gives you a firm shove back out the door. "Not in that thing, you don't, pal!"

Inside the vault, in a mine car
Standing in the middle of this dimly lit chamber, you realize that just maybe you should've splurged on a more expensive flashlight. You also realize that there are four ways you can go: a marble archway to the north, a muddy cave opening to the east, an oak door set in a brick frame to the southeast, and west back outside where you came from.
The old mine car is loaded with a pencil.
A big rock is here.
A heavy rope is tied to the mine car.

>out
You get out of the mine car.

>push car e
(with the heavy rope tied to the mine car)
You push the mine car over to the...

Character Room
The Character Room provides a couple of good examples of character scripts and events. Exits are north and west.
A burly guard is here.
A mine car is here. The old mine car is loaded with a pencil.
A heavy rope is tied to the mine car.

The mine car slows to a stop.

The guard lifts his big boot up to the mine car and gives you a firm shove back out the door. "Not with that thing, you don't, pal!"

Inside the vault
Standing in the middle of this dimly lit chamber, you realize that just maybe you should've splurged on a more expensive flashlight. You also realize that there are four ways you can go: a marble archway to the north, a muddy cave opening to the east, an oak door set in a brick frame to the southeast, and west back outside where you came from.
A big rock and a mine car are here. The old mine car is loaded with a pencil.
A heavy rope is tied to the mine car.

>get rope
Taken.

>e
(with the heavy rope tied to the mine car)

Character Room
The Character Room provides a couple of good examples of character scripts and events. Exits are north and west.
A burly guard is here.
A mine car is here. The old mine car is loaded with a pencil.
The heavy rope that you're holding is tied to the mine car.

The guard lifts his big boot up to the mine car and gives you a firm shove back out the door. "Not with that thing, you don't, pal!"

Inside the vault
Standing in the middle of this dimly lit chamber, you realize that just maybe you should've splurged on a more expensive flashlight. You also realize that there are four ways you can go: a marble archway to the north, a muddy cave opening to the east, an oak door set in a brick frame to the southeast, and west back outside where you came from.
A big rock and a mine car are here. The old mine car is loaded with a pencil.
The heavy rope that you're holding is tied to the mine car.

>n
(with the heavy rope tied to the mine car)

Object Room
This room contains a collection of objects with different properties, attributes, and associated routines in order to give some idea of basic object design. In addition to the various furnishings, you notice a dartboard hanging on one wall.
A large drum--not the musical kind--is here. Attached to it is a warning note.
Lying in the corner of the room is a non-descript, unnamed object.
A wooden chair, a card table, a transparent box, an opaque box, and a mine car are here.
A deck of playing cards has been placed appropriately on the table.
Also sitting on the card table are three shiny gold coins and a pad of paper. The old mine car is loaded with a pencil.
A green dart is sticking out of the old dartboard.
The heavy rope that you're holding is tied to the mine car.

>

So, if you read carefully, you may have noticed that it mentions the attachables if the rope is being dragged or pulling something, but it doesn't if the player is just holding it (I also added some code so held attachables tied to something in the room are mentioned in the room's description).

My new code might not work in every situation (in fact, I can think of at least one instance in which it won't), but attachables are so rarely used in any case; if the day comes that an author codes something that doesn't work with the new code (specifically, the attachable would have to be tied to something in a container and the player would have to GO in a direction that leads to a locked door or something), I'll be happy to help them tweak their code so that it works.

Interestingly, playing around with "Vault of Hugo" inspired me for what I'd like to work on next, too, which is smarter room descriptions when the player is in a container or on a platform.  I've successfully coded that in the past so it's mainly a case of integrating it into Roodylib as cleanly as possible.