Skip to main content
gamedev.net
🔒 Locked

Scripting Engine Architecture

Started by mortiz01 May 28, 2007 at 8:58 AM 0 replies 1.2k views
Original Post
mortiz01
mortiz01
On the project I'm currently working on we're aiming for a rudimentary scripting engine that makes use of the Lua language. The problem? We haven't a particularly lot of experience in making these engines, although we've used script (Lua) for identifiable problems before (as oppose to a generic solution that we require now). We're aiming, in the end, for something similar to the Neverwinter Nights scripting engine (although not as advanced, and time isn't an issue). Basically we need some advice an the engine architecture. The key here I think is the allowing of variables, functions and classes to be shared between scripts in a clean, easy way (implementing features such as inheritance and polymorphism), from both a coding and scripting perspective, I think once this is in place all else follows. The other side to it of course is the engine hooks, which should be minimal and as generic as possible. We’re only going to be using script for the AI and game rules, the graphics, sound and similar aspects will still all be handled internally, although given that the game-logic will need to interact with the video and sound components on some level then these components should be exposed to the script, a special game logic script may deal with OnRender() and draw a list of registered entities and the map. Some aspects of the logic engine will remain internal, this includes map information (tile info, layers, navigation graph etc.) and certain functions will remain internal (path-planning for example), though these will also will present interfaces to the script. To accomplish a lot of the above LuaBind or an equivalent will most likely be used. So if there are any devs here who have worked on scripting engines before and feels like lending a helping hand you can post some advice here (although I understand the above post doesn't leave much for you to go on) or, more preferably, if you've got some time on your hands we could talk over ICQ and a cup of coffee ;) . If what I've said above is too vague please inform me. We basically just need a starting point and a road map and we'll deal with the rest. Thanks for your time.
wmurdick
wmurdick
I have done something similar to this in a text-based RPG I have been working on. Basically, I have a script manager that manages the LUA virtual machine and executes scripts that are passed to it. I have an event manager that takes care of system events (which are data driven, not hard-coded to keep it abstract).

Every thing in the game is an object and each object has a map on it that accepts properties that can be integers, strings, bool, object (pointers basically), etc.

Basically thats all you need. You can retrieve objects using name, keyword, ID, or even in a manner similar to NWN (last object doing some action) and then retrieve (or set) properties from it.

Objects can be setup to listen for events and to call specific scripts whenever that event is heard.
"Iacta alea est" - Julius Caesar"So far as I know, I've never been defeated by a 'powerful over-arching potentiality' before"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.