It worked out really well, saving me from writing a lot of fiddly code.
For example imagine you wrote an "EXAMINE" command, and you wanted to allow all objects to be examined. The horrid way to do it would be something like this:
if target == "desk"
print( "The desk is ..\n" );
if target == "book"
print( "The book is ..\n" );
With a table-based approach you just define your struct (in C) or item-table (in assembly) and your code now looks like this:
Sure you have to write the lookup function to find the object, but it means you don't have to duplicate the logic for every action (get, drop, examine, use, etc).
Using tables for items, and locations, basically saved me a lot of custom code, cut down on repetition.
The most interesting text adventure I saw years ago (with online connection", was a person who had written a fairly good frame of a text adventure, and was also sitting at the keyboard choosing which macro to hit or typing things in. It took me awhile to catch on, because it was mostly automated.
For example imagine you wrote an "EXAMINE" command, and you wanted to allow all objects to be examined. The horrid way to do it would be something like this:
With a table-based approach you just define your struct (in C) or item-table (in assembly) and your code now looks like this: Sure you have to write the lookup function to find the object, but it means you don't have to duplicate the logic for every action (get, drop, examine, use, etc).Using tables for items, and locations, basically saved me a lot of custom code, cut down on repetition.