🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Scripting Architecture

Started by
0 comments, last by AzCoder 21 years ago
I am in the process of adding scripting to my engine. Currently I have chosen Lua and am beginning to embed it. Do you have any advice in terms of what and how to expose functionality of the engine to the script? For example, I could expose the AddExploder method of singleton Explosion manager. That is intuitive. But what about the actual AI of a game entity? If I have 50+ entities on the screen, should I execute 50+ AI scripts on every update tick? Is that the best approach and will it perform? I realize this is a high-level question that is very tied to the design and sub-systems of the engine, but I would really appreciate any insight... Thanks in advance for any posts.
Advertisement
Often it''s best to have a state stored on the application side (eg. hunting, fleeing, waiting, whatever) and on the scripting side you have ''event handlers'' that react to in-game events and return a new AI state accordingly. For example, an event generated might be "Attack", so the attacked entity will call its "OnAttack" event handler, which is defined in your scripting language. That will make a decision based on the available data and change the AI state accordingly before returning. Then your main loop can process all entities according to their state. In essence, this is quite similar to how a web browser and embedded &#106avascript works. <br><br><small>[ <a href="http://www.dinkumware.com/vc_fixes.html">MSVC Fixes</a> | <a href="http://www.sgi.com/tech/stl/">STL Docs</a> | <a href="http://www.libsdl.org/index.html">SDL</a> | <a href="http://www.gameai.com/ai.html">Game AI</a> | <a href="http://www.ecst.csuchico.edu/%7Ebeej/guide/net/">Sockets</a> | <a href="http://www.parashift.com/c++-faq-lite/">C++ Faq Lite</a> | <a href="http://www.boost.org">Boost</a> <br> <a href="http://www.tuxedo.org/~esr/faqs/smart-questions.html">Asking Questions</a> | <a href="http://www.gamedev.net/reference/programming/features/orgfiles/">Organising code files</a> | <a href="http://pages.eidosnet.co.uk/kylotan/downloads.html">My stuff</a> | <a href="http://sourceforge.net/projects/tinyxml">Tiny XML</a> | <a href="http://www.stlport.org">STLPort</a>]</small>

This topic is closed to new replies.

Advertisement