Smell restrictions (Hugo example)
From IFWiki
!:: ! Smell Restrictions Example by Roody Yogurt for IFWiki !:: #include "verblib.g" ! Verb Library ! we must define the "smell" verb if the verbstub files haven't been included #ifclear _VERBSTUB_H verb "smell", "sniff", "inhale", "breathe" * DoSmell * object DoSmell #endif #include "hugolib.h" ! Standard Hugo Library !:: Game Initialization routine routine init { prompt = ">" window 0 ! resets the windows in case the player is restarting a game cls DEFAULT_FONT = PROP_ON Font(DEFAULT_FONT) player = you location = street move player to location old_location = location FindLight(location) DescribePlace(location) location is visited CalculateHolding(player) } !:: Main game loop routine main { counter = counter + 1 run location.each_turn runevents RunScripts if speaking not in location speaking = 0 PrintStatusLine } player_character you "you" { before { actor DoSmell { if (object ~= you,spacesuit) and spacesuit is worn "You can't smell anything while wearing the spacesuit." else return false } } after { object DoSmell { "Forgot your deodorant, did you?" } } } room street "Street" { long_desc "You are in a street. The sewer is below you." d_to sewer after { location DoSmell { "You pick up a faint odour from below." } } } object flower "flower" { article "a" noun "flower" after { object DoSmell { "It smells wonderful." } } in street } object spacesuit "spacesuit" { article "a" noun "spacesuit" "suit" after { object DoSmell { ! regular response is "You smell nothing special." "You smell nothing special about the spacesuit." } } nearby ! puts it by last-defined object is clothing } room sewer "Sewer" { ! (the other way of doing a long_desc) long_desc : "You are in a sewer. The street is above you." u_to street } object sewage "sewage" { article "some" noun "sewage" is static react_before { if verbroutine = &DoSmell and object ~= self and spacesuit is not worn { "The disgusting reek of the sewage overwhelms your nose. You can't smell anything else." } else return false } after { object DoSmell { "It reeks." } } in sewer } ! The Hugo library doesn't normally do much with SMELL, other than a stub ! routine in the appropriately-named "verbstub" file. This is a replacement ! based on DoListen. #ifset _VERBSTUB_H replace DoSmell { if not object { if not location.after { "You smell nothing special." return true } verbroutine = "" return true } elseif not object.after "You smell nothing special." ! we have to clear verbroutine or else location.after.DoListen will run again verbroutine = "" return true } #else routine DoSmell { if not object { if not location.after { "You smell nothing special." return true } verbroutine = "" return true } elseif not object.after "You smell nothing special." ! we have to clear verbroutine or else location.after.DoListen will run again verbroutine = "" return true } #endif