|
kurt miller's homepage
( My development journal and homepage has moved to a new system here: kurtm.flipcode.com ) |
|||||
While working on my game, I implemented a simple key/value script loader without really thinking twice about it. I've noticed only recently how incredibly useful they are in practice, especially given their simplicity. If you have a more sophisticated scripting system implemented in your project, they're not really neccesary. For the rest however, they're extremely handy when it comes to avoiding hard-coded values and increased organization. In its simplest form, I'm just refering to a text file with lines made up of key = value. The loader loads them up, and lets you access data like getValue("key"). No magic, nothing novel, but very useful. A lot of people are using fancy XML parsers and the like these days, but personally I favor simplicity and readability. The only complexity I added to my loader was support for nested scripts. The main advantage is not having to write specific loaders for types/keys. The flexibility provided naturally by a key/value pair reveals itself as you find it fits more and more scenarios. I use std::map for my particular implementation. A couple example scripts from my game project are below: map01.kvs:
skybox_overcast.kvs:
|
|||||
| Site Contents Copyright (c) 2002-2004 Kurt Miller. Please do not reprint this jibberish anywhere. |