by Roody_Yogurt » Thu Dec 12, 2019 1:22 pm
Nice going, pinback!
Using routines to return variables can be useful for other situations, too. For a long time, it bugged me that the Hugo standard library didn't support >LISTEN without an object, but trying to add support for room sounds was trickier than one would first imagine because messages would be called multiple times throughout the player/location before/after cycle. For a long while, Roodylib got around this by clearing the verbroutine global so messages wouldn't be called a second time. Eventually, this bugged me, though, since ideally, the game should always know what the last turn was.
Somewhat recently, I decided to go a routine based route:
Code: Select all
routine RoomSounds(obj)
{
if verbroutine = &DoListen and not object
return location
else
return false
}
where you would put something like this in the rooms which have sounds:
Code: Select all
before
{
RoomSounds(location)
{
"No sounds but the wind."
}
}
Nice going, pinback!
Using routines to return variables can be useful for other situations, too. For a long time, it bugged me that the Hugo standard library didn't support >LISTEN without an object, but trying to add support for room sounds was trickier than one would first imagine because messages would be called multiple times throughout the player/location before/after cycle. For a long while, Roodylib got around this by clearing the verbroutine global so messages wouldn't be called a second time. Eventually, this bugged me, though, since ideally, the game should always know what the last turn was.
Somewhat recently, I decided to go a routine based route:
[code]routine RoomSounds(obj)
{
if verbroutine = &DoListen and not object
return location
else
return false
}[/code]
where you would put something like this in the rooms which have sounds:
[code] before
{
RoomSounds(location)
{
"No sounds but the wind."
}
}[/code]