Monday, November 5, 2012

"extra" extra_scenery

In the game-I've-most-recently-worked-on (I don't want to call it my "WIP" as I really should be starting on a HugoComp game soon), I got a little frustrated with the default handling of extra_scenery. The game in question has 2 or 3 words that should always result in "You don't need to refer to that.", on top of each room's additional list of words. I really didn't want to add those 2 or 3 words to every room's extra_scenery property, so I eventually just threw the entire list of words into the room class definition.

This was a pretty inelegant solution so I intended to try to come up with a better solution eventually. Well, that day ended up being yesterday, and here's what happened.

Originally, I tried to declare my own extra_scenery_words array and replace the room class's property array with a property routine that checked it. This was problematic.

The main thing was, Parse's extra_scenery checking code already checks every word in the word array against the extra_scenery property, so to find a match myself, I'd have to check every word array word against every extra_scenery_words word, so there's some wasted looping right there.

In the end, I thought the simplest solution was just to edit Parse and have it check the player object for extra_scenery words, too, so you can put your always-on extra_scenery there (this is also appropriate as I often use extra_scenery for player body parts that aren't implemented and such). The Roodylib  Parse routine now has this:
    for (a=2; a<=words and word[a]~="" and word[a]~="then"; a++)
    {
        if Inlist(player, extra_scenery, word[a])
        {
            Message(&Parse, 1)
            word[1] = ""            ! force ParseError(0)
            words = 0
            customerror_flag = true
            return true
        }
        elseif Inlist(location, extra_scenery, word[a])
        {
            Message(&Parse, 1)
            word[1] = ""            ! force ParseError(0)
            words = 0
            customerror_flag = true
            return true
        }
    }
(I'm not going to upload a new release of Roodylib just for this, but it'll be in the next version, of course)

I figure this'll take care of the majority of extra_scenery needs. If you find that you really need to tie extra_scenery behavior to an object, I also came up with this work around:
  1. Have your init routine set one of your player.extra_scenery property elements to a call to a routine:
    player.extra_scenery #3 = call &CheckStuff
  2. Write a routine for the above that returns a dictionary word under the right circumstances:
    routine CheckStuff
    {
        if FindObject(mess, location)
            return "stuff"
    }
That may be a little ugly, but hopefully your game doesn't have a lot of words like that!



No comments:

Post a Comment