Lockpicking?

So, I’ve been trying to implement a lockpicking system to my game just in case someone is feeling lucky in terms of skipping sections of the game, but Skeleton Keys isn’t helping (I tried to use i and it would say the Key doesnt fit.)

Mind trying out and fixing this code, cause i’ve tried any simple solution.

[code]The Lockpick is a kind of thing. The description of the Lockpick is “A handy tool for unlocking doors you want to get past. Horribly fragile, though. (Use by saying ‘Pick lock of -object-’ No need to use the noun.”

Picking is an action applying to one visible thing. Understand “Pick [something]” as picking. Understand “Pick lock of [something]” as picking. Understand “Pick [something]'s lock” as picking.
Understand “Picking [something]” as picking.

Instead of Picking [anything] (called The Toolee):
if the player is carrying a lockpick (called The Tool) Begin;
if a random chance of 1 in 11 suceeds Begin;
remove The Tool from play;
say “The lockpick breaks in your hand.”;
otherwise;
now The Toolee is unlocked;
say “The tumblers within the lock turn as the [The Toolee] is unlocked”;
end if;
otherwise;
say “You’ll need at least 1 Lockpick for that.”
end if.[/code]

So here I copied the code from your post and put it into code-tags, so that the indentation is preserved.

The Lockpick is a kind of thing.  The description of the Lockpick is "A handy tool for unlocking doors you want to get past. Horribly fragile, though. (Use by saying 'Pick lock of -object-' No need to use the noun."

Picking is an action applying to one visible thing. Understand "Pick [something]" as picking. Understand "Pick lock of [something]" as picking. Understand "Pick [something]'s lock" as picking.
Understand "Picking [something]" as picking.

Instead of Picking [anything] (called The Toolee):
	if the player is carrying a lockpick (called The Tool) Begin;
		if a random chance of 1 in 11 suceeds Begin;
			remove The Tool from play;
			say "The lockpick breaks in your hand.";
		otherwise;
			now The Toolee is unlocked;
			say "The tumblers within the lock turn as the [The Toolee] is unlocked";
		end if;
	otherwise;
		say "You'll need at least 1 Lockpick for that."
	end if.

Here’s how I would rewrite it a little bit.

A lockpick is a kind of thing.

Picking is an action applying to one thing and requiring light. Understand "pick [something]" or "pick lock of [something]" as picking.
The picking action has an object called the lockpick used.

Setting action variables for picking:
    if the player carries a lockpick, now the lockpick used is a random lockpick carried by the player.

Check picking something when the noun is not a door and the noun is not a container:
    say "[The noun] can't really be opened, per se." instead.

Check picking something when the noun is not closed:
    say "[The noun] [are] already open." instead.

Check picking something when the noun is not locked:
    say "[The noun] [do]n't seem to be locked in the first place." instead.

Check picking something when the player does not carry a lockpick:
    say "You would need a lockpick for that." instead.

Check picking something:
    if a random chance of 1 in 11 succeeds:
        say "The pick breaks in your hand!";
        remove the lockpick used from play instead.

Carry out picking something:
    now the noun is unlocked.

Report picking something:
    say "The tumblers turn within the lock, and [the noun] [open] easily."

This is a fairly elaborate way to set up an action, but I’ve found it’s usually better in the long run. If something else comes up later (say, the player finds a magic unbreakable lockpick, or a pair of thick gloves which prevent them from manipulating the lockpick precisely enough, or a safe with a combination lock and no keyhole), it’s easy to add another rule to handle it. (Instead of picking the incredibly complicated door: say “Its lock seems too complicated for you to open.”)

A few things I changed from your code, other than the reorganization:

  • “Applying to one visible thing” isn’t what you want here. It’s a bit counterintuitive, but specifying that an action applies to “one visible thing” means that the object only needs to be visible: you can examine a diamond in a glass case, for example, even if you can’t reach through the case to touch it. “One thing” without the “visible” quantifier means that it needs to be both visible and touchable, since this is the most common use case. And adding “requiring light” means that there needs to be some source of light: you can open a door in near-total darkness, but not read a book.
  • Begin - end constructions aren’t used very much anymore, they’re a relic from the early days of I7. Indentation serves the same purpose now.
  • Anything in square brackets, outside of quotation marks (like your “[anything]”), is considered a comment and ignored by the compiler. You only need those inside the quotation marks in Understand lines.

Also … I know Draconis knows this (for one thing, he referred to “a random lockpick carried by the player”), but unless I blinked and missed it, I don’t think he mentioned it … if you only have one lockpick in the game, you definitely do NOT want to say “A lockpick is a kind of thing.” You only want to say “The lockpick is a thing.”

Very good point. I should have mentioned that. (Though if you only have one lockpick, you’ll probably want some way to repair it, otherwise the player will get very frustrated if it breaks the first time it’s used.)

Thanks mates! I’m a bit fresh in Inform, so I don’t known some of the more complicated stuff, though I’m learning as I go and implementing background stuff I do know.

There are multiple lock picks in place but you only get two at the start. If you want more you gotta scour through chests (which have the risk of creating a Mimic creature I implemented.)

Again, Thanks!

(What’s a mimic you ask?)