I am trying to make a text adventure game, but for some reason, it doesn’t seem to work! Can anybody tell me what’s going wrong?
Here’s what I’ve got so far.
set LocDescription to "You are standing in a room with doors to your north, south, east, and west."
set location to "c"
set Winner to "0"
set HaveKey to "0"
set HaveBoulder to "0"
set buttonOn to "0"
set death to "0"
repeat
if death is 0 then
display dialog LocDescription default answer "" buttons {"DO"} default button 1
else
display dialog LocDescription buttons {"OK"} default button 1
quit
end if
set theThingToDo to the text returned of the result
if theThingToDo is "north" then
if location is "c" then
if HaveKey is "1" then
set location to "n"
set LocDescription to "You insert the key into the keyhole, and it opens, allowing you to return to your own world. You win!"
set Winner to "1"
else
set location to "c"
set LocDescription to "You approach the door to your north. You notice there is a keyhole, but you don't have the key."
end if
else if location is "s" then
if buttonOn is "0" then
set location to "c"
set LocDescription to "You are back in the center room. No changes. Sigh..."
else
set location to "c"
set LocDescription to "You are back in the center room, again. However, this time the door to the west is open."
end if
else
set location to "You try to walk north, but you hit a wall."
end if
else if theThingToDo is "south" then
if location is "c" then
set location to "s"
set LocDescription to "You are standing in a room with a button on the floor."
else
set LocDescription to "You try to walk south, but you hit a wall."
end if
else if theThingToDo is "east" then
if location is "c" then
set location to "e"
set LocDescription to "You are standing in a room with a boulder to the ground."
else if location is "w" then
set location to "c"
set LocDescription to "You are standing in the center room, again. Absolutely no changes whatsoever. It's the same old room."
else
set LocDescription to "You try to walk east, but you hit a wall."
end if
else if theThingToDo is "west" then
if location is "c" then
if ButtonPressed is "1" then
set location to "w"
set LocDescription to "You are standing in a room with a key on the ground."
else
set LocDescription to "You approach the door to the west, but it won't open."
end if
else if location is "e" then
set location to "c"
set LocDescription to "You are standing in the center room, again. There are no changes."
end if
else if theThingToDo is "take boulder" then
if location is "e" then
set HaveBoulder to "1"
set LocDescription to "You now have a boulder."
else
set LocDescription to "What boulder?"
end if
else if theThingToDo is "take key" then
if location is "w" then
set HaveKey to "1"
set LocDescription to "You now have a key."
else
set LocDescription to "What key?"
end if
else if theThingToDo is "drop boulder" then
if HaveBoulder is "1" then
if location is "s" then
set ButtonPressed to "1"
set HaveBoulder to "0"
set LocDescription to "You drop the boulder on the button. You hear a door open."
else
-- easter egg ;)
set LocDescription to "You drop the boulder, and it lands on your foot.
You are dead."
set death to "1"
end if
else
set LocDescription to "What boulder?"
end if
else if theThingToDo is "drop key" then
--easter egg ;)
if HaveKey is "1" then
set LocDescription to "You don't want to lose the key!"
else
set LocDescription to "What key?"
end if
else if theThingToDo is "push button" then
if location is "s" then
set LocDescription to "You push the button, and you hear a door open. You release the button, and the door closes. Nice try, Einstein."
else
set LocDescription to "What button?"
end if
else if theThingToDo is "examine boulder" then
if HaveBoulder is "1" then
set LocDescription to "The boulder is fairly ragged. It is also fairly heavy."
else
set LocDescription to "What boulder?"
end if
else if theThingToDo is "examine key" then
if HaveKey is "1" then
set LocDescription to "The key is made of solid gold. It is probably worth a lot of money."
else
set LocDescription to "What key?"
end if
end if
end repeat