Look At Current Room

Liam315
While watching my game being tested I noticed that a player may try to examine the room by name and in some cases there was no response. e.g. The player is told that they are in a kitchen, but when they type "examine kitchen," Quest responds that it can't see a kitchen. Rather than create a scenery item to take care of every room, I coded a cover-all response in one of the default functions that just reprints the current room description, and I thought I'd share it here in case anyone else might want to make use of it.

Details:

- The following code returns the current room description when a player enters "look at/examine [object]" and [object] is a match for the name of the current room.

- Negates the need to create a scenery object that responds to the player trying to examine the room like an object.

- Priority is given to objects in the room, only when a match is not found will the attempt be made to compare the player's input with the name of the current room.

- You must copy and paste the code over the default function UnresolvedCommand.

- The relevant lines here that have been added/modified from the original are 4-16.

// TO DO: Update names below, we don't need these two variables
unresolvedobject = objectname
unresolvedkey = varname
lookhere = False
if (game.pov.currentcommandpattern = lookat) {
candidateroomname = LCase(Replace(StringDictionaryItem(game.pov.currentcommandvarlist,"object")," ",""))
matchtoroomname = LCase(Replace(GetDisplayAlias(game.pov.parent)," ",""))
if (Instr(matchtoroomname,candidateroomname) > 0) {
lookhere = True
}
}
if (lookhere) {
msg ("")
ShowRoomDescription
}
else if (HasString(game.pov.currentcommandpattern, "unresolved")) {
if (ListCount(game.pov.currentcommandvarlist) > 1) {
msg (game.pov.currentcommandpattern.unresolved + " (" + unresolvedobject + ")")
}
else {
msg (game.pov.currentcommandpattern.unresolved)
}
}
else {
if (ListCount(game.pov.currentcommandvarlist) > 1) {
msg (Template("UnresolvedObject") + " (" + unresolvedobject + ")")
}
else {
msg (Template("UnresolvedObject"))
}
}
game.unresolvedcommand = game.pov.currentcommandpattern
game.unresolvedcommandvarlist = game.pov.currentcommandvarlist
game.unresolvedcommandkey = unresolvedkey

This topic is now closed. Topics are closed after 14 days of inactivity.

Support

Forums