New Action: Flirting?

Okay so I think my main problem is that I still don’t quite get how to make new actions but anyway…

I want to make a new action called “flirting” which will allow the player to flirt with a security guard who then will be distracted, thus allowing the player to pick his pocket and take a key.

So I THINK I need to make a new action, create the action of pick-pocketing and to somehow make “distracting” a thing.

Can anyone help?

Here’s the basic blueprint for creating a new action:

Flirting with is an action applying to one thing.

This creates the “flirting with” action – but it’s important to remember that at this point, “flirting” is only how the game refers to it internally. You haven’t yet defined how the player will refer to it.

Understand "flirt with [someone]" as flirting with.

This tells Inform how the player will access the flirting command. Using the [someone] token means that Inform will not allow the player to flirt with inanimate objects; if you want to that to be possible, use [something] instead.

This is also how you can add synonyms or alternate sentence constructions, if you want. Like so:

Understand "flirt at [someone]" as flirting with. Understand "tease [someone]" as flirting with.

Now, finally, you can set up rules to define what happens when you flirt with someone. The quick-and-dirty method is to just use an instead rule, but best practice is to set up check, carry out, and report rules.

Check rules are usually where you put all the conditions that would prevent flirting – you’re “checking” to make sure all the conditions are right before you allow the flirting to succeed. This is a good place to put all the common sense “you can’t do that” rules, like:

[code]Check flirting with yourself:
say “No need; you’re already in love with yourself.”;
stop.

Check flirting with something that is not a person:
say “[The noun] does not reciprocate your affection.”;
stop.[/code]

Carry out rules are usually where you put any changes to the game state caused by the action. Note, this doesn’t mean displaying text (that should go in a report rule); but rather stuff like altering a thing’s properties, moving objects around in the world model, etc.

[code]A person can be distracted.

Carry out flirting with someone:
now the noun is distracted.[/code]

Finally, reporting rules are where you display text that tells the player that the action just happened.

Report flirting with someone: say "You bat your eyes coquettishly, and [the noun] is instantly smitten."

You should also read up sections 12.7-12.9 of the Inform documentation.

Already have; sadly although most of the manual was easy to understand the “Action” section was not (at least for me!).
But I’ll try it and report back. Thanks!

It works! BUT,
How do I now take the key from the guard?
I have the “Instead rule” come up as "Instead of taking gold guard key:
say “You can’t just take it! You’ll have to figure out a way to distract him first…” to replace the "it belongs to someone else phrase.

So how do I take the key? ie. pick his pocket.

I assume I would probally code “If [someone] is distracted than …”
but what would come next if I’m right?

You create a new rule for that.

Think about the conditions under which you want the rule to trigger, and about what you want to happen. You want the rule to trigger when you take the key (but only when the guard is carrying the key – you don’t want the rule to trigger if you put the key down later and then pick it up again). You also want the game to behave differently according to whether the guard is distracted or not. So:

Instead of taking the key when the guard carries the key: if the guard is distracted: say "While the guard is making googly-eyes at you, you deftly slip the key off his belt."; move the key to the player. otherwise: say "The guard is too alert for you to just take the key. If only you had a way to distract him..."

An error message!

You wrote ‘otherwise’ : but the punctuation here ‘:’ makes me think this should be a definition of a phrase and it doesn’t begin as it should, with either ‘To’ (e.g. ‘To flood the riverplain:’), ‘Definition:’, a name for a rule (e.g. ‘This is the devilishly cunning rule:’), ‘At’ plus a time (e.g. ‘At 11:12 PM:’ or ‘At the time when the clock chimes’) or the name of a rulebook, possibly followed by some description of the action or value to apply to (e.g. ‘Instead of taking something:’ or ‘Every turn:’).

I think that’s because mike made a boo-boo. See where it says “move the key to the player.”? It should be “move the key to the player;” - semicolon at the end.

Yup! You were right Peter! He forgot a semi-colon… All fixed!

Still. I’ve successfully distracted the guard but it just keeps saying “That seems to belong to the Guard.”
What’s up?

Hmm, can you post your entire code? When I put everything together and compile it (after correcting that semicolon), I get this:

[code]Test Chamber is a room.

Flirting with is an action applying to one thing.

Understand “flirt with [someone]” as flirting with.
Understand “flirt at [someone]” as flirting with.
Understand “tease [someone]” as flirting with.

Check flirting with yourself:
say “No need; you’re already in love with yourself.”;
stop.

Check flirting with something that is not a person:
say “[The noun] does not reciprocate your affection.”;
stop.

A person can be distracted.

Carry out flirting with someone:
now the noun is distracted.

Report flirting with someone:
say “You bat your eyes coquettishly, and [the noun] is instantly smitten.”

A man called the guard is here. The guard carries a key.

Instead of taking the key when the guard carries the key:
if the guard is distracted:
say “While the guard is making googly-eyes at you, you deftly slip the key off his belt.”;
move the key to the player;
otherwise:
say “The guard is too alert for you to just take the key. If only you had a way to distract him…”

Test me with “take key / flirt with guard / take key / i”.[/code]

It’s pretty vast but this is everything so far. I’m planning to add a lot more descriptions but this is mostly bare bones at the moment.
You’ll note that I’m calling “the guard” an “orderly” and their are many key’s so the key I’m referring to is “the gold guard key”.

[code]“Returning to Real” by Sean Stark

When play begins:
say “You awaken with a start. You find yourself lying in a hospital bed, the scratchy white material angry against your skin. You glance around and see next to you a bedside table to your right. Laying ontop is that beautiful note you spent so long on, carelessly placed. You notice a wooden door straight ahead and a metal door to your right. In the left corner at the back is a cupboard and on your left close to you is a window. You are so enraged at having been brought here.”

The player is female.
The player wears a hospital gown and underwear.

Hospital Room is a room with printed name “Hospital Room (In Bed)”. It is south of Hospital Main.

Include Basic Screen Effects by Emily Short. Include Menus by Emily Short. Include Basic Help Menu by Emily Short.

The Orderly is a man. The carrying capacity of The Orderly is 2. The Orderly is in the Hallway Central. The description of The Orderly is “Tall, slender with a square jaw. He wears a white uniform and hanging on his beld is a shiny gold key. He looks at you with lust; maybe you could make use of that…” The Orderly carries the Gold Guard Key.

Hallway Central is a room with printed name “Hallway (Central)”.

Hallway North is a room with printed name “Hallway (North)”. Hallway North is north of Hallway Central.

Hospital Main is a room with printed name “Hospital Room”. “A medium-sized Hospital Room, it contains a bedside table, a cupboard, a large window and two doors.” It contains a bed, a bedside table, a window and a cupboard. Hallway South is south of Hallway Central.

The Bathroom is a room. The closed wooden door is a door. The wooden door is north of Hospital Main and south of the Bathroom. The wooden door is lockable and locked. The matching key of the wooden door is the Gold Guard Key.

The bathroom contains a shower, a sink, a mirror and a set of drawers. A sink is an open container. The set of drawers is an openable container.
Instead of opening the set of drawers, say “You open it but sadly, they are all empty.”

Instead of exiting when the location is Hospital Room:
say “You get out of bed.”;
now player is in Hospital Main.

Instead of going north from Hospital Room, say “Just STAND UP already.”

Instead of going south from Hospital Room, say “You don’t feel like going back to bed yet.”

The description of the mirror is “You gaze at yourself and frown. Your plain face gazes back at you with jade green eyes. You stand at five foot five with pale skin and long, dirty blond hair.”

The metal door is a door. The metal door is closed. It is east of Hospital Main and west of Hallway Central. The matching key of the metal door is the Silver Guard key. The metal door is lockable and unlocked door.

The bedside table is a supporter.

The top drawer and the bottom drawer are part of the bedside table. The top drawer and the bottom drawer are openable open containers. The bottom drawer contains the heart key.

The bed is a supporter.

A thing has some text called printing. The printing of a thing is usually “blank”.

Understand the command “read” as something new. Understand “read [something]” as reading. Reading is an action applying to one thing, requiring light. Check reading: if the printing of the noun is “blank”, say “Nothing is written on [the noun].” instead. Carry out reading: say “You read: [printing of the noun][line break]”. Report reading: do nothing.

Note is a thing with the printed name “note”. It is on the bedside table.
The description is “White paper with scratchy handwriting written on it which you recognise as your own.” The printing of Note is “You tried to stop me but I have made up my mind. Yours sincerely, Casey Moon.”

The cupboard is an locked lockable closed openable container. The matching key of the cupboard is the heart key.

Razor is a thing. Razorblade is a part of Razor. The razor is in the sink.

A rope is a kind of thing.

Definition: a thing is nonrope if it is not a rope.

Attachment relates things to each other in groups. The verb to be stuck to means the attachment relation.

Definition: a thing is tied if the number of things stuck to it is greater than 1.

Definition: a thing is free if it is not tied.

Definition: a rope is free if the number of nonrope things stuck to it is less than 2.

Definition: a thing is hindering if it is stuck to the noun and it is not within the location.

A thing can be round or unevenly shaped. A thing is usually round.

Definition: something is anchored if it is fixed in place or it is scenery or it is part of an anchored thing.

Definition: something is draggable if it is not had by the player and it is not the player and it is not anchored.

Rule for writing a paragraph about a rope (called the coil):
if the coil is stuck to something which is in a room (called the next room) which is not the location:
let the way be the best route from the location to the next room;
if the way is up or the way is down:
say “[The coil] runs [way] into [the next room].”;
otherwise:
say “[The coil] snakes across the floor [way] towards [the next room].”;
otherwise:
say “There is [a coil] here[if the coil is stuck to a visible nonrope thing], tied to [the list of nonrope visible things which are stuck to the coil][end if].”

To decide what room is the home of (item - a thing):
if item is a door:
let front cut be the number of moves from the location to the front side of the item;
let back cut be the number of moves from the location to the back side of the item;
if front cut is -1, let front cut be 999;
if back cut is -1, let back cut be 999;
if the location encloses the item, decide on the location;
if front cut is greater than back cut, decide on the back side of the item;
decide on the front side of the item;
decide on the location of the item.

Rule for writing a paragraph about a nonrope thing (called the anchor) which is stuck to a rope (called the coil):
if the coil is in an adjacent room:
let the next room be the home of the coil;
let the way be the best route from the location to the next room;
if the way is up or the way is down:
say “[The coil] runs [way] from [the anchor] into [the next room].”;
otherwise:
say “From [the anchor] runs [a coil], heading off toward [the way].”;
otherwise:
if the coil is stuck to something which is not visible,
say “[The coil] is tied to [the anchor][if the coil is stuck to something in an adjacent room (called the next room)], and from there runs off towards [the next room][end if].”

After printing the name of a rope (called the tied object) while taking inventory:
if something nonrope is stuck to the tied object:
say " (attached to [the list of nonrope things which are stuck to the tied object])";
otherwise:
say " (with both ends free)".

Instead of examining a rope (called the cord) when something is stuck to the cord:
say “[The noun] is tied to [the list of secondary things which are stuck to the noun].”

After examining the player when the player is stuck to something which is not the player:
say “You’re currently lashed to [the list of secondary things stuck to the noun].”

After examining something which is stuck to something secondary:
say “[The noun] is currently attached to [the list of secondary things stuck to the noun].”

After deciding the scope of the player:
if something stuck to a rope (called the coil) is in the location, place the coil in scope.

A reaching inside rule:
if the noun is a rope:
let the anchor be a random visible thing stuck to the noun;
if the anchor is touchable, allow access.

Before tying something to a rope:
if the noun is stuck to the second noun, say “[The noun] and [the second noun] are already tied together.” instead;
if the second noun is not free, say “[The second noun] has no ends free.” instead;
if the noun is round, say “You can’t realistically tie anything to [the noun].” instead.

Instead of tying a rope to something:
try tying the second noun to the noun.

Instead of tying something to a rope:
now the noun is stuck to the second noun;
say “You loop [the second noun] around [the noun] and knot firmly.”

Instead of tying something to a nonrope tied thing:
let the coil be a random rope stuck to the second noun;
try tying the noun to the coil.

Instead of tying a nonrope tied thing to something:
let the coil be a random rope stuck to the noun;
try tying the second noun to the coil.

Instead of tying a free nonrope thing to a free nonrope thing:
if the player carries a free rope (called the coil):
try tying the noun to the coil;
if the noun is stuck to the coil and the coil is free:
try tying the second noun to the coil;
otherwise:
say “You lack the requisite spare rope.”

Understand “untie [something] from [something]” as untying it from. Understand “untie [something]” as untying it from.

Rule for supplying a missing second noun while untying something from:
if the number of secondary things stuck to the noun is 0, say “[The noun] is already entirely free.” instead;
if the noun is a rope:
if the number of touchable nonrope things which are stuck to the noun > 1:
say “You’ll have to say which thing you want to untie [the noun] from.”;
rule fails;
otherwise:
if the number of touchable nonrope things stuck to the noun is 0, say “You can’t reach [the random nonrope thing stuck to the noun].” instead;
let the tied object be a random touchable nonrope thing which is stuck to the noun;
say “(from [the tied object])[line break]”;
now the second noun is the tied object;
otherwise:
if the noun is stuck to a rope (called the tied object):
say “(from [the tied object])[line break]”;
now the second noun is the tied object.

Untying it from is an action applying to two things.

Before untying a rope from something: try untying the second noun from the noun instead.

Before untying something from a rope:
if the second noun is not held:
say “(first picking up [the second noun])[line break]”;
try taking the second noun.

Check untying it from:
unless the noun is stuck to the second noun or the second noun is stuck to the noun,
say “[The noun] and [the second noun] are already not tied together.” instead.

Carry out untying it from:
now the noun is not stuck to the second noun.

Report untying it from:
say “Untied.”

After reading a command: now every thing is unmentioned.

Before pulling something anchored: say “[The noun] is firmly anchored.” instead.

Instead of pulling something tied:
if the noun is unmentioned:
say “The impulse is transmitted to [the list of pullable things stuck to the noun].”;
repeat with item running through pullable things stuck to the noun:
say “[item]: [run paragraph on]”;
try pulling the item;
if the noun is a rope and the noun is not within the location:
if the number of nonrope hindering things is 0, move the noun to the location;
otherwise:
continue the action.

Before pulling something which is not visible:
if the noun is anchored:
say “[The noun] resists, for whatever reason.” instead;
otherwise:
let space be the holder of the noun;
let way be the best route from the space to the location;
if the way is a direction:
move the noun to the location;
say “[The noun] [if the way is up]rises[otherwise]slides[end if] into view.” instead;
otherwise:
move the noun to the location;
say “[The noun] slides into view.” instead.

Definition: a thing is secondary if it is not the noun. Definition: a thing is pullable if it is not the noun and it is not the player.

Before going a direction (called the way) when the player has something (called the link) which is stuck to something anchored (called the anchor):
let the next room be the home of the anchor;
if the next room is not a room, continue the action;
if the next room is the location:
if the link is stuck to at least two anchored things,
say “You can’t go far while you’re carrying [the link] tied to [the list of anchored things stuck to the link].” instead;
otherwise:
let the safe way be the best route from the location to the next room;
if the safe way is the way:
if the player is not stuck to the anchor, say “(coiling up your rope again as you go…)”;
otherwise:
if the safe way is a direction,
say “While you have [the link] you can’t really head any direction but [best route from the location to the next room].” instead;
otherwise say “You’re tied up here.” instead.

Before going a direction (called the way) when the player is stuck to something anchored (called the anchor):
let the next room be the home of the anchor;
if the next room is not a room, continue the action;
if the next room is the location:
if the player is stuck to at least two anchored things,
say “You can’t go far while you’re tied to [the list of anchored things stuck to the player].” instead;
otherwise:
if the best route from the location to the next room is the way:
say “(coiling up your rope again as you go…)”;
otherwise:
say “Your attachments prevent you going any way but [best route from the location to the next room].” instead.

After going somewhere when the player has something (called the link) which is stuck to something draggable:
if the player is not stuck to the link:
say “You drag along behind you [the list of draggable things which are stuck to the link].”;
now every draggable thing which is stuck to the link is in the location;
continue the action.

Report going somewhere when the player is stuck to something draggable:
say “You drag along behind you [the list of draggable things which are stuck to the player].”;
now every draggable thing which is stuck to the player is in the location.

The cupboard contains a rope.

Flirting with is an action applying to one thing.
Understand “flirt with [someone]” as flirting with.

Understand “flirt at [someone]” as flirting with.
Understand “tease [someone]” as flirting with.

Check flirting with yourself:
say “No. You’re not your type.”;
stop.

Check flirting with something that is not a person:
say “[The noun] does not reciprocate your affection.”;
stop.

A person can be distracted.

Carry out flirting with someone:
now the noun is distracted.

Report flirting with someone:
say “You bat your eyes coquettishly, and [the noun] is utterly ingrosed in you.”

Instead of taking the key when the Orderly carries the key:
if the Orderly is distracted:
say “While the Orderly is making googly-eyes at you, you deftly slip the key off his belt.”;
move the key to the player;
otherwise:
say “The Orderly is too alert for you to just take the key. If only you had a way to distract him…”

[/code]

There are multiple keys, so your rule needs to specify which one you mean:

Instead of taking the gold guard key when the Orderly carries the gold guard key:
	 if the Orderly is distracted:
		  say "While the Orderly is making googly-eyes at you, you deftly slip the key off his belt.";
		  move the gold guard key to the player;
	 otherwise:
		  say "The Orderly is too alert for you to just take the key. If only you had a way to distract him..."

Works! I thought it was something simple I was missing… that’s always the way. Thanks.

Where is the key exactly in your model world? If you defined it like this:

The pocket is part of the guard. The key is in the pocket.

then “the guard carries the key” won’t come out true, because the guard isn’t directly carrying the key.

Try changing that line to

Instead of taking the key when the guard encloses the key:

which should take care of every case where the guard carries it, or the key is part of the guard, or the key is in a container that is part of the guard, etc. etc.

The current “flirting” action is working really well. Thanks a lot to everyone.