Here’s a more complicated implementation that includes keypads as separately implemented things and makes a new action instead of using the built-in “setting it to” action, applying to a number rather than a text. I made keypads into a kind, which might not be what you need–you could write your rules much more specifically if you only have one keypad. Also, um, for some reason when I read what you said I thought it was actually a microwave.
Anyway, the important things are the way that I defined the action (you need to say “typing it on” so you can later say things like “Instead of typing 123456 on the microwave’s keypad”) and the fact that the number goes in “the number understood” and the keypad goes in “the second noun” even though there’s no first noun. I included some friendlinesses like redirecting typing on the microwave to the keypad but there could be more (for instance, refusing “UNLOCK MICROWAVE” with a message that they have to use the keypad, and providing a helpful message when the player types something that isn’t a number).
[code]Typing it on is an action applying to one number and one thing. Understand “type [number] on [something]” as typing it on.
A keypad is a kind of thing. The description of a keypad is usually “To enter a passcode on the typepad, say ‘type (number) on [item described].’”
A keypad has a number called the code. A keypad has a thing called the associated lock. [This implementation assumes that keypads always are used to unlock things. If we wanted to get complicated we could give every keypad a rule, which would be an effect that would happen when you enter the code–and which could be “now the microwave is unlocked,” or it could be something more complicated.]
Before typing when the second noun is not a keypad and the second noun incorporates a keypad (called real target):
try typing the number understood on the real target instead. [So we don’t give an unhelpful message for “Type 123 on microwave”; we just redirect it to the keypad.]
Check typing when the second noun is not a keypad: say “You can’t type a number on that.” instead.
Check typing something on a keypad (called target) when the number understood is less than 10 and the code of the target is not less than 10:
say “Don’t try to type one digit at a time; just type in the whole code.” instead.
Check typing when the number understood is not the code of the second noun: say “[The second noun] beeps irritatingly and refuses to do anything. Must have been the wrong code.” instead.
Check typing when the associated lock of the second noun is not locked: [this should only be reached when you’ve typed the right code]
say “[The associated lock of the second noun] is already unlocked.” instead.
Carry out typing: [because of the check rules this should only fire when we’ve typed the correct code on a keypad whose associated lock is unlocked]
now the associated lock of the second noun is unlocked.
Report typing: [this also will only fire when the carry out rule has fired]
say “[The associated lock of the second noun] unlocks with a click.”
[and a scenario]
Kitchen is a room. A microwave oven is a locked transparent container in the kitchen. The description of the microwave oven is “It has a keypad–but where it ordinarily would say ‘START’ it says ‘UNLOCK.’ Strange. Perhaps you have to type a code on the keypad?”
The microwave’s keypad is a keypad, part of the microwave oven. The code of the microwave’s keypad is 123456. The associated lock of the microwave’s keypad is the microwave oven. Understand “microwave keypad” as the microwave’s keypad.
A gold nugget is in the microwave. The description of the gold nugget is “[if the gold nugget is in the microwave]Who put a gold nugget in the microwave? Didn’t they see American Hustle?[otherwise]It’s a valuable gold nugget.[end if]”.
[and a clue]
The player carries a note. The description of the note is "It says 'Congratulations, you took inventory! The code of the microwave oven is .'"