Wednesday, August 22, 2012

More about scripting

I am thinking about how to design a good scripting API. Currently, the PlayerCharacter object and the Item object are passed to item use scripts. Unfortunately the PlayerCharacter object can't do much, because most is done by the controllers owned by MapInstance. I can access the MapInstance through the getMapInstance method of the PlayerCharacter, but the map instance doesn't expose the controllers. And for good reason: the main way of communicating with them are messages.

Well. I could pass the message dispatcher to the scripts, but crafting messages is a tad too complex for a scripting API.

So what could I do?

I could add some methods to MapInstance specifically for scripting. I already did that for monster spawning. But that wouldn't make sense for things which have nothing to do with the current MapInstance. Teleporting a player to another map, for example.

Maybe another global object is in order which has static methods specifically for providing helper methods for scripts.

No comments:

Post a Comment