The button command set up a subprogram so that it runs when you click the button. Remember to use -> and then indent your program. A subprogram used like this is called a function.
write 'You see a tarnished old brass lamp.'
button 'Rub the lamp', ->
x = random 3
if x is 0
write 'Squeak squeak.'
if x is 1
write 'You hear a rumbling sound.'
if x is 2
write 'A genie appears and grants you three wishes!'