On 30 Dec '05, at 7:05 AM, John Klimek wrote:
Using globals is usually bad form, unless the object really is global in scope. In this case it sounds like the better thing to do is to make the scripts define functions that are methods on the entity object. (Or almost equivalently, register functions that will be called by particular types of entities, passing the entity as a parameter.)
Again checking the type of an object at runtime is often not the best design. If the script functions were entity methods, then each function would apply to a particular type of entity and it wouldn't need to check the type.
Have you looked at MOO (an object-oriented MUD language) and its LambdaCore library? These would be excellent sources of design ideas for implementing this type of environment. So would interactive-fiction languages like INFORM. This particular wheel has been invented many times over, so take advantage of what's already been worked out!